24 ms·
Yew: Rust framework for making React-like client web apps
- ctulek 9y agoI 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 9y agoHow would GraphQL be useful for a desktop app?
- odammit 9y agoI 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
- deleted 9y ago[deleted]
- k__ 9y agoAlso, you can use it to query local data too. This enables you to transparently move data-source around.
- y_u_no_rust 9y agotalk about going backwards ffs
- odammit 9y agoThat’s a good point! Never thought about local data sources. I’ve only mapped over SQL, REST, and redis/etc.
- ComputerGuru 9y agoNative applications don’t need that, though. Modern languages embrace async/await and don’t waste cycles or block the UI or even the backend unnecessarily waiting for network/local IO or user interaction. In that regard, rust is actually behind. Async/await is still coming.
- odammit 9y agoNative applications don’t get blocked waiting for backend engineers to implement a new REST endpoint? Native applications don’t benefit from smaller responses of just the data they need to render a view? I am confused.
- ctulek 9y agoA typed query language will definitely help for anything you store either locally or remotely. In this case, it would provide information to compiler to do most of the type checking for you. It is not only GraphQL itself I had in mind though. It is also about implementing a client library similar to Apollo GraphQL where you can provide watch queries wrapping your UI components. Watch queries provide great developer ergonomics for handling the flux data flow, that is, whenever there is a change to your data in store, if the corresponding elements in datastore are watched by a query, the UI components wrapped by this watch query are re-rendered with new data, automatically. I think this combination will help desktop development by helping to reduce boilerplate code and by providing a convention to development team. We enjoy this combination already in web UI development for the last one year, in our team.
- danieldisu 9y agoI think Rust may be a bit too low level for that but at least you will be in the HN frontpage with that combination for sure!
- xfer 9y agoHow is rust too low level for a desktop app? All the native ui toolkits are in C/C++ ...
- StavrosK 9y agoIs there any good/mature/sane library for UI in Rust? I'd love to use Rust for a desktop app I want to write.
- lj3 9y agoDoes Nuklear fit your definition of sane UI library? https://github.com/vurtun/nuklear https://github.com/vurtun/nuklear https://github.com/snuk182/nuklear-rust https://github.com/snuk182/nuklear-rust
- StavrosK 9y agoThat looks interesting, but I'm talking about something more like GTK, ie something that looks somewhat native and is easily portable across OSes.
- andrewflnr 9y agoThis comes up in /r/rust periodically, and IIRC the answer is still pretty much "no". It is getting better, though, slowly. I'm on my phone and too lazy to find a link for you, but search /r/rust for discussions about GUI libraries/frameworks.
- steveklabnik 9y agoIntegration with GTK is getting easier and nicer, but there's more work to do.
- 9y ago
- steveklabnik 9y agoThere's been some work on GraphQL and Rust https://www.gjtorikian.com/posts/2017/08/15/wrapping-rust-in-ruby-to-parse-gql/ https://www.gjtorikian.com/posts/2017/08/15/wrapping-rust-in...
- mastax 9y agohttps://github.com/antoyo/relm https://github.com/antoyo/relm is almost that, except elm-inspired rather than react-
- bcherny 9y agoWow, that's a really clean API. Nice work!
- cdaringe 9y agoGreat concept. This is my desired FutureStack for 2018!
- kochthesecond 9y agoWhy 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 9y agoProbably for performance reasons, allocating a whole new state each frame is pretty expensive.
- kochthesecond 9y agoI would argue that it is obviously worth it for the simplicity of being explicit what is the next state. This kind of performance optimization, especially outside of game engines seem unnecessary.
- cube2222 9y agoThis is Rust. Not exactly a language that makes compromises on performance for the sake of simplicity.
- vvanders 9y agoEach cycle you waste on mobile is milliwatts you're burning from the battery. Even if the user doesn't perceive it their battery will appreciate it.
- kochthesecond 9y agoYou save a single allocation for every state change in your app? Never mind the actual render cycle? And lose a simple reference check to decide if you can short-circuit a part of your app?
- algesten 9y agoit's not any more expensive than allocating a new object in Javascript. possibly less. if you want immutable models, allocation will most likely happen on mutation.
- api 9y agoSo here's my Christmas present, and maybe an excuse to learn Rust. Ho ho ho!
- mlevental 9y agocolor 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?
- steveklabnik 9y agoWasm can't directly, but it can call into JavaScript, which can. That's what this does. DOM support for wasm really means native DOM support, which removes that layer of indirection, and therefore will make it faster.
- mlevental 9y agoi was going to ask if DOM support is on the road map and this comment https://news.ycombinator.com/item?id=13614886 https://news.ycombinator.com/item?id=13614886 claims it is but it's no longer in the high level goals in the spec link is dead... so do you know if it is?
- lj3 9y agoI don't know where it is on the current roadmap, but there's some activity here: https://github.com/WebAssembly/host-bindings/ https://github.com/WebAssembly/host-bindings/
- mlevental 9y agoweird i tried to post a thumbs up and hn deletes it. is it because it's a single rune? no it doesn't appear in this reply either.
- ComputerGuru 9y agoAside from the fact that a single thumbs up doesn’t qualify as a comment by HN standards, select Unicode characters are whitelisted but the rest are sanitized.
- carlosdp 9y agoI was literally thinking "Maybe I should try using stdweb with React" last night. Awesome work, can't wait to use it/contribute!
- fiatjaf 9y agoComing next year: PHP apps that compile to WASM, so you can <?php ?> right in your HTML.
- krapp 9y agoOr, I bet, a WASM port of Arc and the default Arc forum.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- aeleos 9y agoWhen 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
- MrBuddyCasino 9y agoAs 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.
- jacobush 9y agoI'd like to think it is more like when Oxygen entered the scene. Maybe we can never get rid of of Javascript, but like anaerobic bacteria, maybe it can stay put and out of sight under some rock.
- sophiebits 9y agoDon’t worry, we know.
- murukesh_s 9y agoWondering if you are doing anything about it? p.s asking as @spicyj is, from her profile, an "eng manager of React @ Facebook".
- hokkos 9y agoThe counter demo is 9.4mb in amsjs and 1.5mb is wasm.
- mkl 9y agoIs this after running wasm-gc? https://www.hellorust.com/news/native-wasm-target.html https://www.hellorust.com/news/native-wasm-target.html
- dethos 9y agoThis 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.
- Dowwie 9y agoWanted: Full stack rust developer
- bsaul 9y agoAny update on wasm support for mobile platforms ?
- whatever_dude 9y agoUh, 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).
- patientplatypus 9y agoMaybe 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.)
- coldtea 9y ago>What can this do that vue.js or react cannot? It allows you to write your web app in Rust. >And I don't mean it does it differently I'm looking for it does it better or JS framework doesn't do it. "Better" depends on the use case, so merely by being different something might better fit another use case.
- patientplatypus 9y agoOk...is there a use case where Rust is better? This seems like you're punting. Why would I want to invest the time and energy to learn this?
- xfer 9y agoYou wouldn't invest time and energy to build web app in rust, but you would be able to write your frontend in rust instead of investing time and energy in $JSFRAMEWORK of the year.
- _Tev 9y agoOf the year? So react is new or something? This is super outdated meme at best.
- kbenson 9y agoFor some of the same reasons you might want to write your back-end in JS, but going the other direction. You could share code between front-end and back-end, but have a very strongly typed, secure, fast, and less prone to bugs language to do it in. Not everyone's cup of tea, but if you're already got a lot of code written on the back-end, this might make a lot of sense.
- qarioz 9y agoBenchmark?