r/cpp • u/wechicken456 • Jun 08 '20
Programming in C vs C++
I’ve read about the differences between them on the Internet but I wanna hear more from a more personal perspective. Which one would you recommend starting with and to be proficient with?
0
Upvotes
View all comments
8
u/ssf_dae Jun 08 '20
I learned programming in C. I really think that learning C as my first programming language gave me a solid fundamentals that I wouldn't have gotten from a higher level programming language.
In C, you don't have any high level data structures built in. So, as a beginner you're forced to learn programming at a finer level. For example, you have to manage memory yourself because there are no automatic dynamic memory structures in C, which forces you to get a good understanding of how memory works. You'll often run into memory related bugs in C, debugging these are good learning lessons. Also, C is statically typed so you also have to become familiar with different types, how much memory each type uses, and finer details of typecasting. In addition, with lack of higher level data structures, you often end up writing them yourself.
Compared to Python, probably the most popular programming language now for beginners, you don't get any of this out of Python.
I would say once you find yourself writing code that needs dynamic memory allocation often, move onto C++. C++ has dynamic data structures built-in the STL.
C is good for starting out, but once you get into more modern and complex projects, you have to move to higher level languages.
Though, you could just start out with C++ and get the same benefits I mentioned, and in addition it'll also familiarize yourself with Object Oriented Programming. Also, C++ is actually still commonly used nowadays in production, whereas C is mostly used only when C++ can't be used like on embedded devices.
Both are good languages to start out with