Live data from Hacker News

Why You Should Know C++

unknownprogrammer.com

51–60 of 63 posts

Re: Why You Should Know C++

#51
post #29

Earlier quoted context omitted.

The stylistic differences are wide. Learning to for instance do C style APIs using opaque types, extended macro-fu, broader use of function pointers, etc. are the sorts of non-obvious things that good C developers do that you'll mostly miss working just on C++ code-bases.

I don't think that non-obvious and "good developers" should be joined together in one sentence. It's possible to do a lot of macro magic, it's possible to do a lot of function manipulation, but this is not good development. This is efficient development when you are working with projects or systems that require that sort of thing (maybe large dataset manipulation or embedded systems), but in my opinion, doing those t…

It's not that those features aren't exposed in C++, it's that C++ has different (more modern) mechanisms for doing the same thing.

C++ has templates, so you don't need to do as much with macros. C++ has virtual functions and overloaded operators (allowing for functors), so you don't need to do as much with function pointers. Structures can have methods in C++, so the way that you'd set up an opaque type is quite different in C++.

C++ also has about 10000 other features as well though, which is what makes it unwieldy to learn. The patterns mentioned above aren't about efficiency; they're about encapsulation.

Just to give an example -- in C++ if you want to set up a callback, for example with an observer pattern, you'd use a pure virtual function (and then pass in a concrete instance of that class) or a functor. You can't do that in C, so you use a function pointer. You learn to work with function pointers more because they're a necessary part of designing C APIs, whereas they're not in C++.

(Note that it's the language I'm best at, followed by C, so this isn't random C++ hating.)

Re: Why You Should Know C++

#52

Life is too short for c++. That's what I always say (even at job interviews..)

There are indeed so many things to learn, but as a developer or someone who would be in the development world (be it building tech startups, developing software, etc) there is a must-know set of tools. C/C++ happens to be very high on the list. And learning more really doesn't hurt.

Not just C++, but also learn C, Java, Perl, Python, Erlang, Lisp, PHP, Shell Scripting, Assembly, Ruby, along with their most used libraries/frameworks. The more diversify your skillets, the better you can use the right tool for the moment, improving performance of that, lower development time. (Eg. A spoon can be used to build a house, but it's hardly the best tool out there).

This way, want to hack up a quick content management or low computational front end system, whip out your php/python/ruby with your favourite framework out. Got a bottleneck at high cpu or memory bound place, rewrite that piece in C/C++. Need to deploy a cross platform app really quickly, Java. Want to bind or write a test for a bunch of tools, use Python or Perl. The list goes on.

Summary: Learn More, use the right tool, do less, get more accomplished.

Re: Why You Should Know C++

#53

Life is too short for c++. That's what I always say (even at job interviews..)

There are indeed so many things to learn, but as a developer or someone who would be in the development world (be it building tech startups, developing software, etc) there is a must-know set of tools. C/C++ happens to be very high on the list. And learning more really doesn't hurt. Not just C++, but also learn C, Java, Perl, Python, Erlang, Lisp, PHP, Shell Scripting, Assembly, Ruby, along with their most used libra…

"C/C++" is not a single language, by all means learn C.

Re: Why You Should Know C++

#54
post #53

Earlier quoted context omitted.

There are indeed so many things to learn, but as a developer or someone who would be in the development world (be it building tech startups, developing software, etc) there is a must-know set of tools. C/C++ happens to be very high on the list. And learning more really doesn't hurt. Not just C++, but also learn C, Java, Perl, Python, Erlang, Lisp, PHP, Shell Scripting, Assembly, Ruby, along with their most used libra…

"C/C++" is not a single language, by all means learn C.

[deleted]

Re: Why You Should Know C++

#55
post #53

Earlier quoted context omitted.

There are indeed so many things to learn, but as a developer or someone who would be in the development world (be it building tech startups, developing software, etc) there is a must-know set of tools. C/C++ happens to be very high on the list. And learning more really doesn't hurt. Not just C++, but also learn C, Java, Perl, Python, Erlang, Lisp, PHP, Shell Scripting, Assembly, Ruby, along with their most used libra…

"C/C++" is not a single language, by all means learn C.

One should learn both. If you spend the time to learn C, might as well spend a tiny bit more and learn the C++ concepts as well. There are ton of pure C libraries, but a lot of algorithmic stuff in C++ STL/Boost kinds, knowing both C and C++ is essential, each by them selves wouldn't necessarily help one too much.

Re: Why You Should Know C++

#57

My reason not to learn C++: There are so many things one should know, that it is not rational to learn all the arcane details of C++. Every decision to learn something is an implicit decision not learn everything else.

If you know any other object-oriented language, it's easy to make the case that you should learn C and skip C++.

Re: Why You Should Know C++

#58
post #43

Earlier quoted context omitted.

The difficulty in both languages lies in pointer manipulation and understanding the system below, it does not lie in using classes or templates. That's utterly untrue. The low-level details of C++ are mostly the same as C's, unless you want to write a shared library in C++ and thus need to extern the C++ symbols, or need to worry about the details of the object-system implementation like vtables, or need to mess with…

If I were to extend C by adding python style classes on top of it, I would end up with roughly the same number of keywords. I don't think it's true that C++ has a lot of new concepts in the language itself. I agree that C++ is very library oriented, and it changes your approach to the language, but this is not a fault of the language itself, this is a side-effect of its very wide popularity. If you have a pattern use…

"Templates are not used"? Do you mean that you code C++ without the standard library?

Re: Why You Should Know C++

#60
post #15

Earlier quoted context omitted.

Learning C++ you will not know C. At least, not in the time it could have taken you to learn C by itself. There are a few core differences, and with C++ you'll spend a lot of time learning things that will distract you from the core language. If you want to learn C and understand it's advantages don't assume you'll pick up what you need by learning C++.

Yes you will. It's better to learn C++ straight up, because the things you learn there will help you become a better modern developer compared to just C. The core differences between C and C++ (apart from the entire object oriented thing) are easy for any competent developer to pick up. Were they difficult for you to understand?

It's not about knowing the core differences, it's that the actual practice of writing a lot of C makes one familiar with its advantages. It's difficult to appreciate the value of C's small size if you are only coding in C++. Without doing a lot of coding in straight C, it'll be a lot harder to understand and recognize the various tricks and techniques other C programmers use to make the most of the small language.

I'm not saying there are no good reasons to learn C++. Just don't think that you'll really appreciate C until you've actually used it all by itself (with maybe a few C++isms here and there like //comments).

Post reply on HN