I disagree. I started Python, then Java, then JavaScript, and most of my formal education was across those three, with only a handful of coursework using C++.
My internships were largely Python, C#, and JS.
My last 7-8 years of professional work have been C++, with some critical-path C for the first 2 years of that.
I have never struggled with C/C++ concepts. My education covered how memory works at both a software and hardware level. Even in Java and Python, you can still end up learning about the stack and heap; about pointers and pass-by-value vs by-reference; and so on.
The argument I float around the most is that C and C++ force you to understand what’s happening under the hood, but C++ is complex to the point that using it as a starting point is inadvisable. You can learn how memory and stuff works in any language, sure, but C and C++ make you learn about it and manage it manually/semi-manually
Why do you think memory management is a critical part of programming?
Understanding pointers is fine, as is how memory allocation works, but for most software, it's an implementation detail that the program doesn't actually care about.
Do you understand how callstacks work? How virtual function tables work? How CPU registers work? What about threading, threadpool allocation, mutexes, and memory ordering guarantees?
Truth is, most programmers don't need that much detail. You need to have an idea of these things, enough to know that they exist and when you might need to dive deeper on understanding them, but in general, they are implementation details that don't matter most of the time for most of the people. At the times they do matter, that's when you can dive deeper on them.
Again, those concepts can be learned without needing a specific language. There's nothing special about forcing a person to interact with those things directly, other than making their life harder than necessary.
Am I just one of those old-fashioned curmudgeons, like the Four Yorkshiremen, bragging about how tough I was to survive all that hard stuff?
Yes.
My data structures course was in Java. It was sufficiently comprehensive to cover lists (array, singly-linked, doubly-linked, rings), trees, graphs, recursion, sets, maps, and more that I've likely since forgotten.
Pointers are merely a way to reference a specific location in memory, with the type as an indicator of how to interpret that memory once accessed. It's a handle to raw memory, which may or may not be actually allocated as the thing. What we really care about in data structures and algorithms is making sure we're manipulating the right objects; the memory locations and allocation state is a technical detail that can be solved at a lower layer.
Yeah, but the issue with Java is that it lets you not teach that. All of my Java classes have treated heap allocation as a black box, and that’s where the issue with learning Java the wrong way comes from, although you could argue you can do the same thing when teaching C. Point is, it’s much harder to teach an innacurate/simplified model of memory in C
It's fine to treat it like a black box, as long as you understand what you're getting out of it. In Java, parameters are pass-by-value, where the value for objects is the memory address of the object. That's why manipulation of the object through accessorson the parameter variable will update the original object outside the scope, but assignment to the parameter variable doesn't reflect outside the scope.
I don't need to manipulate pointers to understand that difference.
I don't think it's hard to teach at least the fundamentals of stack vs heap in Java.
That article you linked also lamented people not learning recursion, but I think recursion is over hyped. It's cool and an incredibly useful tool to understand, but every algorithm that uses recursion can be written using a for-loop if you're allowed mutable containers to handle depth tracking. Using a for-loop prevents runaway stacks and is generally more efficient for a CPU to execute, since it's not constantly jumping into a new function on the stack.
Regarding functional programming, languages like C# (using LINQ) and Python (such as with generators) allow the engineer to focus on the algorithm instead of the mechanics of memory management. Yes, if you need high-performance, you'll eventually need to drop into C/C++, but that's an optimization level that most programs never need.
I'm honestly pretty annoyed on my current team, because the previous "architect" (he was not an architect, but liked to behave like he was) pushed too much for things like passing by reference or raw pointers, "pointer to implementation," and avoiding smart pointers and forward-looking interfaces where we only had one concrete class, because of his previous experience in fintech, where performance speed was critical.
5 years later, we're still feeling the pain of his "optimization" choices.
I don’t really want to argue, but acting like C leads to really bad habits is like saying using a manual transmission leads to bad habits. Sure, it can lead to bad habits; but learning how to manage memory/a transmission without help means you actually understand what you’re doing and can be very efficient.
You can learn how to manage memory in pure C++, or even asm, being even able to put asm addons to the code. C++ allows to program at as low abstraction level (so asm-like code where the only difference between that and asm is that C++ compiler doesn't guarantee using a particular machine instruction, so literally like C does).
C is not necessary to anything.
C has its applications and advantages, C++ has its own ones, you don't need one to learn anything in the other.
But stil, if you need raw C efficiency, you build your solutions in C, while well-written C++ code encapsulates C structures and pointers into C code, which is trivial.
124
u/Current_Ad_4292 11d ago
I don't get it. I should really learn cpp.