Good!!!
Rust is Eating JavaScript
Submitted 1 year ago by volkerwirsing@feddit.org to technology@lemmy.world
Comments
commander@lemmings.world 1 year ago
maximilian@lemmy.ml 1 year ago
Honestly those usecases described here shouldn’t have been done in js in the first place.
Thrashy@lemmy.world 1 year ago
Look, I’m in no position to talk seeing as I once wrote a shell script in PHP, but the profusion of JavaScript in the late aughts and early teens for things that weren’t “make my website prettier!” feels very much like a bunch of “webmasters” dealing with the fact that the job market had shifted out from under them while they weren’t looking and rebranding as “developers” whose only tool was Hammer.js, and thinking all their problems could be recontextualized as Nail.js.
commander@lemmings.world 1 year ago
I agree.
I’m noticing this species has a problem with doing things the obviously correct way the first time.
It’s as though we’d rather put 100x more effort for 10% of the results just to prove that we “can” do it.
Bogasse@lemmy.ml 1 year ago
Well I see huge benefits in building the tools used by a community with the technology this community masters. IMO the Python’s stdlib sucks because it’s written in C which is a huge barrier to entry.
balder1991@lemmy.world 1 year ago
Not all of the stdlib is written in C. Some parts cannot be Python because it’s critical code that needs to be as fast as possible.
Python is already slow for many use cases, if the standard lib was all built in Python it would be just too slow for much more use cases.
ICastFist@programming.dev 1 year ago
Can we please go back to making programs for the target OS and skip the browser dependency?
JackbyDev@programming.dev 1 year ago
Sure! Here! Electron.
curry@programming.dev 1 year ago
[Screams internally]
WhyJiffie@sh.itjust.works 1 year ago
partly I agree, but then I would prefer to run those webapps confined in a web browser
terminhell@lemmy.dbzer0.com 1 year ago
Browsers have almost become the OS. At least in user land.
Venator@lemmy.nz 1 year ago
Can browsers run rust in the front end instead of javascript, or is it limited to transpile time and backend?
sushibowl@feddit.nl 1 year ago
Sort of, browsers can run rust code through webassembly. But i dont think this is a full replacement for JavaScript as of yet.
sugar_in_your_tea@sh.itjust.works 1 year ago
Yeah, you need to have some JS to manipulate graphics, so the Rust web frameworks have a JS shim to do that and communicate with the WebAssembly Rust code as necessary. It works surprisingly well tho.
whereisk@lemmy.world 1 year ago
Is this a 2yo write up, considering the last update was in 2023?
zaphod@sopuli.xyz 1 year ago
It was recently shared on Hackernews, I assume that’s why it’s showing up here now.
mostlikelyaperson@lemmy.world 1 year ago
Originally 4 years old at this point it looks like, and the great shift to wasm has failed to manifest.
vane@lemmy.world 1 year ago
Because corporations doesn’t want web to be open, everyone can javascript, not everyone can read webassembly.
Dark_Arc@social.packetloss.gg 1 year ago
The minifiers have long made JavaScript just as indecipherable
vane@lemmy.world 1 year ago
You can’t place breakpoints inside wasi binaries. You can place breakpoints inside minified js code.
0x0@programming.dev 1 year ago
You can deminify, decompiling is a bit harder.
mesamunefire@piefed.social 1 year ago
I thought python has kinda exploded lately...
sugar_in_your_tea@sh.itjust.works 1 year ago
I use it at work, and it’s finally getting an optimization pass.
I wish I did Rust for work, but options are limited and I like my team.
mesamunefire@piefed.social 1 year ago
Yeah I've been playing around with rust but most know py. And to be fair on my it has fantastic libraries.
Binette@lemmy.ml 1 year ago
Fun fact! Lemmy is made in Rust!
sugar_in_your_tea@sh.itjust.works 1 year ago
The BE, yes, the FE is JS.
Binette@lemmy.ml 1 year ago
The new FE is going to be in rust though
victorz@lemmy.world 1 year ago
Can I just say how beautiful that page is? Such a delight to read the text on it. The legibility. The simplicity. 😙👌
callmepk@lemmy.world 1 year ago
JS become rusty
ColdWater@lemmy.ca 1 year ago
Nom nom nom
sugar_in_your_tea@sh.itjust.works 1 year ago
Everything eventually becomes a crab.
Kolanaki@pawb.social 1 year ago
That means eventually everything tastes great when smothered in butter. 🤤
call_me_xale@lemmy.zip 1 year ago
Thank god.
solrize@lemmy.world 1 year ago
The JS tooling universe has always seemed like a Lovecraftian hellscape to me. I’ve managed to stay away from it so far, but if I were caught in it, of course I’d be trying to escape any way I could. It sounds like Rust’s attraction here has been as a viable escape corridor rather than anything about Rust per se.
In particular, I get that everyone wants their code to be faster, and I get that certain bloaty apps (browsers) need to get their memory footprint under control, and a few niche areas (OS kernels, realtime control) can’t stand GC pauses. Other than that though, what is the attraction of Rust for stuff like tooling? As opposed to a (maybe hypothetical) compiled, GC’d language with a good type system and not too much abstraction inversion (Haskell’s weakness, more or less).
Has Golang fizzled? It has struck me as too primitive, but basically on the right track.
Rust seems neat from a language geek perspective, but from what I can tell, it requires considerable effort from the programmer handle a problem (manual storage reclamation) that most programs don’t really have. I do want to try it sometime. So this post is intended as more inquisitive/head scratching rather than argumentative.
sugar_in_your_tea@sh.itjust.works 1 year ago
Go is fine, but it has its flaws. I prefer Rust because:
- memory safety is a compiler check, not a runtime check, so you catch issues earlier
- locks contain their values, so you can’t accidentally do anything unsafe
- no nil (
()is semantically different), so no surprises with contracts - everything is an expression, which lends itself really well to FP concepts
- actual dependency management at 1.0
- pretty much no runtime, so calling from another language is super easy
- targets WASM and microcontrollers
- no pointers (not exactly true)
It takes longer to learn, but I’m about as productive with both now.
solrize@lemmy.world 1 year ago
Thanks, “Comprehensive Rust” is readable so far, though I haven’t gotten to the “fun” (memory management) parts yet.
qaz@lemmy.world 1 year ago
I usually pick Rust for CLI tools because:
- It’s statically compiled and isn’t dependent on system binaries and won’t break if there if the system has the wrong version like C/C++, allowing you to distribute it as a single binary without any other installation steps
- Still produces fairly small binaries unlike languages like Java or C# (because of the VM)
- Is a modern language with a good build system (It’s like night and day compared to CMake)
- And I just like how the language works (errors as values etc.)
Dark_Arc@social.packetloss.gg 1 year ago
- It’s statically compiled and isn’t dependent on system binaries and won’t break if there if the system has the wrong version like C/C++, allowing you to distribute it as a single binary without any other installation steps
You can do that with C++ too.
- Still produces fairly small binaries unlike languages like Java or C# (because of the VM)
I mean, the jars are actually pretty small; but also I really don’t get the storage argument. I mean we live in a world where people happily download a 600 MB discord client.
- Is a modern language with a good build system (It’s like night and day compared to CMake)
Meson exists … as do others.
- And I just like how the language works (errors as values etc.)
Fair enough; though why? What’s wrong with exceptions?
I work in a code base where I can’t use exceptions because certain customers can’t use exceptions, and I regularly wish I could because errors as values is so tedious.
rottingleaf@lemmy.world 1 year ago
The JS tooling universe has always seemed like a Lovecraftian hellscape to me.
That’s most of any programming of today for me.
If it can’t be grasped in a couple of days - then na-ah.
I can patch something I need working which doesn’t, written in C.
autotools ftw
pr06lefs@lemmy.ml 1 year ago
I think there’s room for a rust-lite language that is GCed. Something with a functional-style type system and that compiles to machine code.
Roc is a candidate for this language. Basically Elm that compiles to machine code, but with a number of tweaks to make it work for more than just a web front end. Like Elm, the type system is haskell like, but simplified.
sugar_in_your_tea@sh.itjust.works 1 year ago
Sounds kinda like Go. It’s not functional, but functional patterns work well there.
It’s not great for FE though.
balder1991@lemmy.world 1 year ago
There’s already Swift, which isn’t garbage collected, but the ref. counting does the same in practice.
The only problem with Rust and Swift, Kotlin etc. in my opinion is that they keep growing and getting more complex with no signs of stopping.
solrize@lemmy.world 1 year ago
Thanks, Roc sounds interesting. Ocaml also maps more closely to machine operations than Haskell does, so it has always seemed like another alternative. AMD has something called ROCm which is their version of CUDA, but I assume that is unrelated.
Glitchvid@lemmy.world 1 year ago
Maybe give it a try; it’s my favorite language to write programs in now, it has an extremely good standard library, and for everything else there’s a mass of high quality crates, its build system is actually competent and makes compiling on Windows or Linux trivial, plus many, many more quality of life features.
CHOPSTEEQ@lemmy.ml 1 year ago
If Rust had been around when I was an underclassman, I would have been totally locked into the full CompSci track. Instead, I got introduced to Java and C (and calculus…) and that looked like a nightmare compared to what I had been playing with in JS/Python land, so I noped on out of there and got a Comp Sci Lite degree.
Years later, I’m just completely in love with Rust.
solrize@lemmy.world 1 year ago
Yes it’s on my infinite todo list. I’m just being too much of a curmudgeon about the available textbooks, and had a sinking feeling when the main one didn’t get “hello world” out of the way on page 1, and shift to the specifics of the language.
Tanoh@lemmy.world 1 year ago
Has Golang fizzled? It has struck me as too primitive, but basically on the right track.
My biggest issue with Golang by far is the close tie to Google. They are not our friendly innovator, time and time again they make decisions that will help them earn more ad money, and nothing else. And they have a lobg history of releasing something and then never fix the issues with it, and then more or less abandon it.
Other than that there are afaik some other issues with go, I’m not an expert but from what I hear the GC is quite aggressive and you can’t tell it to run when you want. Doing something time sensitive? Well, bad luck. GC time!
sugar_in_your_tea@sh.itjust.works 1 year ago
The GC in Go is fantastic IMO since it runs in a separate thread. I used it since 1.0 (switched our product from node.js), and dealt with all the the pain of an imprecise GC (fixed in 1.5?) and all the little improvements to arrive at it’s current state.
The main issues I have with it are pretty core to the language, unfortunately, such as:
interface{}is basically avoid*, but since it’s a fat pointer, it can holdnilwithout itself beingnil, which can happen by accident- runtime reflection is a bad habit, but it’s unfortunately really common
- it’s really easy to deadlock by making stupid mistakes; if it had automatic unlocking based on scope (like Rust, or something like Python’s context managers), we could solve this, but
deferjust isn’t good enough - no destructors - with destructors, we could build a solution to deadlocks
Maybe they fixed some of those issues, idk, I haven’t used it for several years.
0x0@programming.dev 1 year ago
the close tie to Google.
Guess who’s one of the rounders of the Rust Foundation…
solrize@lemmy.world 1 year ago
True about Google ;). Yes, there are programs that really don’t want GC. I consider those to mostly be niche applications since most of us are fine with using e.g. Python, which has automatic storage management (won’t quibble about whether it is GC per se) that has occasional pauses. SImilarly, tons of important programs are written in Java, which is GC’d. Of course Java is tied up with Oracle just like Go is tied up with Google.
Go’s main problem from what I can tell is that the language itself is too old fashioned. I’ve used it but am not expert. It feels like an improved version of C, rather than a modern, type-safe language.
asdfasdfasdf@lemmy.world 1 year ago
- Rust is the best language for writing WASM in, so you can write Rust and run it in the browser without transpiling to JS.
- Rust isn’t just about speed or GC pauses. Its type system is amazing and allows you to encode things that you cannot in any other mainstream language.
- It’s so incredibly well designed, it fewla like that clip from Ricky and Morty where Morty feels what standing on a truly even plane feels like then has a panic attack when he leaves. Rust rethought everything from scratch, and isn’t just some new syntax or fancy compiler tricks. No null, no exceptions, no inheritance, new typing capabilities, etc.
solrize@lemmy.world 1 year ago
Interesting point about Wasm if that is important. You can also compile C++ to wasm but then its C++ ;). I don’t know about Ada to Wasm.
I don’t think Rust is quite mainstream yet either. My impression is that its type system has not caught up with Haskell’s except in a few areas, but of course nobody pretends Haskell is mainstream. I haven’t yet tried Idris.
Golang seems to have a decent runtime model (lightweight threads, GC) though the language itself is underpowered. There is a Golang backend for Purescript that sounded interesting to me. The thing that turned me off the most about Purescript was the JS tooling. Purescript (purescript.org) is/was a Haskell-like language that transpiles to JS, intended for use in browsers, but Typescript filled this space before Purescript got much traction. That felt unfortunate to me.
I don’t think HLL (high level language) has an official definition, but informally to me it has generally meant that the language is GC’d and that the native integer type is unbounded (bignum). By that standard, Rust and Ada are low level. I’ve so far thought of Rust as a modernized Ada with curly braces and more control of dynamic memory reclamation. Maybe there is more going on than that. Ada is still ahead of Rust in some ways, like generic packages, but Rust is working on that.
If you have a suggestion of a no-nonsense Rust book, I’d be interested in looking at it. doc.rust-lang.org/book/ beat around the bush way too long before discussing the language, but I guess I should spend more time with it.
artificialfish@programming.dev 1 year ago
I think once you get into rust you just have a hard time going back, and it doesn’t feel “hard” anymore. I can practically rust as easily as I can python.
solrize@lemmy.world 1 year ago
I had the impression Rust doesn’t handle concurrency particularly well, at least no better than Python, which does it badly (i.e. with colored functions). Golang, Erlang/Elixir, and GHC (Haskell) are way better in that regard, though they each have their own issues. I had believed for a while that Purescript targeting the Erlang VM and with all the JS tooling extirpated might be the answer, but that was just a pipe dream and I don’t know if it was really workable.
adespoton@lemmy.ca 1 year ago
JavaScript has its place as a lightweight runtime interpreter.
Rust has its place as a secure and modern way to engineer and produce dependable software.
jimmy90@lemmy.world 1 year ago
with wasm and friendly new web frameworks, the only thing keeping js alive is inertia
adespoton@lemmy.ca 1 year ago
Essentially, JS is the new Flash….
sugar_in_your_tea@sh.itjust.works 1 year ago
Eh, it’s not that lightweight, Lua is much better for that.
Diplomjodler3@lemmy.world 1 year ago
Guten Appetit!
GreenKnight23@lemmy.world 1 year ago
andallthat@lemmy.world 1 year ago
well, joke’s on you. Since I rewrote her in Rust, my mum runs the 100 meters hurdles in 14 seconds