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.

Let’s sunset C/C++

31 pointsby vu3rddalmost 10 years ago

23 comments

flohofwoealmost 10 years ago
Excuse my french, but: What a load of bullshit.<p>It&#x27;s not the language, it&#x27;s the tools.<p>Add a static analyzer pass to each C&#x2F;C++ compiler which is switched on by default. Add clang-address-sanitizer-style code when compiling in debug mode, and also offer runtime checks as option for release-compiled code. Both combined would have caught 99% of memory safety issues that pop up now and then.<p>If necessary extend the language with optional ownership keywords a&#x27;la Rust, and allow me to switch off features I don&#x27;t require to reduce complexity.<p>Most important of all: provide options that I don&#x27;t need to pay at runtime for memory safety with precious CPU cycles.
评论 #10059684 未加载
评论 #10059653 未加载
评论 #10059691 未加载
评论 #10059632 未加载
评论 #10059618 未加载
Timmonsalmost 10 years ago
This is quite ignorant of why C&#x2F;C++ is used.<p>It is used for that exact memory control and access that this article demonizes so that we can have efficient and thought out systems.<p>When those systems aren&#x27;t well thought out or secure you have security issues. C&#x2F;C++ lets you build a wobbly treehouse _and_ a secure fortress. It is up to the developer which one is made...
评论 #10059561 未加载
评论 #10059523 未加载
评论 #10059682 未加载
评论 #10059578 未加载
评论 #10059524 未加载
J_Darnleyalmost 10 years ago
So what language to you propose we use to rewrite all video and audio software? Javascript, Lua, Brainfuck, what? Sure make every numeric value a double, nobody ever wants a char. Don&#x27;t allow contiguous blocks of memory. Or if you do check every access is within the bounds. Its all safe! Nobody cares that suddenly we can&#x27;t decode an MP3 in realtime.<p>Are you going to outlaw assembly too?<p>What utter insanity.
评论 #10059704 未加载
评论 #10059581 未加载
评论 #10059753 未加载
评论 #10059562 未加载
评论 #10059594 未加载
评论 #10059607 未加载
评论 #10059614 未加载
评论 #10059568 未加载
charlesLalmost 10 years ago
Ugh... these kinds of extreme posts really piss me off. Yes, C is unsafe. Yes, there are safer higher level languages, but there&#x27;s a reason C is used. Because it&#x27;s <i>REALLY</i> freaking fast, and allows you to actually tune how memory is used.<p>The issue with C is not the language itself. It&#x27;s the complexity of the project. Once a project reaches a certain size, no programmer will be able to keep the entire thing in their head at one time. That&#x27;s why the bugs appear.<p>I have no issue with saying that C is hard to work with in giant projects. If you have an issue with that, write the sections of code that bottleneck in C, and then glue them together with a higher level language (I personally like Lua for this).<p>Also, the post is mainly complaining about security issues for Chrome. Assuming Chrome is rewritten in Rust or Go, will these security issues vanish? Of course not. Bugs (especially security bugs) will exist in all software, whether it&#x27;s written in C or Ruby.<p>So the results of rewriting all C code in the world is: slower, less optimized code and continued existence of security bugs. Sounds great.
评论 #10060482 未加载
评论 #10064532 未加载
rrss1122almost 10 years ago
&quot;I don’t see many people in the security industry taking up this call...&quot;<p><a href="http:&#x2F;&#x2F;www.viva64.com&#x2F;en&#x2F;b&#x2F;0324&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.viva64.com&#x2F;en&#x2F;b&#x2F;0324&#x2F;</a> [Criticizing the Rust Language, and Why C&#x2F;C++ Will Never Die ]<p>&quot;It is crystal clear for every sane programmer that C&#x2F;C++ is not going to die in the nearest future. No one is going to rewrite almost all of the existing desktop applications, operating system kernels, compilers, game and browser engines, virtual machines, databases, archivers, audio and video codecs, tons of other C-libraries, and so on and so forth, into other languages. This is a huge mass of fast, debugged, and time-proven code. Rewriting it is way, way too expensive, risky, and, honestly, doesn&#x27;t seem to make sense except in the heads of the most frantic Rust fans. The demand for C&#x2F;C++ programmers has always been high and will remain so for a long time to come.&quot;<p>Seems like just more proselytizing from Rust fans looking to expand their ranks. Of course more people in the security industry are not taking up this call, because it is a ridiculous suggestion.
评论 #10064539 未加载
walkingolofalmost 10 years ago
&quot;There are only two kinds of languages: the ones people complain about and the ones nobody uses&quot;. -Bjarne
swahalmost 10 years ago
Another way to look at it: the ones that can write that software are still chosing C&#x2F;C++. The ones who would like to use Haskell&#x2F;Rust&#x2F;Java are discussing online.. :)
sklogicalmost 10 years ago
C still got a right to exist even in the very sensitive mission-critical environments, as long as MISRA requirements are followed (and, the good thing is that they can be automatically enforced).
评论 #10059572 未加载
w8rbtalmost 10 years ago
Secure software can be written in C or C++ (they are two different languages BTW). For example, OpenBSD and OpenSSH. Both are written in C and both have very good security records.
评论 #10059567 未加载
tempodoxalmost 10 years ago
To this, I can only agree. I love C and I can write secure software in it, but the costs of doing that are generally not worthwhile in today&#x27;s market (if they ever were).<p>C will still have a place in its niche, but it shouldn&#x27;t be considered the standard general-purpose language any more.<p>Our processors have gotten so fast we can run slow-motion versions without even noticing (smartphone &amp; tablet CPUs), so don&#x27;t tell me anything other than C would be “too slow”.<p>C is unbeatable as long as riding rodeo on your raw CPU is all you could ever want. But software has evolved, mankind&#x27;s dependency on software has evolved, and so have our expectations &amp; standards. It&#x27;s time to learn the lesson and move on.
评论 #10059738 未加载
评论 #10060222 未加载
评论 #10059652 未加载
AnimalMuppetalmost 10 years ago
The article claims that the problem with Flash is not so much Flash itself, but that it&#x27;s written in C&#x2F;C++. It &quot;proves&quot; the point by listing a bunch of high-profile exploits in various other systems, then repeats the claim that C&#x2F;C++ is the problem, and advocates abandoning C&#x2F;C++.<p>That&#x27;s... not exactly proof. It&#x27;s barely even evidence.<p>Yes, you can argue &quot;all these programs have all these flaws, and all are written in C&#x2F;C++&quot;. And that&#x27;s true. They are written in C&#x2F;C++, and they have these flaws.<p>Now let&#x27;s look at the programs that do the same kinds of things, and are as widely used, and are <i>not</i> written in C&#x2F;C++, and compare the number of exploits... oh, you don&#x27;t have a handy list of equivalent programs to compare? Go work on that; I&#x27;ll wait.<p>The fundamental problem is that these programs are trying to safely handle hostile input, with attackers having essentially infinite time to experiment and craft attacks, including attacks that the authors didn&#x27;t know that they needed to defend against at the time the code and&#x2F;or the spec were written.<p>Would the whole world be safer if everything were at least written in Java? Yes, it might be <i>safer</i>, but not <i>safe</i>. And it would take more resources, and often take longer to start up. And it would be vulnerable to bugs in the design and implementation of the JVM, which would become a single point of failure for a lot of software. That world would, perhaps, be somewhat safer, but it wouldn&#x27;t be the security paradise that the article envisions.<p>Not everyone is a fool who doesn&#x27;t use the tools you think are best...
vu3rddalmost 10 years ago
I think a lot of comments in this thread are too harsh. I am a C programmer myself and see the value of it in embedded systems, operating system kernels etc.<p>While it is possible to write correct programs in C and C++ (which are very different languages, but usually mentioned together because of their names and history), it is too easy to make mistakes that are not caught by the compiler. It is easier to be sloppy in C than in say, Go or Rust. I have seen this in my own code and also in others&#x27; code.<p>C is not the only way to write system programs. Oberon, Inferno are good examples of OS environments written in safer languages.<p>But I agree that some of the disadvantages of C are also its advantages.<p>The author of the blog post has more followup posts:<p><pre><code> http:&#x2F;&#x2F;trevorjim.com&#x2F;why-safe-languages-are-the-best-way-to-achieve-memory-safety&#x2F; http:&#x2F;&#x2F;trevorjim.com&#x2F;an-unsafe-legacy&#x2F; http:&#x2F;&#x2F;trevorjim.com&#x2F;unsafe-at-any-speed&#x2F; </code></pre> [edit: fix typos, rephrase a few sentences, fix links]
carlosrgalmost 10 years ago
C++11 is pretty &quot;memory safe&quot;. But obviously it allows the programmer go low-level and deal with dangling pointers if he&#x2F;she wants. After all, the programmer&#x2F;engineer is supposed to be a professional that can handle these things and make autonomous decisions.
评论 #10064544 未加载
sdf45almost 10 years ago
As of yet, a browser (in particular the JavaScript JIT) cannot be implemented in a safe language.<p>It is not even clear how a safe language that would permit this would look like.<p>Thinking that banning C&#x2F;C++ magically solves all problems is naive.
评论 #10059698 未加载
notacowardalmost 10 years ago
&quot;This is a huge job&quot;<p>I don&#x27;t think the author fully appreciates just <i>how</i> huge, and how many new bugs would be introduced by rewrites on that scale. It might be reasonable to say C&#x2F;C++ should be deprecated for new projects, but truly vast amounts of C&#x2F;C++ will remain with us for the foreseeable future. Perhaps a better approach would be to ease integration of new code written in memory-safe languages with older code written in C&#x2F;C++, which tends to be tedious at best nowadays.
p0ncealmost 10 years ago
C++ is safe enough, provided you use the tools like Intel Inspector, valgrind, and static analyzers. With C++11 memory corruptions became a somewhat rare occurence.
评论 #10059959 未加载
eatonphilalmost 10 years ago
I&#x27;m confused when the author says the DOM is garbage collected only in IE&#x2F;Blink. How is DOM memory managed elsewhere? At first guess, I thought the JavaScript runtime (which surely always uses garbage collection) would manage the DOM, but I&#x27;m guessing that&#x27;s not actually the case. Who is typically in charge of memory management at that layer?
评论 #10060531 未加载
planteenalmost 10 years ago
Is there even an operating system not written in asm&#x2F;C&#x2F;C++ to run these &quot;secure&quot; non-C&#x2F;C++ applications?
评论 #10060535 未加载
J2Alphaalmost 10 years ago
I do appreciate a good troll once in a while but they shouldn&#x27;t rise to the top page of HN. It gives them ideas above their station.<p>I have a burning question tough, What pray tell safe language would you use to write the original garbage collector, because Garbage collecting is only a form of abstracting good pointer practices away, helping programmers write complex programs easily.
评论 #10059665 未加载
stef13013almost 10 years ago
If it&#x27;s a joke it is quite good.<p>Your post is full of memory leaks, can you rewrite it with a better language... Please.
cranklinalmost 10 years ago
garbage collection makes not a language safe
just4oncealmost 10 years ago
Absurdly absurd ideas and ramblings. I suppose we can write our &quot;safe languages&quot; in &quot;safe languages&quot; then we&#x27;ll never have need of really programming anything ourselves. We can simply pat together what ever is &quot;safe&quot; for us to do in our little play sandbox and act like we&#x27;re adults who understand the problems faced when programming in &quot;real&quot; languages.<p>This would be similar to replacing all automobiles with stuffed animals because, who in the world ever heard of stuffed animals getting into pile-up wreaks on the freeway and causing death misery and misfortune.
评论 #10059458 未加载
justwannasingalmost 10 years ago
My problem with this article and its statement is that it&#x27;s saying to &quot;sunset&quot; C&#x2F;C++ because it causes problems but the problems are caused by an incompetent user, not C.<p>I see so many articles complaining about C letting you shoot yourself in the foot but no one who would shoot themselves in the foot should be handling a gun.<p>&quot;You know you wouldn&#x27;t have so many splatters on that painting, Mr. Pollock, if you would just let a computer handle that brush for you!&quot;