Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly: create a library to convert JavaScript code to WAT #23

Open
yorkie opened this issue Jun 8, 2017 · 2 comments
Open

WebAssembly: create a library to convert JavaScript code to WAT #23

yorkie opened this issue Jun 8, 2017 · 2 comments
Assignees
Labels

Comments

@yorkie
Copy link
Owner

yorkie commented Jun 8, 2017

To enable WebAssembly to be read and edited by humans, there is a textual representation of the wasm binary format.

The above sentences are from MDN's article: Understanding WebAssembly text format.

This way that we write the code runs on modern browsers is still not readable, this is the example that wasm text format project: https://github.com/mafintosh/blake2b-wasm/blob/master/blake2b.wat. I hardly read over 300 lines, even the whole source file contains 2800+ lines.

Improving this source would have the following 2 ways for now:

  1. split the big file into many modules in a structured place, that's play WAT better
  2. writing the same implementation in existing language that's friend to developers

I'll go for the latter, the former method may works, but with a hard learning curve. Obviously the existing language is the JavaScript itself. Aha, that we would do: write JavaScript and compile it to binary executable, and run in JavaScript VM. Interesting, right?

Having to say, this idea looks like what I was expecting in yorkie/lv, which gets AST via esprima, and generates Assembly source code for NASM. About the implementation of the new thoughts, we don't need esprima any more, because we can provide APIs by following WAT's specification, and generates WAT source directly.

If you have interested in this project, feel free to leave comments here :)

@yorkie yorkie added the Idea label Jun 8, 2017
@yorkie yorkie self-assigned this Jun 8, 2017
@yorkie
Copy link
Owner Author

yorkie commented Jun 8, 2017

In computing, s-expressions, sexprs or sexps (for "symbolic expression") are a notation for nested list (tree-structured) data, invented for and popularized by the programming language Lisp, which uses them for source code as well as data.

Oops, the WAT is using the S-expressions which is used as well by LISP, just curious why WebAssembly make this choose so far :)

@yorkie
Copy link
Owner Author

yorkie commented Jun 13, 2017

Created this library at https://github.com/yorkie/watjs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant