8 ms·
Rust on the Frontend and Backend
- alexjplant 5y ago> .NET had a feature where you could essentially code as if you were writing a form application in C# and it would compile to a web form and wire up JavaScript, HTML and CSS so you never had to learn anything about web technologies. This is likely referring to ASP .NET Web Forms. While this is theoretically true the reality was more nuanced; you had to know HTML/CSS in order to style your applications and you had to know a wee bit of jQuery to make things happen on the page when you didn't want to trigger a "postback" (their proprietary term for a POST request laden with the requisite ViewState and session magic). The _real_ magic of ASP .NET was implicit state management... you didn't have to know anything about sessions, cookies, HTTP, CSRF, or LocalStorage (which, sadly, was around for some of Web Forms's heyday because many devs clung onto it for much longer than they should have). The whole point of Web Forms was to replicate the WinForms experience in a web context so that devs didn't have to reason so much about client vs server state. Everything was rendered server-side and state was retained via a combination of session and the aforementioned "ViewState", which was basically a massive encrypted form field with the application state that got submitted with every request. It could probably be argued that Web Forms doesn't even really qualify as web development. I've weaned developers off of WebForms and for most of them it was their first exposure to basic tenets of web development like HTTP verbs (let alone RESTfulness), JSON, vanilla Javascript, sessions, and actual honest-to-God state management.
- pkos98 5y ago> .NET had a feature where you could essentially code as if you were writing a form application in C# and it would compile to a web form and wire up JavaScript, HTML and CSS so you never had to learn anything about web technologies. So does JVM now :). But with a more en-vogue API. https://blog.jetbrains.com/kotlin/2021/05/technology-preview-jetpack-compose-for-web/ https://blog.jetbrains.com/kotlin/2021/05/technology-preview...
- overtomanu 5y agoI think jsp/jsf were the equivalent to ASP on java side
- alexjplant 5y agoIf memory serves vanilla JSPs were largely stateless but JSF was pretty much the Java version of Web Forms. Obviously it being JVM it required a lot more bootstrapping since it was less opinionated/OSS but the effect was largely identical.
- spaetzleesser 5y agoVery true. I did Webforms for a while. It was fine but once I needed things like Ajax things got pretty convoluted. There were callback panels and stuff. Things were super complex and I spent a lot of time fighting the framework. Then I learned about jquery and saw how simple Ajax calls really are. Same for a lot of other things: the Webforms abstractions made things more complex than they really are. And you don’t learn how things really work. Since then I am very wary of frameworks that provide a lot of abstractions. Easy to get into but after a while there is a risk spending more energy fighting the framework than you would have spent learning the native way. Happened in my company with Xamarin. Looked good for C# but after a few months everything got scrapped and the devs went native.
- seumars 5y ago>The advantage is that [learning Rust] automatically filters, uh…, script kiddies >So if you want to hire someone to write Rust for you, it’s pretty safe. I'd be really sceptical of hiring someone who refers to other developers as "script kiddies". Rust has been getting a lot (well deserved) attention but I hope people aren't learning Rust as a status symbol.
- capableweb 5y ago> but I hope people aren't learning Rust as a status symbol. Of course they do. Lots of learning today seems to be based around "what looks nice to put on my resume?" which is effectively a status symbol, rather than choosing tooling that is actually the best for the job. Same applies for a ton of stuff as well, not just Rust.
- dboreham 5y ago"Resume-driven development"
- seumars 5y agoWeb development > personal development
- capableweb 5y agoNo, that's something else. Choosing languages in order to look better on the resume is not personal development, it is resume-driven development. Learning new languages in order to become a better programmer overall is personal development, or learning languages that fits better with "you as a person". But chasing hype is not "personal development" and that meme needs to die.
- moritzwarhier 5y agoSad and true. The other side of the equation is people being forced to work under abysmal constraints, because of technical choices made years or even decades ago. That being said, "Rust on the frontend" sounds pretty ridiculous to me. I'm sorry for not having read the article before commenting.
- christiansakai 5y agoI think it is a disadvantage to write Rust on the frontend. Frontend code moves too much and quick prototyping/iteration is more important than memory control. As for typing, just use TypeScript. It is really good enough already.
- smoldesu 5y agoI haven't had many issues with it. My development cycle has normally involved getting the basic functionality of my program to work, then adding a UI layer over it with the GTK crate. In terms of how fast it is to prototype/iterate, I could very easily manipulate and edit the UI file in Glade, then rebuild the program in only a couple seconds to test the result. >Frontend code moves too much and quick prototyping/iteration is more important than memory control. You can have both, really: Rust makes a lot of compromises on it's debug builds, but it compiles lightning fast. As I said above, you can change your program and see how it looks in realtime by simply dropping "cargo run" into the shell. There's not much I can do for you here except tell you to see for yourself.
- christiansakai 5y agoI see. Last time I saw Rust compilation speed isn’t that fast.
- smoldesu 5y agoFirst time compilation is notoriously slow, since Rust has to compile your dependencies into object files, and to make "release" binary, it has to re-compile those same dependencies to make a statically linked and optimized executable. The actual debug process is fairly quick though, since it can just link the deps to a lazily compiled binary for debugging purposes.
- jokethrowaway 5y agoI disagree TypeScript is good enough. It's easy to run into untyped (or partially typed) dependencies (a massive pain to write) or in internal code which uses any/unknown somewhere (causing typing holes which allow for whatever inputs). I love types but I can't trust TypeScript types to be valid, I've been bit too many times. Rust (or any other really typed language) would be great if the solutions are mature enough. It's not just for memory control.
- lefrenchy 5y agoI like this idea and want to keep up with it. The only that would hold me back is that I feel spoiled writing JSX, I just think it's such a nice way to write the front-end within the javascript. If you could get JSX like syntax in Rust I would be 100% sold on this. Does anyone know if that is possible? I assume you'd have to write a parser for this?
- christiansakai 5y agoRust has macros so this is possible. Maybe wont look exactly like JSX but it is good enough.
- texodus 5y agoYew has an `html!` macro and a very React/Elm like architecture https://github.com/yewstack/yew https://github.com/yewstack/yew
- steveklabnik 5y agoThere are a bunch of these, https://github.com/bodil/typed-html#quick-preview https://github.com/bodil/typed-html#quick-preview being the one I enjoyed most last time I was giving this a shot.
- ironmagma 5y agoThere are a few libraries that support this exactly: https://github.com/stoically/syn-rsx https://github.com/stoically/syn-rsx https://github.com/yewstack/yew https://github.com/yewstack/yew But there are others like Sauron, Maple, and Percy that have their own Elm-like approach which is probably almost just as good.
- msoad 5y agoTo me, Rust only makes sense for very CPU intensive applications that don't need the DOM. Run the Rust code in a Web Worker and use OffScreenCanvas to show the results. This can work great for things like remaking Photoshop or Maya for the web. For you everyday web <form> and <input /> don't complicate things too much.
- the__alchemist 5y agoI wrote the the Seed framework mentioned in the article. I'm still happy with the API, but now my websites are all server-rendered, with no frontend frameworks, no frontend dependencies or build steps, and targeted JS to perform DOM manipulations when required. YMMV!