The Crystal Programming Language Forum

Crystal in (possible) WASM everywhere future?

I’ve just read this article on a role a WASM could play outside Web browsers which I’ve personally found very interesting for a lot of reasons.

It’s reminded me of this super fun talk which I also highly recommend to anyone (as any other talks/screencasts by Gary Bernhardt).

It’s like the future described in this talk is coming true step by step :slight_smile:

So I guess I have a lot of thoughts after reading the article right now, but mostly I’m thinking of this:

How Crystal with implicit imports borrowed from Ruby and a global type inference can fit into a model described in this Mozilla article - “nanoprocesses”?

For those of you who don’t want to read the whole article, the “nanoprocess” is a very lightweight way to isolate a piece of code for security reasons and an explicit way to request/provide access to resources like files, sockets and anything that should be protected. So it’s a way to implement the principle of least authority


I was thinking and write some comments on Trion OS forum on SourceForge for about similar stuff back in May 2004 . Universal bytecode that can be executed on any device, desktop IoT device and so on. Actually looks like I am father of Docker and Kubernetes ;) At least I coned that idea way back before actual implementation. May be they read my messages on that forum somehow ?)

Here is that message:

1 Like

Well I’m skeptical at the moment. Universal bytecode is the JVM all over again, let’s hope they have learnt from history. As for those “nanoprocesses” with fine-grained permissions and data copies I don’t think they’ll ever make it work outside their bubble, but I guess we’ll just have to wait and see.

I want WASM to replace js in the browser, that’s as far as my needs go.

reinvent java

Except that JVM have failed to hold “write once, run everywhere” promise, while JavaScript succeeded more on that front. And WASM is the next step.

The thing with this “terrible terrible JavaScript” is that it’s now everywhere and is probably the most used programming language. Turns out it didn’t even needed to be the best programming language for that to happen. But it was first, and then multiple vendors had to agree and implement it and all other features of evolving Web platform.

I see WASM as a very similar thing. It will be implemented by all browser vendors, it will work everywhere (Web). To bring it outside the Web is a logical step forward given the amount of “resources” available to that ecosystem (number of platforms, libraries, developers, you name it).

I would probably worry about Web itself to be on decline (watched one talk, but can’t remember the title from the top of my head), which of course can affect the WASM story outside of the Web.

I agree, it’s too early to make any conclusions and as everything in this world it’s hard to predict. But at least WASM itself is showing a great progress and thinking about Crystal’s future in the bigger context is also important.

Maybe:) OTOH it’s not that uncommon for different people to come up with very similar ideas at roughly the same time.

Idea was described at least 6 years before first Docker release and 10 years before Kubernetes first mentioning ;)

Idea is more low level though as it was for grid/cloud operating system. Can be done with LLVM BC easily. Wasm just one step above. All current browsers are using JIT somehow and most likely they use LLVM for that.

Meanwhile WebAssembly 1.0 Becomes a W3C Recommendation and the Fourth Language to Run Natively in Browsers

Support for WebAssembly in browsers is already great.

Other great news is that things needed for Crystal to support WASM target such as

  • Threads
  • Exception handling
  • Garbage collection

are already in progress. See Features to add after the MVP

Fingers crossed for fast progress in this area. Can’t wait to use Crystal in browser or any other WASM runtime.