Live data from Hacker News

Why You Should Know C++

unknownprogrammer.com

21–30 of 63 posts

Re: Why You Should Know C++

#21
post #12

I like to use C++ just as a better C. Things like single line // comments and not having to declare all your variables at the top of your functions is really useful. STL is also really useful in that you don't have to (badly) reinvent basic data structures like vectors and maps. Of course, STL also means reading compiler errors that are pages long... :-/

[deleted]

Re: Why You Should Know C++

#23

Wow, I like C++ (at least, more than most), but I don't agree on any of those points. In fact, I am sad to say that unless your job requires it, I can't really think of any reason to learn the language. It relies on a mixture of paradigms that are easier learned from other languages where they are isolated. And for lolevel stuff, you are better off learning C.

I'd phrase the C / C++ rift a little more carefully --

To do low-level C++ you'll have to learn low-level C anyway and learning C in and out is a far easier endeavor than learning C++ in and out. So if you're wanting to dip into low-level stuff, you need to learn at least C and may want to learn C++ as well.

(More generally the above does not hold -- the way you approach and solve problems in C and C++ does vary a good deal in higher-level stuff, but if you're doing bit-wrangling, you do tend to end up with something that approximates C bunched into classes.)

Re: Why You Should Know C++

#24
post #7

Earlier quoted context omitted.

Windows API is pure C. GTK is pure C. And these are quite serious (and not exactly obscure) development frameworks.

The Windows API is an array of functions that can be called the same from C as from C++. Microsoft provides several object oriented wrappers for this API, and it's very rare that any significantly large application is not calling the API over some kind of wrapper.

No, I think it's C. It's written in C and was (at least initially) designed to be called from C code. I think #ifdef __cplusplus followed by extern "C" doesn't make a C API C/C++. Also the fact that there are several Microsoft and third-party wrappers out there doesn't make it any less C, at least in my opinion.

Re: Why You Should Know C++

#25

I feel the most compelling reason to use C++ is that it is one of the de facto programming languages in competitions.

This is the same reason I drive a NASCAR stock car to work.

Seriously, the defining aspect of most programming competitions is that you're making a program as fast as possible, whatever it takes. C++ rewards this: if you keep sinking an order of magnitude more effort into it, you can seemingly always shave off another tenth of a percent of the time. There are some cases in which this is actually relevant (many involving graphic rendering, a niche I work in, PS), but they're really a tiny part of programming.

It makes sense to code them in C++ (or C), but it's really not the best fit for more general development, which usually places a higher priority on being able to deliver an adaptable and correct solution.

Re: Why You Should Know C++

#26
No discussion of C++ should go without mentioning the C++ FQA (Frequently Questioned Answers). It carefully explains every single thing wrong with the language, and there's a LOT to explain.

http://yosefk.com/c++fqa/

Skip to http://yosefk.com/c++fqa/defective.html for a great overview. And if anyone ever mentions "templates" again I'm gonna smack them hard.

Re: Why You Should Know C++

#27
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.

Re: Why You Should Know C++

#28
post #7

Earlier quoted context omitted.

What's the point of using C when most modern programs on modern operating systems are written using frameworks that are a form of objectified C? All serious development frameworks nowadays for desktop applications are either C++ or Objective C. Most native libraries are one of the two. Even the driver SDKs are mostly build on an object oriented approach. And learning C++, you will know C. Your opinion is a popular op…

Windows API is pure C. GTK is pure C. And these are quite serious (and not exactly obscure) development frameworks.

Yes but the C++ based MFC wrappers for Win32 make Windows development much easier.

Re: Why You Should Know C++

#29
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?

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.

Re: Why You Should Know C++

#30
"You will hardly be seen as a hacker if you don’t know C++"

Yeah right! You are "seen as a hacker" if you write code that is useful to others and/or is brilliant in some respect. Nothing to do with knowing a particular language.

If knowledge of a specific language is a criterion, I'd rather have someone be an expert in C/lisp/smalltalk/haskell/prolog.... C++ originates or embodies no concepts that weren't discovered or done better elsewhere.

e.g: An expert smalltalker is more likely to understand OO than a C++ programmer.

Post reply on HN