4 ms·
> The control and performance are there, as happens to C++, but the productivity is basically the same This is not very fair to Rust. It's absolutely more prod
by zozbot234 5y ago
> The control and performance are there, as happens to C++, but the productivity is basically the same
This is not very fair to Rust. It's absolutely more productive than C++ when you account for the productivity benefits of "not shooting yourself in the foot" with pesky memory-safety bugs. Let's not even talk about scripting tools like Python, Ruby or JS that were never designed for "programming in the large" yet have somehow become popular in that role (with predictable consequences wrt. technical debt and lack of long-term maintainability).
The proper, challenging comparison is with correctness-oriented GC languages like Haskell, OCaml, possibly F#. And Rust might nonetheless have the better community, since it can address systems-level and performance concerns out of the box unlike those.
- Serow225 5y agoI work at a place that has started using Rust for backend services lately and I enjoy it, but IMO using F# instead would have given many of the benefits with a lower on-ramp time for new devs and generally higher dev velocity…
- berkut 5y agoI don't agree it is at the prototyping level... I think C++ is quite far ahead there than Rust IMO... For a 'stable' production implementation after prototyping, I agree that the benefits Rust provides (if it compiles, it will either panic or work) are well worth it, and so longer-term, I buy that you probably will spend less time, but in my experience, things like not being able to specify default field values inline (you need to provide a 'new' function, or 'default' impl, meaning you then have very tightly-coupled parts in different places in the code) compared to C++11's member variable inline initialisation is very fustrating when in the early stages of prototyping, when things are changing a lot. Similarly, as mentioned above - string handling, with as_str(), to_string(), String::new(), from(), etc, I think make some sense at a full production level when you might care about ownership / copies / allocations, and want them to be explicit, but when you're just prototyping stuff to work out data structures and relationships, it's increadibly annoying IMO when you're refactoring.
- zozbot234 5y ago> things like not being able to specify default field values inline Rust's "struct update syntax" can be reused to do this. `MyStruct { my_field: 42, ..my_local_defaults }`, where my_local_defaults is an instance of MyStruct that's in scope.
- berkut 5y agoThat's not what I meant by inline. In C++, you can set the default at the same time as you declare the member variable, meaning the three things (variable type, variable name and variable default) are in exactly the same place in the code on the same line. In Rust, you can't do this, you need to implement new() or default() (or manually specify all field items when declaring the struct), which is normally in another place in the code, so you have tightly-coupled code in two places, which is as bad as C++ headers and implementation files which is what a lot of Rust evangelists seem to complain about on here about C++ (it's a valid complaint, but I don't think Rust completely gets it right, as is complicates / makes things more verbose in other ways like this one).
- nicoburns 5y ago> things like not being able to specify default field values inline I’m cautiously optimistic that Rust will get this at some point. There’s quite a lot of demand for this in the Rust community (although some opposition too)
- jmatthews 5y agoIs that narrative still true post-modern cpp? On some level it feels like the cpp narrative was written in the early 2000s and hasn't kept pace with reality. Too cluttered, too object-centric, bad compile times, sure. Is the cognitive load of choosing safe pointers that much more than navigating the borrow checker?
- zozbot234 5y ago> Is that narrative still true post-modern cpp? The key reference on "modern" C++ is the "C++ Core Guidelines". They're pretty comprehensive but quite complex as well, and they don't really manage to establish a "sound" or "safe" idiom for the language; they're more focused on avoiding the most common pitfalls.
- ncmncm 5y agoNo, it's just an old marketing line that has failed to track reality. It is never surprising when that happens. Once upon a time C++ was supposed to produce "code bloat". Now it doesn't, without any changes to address that.
- ncmncm 5y ago> [Rust is] absolutely more productive than C++ ... I have spent strictly more time in the last five years filing compiler bugs than chasing memory usage errors in my C++ code. So, whatever benefits the extra work needed to make rustc happy, and time waiting on slow, slow builds is supposed to deliver, it fixes no problem I have. The same is probably true for anybody coding C++ using modern library facilities. There is just no temptation to do anything dodgy. It would be more work than the safe thing. So, the marketing insists on these benefits, but I don't see them. It is likely old code was more prone to such bugs, but we are talking about coding now, not then. Rust has lots of nice features to make coding pleasant, and you can evidently get used the nannying, so it seems like an OK choice for a project that nobody else will need to maintain.
- zozbot234 5y ago> The same is probably true for anybody coding C++ using modern library facilities. There is just no temptation to do anything dodgy. std::string_view is but the latest example of a "modern" C++ facility that turns out to be a dodgy footgun, due to the lack of safeguards around lifetime errors. C++ still lacks a general equivalent to string_view for arrays (what Rust calls a slice) for the same reason. These seem like significant drawbacks to me.
- 10000truths 5y agoC++ does have this, it’s called std::span. https://en.cppreference.com/w/cpp/container/span https://en.cppreference.com/w/cpp/container/span
- pjmlp 5y agoJust make /analyze part of the compiler options and some of those issues will be visible.
- kobebrookskC3 5y ago> I have spent strictly more time in the last five years filing compiler bugs than chasing memory usage errors in my C++ code. maybe because your code isn't worth having people actively attack?
- FpUser 5y ago>"It's absolutely more productive than C++ when you account for the productivity benefits of "not shooting yourself in the foot" with pesky memory-safety bugs" When doing generic application level programming: use STL containers, iterators and algorithms properly and you won't have any of those pesky bugs. Does not require much efforts. If you do want to shoot yourself C++ will of course offer thousands of ways for you to do so. But with modern C++ it has to be your choice. Unless of course you are working on some specialized system type code, libraries like STL and other similar tasks.
- oscargrouch 5y agoI agree with you that one language will take the productivity you've gained in a later stage, but we would need to subtract the time fixing those bugs, as compared to the time spent on code to avoid them in both languages (one before and another later). I'm pretty sure that a lot of people will be more productive with Rust as compared with C++ as with others will be the opposite. So i guess in by making an average over those two crowds, i doubt they will differ that much. The sort of bugs Rust will avoid that are kind of hard to debug, giving it doesn't happen that often is the problem of shared state in a multi-thread environment.. the other kinds are often easy to spot in C++, the only difference is that they are caught in runtime.
- deschutes 5y agoMemory safety bugs can be intimidating and sometimes challenging. Mostly they're not though. Conscientious programmers aren't going to spend too long in the shooting themselves in the foot phase. To me the awful compilation model and horrendous compile times are much bigger productivity bummers. I enjoy helping folks debug memory safety bugs that stumped them. It takes the drudgery out of the day. And it's usually an opportunity to teach them something.