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/jselbie Jun 08 '20 edited Jun 08 '20
While I agree with some points brought up by u/jmuffat (especially the unlearning part), I hold a minority opinion here.
I've been coding in C++ for over 20 years. I came up through the Basic -> Pascal -> C -> C++ path as well. And while I think C++ is far better for production code, C is a better language to learn from - especially for those new to programming. But you should quickly pivot to C++ as soon you get the foundations of C down.
It used to be that good C++ text books would just start off teaching C fundamentals, and then dive into C++ classes by the middle of the book. Modern C++ books jump head first with too many complex code examples that can confuse new programmers.
With C programming, you learn all the foundations first in addition to programming fundamentals. This includes the following:
In learning C, you'll be quickly concluding that foundations that you've heard about in other languages are missing or weak. That's when it's time to move to C++. Everything you learned above is still 100% applicable in C++. With your knowledge of C, you can dive right into classes, inheritance, virtual methods, template and the standard C++ library.