3 ms·
I love C++ and I’ve to admit that it will need a subset language soon but the examples given in this article wouldn’t possibly exist in well checked code-bases
by DethNinja 5y ago
I love C++ and I’ve to admit that it will need a subset language soon but the examples given in this article wouldn’t possibly exist in well checked code-bases because you can immediately see usage stinks just by looking at it.
I think every C++ is bad article can be summarised like this:
1. C++ has lots of features.
2. Let’s nonsensically combine these features to shoot ourselves on the foot.
3. Uh oh, C++ didn’t help us write good code. Hence, C++ sucks.
People have to accept that in real life there is a thing called code-reviews and senior engineers are supposed to prevent such badly written code.
- Silhouette 5y agoPeople have to accept that in real life there is a thing called code-reviews and senior engineers are supposed to prevent such badly written code. Why should people accept that? There is overwhelming evidence that such reviews do not reliably prevent such problems from making it into production. In some cases, other languages exist that do reliably prevent the problem from ever making it into production because the problem is impossible by design. We can and should consider from time to time whether the advantages offered by an old but established language are now outweighed by the advantages offered by a newer but better designed language. If that doesn't happen with increasing frequency as time passes, we have a serious problem as an industry.
- jandrewrogers 5y agoI think it is fair to point out that it requires a comparatively high degree of skill and experience to use C++ well relative to many other languages. Most people do not use C++ well because doing so is quite difficult and requires a large investment of time. This is not helped by the fact that it has an enormous amount of legacy baggage that is technically valid code that no one should ever use — there is an entire anti-language you have to learn too. Its standard library has many flaws such that many experienced programmers eventually write and use their own alternatives to many parts of it. These are all legitimate hurdles and criticisms, it is neither a pretty nor easy language. The major benefit of C++ is that with sufficient mastery you can do complex things strictly, safely, and concisely that are difficult-to-impossible in any other systems language due to its flexibility and metaprogramming facilities. Its flaws are very real, but so are its strengths.
- dgs_sgd 5y agoAs someone not very acquainted with C++ I was under the impression that the vast standard library was one of the great selling points of the language. What are some examples of defects that force programmers to rewrite parts of it?
- saagarjha 5y agoThe standard library is quite good, but is designed to be fairly general. Sometimes this means that you can do better with something you write yourself.
- jcelerier 5y agodepends where you come from. If you come from Python, Java, you'll find that there's a lack of support for networking, etc. and that it is not vast at all. After all we lack a W3CEndpointReferenceBuilder (https://docs.oracle.com/javase/10/docs/api/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.html https://docs.oracle.com/javase/10/docs/api/javax/xml/ws/wsad...).... not sure how it's possible to be productive without that. If you come from C you'll think that there are allocations everywhere and judge it unfit for purpose (even if in my experience, C libraries and software tend to allocate much more than C++, and use worse datastructures like linked lists, etc. just because it's easier to code in C). Finally the C++ committee and standard library implementers refuses to break ABI / API, which means that : * the C++ standard is not able to follow the state-of-the-art for e.g. hash maps, as the fastest hash maps (if you only care about speed of insertion / retrieval, which is let's be honest 99.5% of the use cases out there) because unordered_map has strict requirements that these newer hash maps do not satisfy. * things like regex stay broken
- gypsyharlot 5y agoLet's not confuse this with skill, though. I think ego is the reason why this has been allowed to go on for this long... The "skill" is mainly pointless memorization of a bunch of idioms. I've attended C++ training with committee members that have made C++ their life... and it was quite discouraging to see that even they do: Let's try this... oh, that didn't work. Let's try this... hmm, right. I know what this is, I've seen it before. Now, it works.
- v8dev123 5y agoThese Rustic people write very dishonest articles. They write all flaws of C++ and then compare how bad C++ is. It really harm the Rust language itself not the C++. Professionals will dislike Rust because of it's community not the language. Rust people should put more effort writing a formal specification else many people will consider Rust as undefined. My comment getting flagged and downvoted and therefore posting here.
- adwn 5y ago> People have to accept that in real life there is a thing called code-reviews and senior engineers are supposed to prevent such badly written code. Ah, yes, the "you're holding it wrong" argument, just like the article predicted. The problem with this is that your version of "real life" is significantly different from the real "real life", in which often no code-review is held, or the reviewer misses bugs.
- pjmlp 5y agoC++ was my passion after Turbo Pascal, I fought to use it instead of C on university assignments, was a TA in C++, did research at CERN in C++, and used it at several multinationals before migrating into managed languages. Well checked code-based is something that I have hardly seen in real life, outside conference talks about best practices.
- pornel 5y agoBugs in the article are trivially obvious, because they're in 3-line code examples, explicitly pointed out. The problem is, the same bugs happen in actual large codebases, without the priming to look for this particular issue out of hundreds of possible issues. It's a difference between an article saying "This is Waldo" (duuh!) and a "Where's Waldo?" game, where you don't even know how many Waldos are there.
- clarge1120 5y agoTo add, C++ has survived for many years as the defacto system-level programming language (C has too). It has survived good and bad shifts in software engineering. The old "C++ is not going anywhere" argument applies. C++ is not great choice for small, or transient projects. There are other languages that are a better investment for those projects. But if you're writing an infrastructure-level application, that is expected to have a shelf life in decades, C++ (or C) is a pragmatic and rational choice.