Rust is Eating JavaScript
-
I thought python has kinda exploded lately...
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. So I use it for hobbies until I have a reason to leave.
-
That means eventually everything tastes great when smothered in butter.
That's why French food is world renounced, it has copious amounts of butter.
-
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.
Sounds kinda like Go. It's not functional, but functional patterns work well there.
It's not great for FE though.
-
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!
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 holdnil
without 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
defer
just 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. I did use it for about 10 years though.
-
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.
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.
-
Sounds kinda like Go. It's not functional, but functional patterns work well there.
It's not great for FE though.
What's FE?
-
This post did not contain any content.
Can we please go back to making programs for the target OS and skip the browser dependency?
-
What's FE?
Front end
-
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. So I use it for hobbies until I have a reason to leave.
Yeah I've been playing around with rust but most know py. And to be fair on my it has fantastic libraries.
-
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.
Wasm bindgen is an absolute nightmare of auto-generated function names. From a purely performance/functionality perspective it works but it's hella ugly. I hope some alternative arrives at some point.
-
This post did not contain any content.
Honestly those usecases described here shouldn’t have been done in js in the first place.
-
with wasm and friendly new web frameworks, the only thing keeping js alive is inertia
Essentially, JS is the new Flash….
-
The BE, yes, the FE is JS.
The new FE is going to be in rust though
-
The minifiers have long made JavaScript just as indecipherable
You can't place breakpoints inside wasi binaries. You can place breakpoints inside minified js code.
-
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.
Thanks, "Comprehensive Rust" is readable so far, though I haven't gotten to the "fun" (memory management) parts yet.
-
Honestly those usecases described here shouldn’t have been done in js in the first place.
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.
-
Can we please go back to making programs for the target OS and skip the browser dependency?
Browsers have almost become the OS. At least in user land.
-
You can't place breakpoints inside wasi binaries. You can place breakpoints inside minified js code.
I mean, maybe it's not easy because they don't provide debug information, but a sufficiently motivated person can debug a web assembly binary.
-
Thanks, Rustlings doesn't sound like what I want either. I was hoping for a counterpart of Stroustrup's C++ Reference Manual, or Riehle's "Ada Distilled" or even K&R's book on C. Something that systematically describes the language rather than distractions like the toolchain, mini projects, cutesey analogies, etc. I'm being too persnickity though, mostly because it hasn't been important to me so far.
Sounds like you want the Rust Book: https://doc.rust-lang.org/book/
Edit: Just realized you said you didn't like it sorry
-
I'd say Rust is definitely mainstream. Obviously not the level of JS or Python, but it's being used all over the place. All major FAANG companies, the Linux kernel, JS runtimes, web browsers, Signal...
IMO GC has nothing to do with high or low level. It's just incidental that there's a correlation. In GC you usually don't need to think about manually allocating or deallocating memory or truly understand what pointers are (in some ways anyway). In C / C++ you do.
In Rust you almost never manually allocate or deallocate, and you have both very high and low level APIs.
I'd say Rust is both high and low level. It just depends what you use it for.
As for books, maybe you'd like trying Rustlings instead.
rust is both high and low level
I like to describe this as "low level language with high level ergonomics"