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.

Why not C++?

47 pointsby cronjobberabout 9 years ago

12 comments

pmarreckabout 9 years ago
C++ is still plenty viable, but if you like avoiding bugs, John Carmack seems to have come to the conclusion that using a functional style (which is not exactly <i>encouraged</i> by C++) is advantageous: <a href="http:&#x2F;&#x2F;gamasutra.com&#x2F;view&#x2F;news&#x2F;169296&#x2F;Indepth_Functional_programming_in_C.php" rel="nofollow">http:&#x2F;&#x2F;gamasutra.com&#x2F;view&#x2F;news&#x2F;169296&#x2F;Indepth_Functional_pro...</a><p>&quot;My pragmatic summary: A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. In a multithreaded environment, the lack of understanding and the resulting problems are greatly amplified, almost to the point of panic if you are paying attention. Programming in a functional style makes the state presented to your code explicit, which makes it much easier to reason about, and, in a completely pure system, makes thread race conditions impossible.<p>&quot;No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn&#x27;t convenient.&quot;
jcofflandabout 9 years ago
C++ is still a fantastic language. It&#x27;s hard to learn to use it effectively but once you do you have one of the most powerful programming tools available under your belt. The two main points to using C++ effectively are 1. you must protect allocated resources with smart pointers and 2. threads should only be used to exercise multiple CPU cores and never as a way to work around blocking IO.<p>That later point is a little more complicated&#x2F;subtle and took me years of threaded programming to learn and accept. When adhering to these two rules, C++ is safe and extremely powerful.
评论 #11230756 未加载
评论 #11230788 未加载
评论 #11230716 未加载
评论 #11230639 未加载
评论 #11230744 未加载
评论 #11230710 未加载
评论 #11231588 未加载
评论 #11230663 未加载
justinsaccountabout 9 years ago
I had this to say about c++&#x2F;go recently:<p>Working on a c++ project: I feel stupid... and nothing works.<p>Working on a golang project: go is stupid... but everything works.<p>My issue with c++ is someone needs to write a &quot;c++: the good parts&quot; I may end up with rust, but right now I look at the documentation and some rust code and it&#x27;s a bit overwhelming.<p>Go may be stupid in a lot of ways, but for the most part it&#x27;s pretty obvious how to accomplish something.
评论 #11230852 未加载
评论 #11230938 未加载
评论 #11230899 未加载
jacques_chesterabout 9 years ago
Summarising how I usually seeing these discussions go:<p>The usual argument goes that C++ is bad because of the problems of C.<p>The counter-argument is that &quot;nobody does that in modern C++&quot;.<p>The counter-counter argument is that:<p>1. there&#x27;s a <i>lot</i> more not-modern-C++ than there is modern C++.<p>2. there seem to be dozens of not-really-smoothly-interchangeable notions of what &quot;modern C++&quot; is, because the language is so vast, and there have in fact been several overlapping generations of &quot;modern C++&quot;.<p>3. It still requires conscious and vigilant effort, over and above the baseline the language gives you, to not introduce game-over security or reliability flaws.<p>The counter-counter-counter argument is that these are true of every language.<p>Which, being not strictly and completely true in the particulars, is where the whole thing degenerates into personal reflections about $PET_LANGUAGE, hair-pulling, personal insults, blog posts about monads at twenty paces etc etc.
评论 #11230740 未加载
评论 #11230711 未加载
评论 #11230921 未加载
评论 #11230963 未加载
评论 #11230712 未加载
quchenabout 9 years ago
Cached version: <a href="http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:UB-yaeW3LgcJ:lambda-the-ultimate.org&#x2F;node&#x2F;5313+&amp;cd=1&amp;hl=en&amp;ct=clnk&amp;gl=de" rel="nofollow">http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:UB-yaeW...</a>
评论 #11230820 未加载
zoulabout 9 years ago
While I admire the amount of thinking that went and still goes into C++, for me the question is opposite: why ever C++? It seems to me that trying to improve a language by ecosystem or convention will always be worse than using a language already designed around what we have learned and what has changed since C++ was born.<p>If somebody <i>really</i> needs to have the performace or be that close to the hardware, they can still probably find a better language today (Rust, Go?). But all others will certainly be better served by more modern, higher level languages. Just reading the examples in the PDF makes my head hurt.
评论 #11230697 未加载
评论 #11230685 未加载
评论 #11230838 未加载
评论 #11230674 未加载
评论 #11230734 未加载
评论 #11230694 未加载
jokoonabout 9 years ago
The only thing that has always been behind, and might still be for a couple of years, is the include system, which causes huge delays when compiling and linking, even when editing one single file.<p>When I make edits and hit build, the old C include system kicks in and it&#x27;s a very long process. I&#x27;m using C++ but precompiled headers are not a standard (many details will prevent you to use them) and there are not decent ways to reduce build time to bearable ranges.<p>I&#x27;m sure this is the main point that makes C++ so unattractive. If you&#x27;re a programmer, having shorter code-write&#x2F;build&#x2F;test&#x2F;repeat cycles is important if you don&#x27;t want to lose focus on what you&#x27;re doing. I don&#x27;t know if build delays are specific to C++ or specific to microsoft, but if modules were available in some beta form I would try them ASAP. Even platform specific techniques would interest me...<p>So yes, I&#x27;ll love C++, but not only the ABI and build configs are not easily solved by CMake, but build times will never make C++ attractive enough. It&#x27;s not not realistic to pretend you can be really productive with C++.
评论 #11230807 未加载
sehrabout 9 years ago
cache<p><a href="http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:http:&#x2F;&#x2F;lambda-the-ultimate.org&#x2F;node&#x2F;5313" rel="nofollow">http:&#x2F;&#x2F;webcache.googleusercontent.com&#x2F;search?q=cache:http:&#x2F;&#x2F;...</a>
dmanabout 9 years ago
Site is down so I cant comment on content from the article.<p>As a working programmer here are some things that I consider to be C++ virtues<p>a. Control over memory layout<p>b. Control over allocation policies<p>c. Deterministic deallocation of objects on scope exit<p>d. Generics and specialization of generics<p>I am always mystified how many languages miss out on item a.
timwaaghabout 9 years ago
I clicked the title and it provided a great answer. something about mysql not connecting. i thought it answered the question until i googled it. a better title would be &#x27;why not php&#x27;.
cyber1about 9 years ago
Because we have Rust!
Gratsbyabout 9 years ago
LOL... why not PHP.