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

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

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

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

SEO短格式内容与长格式内容(分类目录何时使用哪个?)

我们都知道制定可靠的内容策略的重要性以及正确解决方案可以实现的指数级增长。但是,在内容营销界也存在许多误解。 在过去的某个时候,您可能已经得到建议,说一段内容越长,效果越好。或者,您网站上的每个内容至少应包含2,000个字。  事实是这些不是真的,它们也不是不真实的-如果这有意义吗? 简短和长篇内容均在成功的内容营销策略中占有一席之地,并且两者在您的营销工具箱中都是非常强大的工具。 您只需要在正确的上下文中选择正确的内容形式

db是什么意思?(.db文件的正确打开方式)

db是什么意思?(.db文件的正确打开方式) db是什么意思?   db一般用记事本打开。db是datebase的缩写,是数据库文件。 用UltraEdit软件打开db文件:   1.点击打开网页浏览器,输入百度网址打开百度首页,然后再搜索窗口输入UltraEdit,然后点击百度一下。   2.点击百度一下以后出现免费下载的网站链接,找到

STDLib_支持科学和数字化的基于 web 的机器学习应用的开源库

STDLib 简介:支持科学和数字化的基于 web 的机器学习应用的开源库 STDLib是一个基于 JavaScript 和 Node.js 应用的开源库,如果您正在寻找一种在浏览器中运行,支持科学和数字化的基于 web 的机器学习应用,STDLib 能满足你的需要。 这个库能提供全面而先进的数学和统计学上的功能,来帮助你构建高性能的机器学习模型。你同样也可以使用它丰富的功能来构建应用程序和其他的库。除此之外,如果你想要一个数据可视化和探索性数据分析的框架 —— STDLib,