
Yew: Rust framework for making React-like client web apps - syrusakbary
https://github.com/DenisKolodin/yew
======
aeleos
When I saw the work being done with adding web assembly support to rust I
though it was cool but I never really put much thought into how far it could
be taken. Seeing projects like this is really great and makes me realize just
how much room there is for using rust for web front ends. Given all the
consideration for performance that the web has needed recently, I am excited
to see what is possible with wasm and rust in the future.

Also, its amazing how fast this has popped up. Wasm was added to the compiler
literally a month ago and already there is a standard library from dom
manipulation and front-end frameworks. 2018 is definitely going to be
interesting

------
kochthesecond
Why does update(...) mutate the model instead of returning the next state?
This would make update a function instead of a side effect mutating the model.

~~~
vvanders
Probably for performance reasons, allocating a whole new state each frame is
pretty expensive.

~~~
whateveracct
Incremental updates to large, immutable data structures do not require
allocating a whole new state per update (despite maintaining immutability!)
Mutation is still frequently more efficient though, at the cost of not being
able to reason immutably about your program. But if you're doing something
that requires multiple versions of your state (e.g. history,
undo/backtracking), the immutable version is going to be more efficient and
_definitely_ easier to write efficiently in the first place.

~~~
imtringued
Most efficiency gains of imperative programming languages like C or C++ come
from the compact and continguous memory layout and usage of the stack which is
usually in the L1 cache.

In theory there would be no difference between mutating an existing memory
area and allocating new memory to write to it. The number of bytes written to
RAM are the same.

~~~
lossolo
> In theory there would be no difference between mutating an existing memory
> area and allocating new memory to write to it. The number of bytes written
> to RAM are the same.

It's not the same, you need to allocate new memory, if it's on the heap then
(depending on your allocator/OS etc) you will be making a syscall, which means
context switch, cache eviction etc.

------
dethos
This is awesome. Is one of things I was hoping to happen when I first heard
about wasm.

Nothing against JavaScript, but I is nice that other languages can now be
first class citizens on the web as well.

------
ctulek
I was imagining a React style UI framework but for desktop apps. The
ingredients I have in mind are React, GraphQL, and Rust. I think these three
solve the problems of their respective areas the best and combining them
together would be priceless.

~~~
Yoric
How would GraphQL be useful for a desktop app?

~~~
odammit
I think GraphQL is useful for getting data for UIs on any platform.

\- build views without being blocked waiting for a new rest endpoint

\- get exactly what the UI needs to render

[edit]

Although to negate my own first point, nb4 being blocked on waiting for new
mutations and queries :P

~~~
k__
Also, you can use it to query local data too.

This enables you to transparently move data-source around.

~~~
odammit
That’s a good point! Never thought about local data sources. I’ve only mapped
over SQL, REST, and redis/etc.

------
MrBuddyCasino
As the great cambric JS framework explosion fizzled out, only a few lucky
survivors where left (angular/react/vue.js).

Little did they know that web-assembly was already scheming their demise.

~~~
sophiebits
Don’t worry, we know.

~~~
murukesh_s
Wondering if you are doing anything about it?

p.s asking as @spicyj is, from her profile, an "eng manager of React @
Facebook".

------
api
So here's my Christmas present, and maybe an excuse to learn Rust. Ho ho ho!

------
carlosdp
I was literally thinking "Maybe I should try using stdweb with React" last
night. Awesome work, can't wait to use it/contribute!

------
hokkos
The counter demo is 9.4mb in amsjs and 1.5mb is wasm.

~~~
mkl
Is this after running wasm-gc? [https://www.hellorust.com/news/native-wasm-
target.html](https://www.hellorust.com/news/native-wasm-target.html)

------
cdaringe
Great concept. This is my desired FutureStack for 2018!

------
bcherny
Wow, that's a really clean API. Nice work!

------
bsaul
Any update on wasm support for mobile platforms ?

~~~
whatever_dude
Uh, it works?
[https://caniuse.com/#search=Webassembly](https://caniuse.com/#search=Webassembly)

Remember you can also have a polyfill (at a performance cost when parsing).

------
fiatjaf
Coming next year: PHP apps that compile to WASM, so you can <?php ?> right in
your HTML.

~~~
krapp
Or, I bet, a WASM port of Arc and the default Arc forum.

------
qarioz
Benchmark?

------
mlevental
color me shocked: this is really a rust web framework (compiles to wasm). i
was expecting a backend framework that supported react development on the
frontend in some non-trivial way. wow. very cool.

but i thought wasm couldn't manipulate the dom? is that not the case anymore?

~~~
pohl
It can through a thin bridge.

See [https://github.com/koute/stdweb](https://github.com/koute/stdweb)

~~~
mlevental
so how mature is this tech? is this really feasible? writing browser client
code in rust?

~~~
steveklabnik
The biggest holdout is non-Edge IE
[https://caniuse.com/#search=wasm](https://caniuse.com/#search=wasm)

The story with Rust compiling to it is still younger; it works well at the
moment, but is very fiddly. The early adopters and enthusiasts are working on
making it all smoother. So for most people, it's still a bit young. Just
depends on your temperament.

~~~
tomatsu
> _The biggest holdout is non-Edge IE_

IE is discontinued. IE11, which was released back in 2013, only gets security-
related updates. It's on life support.

IE11 part of Windows 10 which EOLs in 2020 (mainstream) or 2025 (extended).

~~~
leeoniya
we still have 7.6% IE11 ecommerce traffic which converts very well (US, home
remodeling).

it does appear to be declining ~0.2% per month, but it's a long way off from
dead :(

~~~
lj3
7.6% isn't considered dead?

~~~
pharrington
Actively doing something that predictably results in 7.6% less traffic to your
profit generating website seems quite the _questionable business decision._

~~~
lj3
How much money are you spending on dealing with IE11 bugs? My estimate from my
last job is more than that 7% brings in.

~~~
geofft
Are there actually IE11 bugs at a noticeably higher rate than bugs (or
intentional deprecations) in other browsers? I thought we were just talking
about a lack of new features that are present in Edge.

(If you were talking about IE5 or IE6 I'd understand the argument.)

~~~
leeoniya
most ie11 bugs that are relevant/annoying are around its flexbox impl.
specifically equal height boxes via min-height and such. maybe some other
fancy css animation or 3d transform stuff, but these are not terribly critical
and can degrade without much impact.

thankfully, js and dom bugs are either rare or well-known and have lightweight
polyfills.

------
patientplatypus
Maybe I don't get it, but why would I use this? What problem is it solving
that _insert JS framework_ isn't?

I understand JS is popular to hate, for a variety of reasons, but those
reasons seem mostly to boil down to nerd cred. The "hate what's popular
because being contrarian means I'm cool" crowd.

So, and this is an honest question here, why should I invest the time to learn
an entirely new syntax for a framework to build web applications? What can
this do that vue.js or react cannot? (And I don't mean it does it
_differently_ I'm looking for it does it _better_ or JS framework _doesn 't_
do it.)

~~~
lmm
> I understand JS is popular to hate, for a variety of reasons, but those
> reasons seem mostly to boil down to nerd cred. The "hate what's popular
> because being contrarian means I'm cool" crowd.

Then you're not paying attention. I'm not sure how you expect anyone to answer
your "honest question" when you've already dismissed all the answers. It's not
just fashion, programming language design is a real thing that it's possible
to do badly or well, Javascript is a legitimately bad language, and Rust is a
legitimately good language.

Learn Rust or another ML-family language, actually learn it to the point where
you can write a decent, full-sized, _idiomatic_ program in it. It won't be
easy, but it's worth it. I mean, I could talk through all the reasons such
languages are better, but it seems like you're already determined to dismiss
them, so really the only way is to see for yourself.

~~~
_Tev
> Javascript is a legitimately bad language, and Rust is a legitimately good
> language.

Yeah, statements like these without even trying to back them up are pretty
ridiculous.

Sometimes someone brings some stupid issue that's never a problem in practice,
but most of the time people just admit they simply have no real experience
with JS. They just love to claim how superior they are, and anyone who
disagrees is "not paying attention".

FYI you are just showing how awful are communities around "legitimately good"
languages.

~~~
rebotfc
> FYI you are just showing how awful are communities around "legitimately
> good" languages.

Just to let you know Rust's community is pretty cool and not awful at all. For
instance the Rust Survey 2017 reports that 98.7% of respondents feel welcome
within the Rust Community.

Furthermore according to the Stackoverflow 2017 survey, Rust is the "most
loved" language.

~~~
_Tev
Sure, I bet community is great otherwise, it is just occassional elitism
(which I guess was inherited from the C++ community) that comes off as toxic.

Btw that same survey showed how people are quite fine with writing JS, which
makes this entire thread seem even more ridiculous.

------
Dowwie
Wanted: Full stack rust developer

