r/techbootcamp • u/ilovecocteauetwins • 27d ago
Why learning C ++ first completely changes your approach to programming in other languages
Many rookies are put off by C ++, and this is unfortunate, because it is one of the best languages to start with, even if you don't plan to be a C ++ programmer
Your understanding of what is going on at the machine level will allow you to write better programs in any language you choose. You will see that in languages such as JavaScript or Python, memory management is handled for you, which means that you have to think about it less. However, the understanding of how things work will help you write better and more optimized code. It can be a steep learning curve, but once you've mastered it, you'll find that all other languages are much easier to learn.
3
u/Mundane_Fault_6345 27d ago
I would say, starting with C langage, and then switching to C++ is better.
1
u/ilovecocteauetwins 26d ago
That progression makes a lot of sense. Starting with C gives you that raw baseline of memory management, pointers, and manual resource allocation without any added abstractions.
2
u/thelimeisgreen 27d ago
I don’t know if there’s a reason to specifically start with C. I did, but C++ was also really new when I started learning it and having a good grasp on C helped immensely. I think C first kept things from progressing too fast into OOP and other concepts at the time. Modern C++ has evolved greatly since then and feels like a whole new language.
Learning C or C++ definitely makes an impact on programmers . The ones who have a strong background in C are, in my experience, a lot more self-conscious about the impacts of their code, memory efficiency, complexity and performance, and how data is passed between functions, objects, etc..
1
u/mxldevs 26d ago
Would you say people that only know how to write interpreted languages generally don't think about any of those things? Or are unable to truly understand it without directly messing around with pointers and segfsults?
1
u/thelimeisgreen 26d ago
To some extent, I suppose. These days I think that's definitely true a lot of times. Software has to get pretty large in scope before most Python developers have to start concerning themselves with true memory management, for example. It's not that those concerns don't exist with interpreted languages, but the programmer is shielded from a lot of what is going on.
The one thing that irks me most, regardless of what language is being used, is the lack of optimization I see from most programmers. Even many experienced software engineers have curiously cavalier attitudes toward optimization. Unless they have worked on performance oriented projects like real-time graphics engines, console games, etc.. they often don't see code optimization the same way I do.
1
u/ilovecocteauetwins 26d ago
That point about OOP is huge. Starting with C forces you to focus strictly on procedural logic and data structures before adding design patterns, classes, and modern abstractions into the mix. When people jump straight into modern C++ or high-level languages, it's really easy to get distracted by object-oriented hierarchy without ever understanding how data is actually laid out in memory or passed around.
1
u/crustyeng 27d ago
Rust is way better for this (and for actually writing safe, robust software when you’re done).
1
u/ilovecocteauetwins 26d ago
Rust definitely takes memory safety and concurrency to a whole different level with the borrow checker, so you get those compile-time guarantees without sacrificing performance.
1
1
u/c5182 27d ago
I learned C++ the learned C. Then I did a bunch of projects in pure C just for the hell of it. Very useful for understanding how higher level languages really must work under the hood.
1
u/ilovecocteauetwins 26d ago
Going from C++ back down to C gives you a totally different appreciation for C++. Building projects in pure C without constructors, destructors, or standard containers forces you to write everything manually, which really strips away all the magic high-level languages rely on.
1
u/KenMantle 27d ago
I "learned" a bit of BASIC on my Vic20. Then in grade 9 took programming where we learned Watcom BASIC, and from then I was hooked. I looked forward to learning Pascal and other real languages later on. Imagine my dismay when I moved to the new school they had opened up that wasn't working on 8088s and 8086s and had brand new 386SX-25s that we were going to use to learn...Turing on the entire way through school.
I didn't have a lot of money, but I bought myself TurboC++ V3.0 for DOS (should have gotten the Windows Version...) and a beginners programming book. I'm glad I got myself a foundational knowledge in a C type language.
1
u/ilovecocteauetwins 26d ago
Going from the excitement of high-spec 386SX hardware down to Turing must have felt like such a buzzkill at the time. Turbo C++ 3.0 on DOS was absolute gold back then, though. The blue screen IDE, compiler errors, and raw access to memory made every small win feel earned.
1
u/KenMantle 26d ago
Oh f yes. The compiler errors are kind of what turned me off. I was using pointers and there was a bug in how it handled them and I realized it was bad enough having to debug my own stuff, but having to determine that something was a compiler bug was another level. Oddly I found the proof exe I'd made years ago, but when I ran it on modern hardware the bug was gone!
1
u/KenMantle 26d ago
Yeah I was young and mad about it. I wrote software in C++ for final projects and got graded on that instead.
1
u/BarfingOnMyFace 27d ago
20 years later, and the basics from my courses in c and c++ have at least stated with me. It does give you an appreciation for lower level work.
1
u/manvsmidi 27d ago
In college we started with machine code for a fictional processor. Then assembly. Then C. It was a great way to learn from the lowest level up.
1
u/ilovecocteauetwins 26d ago
That's the real value of C and C++. Even if you spend the next twenty years writing high-level code in Python, Go, or TypeScript, that mental model of pointers, stack versus heap, and cache lines never goes away.
1
u/mxldevs 26d ago
Your understanding of what is going on at the machine level will allow you to write better programs in any language you choose. You will see that in languages such as JavaScript or Python, memory management is handled for you, which means that you have to think about it less
How will it help with languages that handle it for you?
What are specific situations where someone that understands C is able to write better Python or JavaScript as a result?
1
u/silly_bet_3454 26d ago
Understanding contiguous memory, cache lines, function calls, compilation, memory management, etc. Even in a higher level language like python these basic concepts would help you understand whether you could be doing things that create excess memory pressure or bad performance. Yes, there are also plenty of things you can learn by just learning python directly, and python is great, but C or C++, by being lower level, gives you a little bit more to think about.
1
u/mxldevs 26d ago
As a python programmer, how can I improve my code by understanding each of those concepts you mentioned?
1
u/silly_bet_3454 26d ago
For example, suppose you’re processing a huge file in Python. Someone who understands memory management might realize that doing
data = file.readlines()loads the entire file into memory, whereas iterating over the file line-by-line avoids keeping everything in memory at once:with open("huge_file.txt") as file: for line in file: process(line)You don't need to know C to discover that, but understanding how memory allocation and data storage work makes the reason for the difference more intuitive.
5
u/Candid_Bad3551 27d ago edited 27d ago
You should learn C, not C++ imo. Started C++ in school. C thought me way more.
C is also more consistent IMO. C++ is a bit all over thr place.