TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Nobody Understands C++: Intro (2007)

38 pointsby _tk_meover 1 year ago

12 comments

keikobadthebadover 1 year ago
&gt; The comment in question begins “My take on C++ is that the best programs only use a fraction of the features.” The commenter further states that he is weary of operator overloading and templates.<p>&gt; In my experience, people who make comments like the above tend to be people who think they are C++ experts but who are actually only novices. I do not know the commenter personally, so I’m not trying to say anything about him specifically.<p>&gt; I only have 4 years of experience with C++<p>... I am only a C expert, but I agree with the Slashdot guy. After spending years as a believer like the author, I realized all this class-ification effort was pure waste, since most of it would never be reused. Same with all the idiomatic conversions. Don&#x27;t get me started on boost.<p>I withdrew from the cult and get just as much done with high quality C in half the time.
评论 #38057282 未加载
评论 #38057771 未加载
评论 #38057268 未加载
评论 #38057379 未加载
评论 #38057612 未加载
int0x80over 1 year ago
I find today&#x27;s C++ extremely challenging to pick up speed for someone coming from let&#x27;s say, Java. Smart pointers, pointer&#x2F;references, rvalue reference, copy&#x2F;move semantics, (perfect) forwarding, constructors, and how all that interacts with templates. It&#x27;s just so unwieldy complex. It takes me hours to write something that would take less than a minute in Java even though I have experience with plain C. The worst thing is that after it finally compiles I feel I can&#x27;t be sure if I&#x27;ve followed all the rules and best practices correctly or if it&#x27;s going to blow up spectacularly and potentially unsafely at runtime. The fact that a book like &quot;Effective Modern C++&quot; is needed with all those traps and foot guns to be aware of is ludicrous.<p>And don&#x27;t get me wrong - I think C++ is the most powerful language out there on the right hands - it just feels to require a lifetime of learning to became productive on it.
评论 #38057970 未加载
评论 #38057963 未加载
评论 #38059272 未加载
w4rh4wk5over 1 year ago
I won&#x27;t argue that the first example is cleaner, but both seemingly simple examples have a major issue. Lifetime.<p>The observer pattern is notorious for being overly complicated in C++ because you have to ensure Observer and Observable keep valid references to each other.<p>&quot;Modern C++&quot; (what ever that is nowadays) leverages RAII (i.e. scope-based resource management) to improve upon the situation.<p>With your typical observer (i.e. signal&#x2F;slots) library you get a &quot;scoped connection&quot; object when registering the callback function. You store that object in your class and when it is destroyed, it breaks the connection. Furthermore, it facilitates the implementation of correct copy and move semantics.<p>It&#x27;s not that people don&#x27;t &quot;understand&quot; C++, the problem is that there are so so many things to watch out for, even in simple use-cases, that even experienced C++ programmers make mistakes on a regular basis.
评论 #38057521 未加载
flohofwoeover 1 year ago
TBH, C++ has changed so much that any opinion from 2007 isn&#x27;t worth much today, and that applies no matter if you think C++ got better or worse since then ;)
评论 #38057437 未加载
评论 #38057254 未加载
评论 #38057576 未加载
评论 #38057330 未加载
lionkorover 1 year ago
Oh, this is Jason Turner! I&#x27;m sure he&#x27;d no longer write that kind of code, given its pre-C++11.<p>Not really intellectually interesting anymore IMO.<p>People say &quot;I know some C++&quot; and that could mean they have 2 decades, or 2 days, experience.<p>In reality, this is not a C++ problem, this is a software engineering problem. You need to learn to choose a solution that is good, not a solution that sounds good, or that will impress management.<p>If you need OOP, use it, otherwise, stay very far away. Same with callbacks and other funny constructs. You need them? Use them. You use them because they sound cool? It may be that you just want to call two functions after one another -- you dont need a callback to the first for that.
cjfdover 1 year ago
It is not that I necessarily disagree with the author but it does seem like he is making it a bit too easy for himself to make his point. Ever since C++ got lambdas, I would say that bind should be considered deprecated. It is more difficult to understand AND cannot possibly be more efficient.<p>The general point stands though. If you try to make everything as general as you can, you are going to make it more difficult for yourself than necessary. Beware of generalizing from one or fewer examples.
评论 #38057540 未加载
JonChesterfieldover 1 year ago
C++ is very frightened of breaking existing code, including at the binary level. Some shared library built in 2007 stands a decent chance of running today if it avoided <i>the ABI break of ruin and disaster</i> where string and list changed slightly.<p>It&#x27;s also widely considered a very complicated language and there&#x27;s some worry it suffers in user acquisition as a result.<p>If you take those two properties together, the game plan of making the language look nicer without changing how it works is about all you&#x27;ve got. It accretes more stuff with a bias towards making some use case look nicer.<p>It leaves margin for faster code below it because slow choices are forever. More syntax over the same operations is a dubious interpretation of making things simpler.<p>Yet it lives on. People start new projects in it. Some people think the economics work out in favour.<p>Oh, and some people did understand it in 2007. Maybe only five but they did exist. Some of those may still be heavily involved enough to understand the current language, but I wouldn&#x27;t be shocked if they&#x27;re burned out and gone. We might be down to zero.
评论 #38057480 未加载
t43562over 1 year ago
C++ still has the preprocessor and all the horribleness that brings. It&#x27;s also still a language where you need to know a lot of underlying details about how things work because you want to not be slow and you want to know whether or not you&#x27;ve just allocated memory that you have to manage. You need to know about integer sizes, how characters and integers are similar, pointers and dereferencing.<p>You can still leak memory easily and use after free, segfault and so on.<p>So IMO there&#x27;s a cognitive load where you cannot ignore how things are happening as you might in a dynamic language. Stuff can be static or inline or stack based or heap based and all of it matters. C was bad enough but C++ just piled on more and I got tired of that really. Boost took a million years (subjectively) to turn into something decent and I remember not being able to use any of it because of being stuck on an old compiler on Windows.<p>I do hope we&#x27;ve moved on from having to build a lot of optimisation in by hand towards being able to describe a problem with it&#x27;s constraints and limits and have the optimisation done for us.
w4rh4wk5over 1 year ago
&gt; A fellow Slashdot poster has unknowingly made my point for me quite well, and it is what I will use to start this intro. The comment in question begins “My take on C++ is that the best programs only use a fraction of the features.”<p>Plot twist, that Slashdot poster was John Carmack &lt;&#x2F;joke&gt;
Pixie_Dustover 1 year ago
&gt; Nobody Understands C++: Intro (2007) (emptycrate.com) .. including the fella that invented it &#x2F;s<p>If C++ was a human language, then it would be like every new piece of writing consisted of brand-new nouns, verbs, adjectives and it&#x27;s own syntax and grammar.
a1oover 1 year ago
This piece is pre C++11 with in my opinion was the biggest change in C++.
palotasbover 1 year ago
(2007)
评论 #38057148 未加载
评论 #38057256 未加载