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.

C++ is the next C++

92 pointsby GarethXover 2 years ago

14 comments

kensaiover 2 years ago
The &quot;Core Guidelines&quot; site hidden in the references is a gem.<p><a href="https:&#x2F;&#x2F;isocpp.github.io&#x2F;CppCoreGuidelines&#x2F;CppCoreGuidelines" rel="nofollow">https:&#x2F;&#x2F;isocpp.github.io&#x2F;CppCoreGuidelines&#x2F;CppCoreGuidelines</a>
评论 #33437384 未加载
评论 #33438135 未加载
评论 #33439745 未加载
评论 #33437272 未加载
评论 #33437254 未加载
chrsigover 2 years ago
I think in 10-20 years the C++ community will regret enshrining &quot;modern&quot; into so much of the literature.
评论 #33438242 未加载
评论 #33442135 未加载
评论 #33437901 未加载
beeforporkover 2 years ago
&gt; This static analyzer causes programmers to use 2 extra characters when using smart pointers, -&gt; vs (*)., since the overloaded -&gt; operator returns a pointer.<p>This renders it completely impractical -- sorry. You need to figure out a way to make it work, otherwise this is, errrm, useless.<p>And what is &#x27;this&#x27; static analyzer anyway. I thought this is about a language extension introducing possible general static analyzers. Is this a concrete one now? Or why do you already know that it cannot handle &#x27;-&gt;&#x27;? Did I miss something? What is this?
评论 #33438412 未加载
photochemsynover 2 years ago
Generalized rules for how to use C++ in all situations are aspirational and unlikely to be adopted widely. More practically, the large projects that rely on C++ should just have their own rule on what elements &#x2F; styles are used in that particular project, and then use a linter to enforce those specific rules, and have good documentation that explains the rules.
Asookaover 2 years ago
I have a couple of gripes with these guidelines, not because I love writing unsafe programs, but because this way of writing C++ conflicts with the reality of how C++ is implemented.<p>1. shared_ptr is <i>very</i> slow. It makes it safe to share data, but at the expense of many tiny allocations for each object type. C++&#x27;s memory manager isn&#x27;t geared towards that kind of abuse, this is something that can really only be performant in a garbage-collected language where allocation is an atomic pointer increment and deallocation happens &quot;later&quot;. Pushing people towards using this abstraction is wrong most of the time, it is often much better to use arena-style allocations for most cases in C++. I&#x27;ve seen libraries written in modern C++ where malloc and free account for 80% of the runtime. I don&#x27;t see a way to fix this without radically altering the memory manager.<p>2. The impact on code compiled in debug mode is often unacceptable. I expect programs compiled with minimal to no optimisations to be slower, but layering all these abstractions usually produces a lot of runtime junk that gets in the way. For example, std::for_each can often be optimised to a regular for loop, which can then be vectorised, but in debug mode it is compiled to a function call which in turn calls the passed in lambda for each element and operator++ on the iterator. The difference in speed between the two is several orders of magnitude and makes this abstraction unacceptable for hot loops. This is a more minor gripe that can probably be solved by marking some functions as &quot;function-like macros&quot; similar in intent to LISP&#x27;s macros, so the compiler knows they can be always inlined and optimised. GCC&#x27;s -Og flag also helps a lot here. Still, the world isn&#x27;t just GCC and the standard should probably bequeath more library functions with special status, like how memcpy &amp;al can be always optimised to inlined machine code instead of a function call.<p>You&#x27;ll notice both of those concern speed. If the loss of performance from said abstractions is not a deal-breaker for you, then you probably shouldn&#x27;t be writing C++. D, C#, go, Java, maybe even JavaScript, Python or Lua would be a better choice for your project. The reason to use C++ for a new project is because you want to build really complex programs made up of operations that closely match the semantics of the machine on which they run, for the purpose of going <i>very fast</i>. Or you&#x27;re stuck using C++ because you have to interface with C++.
评论 #33438841 未加载
tialaramexover 2 years ago
So, the context for these &quot;... is the next C++&quot; talks, blog posts and papers is largely Chandler Carruth&#x27;s CppNorth talk: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=omrY53kbVoA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=omrY53kbVoA</a> &quot;C++: What comes next?&quot; which is also the &quot;coming out&quot; for the Carbon language.
评论 #33439299 未加载
SleepyMyroslavover 2 years ago
I might get totally misunderstood ^^ but I will try to post an opinion from gamedev side.<p>I have spent lots of time thinking on all proposals that came up this year. And only one idea felt seriously better. No not the &#x27;secure rust&#x27;. The idea behind Circle compiler described by author in one of podcasts I think. That compile time language should stop being ugly magic and should become normal full fledged programming language that can do everything.<p>Recently I have investigated some failures in builds that were happening only on one platform only in one branch only when specific change was applied. And I came to conclusion that gamedev does not have people who understand what C++ does at compile time. And to fix it we don&#x27;t need more more magic in C++. So no, next C++ will not be C++ for us if we will have any other sane alternative. Most likely we are stuck with old C++ until new platforms are out.
评论 #33446791 未加载
daveslashover 2 years ago
I know this is off topic, but right out of the gate, this really irks me...<p>Re &gt;&gt; &quot;<i>Software companies have a problem. There’s not enough candidates that can code C++. </i>&quot;<p>Should be written &quot;<i>There&#x27;re</i> not enough candidates <i>who</i> can code C++.&quot;
评论 #33437956 未加载
评论 #33438281 未加载
Kukumberover 2 years ago
More static analyzers is the way to go<p>Similarly, D also is pushing for more static analysis to enforce safeties<p>I feel like D already is the next C++, it feels like C++ catching up on D, they went with the same syntax as D for modules, it&#x27;s quite telling
评论 #33438169 未加载
rapseyover 2 years ago
I wonder how much C++ is being learned by new generations of programmers. I suspect Rust is taking over there but that is a completely baseless assumption on my part.
评论 #33437207 未加载
评论 #33437132 未加载
评论 #33437554 未加载
评论 #33437154 未加载
评论 #33446453 未加载
29athrowawayover 2 years ago
The obsession with backwards compatibility killed C++.
评论 #33438088 未加载
davedxover 2 years ago
Ah, &quot;make C++ better by adding more features&quot;, we meet again
评论 #33438202 未加载
评论 #33438385 未加载
评论 #33441475 未加载
wheelerof4teover 2 years ago
Rust is the next C++.<p>There, I said it.
评论 #33437490 未加载
评论 #33445958 未加载
评论 #33437422 未加载
评论 #33439262 未加载
评论 #33439819 未加载
评论 #33437816 未加载
评论 #33438721 未加载
bugfix-66over 2 years ago
The successor to C is Go.<p>Go inherits from Oberon through Robert Griesemer, and from C through Ken Thompson (father of Unix) and Rob Pike (Bell Labs).<p>I don&#x27;t bother with C anymore, except in small parts of code where every cycle counts. Just about anything you write in C can be mechanically translated to Go.<p>C++ shows us what NOT to do. I&#x27;ve used C++ for most of my professional programming career and it&#x27;s simply an impediment. Huge waste of time and energy.
评论 #33437263 未加载
评论 #33437439 未加载
评论 #33438071 未加载
评论 #33437208 未加载