WebAssembly

W3C องค์กรวางมาตรฐานเว็บประกาศเผยแพร่เอกสารสเปค WebAssembly เปิดทางสู่การรันโค้ดที่ประสิทธิภาพแทบเท่ากับการรันโปรแกรมแบบ native บนเบราว์เซอร์ ทำให้เบราว์เซอร์กลายเป็นแพลตฟอร์มกลางสำหรับการรันแอปพลิเคชั่น เช่น เกม, ระบบถอดรหัส/เข้ารหัส เสียงและวิดีโอ, อัลกอริทึมเข้ารหัส, ไปจนถึงการรันโค้ดภาษาอื่นๆ

เอกสารแยกออกเป็น 3 ฉบับ ได้แก่

  • WebAssembly Core Specification ข้อกำหนดฟังก์ชั่นของเครื่องคอมพิวเตอร์เสมือนที่จะมารันโค้ด WebAssembly และข้อกำหนดไฟล์ .wasm ที่คล้าย .class ในภาษาจาวา
  • WebAssembly Web API มาตรฐานอินเทอร์เฟซการใช้เรียกโค้ด .wasm ที่สามารถรันโค้ดบางส่วนได้แม้ยังโหลดไม่ครบ ลดระยะเวลาตอบสนองผู้ใช้
  • WebAssembly JavaScript Interface มาตรฐานการเรียกฟังก์ชั่นในไฟล์ .wasm จากจาวาคริปต์

ความพยายามพอร์ตโค้ด native มารันบนเบราว์เซอร์นับเป็นความพยายามระยะยาวโดยก่อนหน้านี้กูเกิลอาศัยโครงการ PNaCl ที่อาศัยการวิเคราะห์ความปลอดภัยของไบนารีว่าจะไม่รันโค้ดที่ไม่ได้รับอนุญาต แต่หลังจากใช้งานอยู่หลายปีกูเกิลก็ทิ้ง PNaCl หันมาสนับสนุน WebAssembly พร้อมกับผู้ผลิตเบราว์เซอร์อื่น และตอนนี้เบราว์เซอร์หลัก เช่น Chrome, Edge, Firefox, และ Safari ก็ล้วนรองรับ WebAssembly 1.0 นี้

ที่มา - W3C

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ตอนนี้ยังรอเว็บคุย peer-to-peer กันโดยตรงได้อยู่นะครับ ? เอาแบบไม่ต้องมีคนกลางมาช่วยตอนเริ่มต้นแบบ WebRTC ด้วยเนี่ย

มันเหมือนหรือต่างจาก Applet ของ Java อย่างไรบ้างครับ ใครศึกษาแล้วแนะนำหน่อยครับ หรือว่าทำหน้าที่แค่ Library ส่วน User Interface ก็ยังเป็นหน้าที่ของ HTML, CSS, JavaScript หรือทำได้ทั้ง 2 แบบ แล้วถ้าเราทำให้มันโหลดโมเดลของ ML ลงมาไว้ที่ Browser ได้ไหม

แล้วถ้าเคยลองแล้ว มันช้ามากไหมตอนโหลดครั้งแรกที่ไฟล์ยังมาไม่ครบ

ผมเคยลองแค่ครั้งเดียวนะครับตอนนั้นทำงานส่งอาจารย์ เขียนโปรแกรมเป็น C++ และแสดงผลบนเว็บ คือมันมาทำงานเป็นเหมือน Library นะแหละ ก็ยังใช้ HTML, CSS, JavaScript ทำงานในส่วนแสดงผลอยู่ดี แต่มันสามารถนำโปรแกรมที่เขียนโดยใช้ SDL มาแสดงผลได้เลย แต่ผมไม่ได้ลองเล่น เขียน SDL ไม่เป็น ส่วนการโหลดโมเดล ML ผมไม่มีความรู้ด้านนี้ และโหลดช้ามากไหม ผมลองใน local และโปรแกรมผมก็ไม่ได้ใหญ่มาก ก็รอไม่ถึง 2 วินาทีก็เสร็จ คือหลักๆมันก็โหลดแค่ตัวโปรแกรมที่เรา compile ไว้แล้ว โค้ดผม 5 ร้อยกว่าบรรทัด คำนวนเรื่อง A* compile ออกมาหนักแค่ 222KB เอง ส่วนการนำเอาโปรแกรมที่ compile ไปใช้ web browser มันจะทำในส่วนนี้ และก็อาจจะมี Javascript ที่มาเชื่อมตัวที่ compile แล้วกับ web brower อีกนิดหน่อย ผมไม่ได้ minify มัน ก็อยู่ที่ 140 KB ลองก็อปไปใส่ในเว็บที่ช่วย minify ก็เหลืออยู่ประมาณ 79 KB มันก็ไม่ได้หนักมาก

ผมศึกษาแค่การใช้กับ C++ อย่างเดียว compile โดยใช้ emscripten และเรียกใช้บนหน้าเว็บโดย Javascript ที่มันทำเป็น Function ไว้ให้ ถ้าเป็นอย่างอื่นนอกเหนือจากนี้ผมไม่เคยลอง มันอาจจะมีที่ดีกว่าก็ได้

ห่วงเรื่องความปลอดภัยชอบกล
แต่เข้าใจว่าทำงานใน sandbox น่าจะปลอดภัยระดับนึง

ต่อไปจะมีเรียกใช้ hardware โดยตรง เช่นพวกชิป AI ด้วยมั๊ยนะ?

ถ้าตัว WebAssembly เองผมว่าความน่ากังวลต่ำครับ สิทธิ์ความปลอดภัยไม่ต่างจาก JS เดิม เทียบกับ API ใหม่ๆ ที่ให้สิทธิ์ใหม่ๆ อย่างพวก WebGL เข้าถึง GPU หรือพวก File API พวกนั้นมีปัญหาความปลอดภัยและความเป็นส่วนตัวตามมาเรื่อยๆ