What if we have a C that removes the quirks without adding too much brain drain? So no implicit type conversions, safer strings, etc.
This seems like such an obvious thing to have - where is it? Zig, Odin, etc. all seem much more ambitious.
Matt Godbolt sold me on Rust by showing me C++
21–30 of 675 posts
Re: Matt Godbolt sold me on Rust by showing me C++
#22The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking r…
Maybe contrarian, but imo the `Result` type, while kind of nice, still suffers from plenty of annoyances, including sometimes not working with the (manpages-approved) `dyn Error`, sometimes having to `into()` weird library errors that don't propagate properly, or worse: `map_err()` them; I mean, at this point, the `anyhow` crate is basically mandatory from an ergonomics standpoint in every Rust project I start. Also,…
Re: Matt Godbolt sold me on Rust by showing me C++
#23Quantity(100) is counterproductive here, as that doesn't narrow the type, it does the opposite, it casts whatever value is given to the type, so even Quantity(100.5) will still work, while just plain 100.5 would have given an error with '-Wconversion'.
Re: Matt Godbolt sold me on Rust by showing me C++
#24The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking r…
Re: Matt Godbolt sold me on Rust by showing me C++
#25The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking r…
[1] https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
Re: Matt Godbolt sold me on Rust by showing me C++
#26Side note, if anyone is interested in hearing more from Matt, he has a programming podcast with Ben Rady called Two's Complement. https://www.twoscomplement.org
Re: Matt Godbolt sold me on Rust by showing me C++
#27What if we have a C that removes the quirks without adding too much brain drain? So no implicit type conversions, safer strings, etc.
Swift is really great these days and supports Windows and Linux. It almost feels like a scripting language other than the compile time of course.
Re: Matt Godbolt sold me on Rust by showing me C++
#28And don't get me started on dynamic graphs.
I would happily use Rust over C++ if it had all other improvements but similar memory management. I am completely unproductive with Rust model.
Re: Matt Godbolt sold me on Rust by showing me C++
#29Right. I attempted using Rust for trading-related code as well. However, I failed to write a dynamically linked always sorted order book where you can splice orders in the middle. It is just too dynamic for Rust. Borrow checker killed me. And don't get me started on dynamic graphs. I would happily use Rust over C++ if it had all other improvements but similar memory management. I am completely unproductive with Rust…
Re: Matt Godbolt sold me on Rust by showing me C++
#30Yes, Rust is better. Implicit numeric conversion is terrible. However, don't use atoi if you're writing C++ :-). The STL has conversion functions that will throw, so separate problem.
> Implicit numeric conversion is terrible. It's bad if it alters values (e.g. rounding). Promotion from one number representation to another (as long as it preserves values) isn't bad. This is trickier than it might seem, but Virgil has a good take on this ( https://github.com/titzer/virgil/blob/master/doc/tutorial/Nu... ). Essentially, it only implicitly promotes values in ways that don't lose numeric information an…