20 ms·
Simplicity and C++? Like speaking of rope in the house of the hanged, as we say in Italy... Congrats for the effort though.
by teknico 8y ago
Simplicity and C++? Like speaking of rope in the house of the hanged, as we say in Italy... Congrats for the effort though.
- pdpi 8y agoThere has been something of a push towards a simpler style of C++, and the speaker (Kate Gregory) is one of the best at articulating how and why it can work. Incidentally — in principle, most of this talk is applicable to _any_ software engineer. It's just that she's coming from a C++ point of view, and talking at a C++ conference. It's definitely worth a watch.
- tonyedgecombe 8y agoYou can't make C++ simpler by adding more to the language.
- EliRivers 8y agoThe simplicity isn't in the language. It's in the programme written with it. That's where it's needed and that's where it counts.
- 01100011 8y agoBut I seem to remember watching a talk by Kate Gregory in the last few weeks where her main point is that you really need to have a full understanding of the language to program in it. So if C++ has baroque complexity that is shunned by best practices you still need to be aware of it. I know the C++ folks would like to escape their past but there just isn't a good way to do that, short of a clean break with backwards compatibility. I bet they could actually pull off a break with old code if they would release tools, ala Abseil, which took care of migration for you. I think it's reasonable to accept that legacy code needs to be freshened up every so often to allow the language to evolve. We have Google translate for human languages, why don't we have it for code? It seems like a far easier task.
- fsloth 8y agoDisagree. In the sense that the code one writes gets simpler. Range based for loop alone does a lot. Auto destructuring of tuples, initialization lists, std::variant... etc. all do their part in making new code less verbose and less bureaucratic. It's just sugaring but it's at least a standard sugaring.
- Yoric 8y agoWhile I agree that C++ has improved a lot, and while all these extensions to the standard library can, when used carefully, considerably increase readability... well, there remains the fact that they still need to be used with extreme care. See https://github.com/isocpp/CppCoreGuidelines/issues/1038 https://github.com/isocpp/CppCoreGuidelines/issues/1038 for an example of what I'm talking about. So, readability increases, but the mental load of making sure that stuff doesn't break in subtle and non-euclidian ways keeps increasing, at least when refactoring existing codebases.
- fsloth 8y agoYeah, memory handling is still challenging to handle correctly - in the sense it need forethought and constantly remembering what one can and can't do (list iterators good long term references, vector iterators bad long term references, etc). string_view is a good example of a situation where garbage collector would save a lot of headache.
- veli_joza 8y agoThe code one writes does get simpler. Unfortunately, the code some dozen developers write ends up with all imaginable ways of writing the same thing. That's my biggest pain with C++.
- fsloth 8y ago"the code some dozen developers write ends up with all imaginable ways of writing the same thing." I do know what you mean. But that's not really the languages problem but of the coding guidelines and using code review to maintain legibility.
- pjmlp 8y agoSure you can, by introducing language features that make it easier to achive the same while being less error prone. For example, in template metaprogramming we can get rid of tag dispatch and SFINAE thanks to static asserts, constexpr and if constexpr. Likewise you might decide to shot your code with C style arrays, or use the STL data types with bounds checking enabled instead.
- danbolt 8y agoI hope that at some point C++ programming can have a solid "good parts" style guide, akin to Crockford's JavaScript book. I feel a lot of that probably isn't conventionally achievable since C++ covers a lot of situations with different needs, but if 20% of the functionality could cover 80% of the needs at some point I think it'd be great for the language.
- AnimalMuppet 8y agoStroutrup's "Tour of C++" might be what you're looking for.
- berti 8y agoLike C++ Core Guidelines? https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md https://github.com/isocpp/CppCoreGuidelines/blob/master/CppC...
- beached_whale 8y agostatic asserts do not replace tag dispatch and SFINAE as they don't affect the overload set, the instantiation has already happened at that point. However, concepts will do this in, probably, c++20. For now, is_detected is like a concepts lite that allows for a big simplification. One thing to remember though is that there are two things at play here. The library writers tools, like TMP, and the users. The users can do a lot and never worry about SFINAE/tag dispatch. The library writers use it to allow the users of the library to have a potentially very simple experience. Also, Greenfield C++ can be way different than pre 2011 C++. The cost of things that people would work around has gone way done to zero in some cases. Like returning a value from a function is like constructing it in place at the caller. So that takes away a need to use the heap to allocate it or to copy it when you return it.
- mhh__ 8y agoYou can't make C++ simpler but you can make some C++ simpler, as in the programs written in it. C++, the language, is too old and too widely used to be made simple.
- octo_t 8y agoThis was actually the topic of Herb Sutter's talk[1]. Things like meta-classes will drastically simplify end-user code.
- pjmlp 8y agoI can say the same about Python for example. Printing hello world might seem easy, now mastering Python....
- emsy 8y agoI still don't understand why people bother with template metaprogramming. And I genuinely mean it. Other languages have much simpler and nicer constructs and seem to work just fine. And even within C++ you can often solve the problem with more verbose, but simpler code. Every time I read an article or watch a talk on it I have the impression that people use it because they can, not because there's some huge upside in using them. Did I miss the magic "aha" moment?
- aswanson 8y agoTemplates make for the most abusively ugly code, at a glance. The syntax interpetaion to translate to natural problem-domain thought is so brutal.
- polskibus 8y agoZero-cost abstraction. In most cases constructs in other languages either lack expressiveness (generics in C#) and/or induce runtime costs (boxing/unboxing, etc.).
- krylon 8y agoIn many (most?) cases, you do not need the performance (which is why people use C#, Java, etc.). When the performance is needed, the burden of using C++ seems like a small price to pay[0], but a lot of the time, the expressiveness offered by C# or Java, etc. is entirely sufficient. Which is why "enterprisey" software is dominated by Java or .Net, and why certain software like Autodesk Inventor 3D is written in C++. [0] Which is why browser engines, etc., are written in C++. Maybe one day Rust will replace C++, but for the time being, C++ is the top of the abstraction/performance pyramid.
- deleted 8y ago[deleted]
- bluGill 8y agoThe magic moment is when you realize that your month of pain writing something complex saves the company years of writing the simpler version by hand. In the template a fixed bug is fixed once and for all. In the other version fixing a bug in once place doesn't mean anything about anything else. Note that for the above to apply you need have a domain where there will be enough uses to make the generic version worth it. Of course, just like it is fun to write code for the IOCCC, there is some perverse fun in writing complex templates.
- dman 8y agoI am genuinely curious about the passion of anti C++ commenters - could you comment on your journey towards your current antipathy towards C++? Did you use it and get burnt? What did you use it for? What were the short comings? How long did you use it for? When did you use it (ie which C++ standard version)? This is directed not just at the above commenter, but I invite replies from anyone who takes the effort to comment passionately against C++. Perhaps if we can understand some commonalities in peoples grievances, we could go back and address them.
- Rusky 8y agoI don't think I tend to be a passionate anti C++ commenter, though I agree with the sentiment. I've used C++ for around a decade, both professionally and as a hobby, in various domains. I use it because I either need (or merely want, in many cases) the control over the resulting end product that it provides. The grievances are well known, and most are being addressed in some form, so asking random commenters isn't going to change anything. But for what it's worth: it just feels like the language is a lost cause. Everything is so irredeemably hard (without breaking back-compat)- from syntax/name resolution/template expansion, and the accompanying problems with error messages and tooling; to build systems and dependency management, and the impossible task of ever getting anything standard there; to memory+thread safety, where every solution is a partial bandaid and there's no light at the end of the tunnel. It's a big, important, widely-used language. It's just not pleasant to work with- and while that can and will improve, it will always be tied to its rather painful legacy.
- codr4 8y agoSecond most of that. I used to be really passionate about C++ back in the days, but it's just too damn complex. Yes, some new features really help; if I could bring one to a desert island it would be lambdas. Tuning C++ these days is mostly trial and error for me, there are so many gotchas to keep in mind that it's more or less impossible to juggle it all mentally. From my experience there comes a point where the required effort tips the scales towards more convenient languages for most projects. But by the time you realize you're usually up to your neck in template goo that no one wants to translate.