Between this and Blazor ( http://blazor.net/, among other wasm projects I'm forgetting right now), I'm glad more complicated UIs are being once again designed on the backend and keeping bundle sizes (relatively) small, rather than making everything in JS on the frontend and expecting everyone to download megabytes of code to visit a website.
I'm looking in your direction Medium, at 6MB with a cold cache!
Large bundle sizes are not a consequence of creating UIs on the frontend, they are a consequence of bad practice. I have created plenty of purely frontend apps that don't even approach 1 MB let alone 6 MB. In fact, most languages that can target WASM seem to produce enormous modules compared to a reasonable frontend JavaScript app. Rust is an outlier in my experience because of its minimal runtime.
It's also worth noting for example that only 1/5th of the data transferred when I load medium.com cold is their JavaScript, so WASM can't really help them either way.
I did not know about tinygo and this is pretty impressive. However, it is only a subset of Go missing a few features, most notably the fact that memory is never deallocated.
Also, the equivalent JavaScript is still a fraction of this size. That's actually roughly the size of Preact, which implements nearly all of React.
Agreed, though it's a lot easier for bad practice to happen with JavaScript than a lot of other languages, and frameworks like this (hopefully) will make for a larger 'pit of success'.
Uuuggghhh, the baseless and ignorant JavaScript hate is a weak argument. It’s not any different than other baseless, weak, ignorant arguments; such as: ______ because _____(protected class) people.
I am paid well to do no work, essentially on retainer, because it’s so common for people to dick this up and then blame the technology for one’s own incompetence. Like anything else it only requires a little bit of practice. Running screaming into the night only to bury your head in the sand behind the magnificent glory of favorite pet framework x isn’t practice.
I describe this to nonprogrammers as hating on pianos because there is too much potential for bad music.
I said it was bad practice that led to the large size of Medium's website, but only 20% of that download size is their application's JavaScript. In what way did the use of JavaScript make it “easier” for the remaining 80% of the download size to happen?
My bet is LiveView will become the king of the fast prototype. It doesn't do SPA, but it does damn near everything else with ease and so few lines of code.
If I get this correctly, both this and Blazor are handling most of the UI logic in front-end, despite they are WASM.
So WASM is just another bytecode encoding that relatively smaller than JavaScript, without solving the problem from the root.
In contrast, a server-side heavy solution like Phoenix LiveView that has been heavily mentioned in this thread would do hold the logic on the server side, so in the client, there's only very few generic logic handling the DOM patching.
It depends on the JS and the WASM framework... Blazor in particular carries a lot of framework overhead with it. Also, like mentioned elsewhere in the article, something similar to JSX for one of these WASM frameworks would be very useful. As would a close to in the box UI toolkit that at least used or resembled material design or bootstrap.
Blazor is nowhere near optimized yet - give Microsoft some time. They just committed to Blazor officially (it was an 'experimental' project until the 19th of April.)
Sauron looks really great and I for one am super excited about the future of Rust + WASM for web apps(with Backend). However I am a bit concerned that even the minimal example is 1.17MB of WASM which seems really high since Rust compiled to WASM should be quite small.
165kb is still fairly big for a minimal example, much smaller than 1.17MB though, compared to React for example. Are there ways to analyze what contributes to the size for WASM compiled projects? I guess wasm-bindgen contributes significantly to the size currently.
EDIT: It's 68KB gzipped and 165KB is the uncompressed size. One great benefit of WASM is that as described in "Making WebAssembly even faster: Firefox’s new streaming and tiering compiler"[0] it's much faster than JS to parse and execute.
I think If you start adding more code, the growth of the release binary will diminish. The todomvc code is only 207KB when compiled and has relatively more code than the minimal example.
There is a lot of rust compilation flags, and I have only tested a few.
I also enabled a lot of wasm-bindgen features in the library, I will eventually tighten it up.
> EDIT: It's 68KB gzipped and 165KB is the uncompressed size
What's the state of brotli content type support in browsers? Wasn't that supposed to be the next generation beyond gzip? Would it get a better still compression ratio? And FB is pushing zstd -- is that something that might be supported eventually?
It's still a lot given that when targetting the entire world (especially either mobile links or portions of the globe that don't have a CDN a millisecond away), a typical assumed link is on the order of 512 kbps bandwidth with 100ms RTT. That's two and a half seconds to load just your framework with a cold cache and without including any content.
Yes, many web developers are just targeting their own areas and test on high-speed links and everything seems fine, but frameworks that aim for widespread use still need to care about every single byte.
Images are not comparable to WASM and especially not to JS. This is described in "Making WebAssembly even faster: Firefox’s new streaming and tiering compile", but the TL;DR is that network is less so the bottleneck than parsing and execution these days.
Further the notion that 168kb is nothing is a bit sad when you consider emerging markets and other low bandwith/CPU scenarios. One of my hopes with WASM is that it can achieve both smaller bundles and better parse/execute performance. To my understanding one of the big blockers for this right now is the lack of a DOM API for WASM.
> Elm gets plundered repeatedly before it ever reaches version 1.0.
I concur. Ever since Elm 0.17 [1], when Evan removed event streams and standardized on The Elm Architecture, Elm seems to have lost its way. Just saying as an interested outsider.
I presume it is a matter of perception: Elm is now perceived as a GUI toolkit rather than a language in its own right. Elm achieved simplicity and, ironically because of that, it is now plain easy to port its main ideas to other languages.
Because elm is elegant. I have written web-app with elm on the client side and rust in the backend. It was great, except for duplication of code when serializing/deserializing json data when making API calls. With sauron, I save up a lot of duplicated codes, and gotta squeeze that webassembly performance as well.
Do you have any experience with Sauron vs Yew? I'm quite interested in Yew due to the benchmark and that their code examples look similar to me. Yew also says Elm inspired.
Since I don't know anything about Elm, I'm curious to see what about Sauron makes it more Elm-y than Yew.
The main issue with Elm is the glacial development pace. I understand why it is the way it is (it shows in how well designed what is there is), but it really does hurt as someone who wants to adopt it.
Yep! I'm writing this from Elm in the Spring, the 2nd of 4 dedicated Elm conferences in 2019.
JS/TS continue to dwarf everything else, but it's possible that Elm is the most widely used JS alternative at this point. (Hard to know definitely though!)
If my hypothesis is correct and it loses ground in benchmarks due to overhead of calling js dom methods, then I would expect native bindings to improve performance. I'm not an expert or anything in this field though, so maybe someone closer to the issue can chime in.
1.) The syntax in creating the view: is just plain function calls which the rust compiler can accurately tell you about errors in your code, ie: typo, unclosed brackets/braces/parenthesis mismatch.
2.) Concise code, there is not too much ceremonial/boilerplate code to get started.
3.) Less code in the library maintain, there is no parser(which are mostly complex).
4.) Sauron is using wasm-bindgen, yew is using stdweb.
The usual mentality is "Use us 'cause we're faster than all those SLOW frameworks!" and then they show you a graph of a benchmark was in a specific instance they're X faster than the common options.
It's fun to see some people being honest about it. "It's good enough" is pretty honest here.
I traded a bit of performance for aesthetics by cloning the children of a node. I tried the todomvc benchmark and saw it wasn't so bad without employing optimizations in placed. It's still in it's early stage though.
Would there be an easy/straightforward way to put a jsx transpiler in front of the rust compilation step, potentially with hot reloading?
I realize that jsx in react is really just calls react.createElement, but I do think it's a very useful abstraction when you're ultimately constructing html.
The main issue is that jsx can contain both mutable references to a variable and immutable references. For example <div onClick={() => count = count + 1}>{count}</div> contains both a mutable reference to count and an immutable reference. Thus, the naive way of storing this in a single struct will fail. The use of the elm architecture (where the onClick handler returns a message, instead of directly updating count) side steps the complicated borrow-checker issues.
It is certainly possible to get around this with the proper procedural macro, but it is not easy, and will never be as "magic-free" as people want.
Look into the framework Yew. It sits somewhere between elm and react in how it's designed, and makes use of an html macro that allows for jsx-like markup.
In the JS scenario, several modules will be cached and change in one may still allow usage of other cached modules, thereby reducing future load times.
How will that work in WASM work, since I'm assuming that the entire app will be packaged at build time as a single binary. Is the assumption even correct?
Or, is it simply a question of architecting your app well into several WASM modules, since I'm assuming WASM modules (or whatever they are called) can call each other and do lazy loading.
I can see this going in two ways: either we'll have WASM "shared libraries" that can be cached, or every website will go the way of apps and contain duplicate WASM modules in it.
Commend on the attempt, foward thinking now wasm is getting more traction. but I can imagine that view syntax turning into an insane > circa the old days of callbacks in nodejs
You can also take a look at the window_tab_rows example. It will allow you to modularize into isolated subcomponents which you can embed into the main component.
As long as all event callbacks are delegated into the update function and unified in an Msg enum, the code will have the same pattern regardless of how big the project is.
In that case, breaking up the functions into several smaller functions helps. The rule of thumb of the size of a function body shouldn't be larger than the size of a computer screen.
Looks cool, really like the name. It’s always interesting to me to see other developers who are good at branding, despite no obvious marketing background.
Probably not, technically, but it's sort of in that (Gandalf The) Grey area where nobody really gives a shit so you'll get away with it. This is just a random project on GitHub, it's not like a major corporation is putting this out. If they did, they could just remove the copyright images and possibly rename it if they felt it was really necessary.
Is that the Internet's idea of "fair use" which is "I can pretty much do whatever I want as long as I say 'fair use'", or the legal one?
Calling it Sauron is almost certainly OK. Using an image from the movie probably isn't, and the reason why isn't copyright, it's trademark. It makes it look like it may be officially related to the trademark owner. This may sound silly to you, but in a world where the New York Times has an active open source contribution page, along with other non-tech-companies that have put out open source like financial companies, audio companies, etc., the idea that a movie production company might put out a web framework is well within the bounds of possibility. For similar reasons, calling it Sauron is OK but I'd want to lean away from any obvious relationship to the Lord of the Rings, such as posting a satirical version of the ring's inscriptions. (A literary estate putting out a web framework is much less plausible, but on the other hand, they're well known to be on the litigious side, so personally I'd avoid it even so.)
On the plus side, the worst case plausible scenario is a cease and desist, which may never come. Things only get nasty if the project refuses after that.
The granting of trademarks is narrower than that. The protection only applies to products and services that are "identical or 'colourfully' similar to the "registered" products or services".
This is not to say that the holder would still not litigate out of fear of losing their mark, though.
That's for using the same word for different things. You can start a new company called Apple in other industries, no problem. You can not use the Apple computer company's logo as yours, though.
You can probably use Sauron, but you can not literally put up a picture of the Eye of Sauron as your project logo without making it appear that you are operating specifically as that trademark holder. With that picture, they're not just claiming to be "a" Sauron, they're implicitly claiming to be associated with whoever currently holds the rights to those movies.
(I'm only hedging on the "probably" because of the known litigiousness of the Tolkien estate. Normally it shouldn't be a problem.)
I'm still waiting for something like scala.js for Rust. I don't like the thought of using two different programming languages and currently it seems scala.js is the most dependable front-end library
What specifically are you waiting for? You can already run rust in the browser, by compiling it to wasm and talking to the DOM using wasm-bindgen (like this Sauron library is doing).
Folks please take care in how you name your open source project. Sauron is not something I want to think about every time I sit down to work, neither are cockroaches (CockroachDB).
There was a time when people named stuff after positive things. If you asked my psychologist ex about people who name things after Saurons and Cockroaches, she'll jump to some 'priliminary conclusions'. This country needs frequent mental checkups like we have frequent dental checkups
I'm looking in your direction Medium, at 6MB with a cold cache!