Hacker News new | ask | show | jobs
by Impossible 5447 days ago
Even though there is a lot of hate for C++ as a language due to its complexity, it does fit in a niche (cross platform, object oriented native language) that no other language does, although D, Objective-C and Go come close.

I wonder if it'd make sense to develop a Coffee Script style language that compiles a "sane" subset of C++, gets rid of some of the nasty\annoying aspects of C++ (header files), and helps enforce good C++ coding practices (const correctness) but is close to C++.

2 comments

The key to enforce const correctness is to reverse the default behaviour. Make everything const by default, scrap "const", and introduce "mutable" (or "assignable", or something).

The result hopefully won't feel like a nano-management attempt, while people will think twice before they make anything "mutable".

D feels to me the closest thing to a fixed C++. But without major additional momentum, I don't see how it can ever catch up to C++ in adoption.
D is pretty nice. It has implemented almost everything people suggest when they mention how to fix C++, but it has some major problems as well. It'd have to be supported by a lot of different vendors on different platforms and architectures, and the standard library would has to be straightened out.

What I was proposing is a C++ compiler that could enforce a specific subset of standard C++, along with making things that are generally regarded as best practices default. Because of the complexity of C++ it might have to be a somewhat simplified version of it to work (something like http://www.csse.monash.edu.au/~damian/papers/HTML/ModestProp...).

There are few industry standards for C++ that define a more reasonable C++. See JSF C++ Coding standards and MISRA C++. gcc has something like -Werror -Weffc++, which also helps programmers to follow some "best practices".
in the media arts and "creative coding" world a couple of the frameworks are OpenFrameworks and Cinder, both of which sort of do provide a set of higher level abstractions, but you can always just do the C++ with them as well.