Show HN: Sauron – A web framework in Rust that adheres to the Elm architecture
github.com
github.com
I'm looking in your direction Medium, at 6MB with a cold cache!
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.
Demo: https://richardanaya.github.io/wasm-module/examples/tinygo_c...
Article: https://medium.com/@richardanaya/hyper-efficient-front-end-d...
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.
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.
To be fair, working in this industry you could have been doing that without doing JavaScript :)
The Big Elixir 2018 - Desmond Bowe - Hot Upgrade Are Not Scary https://www.youtube.com/watch?v=IeUF48vSxwI
https://www.webpagetest.org/result/190426_YD_9088b86bbe21e61...
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.
One crate to rule the DOM
One crate to find the elements
One crate to bring JSON
And in the Rust code bind Strings$> wasm-pack build --target no-modules --release -- --features "wee_alloc"
It will shrink it down to 165KB
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.
0: https://hacks.mozilla.org/2018/01/making-webassembly-even-fa...
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.
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?
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.
Par for the course
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.
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.
[1] https://elm-lang.org/blog/farewell-to-frp
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.
Since I don't know anything about Elm, I'm curious to see what about Sauron makes it more Elm-y than Yew.
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!)
Cough. Cough. Clojurescript. Cough.
edit: Ah, calls to js are still necessary to create DOM elements, so there's lots of back and forth necessary in the wasm frameworks.
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.
5.) It's in the early phase, so the performance is not yet optimized. https://github.com/ivanceras/todomvc-perf-comparison/
FYI, since the most recent stdweb version it's possible to use `wasm-bindgen` with Yew
The README mentions "This project is based on the existing projects: (...) Yew (...)", but I think the author meant "inspired by", not "based on".
I laughed at this, idk why.
It's fun to see some people being honest about it. "It's good enough" is pretty honest here.
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.
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.
Curious as to how WASM impacts browser caching?
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.
fn view(&self) -> Node<Msg> {
div(self.attributes(), self.content())
}
fn content(&self) -> Node<Msg> {
input([
class("client"), r#type("button"), value("Click me!"),
onclick(|_| {sauron::log("Button is clicked"); Msg::Click})
],[],)
}rustorm - an orm in rust
diwata - a database UI in rust.
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.
This is not to say that the holder would still not litigate out of fear of losing their mark, 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.)