4 ms·
Have you written any Rust code by chance? I personally think Rust is easier than C++, possibly because it is a lot smaller language than C++ (at present). It is
by nu11ptr 4y ago
Have you written any Rust code by chance? I personally think Rust is easier than C++, possibly because it is a lot smaller language than C++ (at present). It isn't magic, but it kinda feels like it. To be able to do low level coding knowing you can't blow your foot off is pretty cool.
- nurettin 4y agoI've been using C++ on and off since the 90s (borland C++ 5 times) Tried rust at initial release. Read a csv file line by line, split each line read (because I couldn't find any streams), converted to numbers and calculated some stats. Never again. What rust feels like: you are riding a bike, but it has six safety wheels instead of any normal wheels.
- jeffdn 4y agoI think it’s fair to say that Rust has changed massively since initial release. There are certainly safety aspects, but doing what you describe should be trivial and trigger none or almost none of them. The compiler’s error messages are fantastically helpful these days. Might be worth a tinker some rainy day, but understand being completely turned off of something as well.
- adrianN 4y agoI'm no Rust expert, but I believe reading a file line by line, splitting them, converting to numbers and doing something with them is just a handful of lines using methods on iterators. I suppose it was much harder in the initial release.
- nindalf 4y agoOne major change since initial release was the introduction of a more permissive borrow checker. The newer one accepts many more valid programs thanks to the introduction of non-lexical lifetimes.
- ay 4y agoYou can always use “unwrap()” in throwaway code. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4b7b5949197445ab3c95ef09bd9251d3 https://play.rust-lang.org/?version=stable&mode=debug&editio... If that code ever gets more use than that you expect, you can trivially find all the uses of “unwrap()”, and add the proper error handling. And yes there are quite a few places where things can go wrong. But this explicit “signing for technical debt” when it relates to error handling is a really convenient productivity feature in practice. A simple throwaway CLI for your own use is absolutely fine to use unwrap(), and you can fix it later on if it becomes a problem.
- xyzzy4747 4y agoUnwrap is good to use for things that are expected to work 100% of the time. If unwrap fails in such situations, it’s fine to have the program panic and shut down.
- pjmlp 4y agoI have, even if mostly hobby stuff. Some stuff that places Rust going into the same kind of complexity as C++. Figuring out how to turn DAG algorithms into tree based ones, two macro systems, async infrastructure, Pin and PhantomData special fields, GAT (when they arrive). Lets see how it looks like with 40 years of production code, on the other hand C++ is indeed reaching PL/I levels of complexity for those that care about ISO legalese.
- nu11ptr 4y agoI guess it depends what kind of code you are writing. I've written all of the above w/o too much trouble, but yes, those are the harder parts. However, most of my code is just basic logic, so has very little interaction with that stuff (with exception of async, which I use every day). My C++ is more rusty (pun not intended), but I'm sure there are powerful features that you might use occasionally, but generally don't use much. My point is that day to day coding in Rust is very easy and pleasant, and every once in a while needing an advanced feature that you have to lookup doesn't necessarily make the common case challenging. Like any language, it is hard to tell all this without writing a large project in it.