[HN Gopher] Show HN: A tiny WASM compiler and runtime for demons...
___________________________________________________________________
Show HN: A tiny WASM compiler and runtime for demonstration
purposes
Hello, I'm building a WebAssembly compiler and documenting the
process in the meantime. This aims to be a tool for demonstration
and education purpose. It doesn't aim to do fancy stuff nor to
replace existing ones. I'm building this to learn and to improve
and hopefully it can be useful for others as well :) From last
time I've presented the idea, I've implemented more basic features
on Luna and I've built a custom and tiny runtime for Luna!
(documenting it of course). Any feedback is really appreciated :)
Repo: https://github.com/thomscoder/luna
Author : thomscoder
Score : 36 points
Date : 2022-11-13 16:11 UTC (6 hours ago)
(HTM) web link (luna-demo.vercel.app)
(TXT) w3m dump (luna-demo.vercel.app)
| [deleted]
| ushakov wrote:
| I'm upset WASM doesn't have any types other than numbers, so you
| can't export any real-world functions without relying on glue
| code, which converts strings and objects to numbers and the other
| way around
|
| this is also the reason why the "hello world" of WASM is a
| function adding two numbers - because there are no strings in
| WASM
|
| https://webassembly.github.io/spec/core/syntax/types.html
| nuc1e0n wrote:
| Strings are only an array of numbers (codepoints). Wasm is
| intended as a compiler target that can be easily implemented
| with good performance. The text format is not a high level
| language on purpose. The proper term for this tool is not a
| compiler but an assembler because the text format is a 1-to-1
| mapping of the binary output.
| nitsky wrote:
| Check out the component model proposal, which adds a stable ABI
| for rich types like strings, arrays, structs, etc.
|
| https://github.com/WebAssembly/component-model
| nuc1e0n wrote:
| Not a great proposal IMHO. Strings and other high level data
| structures are distinctions the high level languages that
| output wasm should make. Anyone who's had to do java to .net
| clr interop will say how problematic it was. The only
| resonable way to do it was via text de/serialisation on the
| database or via a web based api, even on the same computer.
| That's crazy when you think about it.
|
| So arrays of numbers will work and have predictable
| performance.
|
| Personally, I'd prefer to see wasm not repeat the same
| disasterous mistakes Java made.
| josephg wrote:
| Whats the status on this? How long before the component model
| is something we can use?
| gnabgib wrote:
| You only just posted this (12 days ago, 75 points, 2
| comments[0]), the vercel app seems to look the same, and still
| references the repo for instructions. This seems way to soon to
| be making a duplicate post.
|
| [0]: https://news.ycombinator.com/item?id=33424354
| [deleted]
| pvg wrote:
| They're only HN dupes if they generate significant discussion
| and this one hadn't.
| haberman wrote:
| I'm curious how small a conforming WASM implementation can be
| (Luna looks extremely small, but not conforming).
|
| In particular I'm curious how feasible it is to create WASM
| polyfills for various languages. Imagine you have a nice C kernel
| that you want to wrap in various languages. In many cases you can
| use native extensions to wrap your C kernel through an FFI, and
| on the web you can use WASM in supported browsers. But what about
| cases where people can't use your native extension? Suppose they
| are using a browser that doesn't support WASM. It's nice to be
| able to offer a polyfill that at least works, even if it is
| slower.
|
| The feasibility of this idea hinges on how easily you can write a
| conforming implementation of WASM in a bunch of different
| languages. But I don't know the WASM spec well enough to know how
| big of an undertaking this is.
| thomscoder wrote:
| helloo! what a nice problem you've brought up. I honestly do
| not know...yet. I'm as well studying the WASM spec as I'm
| making Luna (it still misses concepts like linear memory for
| example). Have not tackled the polyfills yet, I'm sorry. Anyway
| for the specs:
| https://webassembly.github.io/spec/core/intro/index.html this
| is where I get my infos from
| kasajian wrote:
| I think it's interesting the amount of justification given for
| why this is being built. Twice in the same paragraph. And no
| doubt there will be hundreds more wondering why do create
| something that already exists. Software developers are too
| fixated on pragmatism. If you're writing code, the resulting code
| better be something useful OR ELSE.
|
| Do you ever ask someone why they're doing a crossword puzzle?
| Playing a video game? Trying to get of an Escape Room?
|
| No. But if someone say writes their own Lisp as an exercise, oh
| the vitriol from the pragmatists.
|
| I've personally stopped answering that question.
| thomscoder wrote:
| hmm :( i'm sorry if I bored you with explanation. it was not my
| aim
| urbandw311er wrote:
| My reading of the parent comment is that it is actually
| sympathetic to you. I think it's saying you shouldn't have to
| feel you need to justify building this --- it's a great,
| worthy project just to do something to see if it's within
| your capability.
| chubs wrote:
| Thanks for showing this! Today I learned that wasm has a text
| format thanks to you :)
| thomscoder wrote:
| thank you :) happy to be useful!
| droobles wrote:
| This is awesome! I too have wanted to conquer the WASM dungeon
| but haven't dedicated the time myself to approach the project.
| I'm eager to look through this repo and learn a thing or two from
| it.
| thomscoder wrote:
| Thank you very much! :) I'm also writing blog articles. (i have
| to decide if doing a series or a one for the compiler and one
| for the runtime)
___________________________________________________________________
(page generated 2022-11-13 23:01 UTC)