Live data from Hacker News

Nobody Understands C++: Intro (2007)

articles.emptycrate.com

31–40 of 53 posts

Re: Nobody Understands C++: Intro (2007)

#31
I find today's C++ extremely challenging to pick up speed for someone coming from let's say, Java. Smart pointers, pointer/references, rvalue reference, copy/move semantics, (perfect) forwarding, constructors, and how all that interacts with templates. It's just so unwieldy complex. It takes me hours to write something that would take less than a minute in Java even though I have experience with plain C. The worst thing is that after it finally compiles I feel I can't be sure if I've followed all the rules and best practices correctly or if it's going to blow up spectacularly and potentially unsafely at runtime. The fact that a book like "Effective Modern C++" is needed with all those traps and foot guns to be aware of is ludicrous.

And don't get me wrong - I think C++ is the most powerful language out there on the right hands - it just feels to require a lifetime of learning to became productive on it.

Re: Nobody Understands C++: Intro (2007)

#32
post #16

Earlier quoted context omitted.

> I realized all this class-ification effort was pure waste, since most of it would never be reused. I don't think this is a valid take. Classes are not about reuse at all. They are about encapsulation and specifying types/providing interfaces. > Same with all the idiomatic conversions. What's your complain about idiomatic conversions? > Don't get me started on boost. Why is Boost, or any library at all, relevant in…

> Why is Boost, or any library at all, relevant in a discussion about C++? It’s what the article uses to make its point. Did you read it?

Worth noting that the article is from 2007. As of C++11 (from 12 years ago) you can write the equivalent code with just C++ and the standard library (range-based for loops, std:function).

Re: Nobody Understands C++: Intro (2007)

#33

TBH, C++ has changed so much that any opinion from 2007 isn't worth much today, and that applies no matter if you think C++ got better or worse since then ;)

It is still valid.. it would be invalid if C++ removed old features, but it doesn't.

Valid only in the sense of “we can improve on this old way of doing things.” Not valid in the sense that using boost for foreach and function objects would make absolutely no sense since C++11 which has those features built in, and with cleaner syntax.

Re: Nobody Understands C++: Intro (2007)

#34
post #31

I find today's C++ extremely challenging to pick up speed for someone coming from let's say, Java. Smart pointers, pointer/references, rvalue reference, copy/move semantics, (perfect) forwarding, constructors, and how all that interacts with templates. It's just so unwieldy complex. It takes me hours to write something that would take less than a minute in Java even though I have experience with plain C. The worst th…

coming from java you probably don't need all that stuff (and you should already know about constructors). you really need to understand the differences between call/return by value and by reference, and RAII - the rest can be left to the library writers.

Re: Nobody Understands C++: Intro (2007)

#35
post #31

I find today's C++ extremely challenging to pick up speed for someone coming from let's say, Java. Smart pointers, pointer/references, rvalue reference, copy/move semantics, (perfect) forwarding, constructors, and how all that interacts with templates. It's just so unwieldy complex. It takes me hours to write something that would take less than a minute in Java even though I have experience with plain C. The worst th…

Yeah, I love C++ as a hobbyist programmer but will readily admit I basically use it like C but with the added convenience of strings & classes. Hardly how you're supposed to use it these days, but this is fine for my toy projects. But I can't imagine using the language professionally where you've got to be aware of best practices, modern enhancements, etc. Seems overwhelming!

Re: Nobody Understands C++: Intro (2007)

#36

> The comment in question begins “My take on C++ is that the best programs only use a fraction of the features.” The commenter further states that he is weary of operator overloading and templates. > In my experience, people who make comments like the above tend to be people who think they are C++ experts but who are actually only novices. I do not know the commenter personally, so I’m not trying to say anything abou…

In my opinion there are two C++'s: 1) the version used by people writing things like the STL/Boost 2) the version used by people writing apps. A huge amount of the updates to the language are to make the lives of people in category 1 easier. The people who fall into category 2 really don't need to use all the template headachery that the language allows. They can if they want, but they probably don't have to. I've no…

Templates are amazing at helping to extract performance from things by moving run time decisions to compile time when done well. I usually only go there when the profiler points me somewhere is either acting as a bottleneck or something requires to perform better. You can then even decide to go even further through branching to cases you can go into SIMD intrinsics.

Re: Nobody Understands C++: Intro (2007)

#38

> The comment in question begins “My take on C++ is that the best programs only use a fraction of the features.” The commenter further states that he is weary of operator overloading and templates. > In my experience, people who make comments like the above tend to be people who think they are C++ experts but who are actually only novices. I do not know the commenter personally, so I’m not trying to say anything abou…

> get just as much done with high quality C in half the time. Bullshit. C++ may have plenty of warts, and sometimes people go way OTT with templates (90% of Boost), but there's no way you're writing code as fast in C as C++ unless it involves no string manipulation, pointers, containers, etc. String manipulation alone is so awful in C that there's no way you're right. But throw in smart pointers, collections, JSON, r…

This. C++ is awful in many ways, but it can be much nicer than C for writing _application_ code. Use RAII, avoid deep class hierarchies, restrict yourself to the STL and use smart pointer types for lifecycle management. That’s it for starters, you will write much better code than in C.

Then you opt in to certain features like templates or operator overloading based on your bike shedding level.

Re: Nobody Understands C++: Intro (2007)

#39
> Nobody Understands C++: Intro (2007) (emptycrate.com) .. including the fella that invented it /s

If C++ was a human language, then it would be like every new piece of writing consisted of brand-new nouns, verbs, adjectives and it's own syntax and grammar.

Re: Nobody Understands C++: Intro (2007)

#40
post #30
post #16

Earlier quoted context omitted.

> I realized all this class-ification effort was pure waste, since most of it would never be reused. I don't think this is a valid take. Classes are not about reuse at all. They are about encapsulation and specifying types/providing interfaces. > Same with all the idiomatic conversions. What's your complain about idiomatic conversions? > Don't get me started on boost. Why is Boost, or any library at all, relevant in…

Class composition is about reuse. Class inheritance isn't.

That may be the case in practice but it is not literally true, since semantically, inheritance is effectively a form of copy-and-paste in the compiler. It is literally about reusing components written elsewhere. I would argue that both are forms of code reuse, with the latter also having consequences for type checking.
Post reply on HN