5 ms·
I also prefer C and D to C++. But used wisely, C++ can be a really nice language after all changes that started with C++11. The key is to realize C++ is not a
by nextos 7y ago
I also prefer C and D to C++. But used wisely, C++ can be a really nice language after all changes that started with C++11.
The key is to realize C++ is not a language, but a federation of languages. You need to cherry pick a subset you what you want to use and stay disciplined. Otherwise, it is a mess.
- msla 7y ago> The key is to realize C++ is not a language, but a federation of languages. You need to cherry pick a subset you what you want to use and stay disciplined. Otherwise, it is a mess. I've noticed two strains in language design, which I internally call Scheme-style and Common Lisp-style: Scheme-style languages are the trimmed-down languages, often built around a big idea which animates the rest of the design but not always; the defining concept of Scheme-style languages is always how much they can remove to get a pure design, a design which supports writing code in one style. Python, Smalltalk, C, and Scheme are all languages in this mold. Java is kind of a compromised Scheme-style language, or two of them (C and Smalltalk) rammed into each other at high speed, which also goes for Objective-C. Common Lisp-style languages have mini-languages inside of them, or at least support multi-paradigm programming as a core design goal; you can trim a Common Lisp-style language into a Scheme-style subset, but you can't extend a Scheme-style language into something more Common Lisp-like unless you really are dealing with Scheme and have (hygienic) macros to use to add more syntax. C++, Perl, and Common Lisp are all Common Lisp-style; Unix shell is Common Lisp-style in practice because it encourages programmers to write in a bunch of relatively Scheme-style languages at once, all in the same program. Note that both Scheme and Common Lisp have a conceptual core in the Lambda Calculus and axiom-like special forms. C++ lacks this and Perl doesn't really have it either, but most people don't write huge codebases in Perl.
- kazinator 7y agoScheme is only about removing features from a language document, not from actual systems.
- gmfawcett 7y agoArguably, modern Scheme is about removing features from a language document, and putting them in another language document.
- mroche 7y ago> Java is kind of a compromised Scheme-style language, or two of them (C and Smalltalk) rammed into each other at high speed, which also goes for Objective-C. Not much to add to the conversation here, but for some reason every time I read this it gets funnier and funnier. But I do like your breakdown, it’s what I’ve been thinking whenever I see discussions like this.
- fiddlerwoaroof 7y agoObjective-C is kinda nice, if you lift the Smalltalk part out and transplant it into Common Lisp: https://github.com/fiddlerwoaroof/objc-lisp-bridge#type-directed-objective-c-extractors https://github.com/fiddlerwoaroof/objc-lisp-bridge#type-dire... (for a whole program look at: https://github.com/fiddlerwoaroof/objc-lisp-bridge/blob/master/reading-list-reader.lisp https://github.com/fiddlerwoaroof/objc-lisp-bridge/blob/mast... )
- eindiran 7y ago> The key is to realize C++ is not a language, but a federation of languages. You need to cherry pick a subset you what you want to use and stay disciplined. The issue is that no matter how disciplined you are, others will be using a different subset of the features available and you end up using different "languages", even when everyone on your team is ostensibly writing "C++".
- 0x445442 7y agoThis is the way Java's become in "The Enterprise".
- skohan 7y agoI feel a bit that way about rust at the moment. I am still learning, but I have found that a lot of libraries seem to use very different interface modalities, so I spend a non trivial portion of my development time figuring out how to glue these disparate things together.
- nextos 7y agoAren't all powerful languages poised to have this problem? You can write generic imperative C++ by using lots of templates, OO code that looks like Java, low level imperative code similar to C, and even functional code. I can personally say the same thing about Haskell or Common Lisp. Perhaps it's not that extreme, but there are many ways to solve problems in those languages. Even some funny jokes about Haskell exploit this: https://www.cs.utexas.edu/~cannata/cs345/Class%20Notes/10%20Haskell%20Programmer%20Evolution.html https://www.cs.utexas.edu/~cannata/cs345/Class%20Notes/10%20...
- flukus 7y ago> Aren't all powerful languages poised to have this problem? Probably. How many of these powerful languages started out that way and received widespread adoption though? C++ was basically C with classes when it become big. C# and Java are complex beasts now but both gained popularity when they were much simpler. Programming languages need to be comprehensible to your average programmer and not just a few elites.
- kazinator 7y ago> You need to cherry pick a subset ... .. and then ensure that all suppliers of source code into your project stick to that subset.
- quicknir 7y agoThe whole "subset" argument is pretty thin. There are style/convention guides, and there are are more obscure features in C++ the same way there are more obscure features in other languages. But it is not necessary to cherry pick a subset. Out of places that are vaguely keeping up with C++, the only thing I'd consider sub-setting that is commonly applied to C++, is disallowing exceptions and RTTI. There are at least decent reasons for this. Yes, there are places that have additional constraints (like "C with classes" style, i.e. no templates), but it's much more rare (and even more rarely technically justified). Sub-setting should not be confused with the fact that in many cases, the language does not push you as hard down a specific path (for better or worse), yet it might be beneficial for a specific company in a specific domain to have a common solution for something, which results in the company style guide saying: "for this use case, use company_lib::foo, not XYZ". Where I work we use pretty much all of C++, as appropriate, that is there is no blanket ban on anything, or official subset. That does not mean that e.g. there is virtual inheritance all over the codebase; that's a feature you should pretty much never need to use. Writing code appropriately and consistently can only ever be done via discussion and code review; no subset will ever magically fix these issues anyway.
- sdegutis 7y agoMy problem when trying to pick up C++ (to write a simple SDL2 game) was that I just couldn't understand the RAII concepts, especially with modern smart pointer classes and STL container classes, and understanding how to use these three features together to be productive. (I just wanted to make a simple grid of cells to port over my simple PICO-8 lemmings-like game.) Coming from C and thinking of everything in terms of pointers, it was already foreign enough, but the problem was that I couldn't find a definitive reference on how these features interacted and how to use them together successfully. So I gave up on C++. Maybe if I was motivated by needing it for a client project I might have gotten further, who knows.
- quicknir 7y agoThat's a pretty vague statement though. vector and unique_ptr are class templates (generic classes). To understand them you need at least a basic idea of how that works, which you probably do. After that, you just need to understand their API, which includes copy/move constructors, and destructors, which encompasses RAII. There are tons of blog points explaining RAII.
- 6gvONxR4sf7o 7y agoUnfortunately, it seems really hard to learn a modern "good" subset of C++. Too many resources teaching it in too many ways. As an outsider, I have no idea what is good or standard.