WebAssembly

Lohankhapedia (自由的百科全書) 欲共你講..。
跳至導覽 跳至搜尋
WebAssembly
編程範型 Pang-bô͘:Ill; Pang-bô͘:Ill[1]
軟體設計 Pang-bô͘:Ill
程式員
首次發行 2017 年 3月;​ 7年 以前​ (2017-03)
OS Pang-bô͘:Ill
軟體授權 Pang-bô͘:Ill
文件擴展名
  • .wat (文本格式)
  • .wasm (2進制 格式)
啟發語言

WebAssembly (英語 (ing-gú): WebAssembly; ū-tang-sî-á寫做 (siá-tsò)Wasm) ()會當 (ē-tàng) Pang-bô͘:Ill定義 (tīng-gī)一種 (tsi̍t-tsióng)會使 (ē-sái)移植 (î-si̍t) (ê) Pang-bô͘:Ill代碼 (tāi-bé)格式 (kik-sik) (hām) (sio)對應 (tuì-ìng)文本 (bûn-pún)格式[2]以及 (í-ki̍p)用咧 (iōng-teh)促進 (tshiok-tsìn)這類 (tsit-luī)程序 (tîng-sū) (kah)伊的 (i-ê)肅主 (siok-tsú)環境 (khuân-kíng)之間 (tsi-kan)交予 (kau-hōo)軟體 (nńg-thé)接口 (tsiap-kháu).[3][4][5][6]

WebAssembly的主要 (tsú-iàu)目標 (bo̍k-piau) () (teh)網頁 (bāng-ia̍h)頂懸 (tíng-kuân)啟用 (khé-iōng) (ko)勝能 (sìng-lîng)應用 (ìng-iōng)程序, "毋久 (M̄-kú)WebAssembly無做 (bô-tsò)任何 (jīm-hô)特定 (ti̍k-tīng)咧Web (ê)假設 (ká-siat)或者 (hi̍k-tsiá)提供 (thê-kiong)的定 (ti̍k-tīng)Web功能 (kong-lîng)因此 (in-tshú)WebAssembly ()會當咧其他 (kî-thann)環境當中 (tang-tiong)使用 (sú-iōng)."[7]WebAssembly是一个 (tsi̍t-ê) Pang-bô͘:Ill[8][9],伊的目標主要咧支持 (tsi-tshî)任何操作 (tshau-tsok)系統 (hē-thóng)頂懸的任何語言 (gú-giân),[10] 並且 (pīng-tshiánn)實踐 (si̍t-tsiān)當中,所有 (sóo-ū) (siong)流行 (liû-hîng)的語言 (lóng)至少 (tsì-tsió)具有 (kū-iú)一定 (it-tīng)程度 (thîng-tōo)的支持。

WebAssembly ()2015 ()宣佈 (suan-pòo)並佇 (pīng-tī)2017年3 (gue̍h)頭疾擺 (thâu-tsi̍t-pái)發佈 (huat-pòo),佇2019年12月5 (ji̍t)成做 (tsiânn-tsò)World Wide Web聯盟 (liân-bîng)推戰 (thui-tsiàn)[11][12][13] (pīng)佇2021年獲得 (hi̍k-tit) Pang-bô͘:Ill Pang-bô͘:Ill編程 (pian-tîng)語言 (nńg)thtsióng.[14]Pang-bô͘:Ill (W3C) 咧MozillaMicrosoftGoogleApplePang-bô͘:IllIntelPang-bô͘:Ill貢獻 (kòng-hiàn)之下 (tsi-hā)維護 (uî-hōo)這个 (tsit-ê) Pang-bô͘:Ill.[15][16]

規格 (Kui-keh)特色 (ti̍k-sik)[修改]

主機 (Tsú-ki)環境[修改]

大馬 (Tāi-bé)表示 (piáu-sī)[修改]

C元代碼 (guân-tāi-bé)佮對應的WebAssembly
C元代碼 WebAssembly .wat文本格式 WebAssembly .wasm 2進制 (tsìn-tsè)格式

<syntaxhighlight lang="c"> int factorial(int n) {

if (n == 0)
return 1;
else
return n * factorial(n-1);

} </syntaxhighlight>

<syntaxhighlight lang="wat"> (func (param i64) (result i64)

local.get 0
 (i)64.eqz
if (result i64)
伊64.const 1
else
local.get 0
local.get 0
伊64.const 1
伊64.sub
call 0
伊64.mul
end)

</syntaxhighlight>

<syntaxhighlight lang="text"> 00 61 73 6D 01 00 00 00 01 00 01 60 01 73 01 73 06 03 00 01 00 02 0A 00 01 00 00 20 00 50 04 7E 42 01 05 20 00 20 00 42 01 7D 10 00 7E 0B 0B 15 17 </syntaxhighlight>


<syntaxhighlight lang="wat"> (module

(type $t0 (func (param i64) (result i64)))
(func $f0 (type $t0) (param $p0伊64) (result i64)
(if $I0 (result i64) ;; $伊0 is an unused label name
(伊64.eqz
(local.get $p0)) ;; the name $p0 is the same as 0 here
(then
(伊64.const 1))
(else
(伊64.mul
(local.get $p0)
(call $f0 ;; the name $f0 is the same as 0 here
(伊64.sub
(local.get $p0)
(伊64.const 1))))))))

</syntaxhighlight>

註解 (Tsù-kái)[修改]

  1. "WebAssembly/design/Semantics.md". GitHub (ēng Eng-gí). 2021-02-23 khòaⁿ--ê. WebAssembly code can be considered a structured stack machine; a machine where most computations use a stack of values, but control flow is expressed in structured constructs such as blocks, ifs, and loops. 怹practice, implementations need not maintain an actual value stack, nor actual data structures for control; they need only behave as if they did so. 
  2. Mozilla. "Understanding WebAssembly text format". MDN Web Docs. 9 December 2019 khòaⁿ--ê. 
  3. "Introduction — WebAssembly 1.0". webassembly.github.腰. 18 June 2019 khòaⁿ--ê. WebAssembly is an open standard... 
  4. "Introduction — WebA ssembly 1.0". webassembly.github.腰. 18 June 2019 khòaⁿ--ê. WebAssembly is a ... code format 
  5. "Conventions — WebAssembly 1.0". webassembly.github.腰. 17 May 2019 khòaⁿ--ê. WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format)。 Both map to a common structure. 
  6. "Introduction — WebAssembly 1.0". webassembly.github.腰. 18 June 2019 khòaⁿ--ê. ..。 this specification is complemented by additional documents defining interfaces to specific embedding environments such as the Web。 These will each define a WebAssembly application programming interface (API) suitable for a given environment. 
  7. "Introduction — WebAssembly 1.1". webassembly.github.腰. 2021-02-19 khòaⁿ--ê. Its main goal is to enable high performance applications on the Web, but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well. 
  8. Haas, Andreas; Rossberg, Andreas; Schuff, Derek L.; Titzer, Ben L.; Holman, Michael; Gohman, Dan; Wagner, Luke; Zakai, Alon; Bastien, JF (14 June 2017). "Bringing the Web Up to Speed with WebAssembly". SIGPLAN Notices. 52 (6): 185–200. doi:10.1145/3140587.3062363. ISSN 0362-1340. While the Web is the primary motivation for WebAssembly, nothing in its design depends on the Web or a JavaScript environment. It is an open standard specifically designed for embedding in multiple contexts, and we expect that stand-alone implementations will become available in the future. 
  9. "Outside the web: standalone WebAssembly binaries using Emscripten ͘ V8". v8.dev. 2020-07-28 khòaⁿ--ê. 
  10. "Wasmer - The Universal WebAssembly Runtime". wasmer.腰. 2021-02-19 khòaⁿ--ê. Compile everything to WebAssembly。 Run it on any OS or embed it into other languages. 
  11. World Wide Web Consortium. "WebAssembly Core Specification". World Wide Web Consortium (W3). 9 December 2019 khòaⁿ--ê. 
  12. Couriol, Bruno. "WebAssembly 1.0 Becomes a W3C Recommendation and the Fourth Language to Run Natively in Browsers". infoq.com. 9 December 2019 khòaⁿ--ê. 
  13. "WebAssembly Specification — WebAssembly 1.1". webassembly.github.腰. 2021-03-22 khòaⁿ--ê. 
  14. "Programming Languages Software Award". www.sigplan.org. 
  15. Bright, Peter (18 June 2015). "The Web is getting its bytecode: WebAssembly". Ars Technica. Condé Nast. 
  16. "New Bytecode Alliance Brings the Security, Ubiquity, and Interoperability of the Web都the World of Pervasive Computing". Mozilla (ēng Eng-gí). 12 November 2019. 27 May 2019 khòaⁿ--ê. 

參閱 (Tsham-ua̍t)[修改]

外部 (Guā-pōo)連結 (liân-kiat)[修改]