logoalt Hacker News

vinyl7 • today at 3:43 PM • 4 replies • view on HN

The only sane usage of C++ is to only use a very small subset of its features.


Replies

ho_schi • today at 3:59 PM

https://www.stroustrup.com/JSF-AV-rules.pdf

That’s what Stroustrup does and it works. I just too versatile. Luckily there is recently a push_back against adding new stuff for the sake of it.

My own rules, mine: * Templates are nice. * Template Metaprogramming is not. * Objects and Classes are nice * Inheritance is not.

I like composition and interfaces. I avoid inheritance, aside from some natural cases were it fits (UI Widgets).

I’ve seen in recent years projects switching from C to a mere plain C++. Stronger typing, containers, smart-pointers, simple APIs.

➕ show 1 reply
cogman10 • today at 3:53 PM

The only sane usage of C++ is "This is a legacy project, needs to integrate with a legacy C/C++ project, or all our engineers are C++ experts and they don't want a new language".

For everything else, you should pick one of any number of other languages. Rust, swift, zig, go, java, python, javascript. Take your pick.

➕ show 2 replies
lordnacho • today at 3:52 PM

Which makes various c++ repos look quite different. It's like learning Arabic and then finding out that you can't actually talk to all the other Arabic speakers.

➕ show 1 reply
marcosdumay • today at 4:25 PM

I just hope whoever selected the subset knows all of the language, so that they can tell if there's something outside of that subset interfering with it or not.