3 ms·
> It forces an understanding of fundamentals. I don't have a dog in this fight as I haven't learned Rust. This statement, though, came off as ridiculous. I've
by BeetleB 3y ago
> It forces an understanding of fundamentals.
I don't have a dog in this fight as I haven't learned Rust. This statement, though, came off as ridiculous.
I've worked as a C++ developer. Most of my peers didn't understand the "fundamentals". They didn't know a map was implemented as a binary tree, for example. They didn't understand struct packing. The list goes on an on.
C++ allows for quite a bit of abstraction letting people be quite productive without understanding much about the machine. People look up the API in the standard library and they just use it like they would any other language.
That was, after all, one of the selling points of C++ over C.
- Sohcahtoa82 3y agoI must have a different idea of what "fundamentals" are, because map being implemented as a binary tree isn't a fundamental, but simply an implementation detail. When I think of the fundamentals, I think of the lower-level stuff like pointers, memory management (malloc/free/new/delete), and avoiding buffer overflows.
- loganthorneloe 3y agoThis is what I was getting at.
- andersa 3y agoIt doesn't force it, but it is much more fun to use once you understand the fundamentals, since you can still write code where it makes a difference.
- BeetleB 3y agoSo ... the same as Rust, then?
- John23832 3y ago> I've worked as a C++ developer. Most of my peers didn't understand the "fundamentals". They didn't know a map was implemented as a binary tree, for example. They didn't understand struct packing. The list goes on an on. And even if you do know the fundamentals, for a vast majority of programming, you don't need to care. How often does the average programmer need to care about the underlying mechanism a map? How often do they need to care about struct alignment? Etc. > C++ allows for quite a bit of abstraction letting people be quite productive without understanding much about the machine. People look up the API in the standard library and they just use it like they would any other language. Rust similarly does... it just yells about the specifics of the abstractions.
- BeetleB 3y ago> How often does the average programmer need to care about the underlying mechanism a map? I think it's useful to know it's not an O(1) lookup as many programmers seem to assume. Definitely useful to know it is ordered. Also, I once ran out of RAM (over 80GB), because of all the extra pointers needed in a tree. I switched to a sorted array and used a binary search instead - got the same performance, without running out of RAM.
- com2kid 3y ago> How often does the average programmer need to care about the underlying mechanism a map? How often do they need to care about struct alignment? Etc. It is important to know the big O performance of an underlying data structure if it is being used for a non-trivial number of elements. And struct alignment I've had to worry about many times in my career, especially when passing structs between platforms or languages. So for most of my career, these have been important issues. (Though I'll admit between starting my career in compilers and then doing embedded, the first half of my career was fairly biased towards the low level details!)
- John23832 3y ago> So for most of my career, these have been important issues. I appreciate what you're saying, but your career is an outlier. The VAST majority of programmers/software engineers are gainfully employed without knowing any of these things.
- blastonico 3y agoAuthor mentioned about high-frequency trading tools and machine learning. Don't know about machine learning, but a HF C++ developer usually has solid fundamentals. I tend to believe that naïve C++ programmers aren't in those areas.
- loganthorneloe 3y agoI work in ML and this is also the case. I was definitely biased toward my own experience when writing this so my take on this could be incorrect.
- logicprog 3y agoIf that quote from the article was supposed to be comparing C++ positively to rust, honestly it comes off as pretty condescending to me, too. Just because Rust has some safety rails built into it, that doesn't mean it hides the nature of what's going on underneath from you, any more than using a static analyzer on C++ would. Rust isn't any higher level than C++, and you still need to deal with all of the same requirements and underlying concepts and semantics in writing safe code in Rust as C++, it just forces them explicitly ahead of time and does so in an extremely clear manner, whereas C++ "enforces" them at runtime as they arise and in an extremely opaque manner. That's basically the only difference, and in fact, because Rust explicitly and clearly forces you to contend with the concepts of single ownership and proper RAII and when to use which pointer type and the basic practices of avoiding data races and memory safety violations from the get-go in a way that C++ does not, if anything Rust forces you to learn to do everything correctly and grok all the concepts behind it up front far more rigorously than C++ ever would, since in C++ you can kind of skirt by ignoring all of it. And as a testament to this, I have found in casually branching out and reading up on C++ (despite how much of a fan of Rust I am, and the fact that I think Rust is genuinely the future and should probably eventually take over C++'s position for any new projects, I really think that C++ is a very cool language, with some absolutely killer features, and I can absolutely see why those who enjoy programming in it do so, and I actually think I would enjoy programming in it too) that my experience with Rust and Rust's concepts actually makes C++ infinitely easier to understand, because the underlying concepts and implementation of everything is pretty damn similar, which I think should indicate that Rust does in fact encourage you to learn the underlying concepts of things. I've also found that knowing Rust makes my C code infinitely better, because I've got a borrow checker in my head now.
- justin66 3y ago> Most of my peers didn't understand the "fundamentals". They didn't know a map was implemented as a binary tree, for example. I mean, I don't use c++ much, but... the "fundamentals" are that an unordered map is probably implemented as a hash table, and an ordered map could be implemented on a trie, a vector, a linked list, some other thing I can't think of right now, or... some variety of a binary tree. Right? I don't think I would want to assume.
- BeetleB 3y ago> and an ordered map could be implemented on a trie, a vector, a linked list, some other thing I can't think of right now, or... some variety of a binary tree. Right? I don't think I would want to assume. You're correct in that one shouldn't assume a red-black tree. However, the standard does dictate O(...) performance for the map, which strongly suggests an underlying structure. And as I point out in another comment: Knowing that it was indeed a tree helped me debug an issue where I ran out of RAM. In any case, you're point strengthens mine: That you don't need to know "fundamentals" to program in C++.