Our Vision for Rust and WebAssembly
rustwasm.github.io
rustwasm.github.io
Awesome! What's there already is looking good. I wonder if it'll turn into an actual paper book some day like the second edition of TRPL did. [0]
On that note, my copy just shipped today (or at least received a tracking number), so get yours now!*
Alternatively TRPL is also free[1] of course, and there's a somewhat outdated PDF version[2] available. If you're motivated, you can just use that person's scripts to generate an updated copy probably. The advantage of those is that the online and unofficial PDF versions have colorized syntax; the no starch press edition does not last I checked. However, there's no reason not to buy it anyways if you're able. Personally nothing beats paper.
[1] https://doc.rust-lang.org/book/
[2] https://github.com/lise-henry/books
* = No conflict of interest exists here, Steve is just really nice to me on HN and I love Rust. :)
Hooray! I got to actually hold one last week, it was... wonderful. I am biased though :p
You know I just realized, if there's ever a revised print edition it'll likely be sold as a second edition, and that'll make it the second edition of the second edition.
We’re changing the naming for this exact reason, the next iteration of the book is being called the “2018 edition” to match with the new edition scheme generally.
Also my order shipped now, so it's done and in the mail.
Breaking the monopoly Javascript has had on this space for close to 25 years is a good thing. Perhaps people will continue to use it but it will have to be on merits rather than just merely being the only game in town. In any case looking forward to having more choice in this space.
IMHO, modern JS based frontend development is a combination of tedious, error prone, and backwards. If this honestly is the state of the art, then WTF. happened in the past 20 years.
Rust compiled to WebAssembly doesn’t have a runtime. This results in small .wasm binary sizes that are proportional to the amount of Rust code that is being compiled to WebAssembly. Binary size is of huge importance since the .wasm must be downloaded over the network. The proportionality means you only pay (in code size) for what you use. In turn, that means it is feasible for existing JavaScript code bases to incrementally and partially adopt Rust.
Great to hear they're taking this approach. I do think it'd be nice to have DOM access too though, as then you won't need JS at all - I do think long term the attraction of this is to replace JS as a front-end language, not just augment it, but it's nice they're taking an incremental approach.
If you use Rust strings, you may get a large amount of code included to handle them. Also, if you use malloc, that adds a significant amount of code.
It's true that languages like Rust have fewer runtime requirements than languages like Java but none of them are 100% proportional to the code you wrote.
Probably it's far away down the road? But I was under the impression that it will soon get supported.
Also (and this does apply to Rust to some extent too), if you start pulling in the stdlib for your webapp then you can't avoid compiling in a lot of code (for example the fmt or net/http packages are pretty big - fmt adds around 1MB to binaries on my system here). If the stdlib for any of these popular languages could be cached or included somehow in browsers that'd be awesome, as part of the attraction of using them is having a great stdlib.
It'd be great if at some point they managed to slim it down significantly as I'd really love to replace JS with Go specifically.
For example, ClojureScript compiles to JavaScript. Clojure didn't need WebAssembly to do so.
Javascript, despite having monopoly on the client side since 2007, only saw its usage exploded with Node and NPM around 2013. Java applets and Flash were long dead by then. So it seems that JS success is only partially correlated to its hard-won monopoly on the client side. My intuition is that JS ecosystem cannot be that bad and win so many hearts. Using your words, it seems JS won based on some merits.
A few others clues: Hot reloading, fast build time, good debugging and profiling tools, lots of packages, plenty of already answered problems on stackoverflow/github, progressive complexity, multiple approaches possible from FP to OOP, particular attention to the developer experience (error messages, colors...), good set of linting tools with Typescript or Flow, easy to deploy/deliver, works to make desktop/mobile/web/VR apps, customizable build accessible to mortals, good enough package manager, evolving language that understood that it can always do better, welcoming and accessible dev community, mature networking APIs, good runtimes implemented by different companies...
As for build times, modern javascript is like having all of the disadvantages of a tedious build process without most of the advantages. You are spending the time, yet still don't have static type analysis and exclusion of whole categories of bugs. The reality is that, mostly for political reasons, javascript was the only thing that ran in a browser and after particularly MS (but certainly not them alone) ran into trouble with security issues, nobody really dared to do much else for a long time. Plugin APIs were deprecated, proprietary browser specifics were abandoned, etc.
So, what's happening now is a long over due correction where people compile to some heavily optimizable subset of js called wasm. As soon as that becomes commomplace the whole argument for javascript needs to be revisited, pretty much for the first time this century.
I'm seeing this repeated more and more as a compelling case for using WASM. I've even repeated it myself. Does anyone know of examples of JS optimized for one VM not performing well in others, leading to a significant cost? I ask this as a Rust/WASM fanboy. Not doubting; just curious. I feel like I've already read a couple anecdotes but can't remember.
However, such applications will still have the same constraints that drive the current JS ecosystem. As such, there's little reason to believe that frameworks like React, Angular, Vue.js, etc. won't have their wasm-based equivalents. And, if anything, I except more churn for quite a few years, as people use the freedom provided by wasm to build a new generation of frameworks in completely different languages. We may look back on the current era of web development as a relatively stable one compared to what's to come.
So if the current churn is what turns you off web development, I wouldn't bet on wasm being a salve.
https://blogs.msdn.microsoft.com/webdev/2018/03/22/get-start...
In their case they compile a small enough subset of the .NET runtime to WebAssembly, and they got some JS to do the interop (I imagine till that glorious day of freedom comes). It's amazing what they've got working so far honestly.
The "put Rust in your JS" workflow is the first one the working group is focusing on; once that's awesome, other ones will get some work as well.
For example, a friend of mine just shipped a web-app for a client, that wanted something to help them organize local chemists conference between few universities. He wrote it in Elixir. Didn't actually use Javascript, because it doesn't need to be a single-page-app, right? :) Few froms, nice theme. Ok, maybe there was few lines of jquery, where absolutely necessary.
I remember once using Vaadin, just because I already know Java and didn't really care that nobody uses Vaadin anymore :D
Or, if you don't actually have client to solve a problem for, but want to try out a cool tech, I would suggest playing around with PureScript. Inspired by Haskell, compiles to JS, has nice ecosystem and many of the libraries don't have JS dependencies. Or maybe Elm, if you want something simmilar, but more focused/lightweight? :-) Claudia Doppioslash has a nice overview of both: https://www.youtube.com/watch?v=9kGoaUqcq4A
there are 2 different things, there is the DOM/Web API and the language, Javascript.
Nobody forces you to use anything from the JavaScript ecosystem, not even node.js, in order to use the DOM. This complexity is totally unnecessary.
I personally settled on Typescript, nothing more. Its compiler gives me Javascript WITH static typing, and converts my code to a version of JavaScript that will run on the majority of the browsers, even internet explorer 8/9 or old Android browsers. No need for React,Angular, Webpack, Babel and all that stuff...
As I'm not writing games or photoshop in the browser I see no need to use Rust,C,C++ and the SDL just to write web apps.
IMHO some people ultimately miss the true usefulness and use case for WASM: making existing C,C++,... libraries available to Javascript developers, not replacing JS with language X or Z.
Learn the actual web: HTML, CSS, and JavaScript are stable and don’t require any tooling in modern browsers. It’s pretty civilized these days with native support for ES6 classes, modules, arrow functions, data structures, spread & destructuring, fetch, async/await, etc. and things like CSS Grid for layout (head over to https://developer.mozilla.org for anything unfamiliar in that list). Support for non-current browsers can wait, hopefully until someone is paying you, and that’s a great time to learn about polyfills and transpilers.
The nice part about that is that it also plays great with WASM: you can write clean JS and call back and forth easily rather than trying to get dreadnaught-weight frameworks to work differently. I’m enjoying that right now since I see substantial gains swapping Rust-based hashing code to replace pure-JS alternatives.
leftpad-rs.js? :)