5 ms·
> Writing basic data structures isn't a niche, esoteric edge case Maybe it isn't an edge case (although it should be) it also isn't `easy` in a non GC'd langua
by eldenring 4y ago
> Writing basic data structures isn't a niche, esoteric edge case
Maybe it isn't an edge case (although it should be) it also isn't `easy` in a non GC'd language, and a huge source of memory bugs.
I wouldn't say it makes the 'easy stuff hard' as much as the 'hard stuff appropriately difficult'.
- adamrezich 4y agowhy should writing a basic data structure be an edge case? …what?
- TheCoreh 4y agoAll of the "basic" data structures are already provided by either the standard library or crate ecosystem, so you'll rarely (if ever) need to write your own linked list or hash map from scratch. I say "basic" in quotes because once you factor in the concurrency, ownership and memory safety concerns that are optional in other languages, but mandatory in Rust, there really isn't a simple implementation of these structures that is provably correct anymore.
- GrumpySloth 4y agoRust is supposed to be a systems programming language. If writing basic data structures was an edge case in it, the language would be broken. Luckily, in my experience it isn’t (at least not in this way).
- adamrezich 4y agoI'm glad you posted this, I was confused as to whether "basic data structure" meant something different to Rustfolk than it did to the rest of us.
- DeathArrow 4y agoWriting data structures is trivial in C/C++.
- pie_flavor 4y agoAs long as you don't care about UB or edge cases. Every time Rust makes something hard, it's forcing you to handle an edge case up front.
- DonaldPShimoda 4y agoIt's blowing my mind how many commenters here don't understand this. Rust isn't hard just for fun. It's hard because the code you've been writing for so long is actually bad and you've not been thinking it through appropriately. This is why we keep finding serious bugs in code that is decades-old, despite the belief that code so old must be well-tested by now.
- indymike 4y ago> we keep finding serious bugs in code that is decades-old I'm sure of one thing: we will find many and different bugs in decades old rust code one day, too. The problem with software is that it has code in it ;-)
- hn92726819 4y agoDifference of course being that zero of these bugs will be due to buffer overflows or use after free or other memory bugs in safe rust, which is a huge source of bugs in C[1]. I don't understand why this argument keeps coming up. Not all bugs are the same and when you make entire classes of bugs unrepresentable, that's a massive win, especially when they happen to be the class containing >60% of the highest severity bugs in C. https://www.chromium.org/Home/chromium-security/memory-safety/piechart.png https://www.chromium.org/Home/chromium-security/memory-safet...
- lll-o-lll 4y agoIt’s not that simple. Rust is used in the system’s programming space and as a result it will be used in many places where unsafe ends up required to solve problems. There won’t be memory safety bugs in safe Rust, but there will be in the interop/unsafe layers. I think there is a strong argument to be made that if you need a lot of unsafe, Zig is going to be the safer language.