3 ms·
I'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
by nurettin 4y ago
I'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.