Hacker News new | ask | show | jobs
by earenndil 2290 days ago
I wrote on reddit[1] about why I prefer this over c++:

> It's not a technical problem, but a social problem. Yes, I would definitely prefer the c++ RAII (and refcounts would be nice too). If you say 'my project is in c++', that sends a certain message to prospective contributors, about what your priorities and ideals are. It can attract certain kinds of contributors and discourage others. Then you have the problem of how to define your subset of c++. It's easy to say 'no exceptions, no RTTI, no STL'. But there are subtler things. As you mention, templates are occasionally useful. But sometimes they're completely superfluous. Do you allow virtual functions? Multiple inheritance? The answer is almost invariably 'maybe'; you have to exercise taste. I can do that by myself, for my own project. But if I want to be able to accept contributions from others, I need a clearer set of contribution guidelines than 'wherever my whimsy takes me', and for such a purpose 'whatever the c compiler accepts' is the best I can do.

> Also, tcc is about 10x faster than gcc and clang, which makes development a joy.

1: https://www.reddit.com/r/programming/comments/f4gb6n/i_made_...

2 comments

The compiler speed pain is real, and excessive use of templates to do compile time metaprogramming can be intractable, but really it's not the 2000s any more (+) and we should stop pretending that C++ is just C with classes; exceptions, RTTI and STL do actually work now and are portable.

(+) offer not valid on microcontrollers or proprietary C++ compilers

> Then you have the problem of how to define your subset of c++. It's easy to say 'no exceptions, no RTTI, no STL'.

how about you just don't do that like 99% of modern C++ projects and just accept "whatever the C++ compiler accepts".

Remember that "whatever the C compiler accepts" covers most of IOCCC too.

Because the C++ compiler accepts an absolutely insane variety of code styles. I say this as someone who mainly writes C++. If I write my own project, or a project where I only have to work with a small number of people all of whom I know have extensive C++ experience, or a project that is so large that I can afford to consistently rewrite parts, educate contributors and maintain style guides, I choose C++. But anything that doesn't hit these bells, I'd rather use C (or something else). People mixing completely different styles in C++ is a nightmare.
> People mixing completely different styles in C++ is a nightmare.

This is really not my experience. Any decent-sized program will have parts more in a functional style, others in a more OOP one, others in regular-typed Stepanov bliss, others in template or constexpr metaprograms.... and this causes zero issues in practice once people get past their assumptions about what clean code should look like.

I think most large scale projects, or those with special requirements (things like embedded systems) are defining what subset of C++ they are ok with. Here are some examples:

- Chrome: https://chromium-cpp.appspot.com/ - Mozilla: https://developer.mozilla.org/en-US/docs/Mozilla/Using_CXX_i...

Large commercial projects. The problem is the mid sized projects, especially FOSS ones, there isn’t the time needed to curate every pull request and bikeshed. There is also something to be said for having less abstractions, moderately wet code can be easier to follow and fix than needlessly dry code.