Walt_用于WebAssembly文本格式的js风格的语法

更新日期:2020年09月02日 投稿作者:分类目录网 围观人数:28108

Walt


简介:用于WebAssembly文本格式的js风格的语法

Walt是WebAssembly文本格式的替代语法,.walt文件直接编译为WebAssembly二进制格式。 其特点:

  • 不需要C / C ++或Rust,只需输入 JavaScript。
  • 不需要LLVM /二进制工具包,零依赖关系100%用js编写。
  • 快速编译,集成到webpack中!

 

Walt_用于WebAssembly文本格式的js风格的语法 第1张

Walt | Alternative Syntax for WebAssembly | Demo

Walt_用于WebAssembly文本格式的js风格的语法 第2张 Walt_用于WebAssembly文本格式的js风格的语法 第3张 Walt_用于WebAssembly文本格式的js风格的语法 第4张 Walt_用于WebAssembly文本格式的js风格的语法 第5张 Walt_用于WebAssembly文本格式的js风格的语法 第6张

Walt_用于WebAssembly文本格式的js风格的语法 第7张 Walt is an alternative syntax for WebAssembly text format. It's an experiment for using JavaScript syntax to write to as 'close to the metal' as possible. It's JavaScript with rules. .walt files compile directly to WebAssembly binary format.

Highlights:

  • Write "close to the metal" JavaScript!
  • No C/C++ or Rust required , just typed JavaScript.
  • NO LLVM/binary toolkits required , zero dependencies 100% written in JS.
  • Fast compilation, integrates into webpack!

Walt_用于WebAssembly文本格式的js风格的语法 第8张Read the Quick Start Guide

Walt_用于WebAssembly文本格式的js风格的语法 第9张Try it out in the Walt Explorer .

Walt_用于WebAssembly文本格式的js风格的语法 第10张Contributi*** are welcomed! Contributing guide .

Walt_用于WebAssembly文本格式的js风格的语法 第11张Current status: Alpha

Roadmap

Problem

Writing zero-overhead, optimized WebAssembly is pretty tough to do. The syntax for .watfiles is terse and difficult to work with directly. If you do not wish to use a systems language like C or Rust, then you're kind of out of luck . Your best bet (currently) is to write very plain C code, compile that to .wast and then optimize that result. Then you're ready to compile that into the final WebAssembly binary. This is an attempt to take C/Rust out of the equation and write 'as close to the metal' as possible without losing readability.

I feel like this is currently a problem. Most Web engineers are not familiar with the C family languages or Rust. It's a barrier for wide spread adoption of WebAssembly. A competent Front-end engineer should be able to edit WebAssembly as easily as any other systems programmer.

Solution

Provide a thin layer of syntax sugar on top of .wattext format. Preferably porting as much of JavaScript syntax to WebAssembly as possible. This improved syntax should give direct control over the WebAssembly output. Meaning there should be minimal to none post optimization to be done to the wast code generated. The re-use of JavaScript semantics is intentional as I do not wish to create a brand new language.

Here is what an example of a .waltmodule which exports a recursive Fibonacci function looks like:

export  function  fibonacci ( n :  i32 ):  i32  {  if ( n <= 0 ) return 0 ;         if  ( n  ==  1 )  return  1 ;   return  fibonacci ( n  -  1 )  +  fibonacci ( n  -  2 );  }

When this code is ran through the walt compiler you end up with a buffer which can be used to create a WebAssembly module with a fibonacciexport just as you would expect. All done with familiar JS syntax and without any external binary toolkits! A working demo of this exists in the fibonacci-spec.js unit test file .

Project Goals

The ultimate goal of Walt is to make WebAssembly accessible to average JavaScript engineer by providing a subset of JavaScript syntax which compiles to WebAssembly bytecode directly. That WebAssembly should be easy to make use of and simple to integrate into an existing project with the current build tools .

Use cases

Pretty much everyone who wants a quick-start into wasm can use Walt to get there. The use-cases are not specific to this project alone but more to WebAssembly in general. The fact that Walt does not require a stand-alone compiler and can integrate into any(almost?) build tool still makes certain projects better candidates over others.

  • Web/Node libraries, looking to improve performance.
  • Games
  • Projects depending on heavy real-time computation from complex UIs to 3D visualizati***
  • Web VR/AR
  • Anyone interested in WebAssembly who is not familiar with system languages.

See Wiki for detailed design decisi*** etc.

Prior Art

  • wah - A slightly higher level syntax on top of the wasm text format
  • mini-c - Experimental C to WebAssembly compiler

声明:本站资源收集于网络,但不代表本站的观点和立场,具体内容可自行甄别,如果有侵权内容、不妥之处,请联系我们删除。敬请谅解!

网站错误放置备案号将被注销备案及罚款

重要通知 | 网站不按要求放置备案信息最高将处一万元罚款 近日,有不少客户收到阿里云备案核查通知,要求 已备案的网站 下方必须显示正确备案编号、并指向工信部指定网址 https://beian.miit.gov.cn/,否则将面临省通信管理局责令整改、并处五千元以上一万元以下罚款的处罚,或应相关监管部门要求,网站有被关闭、备案被取消接入或被注销的风险。

cn、com域名各个状态说明

cn、com域名各个状态说明: 以client开头的状态表示由客户端(注册商)可以增加的状态 以server开头的状态表示服务器端(CNNIC)操作增加的状态 既不以client开头也不以server开头的状态由服务器端管理 域名的状态解释: ok 正常状态 inactive 非激活状态(注册的时候没有填写域名服务器,不能进行解析) clientDeleteProhibited 禁止删除 serverDeleteProhibited 禁止删除 clientUpdateProhi

12个好用的BT种子搜索网站,你用过几个?

BT Kitty https://cnbtkitty.pw/ 专注于提供BT种子搜索和下载的网站,你可以在这里搜索和下载电影、剧集、音乐、图书、图片、综艺、软件、动漫、教程、游戏等资源,BT Kitty 可以说算得上一款BT种子搜索神器、下载利器。 BT Library https://btlibrary.xyz/ 索引了几千万千万BT种子,包括电影、剧