Hacker News new | ask | show | jobs
by darknavi 1495 days ago
I work in C++ daily and there is something about the simple-ness of C that I love. You get out of magical hell that is templates and return to simple flat-functions and macros.
6 comments

Templates suck because they're the wrong abstraction. Or rather, they pretend to be an abstraction when in reality they're leaky as hell.

Rust's traits are generics done right. I haven't looked at Concepts too much, I hope that they'll be better than templates.

They are, the best ISO C++ alternative is ISO C++ vnext.
D is more appealing and powerful, and if you are familiar with C/C++ there's not much of a learning curve - https://dlang.org/overview.html
Hot take: people make a bigger deal of how complex templates are. Modern compilers find and describe errors much better than in the days of trying to use boost in vc6.
Nothing prevents you to code like that in C++, although I would rather suggest templates instead of macro hell.
That's the thing with C and C++.

C is light and simple, but don't use it much, because it can get too verbose.

C++ allows for succinct code, but it's neither light or simple. Nor does it have any concern for the elegance of its design.

Hence the common practice of using a small subset C++ and pretending it's just C with Extras.

> Nor does it have any concern for the elegance of its design.

It has a lot of inelegant facilities, which, when used under the hood, allow you to express your elegant abstractions.

> Hence the common practice of using a small subset C++ and pretending it's just C with Extras.

That's mostly failure to use C++. Since C++11, and especially with later updates to the standard, idiomatic C++ is very different from C - even if you're not using a lot of the standard library. I'll link to a talk already linked-to in another comment in this discussion:

Rich code for tiny computers / Jason Turner, CppCon 2016 https://www.youtube.com/watch?v=zBkNBP00wJE

> That's mostly failure to use C++.

Isn't this the no true Scotsman fallacy? It looks like you're agreeing with the parent poster that a lot of people use a small subset of C++ to pretend that it's C with extras. If this is true, it's not a failure of all these people because they don't _really_ understand C++. It's a failure of the language designers because they have made something that nobody can agree on how to use.

I should have used a different word. I meant "failure to do X" as in "not doing X", not as in "lack of success in the attempt to do X"

See the two meanings here:

https://dictionary.cambridge.org/dictionary/english/failure

> That's mostly failure to use C++.

How is it a failure when people just find idiomatic C++ undesirable, exactly because it's very different from C.

Basically, the best C++ feature by a very long mile is that it can in fact be used as an extension of C. That's what made it popular in the first place and that's still "what people want".

If it's a failure, then it's that of the C++ committee evolving the language in an echo chamber.

You can take a look at C# generics. They are quite simple.