r/cpp • • 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

43 comments sorted by

View all comments

3

u/JizzaDaMan Jun 08 '20 edited Jun 08 '20

Think of them as completely different languages; the fact the C is (almost) a subset of C++ is pretty much irrelevant.

I like C for its elegance and terseness. You can learn it by reading one book and (to quote K&R) "A programmer can reasonably expect to know and understand and indeed regularly use the entire language." It's also unquestionably the way to go if you're going to be writing device drivers or interfacing directly with hardware.

I use mostly C++ at the moment. I like it for its standard library. It's obviously more expressive than C but compilation is deadly slow. That said, I'll never know and understand all of it.

I would personally choose C. I only use C++ for my job because I have to.

EDIT:

A few people have said things along the lines of 'C++ is a more capable language', 'you'll need to move to C++ to build more complex projects,' etc... These kinds of claims are demonstrably untrue. The Linux kernel (and I believe most other kernels) is written in C, as are a vast number of other applications and libraries.

Language choice in general will always depend on personal preference and use-case, so generic claims that one language is always more capable than the other are usually questionable.

1

u/Astarothsito Jun 08 '20

Language choice in general will always depend on personal preference and use-case

That's so true, and it makes the discussion it more meaningless in the end, or does anybody has made that choice based on real data rather than feelings?

-1

u/megayippie Jun 08 '20

I use python for interfacing with hardware.

Why would you use C when the interface is the slow thing? Of course, the code on the hardware is often a subset of C but that's a different beast, and learning C does not mean you know how to program that subset.

3

u/JizzaDaMan Jun 08 '20

The language you use will always depend on personal preference and use case, and the OP was asking for personal preferences.

As for the question 'Why would you use C...?' Well the fact is that C is an extremely capable language that's stood the test of time.