5 ms·
I've been using C++11, and I really like it. Together with RAII it seems entirely modern and reasonable. Is there a list somewhere that describes what the "bad
by possibilistic 12y ago
I've been using C++11, and I really like it. Together with RAII it seems entirely modern and reasonable.
Is there a list somewhere that describes what the "bad parts" (in the Crockford sense) of C++ are? Bad practices, bad feature interplay, etc.
I've been thinking of writing a little C++ transpiled language of a limited feature set to make prototyping certain things easy. It would try to follow the accepted best practice conventions. I imagine it to be Coffeescript-like, with no separate header files, support abbreviated syntax, syntax for managed pointers, etc. It would probably follow a rudimentary linking scheme.
It might be opinionated in ways that turn some people off: const vars and args by default, virtual methods by default, auto virtual dtors, and probably other "sensible" (in average usages) default patterns.
Finally, I would want to generate simple intuitive interfaces that are linkable to existing C++ headers.
Anyways, this would just be a side project for fun. I don't do C++ professionally. Just for robotics and lasers and hobby stuff. Any information on best practices and bad C++ usages would be awesome to have if I undertake this.
- klodolph 12y agoC++ is somewhat notorious its developers' practice of selecting different subsets of C++ as "the good bits". I think one of the biggest mistakes of C++ was conflating the three different concerns of record types, polymorphism, and encapsulation. All three are bundled up in the catch-all "class", and everyone comes up with their own workarounds which should have been language constructs to begin with. So you'll end up with a language which enforces your C++ style. The good bits everyone agrees on are parts like <algorithm>, and oh man, I have a hard time imagining how you'd make that easy to follow.
- deleted 12y ago[deleted]
- possibilistic 12y agoI hear the "different C++ subsets" meme all the time. To the best of my knowledge, this is typically cited in relation to template generics, exceptions, multiple inheritance, and RAII being used incongruently. IIRC, Google chose not to use exceptions, but this might be unrelated. (ex-googlers I know have mentioned that Google doesn't care about C++ services terminating and having to be respawned) Your comment kind of makes me question my understanding of the different subsets issue... Would you mind elaborating? I could really stand to understand this better. If you can't expand on it, thanks for giving me something to look into. :)
- klodolph 12y agoIn particular: * Inheritance-heavy subsets, which avoid templates in favor of dynamic dispatching. * Template-heavy subsets, which avoid dynamic dispatching in favor of templates. * Subsets avoiding exceptions. * Subsets avoiding RTTI (dynamic_cast and friends). * Subsets avoiding pointers (including smart pointers). * Subsets avoiding the use of container libraries. * Subsets avoiding the use of <string>. * Subsets avoiding the use of <iostream>. You can search for large projects' style guides. For example, Clang uses C++11 features BUT they avoid RTTI and exceptions, which is a relatively common choice.
- yoodenvranx 12y agoI am dreaming of something similar. I'd like to see a simple language wich looks a bit like python and compiles to C++. The central part of this language would be an integrated package manager / module system which replaces make / cmake. Why should I need make? I just want to tell the compiler the file with main() and then it should figure the rest on it's own. The one thing which stops me from writing more c++ is all the setup you have to do to actually get an executable. In python I can just create a file, import some stuff and run it. In C++ I have to deal with makefiles, vs projects, paths and all that crap. Just give me a C++ where I can write "import boost.xyz" and the compiler figures out what that means.
- seabrookmx 12y agoHave you checked out http://nimrod-lang.org/ http://nimrod-lang.org/ ? It compiles to C though, not C++.
- possibilistic 12y agoGot a way for me to contact you? I'll cc you with a github link if/when I get around to this. Would love early design feedback. Alternatively, you can email me from the info in my profile. No worries if not interested, of course.
- film42 12y agoActually, I put a c++ project template together to solve this exact problem. It uses cmake to generate a makefile (including IDE projects that just work), and google mock for testing. You still have to add libraries like boost to the CMakeLists.txt if you want to use it, but it's really easy. Just follow the examples in the project. Github: https://github.com/film42/cpp-starter-template/ https://github.com/film42/cpp-starter-template/
- ihnorton 12y agoYou might be interested in Haxe [1] and Felix [2], although both have broader scope than you indicate. [1] http://haxe.org/ http://haxe.org/ [2] http://felix-lang.org/ http://felix-lang.org/
- possibilistic 12y agoFelix looks really interesting, especially with regard to the first class functional aspects, how they implemented their stack, and the user extensible grammar. I might actually find myself distracted by this instead. :)
- seabrookmx 12y agoI'd check out Nimrod for some inspiration: http://nimrod-lang.org/ http://nimrod-lang.org/ It has a bit more of a Pascal flavour to it, but it is the nicest implementation of a compiles-to-C languages I've seen.