11 ms·
All really good things to mention, but the data races thing is a big deal and gets just a short reference and where is the bit about the borrow checker? The wa
by lordnacho 5y ago
All really good things to mention, but the data races thing is a big deal and gets just a short reference and where is the bit about the borrow checker?
The way I see it the things mentioned are nice appetizers and the data race and borrow checker are the main meal.
IME the most frustrating problems are not that you forgot to exhaust the switch statement or didn't initialise a new field, it's when you get a segfault that's hard to reproduce and you have barely a hint about what's caused it.
- eptcyka 5y agoI've seen people who state their love for Rust and then fail to explain the difference between passing an argument by value, reference or mutable reference.
- carlmr 5y agoI mean those are two separate things. Depending on how you code, Rust can be similarly high level as Python, make it much easier to design with types than C++ and has great package management with cargo. You can find plenty of reasons to love Rust, without even getting to the technical details.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- Thaxll 5y ago> Rust can be similarly high level as Python Not really, once you start something more complicated than hello world and start to try mutate things for example it get 100x more complicated that Python.
- melissalobos 5y ago> start to try mutate things for example it get 100x more complicated that Python. I don't know about 100x, using Box and mutexes it is pretty much as complicated or maybe 2x. If you want it to be efficient and leverage all of Rust then sure, but that wasn't what they were meaning.
- Thaxll 5y agoI don't see where in Rust you could have code that looks high level as in Python.
- melissalobos 5y agohttps://actix.rs/ https://actix.rs/ Look at the first example. It can be very similar.
- jay_kyburz 5y agoHaha, I think you might need to have another look at Python.
- gpm 5y agoNote that their example is something like making a hello world web server using twisted (or whatever the current async framework is) in python... Strange example, but I suppose making the corresponding python more complex is one way to make them equivalent.
- deleted 5y ago[deleted]
- code_biologist 5y agoFor reference I'd say the "current async framework" is either Starlette [1] (low level) or FastAPI [2] (high level) for web stuff, and trio [3] for more stupidproof general async than twisted. IMHO of course! [1] https://www.starlette.io/ https://www.starlette.io/ [2] https://fastapi.tiangolo.com/ https://fastapi.tiangolo.com/ [3] https://trio.readthedocs.io/en/stable/ https://trio.readthedocs.io/en/stable/
- DeathArrow 5y ago> Rust can be similarly high level as Python What about Haskell? Can it be similarly high level as Haskell?
- dsQTbR7Y5mRHnZv 5y agoThis may be the closest thing I've personally seen: https://github.com/timvisee/advent-of-code-2021 https://github.com/timvisee/advent-of-code-2021
- ben0x539 5y agopeople are allowed to love things without being experts or even particularly didactic about it lmao
- melissalobos 5y agoRust is slightly unusual in that most users/potential users of it tend to be very vocal about it. It would be nice if their knowledge matched their enthusiasm.
- ben0x539 5y agolet people enjoy things
- ben0x539 5y agolike that's how you get the knowledge, you're enthusiastic about a thing and then spend a bunch of time with it and then you build up knowledge. it's healthier in that order.
- Xunjin 5y agoOhhh please this is language wars, people don't want healthy arguments, they just want to pick a side and argue, just to earn internet points :D
- macintux 5y ago> Rust is slightly unusual in that most users/potential users of it tend to be very vocal about it. Or that the only users you know about are vocal…because how would you know about the non-vocal ones?
- SolitudeSF 5y agothis not even close to expert knowledge, thats entry level
- eptcyka 5y agoI'm not sour about people enjoying things. Would you not feel peculiar about people who are really enthusiastic about a sous vide machine and use it to heat water for their tea? And when asked about their favourite cut of steak they like to sous vide, they'd stare blankly and proclaim that they are vegan? There's nothing wrong with using tools any which way you want, but the reason d'entre for Rust is fearless concurrency, and the distinction between borrowing and moving, with the addition of Send and Sync marker traits, is kind of the whole point of the langauge. I agree that it could still be a good language without these, but if it wasn't for these features, I doubt there'd be nearly as much enthusiasm behind it.
- tylerhou 5y agoIn addition, most of these checks are provided in other languages or linters for those languages. E.g. C++ has had RAII before Rust has existed. C++ (with -Werror), TypeScript and most FP languages have exhaustive switch checking. Clang can catch many (but not all) initialization errors. The places where Rust adds value (data races, memory safety, explicit unsafe) are not discussed in the article.
- SemanticStrengh 5y agoI would like to see more about atypical language protections. GCC has many underknown flags that protects against very specific things. Kotlin is the first popular language to support structured concurrency, eliminating many classes of concurrency errors. It's basically "RAII" for threads, coroutines. Tailrecursive and deeprecursive allow for making any recursive function stack-overflow safe.
- pjmlp 5y agoI guess C# isn't popular.
- SemanticStrengh 5y agoIt is of course but I doubt C# has structured concurrency?
- nicoburns 5y agoRust also adds value in providing so many of th checks where most languages only have a subset, and being incredibly consistent in having safe defaults.
- tylerhou 5y agoNot untrue, but the post doesn’t mention prior work, so it’s implying that Rust is one of the only languages that has these features, whereas even C++ (notorious for being unsafe) as a majority of the features (in Clang). Clang can even catch many data race issues with the proper annotations. Maybe it’s ignorance, but given how posts proselytizing Rust tend to get popular on HN, it makes me suspicious that the omission was intentional.
- infogulch 5y agoFor my first C class in uni I wrote a curses-style CLI spreadsheet tool with a csv parser, reverse cell reference table, automatic modification-based recursive recalculation, a basic formula parser, an infix notation to reverse polish notation "compiler", and a stack-based RPN evaluator (I may have gone a bit overboard on that assignment). The one multi-user unix server for all students that I wrote it on (named 'foley', some CS reference I think) had an ancient gcc compiler that compiled it just fine, but when run it would segfault. Hardly surprising, I created hundreds of segfaults, but this one would only segfault if I used -O0 and didn't add any logging statements. That's right, it ran fine with any level of optimization above 0 or if I used any logging statements, and only segfaulted on -O0. Utterly infuriating and flagrantly defied my expectations. I got help from some patient soul I found on freenode ##c (I wish I could remember their name) who didn't see any obvious issue or warning and couldn't reproduce any segfault with their much more recent compiler. -Wall+++, asan, nothing cracked it. Everything else was exhausted: it must be the compiler. But I couldn't just update the compiler package because it was a multi-user server and I had zero permissions, so I ended up bootstrapping a 10-years newer gcc through multiple intermediate versions and installing it in my profile (quotas be damned) and used that. It didn't segfault on -O0 anymore. I haven't voluntarily used C since.
- kragen 5y agoThat's not related to C, except in the sense that GCC is written in C. GCC was just emitting incorrect code because it had a bug in its code generator. If there's a bug in the LLVM code generator (which is written in C++), rustc might end up doing the same thing. If you write the compiler in Rust it could still happen. Rust code (that compiles) has less bugs than the corresponding C but not zero bugs. It doesn't sound like you went overboard, it sounds like a good project. Maybe you should have written it in Perl 5.001 though.
- charcircuit 5y agoGCC is written in C++
- 5y ago
- pjmlp 5y agoData race is only helpful for threaded code accessing data structures in-memory. For all the other scenarios of distributed computing or OS IPC, it does very little. Plus Rust lacks a story how it can work with OpenMP and OpenACC.
- oconnor663 5y ago> For all the other scenarios of distributed computing or OS IPC, it does very little. It might be worth clarifying that catching data races isn't just about catching race-conditions-which-are-probably-bugs. Data races are full-blown undefined behavior in the C/C++/Rust memory models, which can (not necessarily frequently but under the right conditions) corrupt memory just as badly as a use-after-free or an out-of-bounds write.
- pjmlp 5y agoAgreed, however when talking about how great Rust deals with those, we should not forget it is only one use case among many others where Rust currently doesn't do any better than the competition. Specially if we take into consideration that focusing back into processes is the only solution to prevent certain exploits.
- shaklee3 5y agoRust does not have a memory model.