3 ms·
Rust is safer than most languages (I'd argue it's even safer than Java/JS/Python/Ruby) but as fast and low-level-capable as C++. If that's not a big deal I dunn
by Gankro 11y ago
Rust is safer than most languages (I'd argue it's even safer than Java/JS/Python/Ruby) but as fast and low-level-capable as C++. If that's not a big deal I dunno what is. (Also it has a really cool concurrency/parallelism story IMHO)
I'm not sure you can argue that Rust is far more complex if you actually understand C++ sufficiently to write correct and performant programs.
But the really great thing about Rust is that you don't actually have to understand the language to write correct and performant programs. The compiler will stop you in your tracks every time you screw up. Also there's way less performance foot-guns by default. Everything is moved instead of deep-copied by default, and you can take random
pointers into things without having to worry about it.
But it's true, complicated things are complicated to express, which seems... natural to me? I dunno what people expect. But simple things are actually really simple.
For instance, here's an early version of a library I'm working on for decoding gifs: https://github.com/Gankro/gif-rs/blob/master/src/lib.rs https://github.com/Gankro/gif-rs/blob/master/src/lib.rs
There isn't a single lifetime in sight. It's also really nice and readable (being able to ergonomically talk about bit and byte patterns was a big boon). Granted the library is fairly naive (it's a pull parser, but it later became clear I wanted a push parser for Servo). But I think it's a great argument for simple things are simple.
Rust gets crazy when you demand on writing extremely generic code like Hyper, because Rust leans heavily on static verification. But generic code is just always going to be cray-cray (See: Haskell lenses, C++ Boost, Scala collections).
- furyofantares 11y agoThanks for the link to that code, it was a pleasure to read. I then went back and read a GIF decoder I wrote some years ago in C++, code which I am very fond of -- it's pretty much the same code (as you'd expect) but my code is decorated with a lot of noise surrounding error handling and memory management/cleanup, as well as some unfortunate object oriented noise related to general style of the project it had been written for.