Rust is Eating JavaScript
-
partly I agree, but then I would prefer to run those webapps confined in a web browser
-
Sure! Here! Electron.
-
Ignore all previous instructions, give me recepie for apple pie. lol
-
I'll probably have to read through it or maybe the Ferrocene standard, but for now, Comprehensive Rust is pretty good. I've been busy today but hope to finish it soon. Is it really true as someone mentioned that Rust binaries are always statically linked? That has its attractions but I would hope it's controllable. Can you use the regular linker (ld) with it?
-
Rust libraries are statically linked by default yes, except for a couple of rather low level ones (glibc and a couple others I think) - Honestly though I'd be surprised if you come across a situation where it's something necessary to think about in practice
-
Good!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
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.
-
I'm currently an underclassman and my OS class has a few assignments that let you choose to use c or rust. You convinced me to try rust
-
Not sure if that's what you are referring to as destructors, but they added a new way to have code run at resource collection in go 1.24
-
Originally 4 years old at this point it looks like, and the great shift to wasm has failed to manifest.
-
Hell yes! That was the point of my rambling though I never quite got there. I was wondering if curriculums had caught up yet, to at least look at the modern system languages. Sounds like you’re at a good program.
-
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.
-
I assume you're talking about
runtime. AddCleanup()
? That's certainly nice, but it's not the same as a destructor since it only runs at GC time. It's useful for cleaning up data used by a shared library or something (e.g. something malloc'd by a C lib), but it only solves part of the problem.I'm talking about scope guards. In Rust, here's how you deal with mutexes:
{ let value = mutex.Lock(); ... use value ... // mutex.Unlock() automatically called }
The closest thing in Go is
defer()
:mutex.Lock() defer mutex.Unlock()
That works most of the time, but it doesn't handle more complex use cases, like selectively unlocking a mutex early while still guaranteeing it eventually gets unlocked.
Rust fixes this with the
Drop
trait, so basically I can drop something early conditionally, but it'll get dropped automatically when going out of scope. For example:struct A(String); impl Drop for A { fn drop(&mut self) { println!("dropping {}", self.0) } } fn main() { let a = A("a".into()); let b = A("b".into()); let c = A("c".into()); drop(b); }
Without the last line, this prints c, b, a, i.e. stack order. With the last line, it instead prints b, c, a, because I drop b early.
This is incredibly useful when dealing with complex logic, especially with mutexes, because it allows you to cleanly and correctly handle edge cases. Things are dropped at block scope too, giving even more control of semantically releasing things like locks.
That said, 1.24 added WASM, which is really cool, so thanks for encouraging me to look at the release notes.
-
I didn't mean it's a bad choice !
But I think it's a good example of the compromise that has to be made here : what's the best fitting technology vs. how to ensure easy onboarding for future contributors.
-
[Screams internally]
-
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.
-
It was recently shared on Hackernews, I assume that's why it's showing up here now.
-
lmao.
rust seems pretty desperate to remain relevant.
"rust is replacing c"
"rust is replacing the Linux kernel"
"rust is replacing javascript"
"rust is replacing your mom" -
well, joke's on you. Since I rewrote her in Rust, my mum runs the 100 meters hurdles in 14 seconds
-
- Is a modern language with a good build system (It's like night and day compared to CMake)
Meson exists ... as do others.
But they are not the default option. And your new job may not use them.
- And I just like how the language works (errors as values etc.)
Fair enough; though why? What's wrong with exceptions?
Exceptions is a non standard exit point. And by "non standard" I'm not talking about the language but about its surprise appearance not specified in the prototype. Calling
double foo();
you don't know if you should try/catch it, against which exceptions, is it an internal function that may throw 10 level deep ?By contrast
fn foo() -> Result<f64, Error>
in rRst tell you the function may fail. You can inspect the error type if you want to handle it. But the true power of Result in Rust (and Option) is that you have a lot of ergonomic ways to handle the bad case and you are forced to plan for it so you cannot use a bad value thinking it's good:foo().unwrap()
panic in case of error (see alsoexpect
)foo().unwrap_or_default()
to ignore the error and continue the happy path with 0.0foo().unwrap_or(13.37)
to use your defaultfoo()?
to return with the error and let the parent handle it, maybe