11 ms·
To me, the key line was "Most of the complexity of C++ is hidden from most of the users most of the time." The complexity is there. Trying to understand the w
by AnimalMuppet 12y ago
To me, the key line was "Most of the complexity of C++ is hidden from most of the users most of the time."
The complexity is there. Trying to understand the whole language at a language-lawyer level is mind-boggling. Trying to write libraries that make proper use of the goodies is very hard.
But using C++ isn't so bad, as long as you don't try to use every aspect of it. Just use the parts you need to be able to do what you're really trying to do. You don't have to pay for what you don't use. That's good enough for a huge number of programmers in a wide variety of contexts.
There's a lot of haters that can point out a huge number of flaws. But here's the thing: Most of them, I never run into. I don't care if the move syntax is confusing; I don't use it. Maybe I never will. If I have to, then I'll care about how good or bad the syntax is. In the meantime, the parts I actually use let me get my work done better than any alternatives.
- ygra 12y agoThe problem is that in any existing codebase that is large enough you'll have such a plethora of different things that are used that it doesn't really matter that I don't use things I don't understand or know yet. I still encounter them when reading code and have to understand them then. At least for me who stumbled into a semi-ancient C++ codebase two years ago (and having known almost nothing about the language before) that was a major impediment in picking up how the language should or might be used properly.
- mgkimsal 12y agoGood point, and was most recently used in the PHP community with the introduction of 'goto' about 5 years ago. "If you don't like it, don't use it" is pretty naive, because more often than not, I'm not using my own code, but someone else's (via inherited code, libraries, etc). Code is written once and maintained for years. I've noticed a trend over the years whereby certain types of developers (ab)use new features in a language when first introduced, then move on to other projects, leaving their "my first time with feature X" code behind for someone else to deal with for years to come. Sometimes it's fine, sometimes it's a nightmare. The GOTO thing in PHP has almost been a non-issue all around, but highlighted the "don't use it if you don't like it" argument's flaws.
- 72deluxe 12y agoStumbling into ancient codebases is always an impediment to understanding the language properly. Like reading C++ from before dynamic_cast was available, and spotting macros to do the same thing littered around MFC code. I also find that the ancient developer's design style and implementation left a lot to be desired, and if someone came across that as an introduction to a language, I think they would have hated the language too. That's why we should always write beautiful code and occasionally throw in obscure language features to force them to learn them :-)
- ef4 12y agoOne does not always have the luxury of sticking to the good parts. Code is communication, and you often have no control over who is trying to communicate with you.
- zenbowman 12y agoThe difference between engineering and tinkering is discipline. Not to say tinkering is bad, its perfectly fine when trying to create the latest viral app or when learning how to do something. When engineering something, discipline is required. And nothing stops any institution seriously committed to engineering to adopting practices that restrict language use to a subset (mandatory code review, static analysis tools that highlight deviant code and disallow it to be pushed, etc).
- ef4 12y agoSure, but unless you're going to keep falling into the "not invented here" trap, you're going to encounter code that comes from outside your organizational boundaries.
- rayiner 12y ago> The complexity is there. Trying to understand the whole language at a language-lawyer level is mind-boggling. It makes me uncomfortable not to have that level of understanding for a language that's so low-level and doesn't have the "Do What I Mean" bent of say Python. I'm "meh" on C++ going forward. I invested a lot of time into my copy of "The C++ Programming Language" (3d Ed.), for C++ 98, but I can't motivate myself to get the new edition and learn in the ins-and-outs of C++ 11. It doesn't seem worth it to me. I'm really hoping Rust catches on. It's a complex language in the same vein as C++, but the bang-for-buck in terms of expressiveness relative to complexity is better, I think.
- dman 12y agoLooking forward to v1.0 of Rust to have some expectation that the constructs that I learn will endure over time.
- pmelendez 12y ago>"for C++ 98, but I can't motivate myself to get the new edition and learn in the ins-and-outs of C++ 11" I can understand that but keep in mind that C++11 is a completely different language to what it is C++98.
- angersock 12y agoThis is a bug, not a feature. There is a lot of good stuff in the new versions of C++, but the language really could've used a bifurcation years ago. That said, it's still the best tool in the toolbox for certain problems.
- loup-vaillant 12y agoWhich problems? That's a genuine question: the way I see it, C++'s niche is shrinking by the year, as new languages and more powerful computers arise. So, what's left?
- vinkelhake 12y ago
- Nitramp 12y agoAnother quote: C++ most suited for demanding systems applications. [...] You choose C++ when the situation is already complicated. ... and then you have two problems </snark>. Yes, C++ has a lot of features, and those features are often individually useful to solve individual issues, but I remain unconvinced that this plethora of features and complexity pull their own weight. You can write useful, efficient software in languages that expose much less complexity to their users. Re: complexity. Not having to understand C++ most of the time, or subsetting the language to have a manageable code base only works until you run into somebody else's code, or some 3rd party library. It's not a fix, it's a symptom of something broken.
- GFK_of_xmaspast 12y ago"C-with-STL-containers" is an incredibly powerful subset of C++.
- loup-vaillant 12y agoWhich is why I'm seriously tempted to add a simple template system on top of C (it has already been done, by the way), then implement containers on top of that. With that, I get the power without the rabbit hole.
- bcoates 12y agoWouldn't it just be simpler to fuse off the part of your linker that handles vtables? IIRC That'll kill every C++ feature that's objectionable to someone who likes the idea of 'C with templates' Unless you want a truly simple C template system, in which case aren't the C11 type sensitive macros sufficient?
- loup-vaillant 12y ago> C11 type sensitive macros Hey, that sounds cool. Do you have a link? A quick search doesn't seem to work. The vtables on the other hand I will steer clear from. Closures are way more useful than class based polymorphism. Combine it with parametric polymorphism (templates), and you won't need to subclass anything ever again —okay, I'm exaggerating a little.
- redtexture 12y agoBook needed: "C++ the Good Parts"
- steveklabnik 12y agoIsn't that "Modern C++ Design" by Alexandrescu?
- zura 12y agoNot quite. I mean, it is an interesting book - functional programming idioms applied to C++ templates which gives you an interesting [generative] techniques applied to several GoF design patterns, but it is not an everyday C++ code you write. I'd say, for general C++ good style, Bjarne's works are more useful. At least, to start with.
- cpeterso 12y agoNeed a "C++: The Good Parts" compiler (or static analysis front end) that enforces the good parts but your code is a compilable by a C++11 compiler. I've heard some Rosy developers joke that Rust is C++ The Good Parts. :)
- octo_t 12y agoThis exist: -Weffc++ http://cpptruths.blogspot.co.uk/2006/08/g-compiler-option-weffc.html http://cpptruths.blogspot.co.uk/2006/08/g-compiler-option-we...
- humanrebar 12y agoThe problem is that "The Good Parts" vary from team to team and from domain to domain. One of the strengths of C++ is that it can fill all those needs. This is important because often the problem you start out solving is different than the one you need to solve.
- pjmlp 12y agoGet "Tour of C++", a new book from Bjarne only with modern C++11.
- cmollis 12y ago"Just use the parts you need". (sounds prosaic, but actually well put). I've used C++ over the years off-and-on (depending on what the clients required). You don't really need to use every 'exotic' feature in order to be productive. If you need something low-level with great compilers and a lot of great lib support, it's actually a nice language. All these new languages are nice, but Go and Rust just chisel off the 'ugly' in favor of some different 'ugly', IMO.
- wtetzner 12y agoThe problem is that other people's code might use the 'exotic' features. Unless you're the only one working on the code, or you have control over what subset of the language is used (including libraries), you have to deal with the whole language.
- 72deluxe 12y agoIs that a problem though? Wouldn't you be happier knowing that portion of the language, despite the difficulty in learning and understanding it to begin with?
- wtetzner 12y agoMy point is that this weakens the argument that having a complicated language isn't such a big deal since you can just use a subset of the language.
- 72deluxe 12y agoAh yes good point. I suppose C++ is one of those languages that is pretty massive. You can probably get by with only knowing a small bit but it does seem like a never-ending journey with knowing it fully in and out. I wonder if it was designed to accommodate the way some real clever boffins think so that they could properly express their thoughts and designs in a language?
- alexvr 12y agoI think this makes it a great language for solo projects. You can write almost however you like and largely ignore features you don't need. The problems arise when dealing with a bunch of programmers with different experience levels and preferences. That's where simpler, more conservative languages like Java shine. C++ gurus used to their massive arsenal of options must cringe when forced to work with simpler languages.