hn_submit
4 days ago
To me this merely signals how broken C++ development really is. Most if not all of the bugs being uncovered are memory related and therefore intimately tied to the mental memory model of C and C++, namely manual memory management.
It's fine for a C or C++ program encompassing a couple hundred lines but beyond that it's a liability.
C and C++ are simply not fit for purpose when large scale software projects are concerned. All of these need to be ported to Rust or another memory-safe language ASAP to prevent mayhem.
The hundreds if not thousands of developers working on Chrome weren't idiots who didn't know what they're doing. The complexity of programming in C/C++ is simply beyond most intelligent individuals' ability to get perfect all the time.
gtowey
4 days ago
I'll await your Rust ports of Windows, Linux and MacOS then.
This isn't really a fair take. Keep in mind that C/C++ has been the backbone of the most important software in the world since the 1970s. At that time we didn't have virtually unlimited compute and memory at our fingertips the way we do now. It was a huge improvement to have a high level language which still could be optimized nearly as well as assembly.
Its staying power is due to the fact that we really haven't had many good alternatives until maybe the last few years. Things are not going to get ported and rewritten overnight, especially when they largely just work like Linux & PostgreSQL. We'd nuke a huge amount of institutional knowledge and inertia to change those up.
And C/C++ are still key in the embedded space where we still have devices constrained on compute and memory. That's not going to go away anytime soon.
This criticism feel like someone complaining about why anyone still uses horses on the day the Model T was announced. Change takes time.
tikhonj
4 days ago
A pretty big part of the reason we didn't switch earlier is that most people—certainly most non-technical leaders, but also a lot of engineers—don't value correctness or security enough. We didn't have good alternatives until recently because we did not, collectively, invest in developing these alternatives.
One surprising thing is that, in the grand scheme of things, developing an alternative like Rust is not that expensive. It takes something like a small team a few years. Maybe a person-decade of effort to get to a viable point? Maybe two, whatever. The industry as a whole throws away orders of magnitude more engineering-years than that on vanity projects and internal dysfunction every year.
Of course, even once we have an alternative, the switching costs are high. And the barriers are far more social, organizational and political than they are technical. But even so, moving to alternatives incrementally has been viable for decades. And hey, if we include moves to garbage collected languages, we have been moving quite a bit... but we could have been moving more. It was only a matter of will and, upstream of that, cultural change.
So really, the problem isn't that people complain too much, it's that they don't complain enough :)
MichaelZuo
4 days ago
The real curious thing is serious C/C++ folks seem like one of the least likely groups imaginable, to want to undergo humiliating and embarrassing blunders…
Yet they seemingly don’t mind that it practically guarantees them to make blunders over and over again.
gtowey
4 days ago
We call them blunders mostly because the solutions are so well known.
In contrast, the last company I worked for did everything in typescript and the amount of problems caused by code that blocked the main event loop was staggering. And at that, our best JavaScript people generally just threw up their arms saying there wasn't a good way to fix it.
Between the two, I prefer a language that lets me fix problems.
fennecbutt
3 days ago
"our best java script people" I've used node.js for more than a decade now, I was there for the start of "now everyone is truly full stack"...but yes the majority of developers I've worked with have had no idea about how js etc works on the inside, no knowledge of event loop or what causes the few memory leaks possible in js.
But then again I only know because I love that shit and started out in c/embedded, c# etc. And on my own weak side I fucken suuuuck at frontend related stuff (not the design stuff at all, just...fuck you css).
IshKebab
4 days ago
Pre-Rust "serious C++ folks" used it because it was the best option if you wanted essentially zero performance overhead no heavy runtime and GC spikes. They didn't like the lack of memory safety but it was seen as an unfortunate but necessary trade-off.
These days most of the sensible people have moved from C++ to Rust and so the "serious C++ folks" are an entirely different distribution of people who are much more inclined to think memory safety isn't a big deal and you just have to not make mistakes.
myko
3 days ago
or Swift! I know it isn't super popular outside of Apple ecosystems but I migrated a C 200k LOC personal project to Swift over the last ~4 years and it's gone really well.
deterministic
18 hours ago
> These days most of the sensible people have moved from C++ to Rust
Wrong. There are more than 16 million C++ developers worldwide.
rustfreeforme
3 days ago
[dead]
deterministic
18 hours ago
Show me a programming language that doesn't result in developers "making blunders over and over again" when developing the kind of very large software C/C++ is used for.
scrame
2 days ago
> The industry as a whole throws away orders of magnitude more engineering-years than that on vanity projects
The industry as a whole throws away orders of magnitude more engineering-years _daily_ in meetings discussing if scrum standups are effective.
deterministic
18 hours ago
> ... don't value correctness or security enough
Wrong. It is the market that doesn't value correctness or security enough.
We have the tools (formal verification) to create bug free software (see seL4 and CompCert for example). However customers are not willing to pay for the extra cost needed.
gtowey
2 days ago
> And the barriers are far more social, organizational and political than they are technical.
At the core it's even more of an economic barrier which isn't even unique to capitalism.
I recall an article talking about why the Romans didn't invent steam engines and things like railroads considering people were aware that steam could be used to do work. The answer was largely that slave labor was so cheap that nobody really cared about finding more efficiency. It didn't solve any problem they had at the time.
The analogy transfers to the tech industry today, economics tend to drive most decisions. While I love technology and think research and innovation is important for its own sake -- particularly because we might not know what we're missing out on unless we explore -- but those controlling the purse strings have other priorities.
Others might point out that the economic cost of the bugs and failure cases in programming languages without memory safety might actually be greater than the cost of developing alternatives or accepting less performance in exchange for correctness. They're probably right! But unless you can measure it and present it on a spreadsheet to the management class, they won't acknowledge or understand it. It's really difficult to measure "incidents you didn't have". In any case it still might be cheaper to work on the next big startup idea, hype it & sell equity -- that strategy has produced trillion-dollar valuations recently. However correctly or incorrectly that may be, the benefit to an elite few is very real.
hn_submit
4 days ago
C is literally "high level assembly" and therefore lacks any guard rails you'd expect in a programming language. It's just unfortunate that so many software developers embraced C for its speed, even when it wasn't strictly needed.
I always remind people that C is a systems programming language and not fit for regular application programming. For that you need an application programming language like Pascal or Java.
sitzkrieg
4 days ago
yea, we certainly wouldn’t want regular user applications to run fast or respect user resources. can’t have that
xigoi
3 days ago
You can have that without writing them in C or C++.
sitzkrieg
3 days ago
you sure can. i recommend forth
hn_submit
4 days ago
I, for one, can't see any speed difference between a program written in Pascal (Total Commander, which I use every day) and one written in C++ (Windows Explorer).
leptons
4 days ago
File browsers are probably the worst example you could use here. The actual file manipulations are handled by the OS. The rest of it is just displaying lists of files, so no real speed difference would be noticed in different languages/programs. Most of the time the file browser is just sitting there waiting for user interaction.
The programs that do benefit from speed aren't file browsers.
asdff
4 days ago
You can’t compare apples to elephants here.
Dylan16807
4 days ago
Even if that was the tradeoff, your average C/C++ program isn't notably fast or lean.
uecker
4 days ago
The C programs I use daily are generally very fast, very lean and very stable: Programs such as linux, terminals, shells, vim, etc.
dzhiurgis
4 days ago
Most programmers don’t have 30 years to perfect their code
uecker
4 days ago
It had no crash during 30 years, not after 30 years.
fluffybucktsnek
3 hours ago
I did, in Linux. It was pretty common too. It got fix. But, every now and then, I still get an occasional panic.
I also recall having my shell crashing (zsh or bash, I don't remember).
Matheus28
4 days ago
I’ll take a Qt application over the Electron garbage that we see all the time nowadays.
Dylan16807
4 days ago
It could be worse but that's not much of an argument for C in particular. There's a lot of ways to do UI that don't involve web engines.
fennecbutt
3 days ago
10-100x develop & maintain cost.
sitzkrieg
3 days ago
good. browser uis always end up sucking more
krior
4 days ago
false dichtonomy
inigyou
4 days ago
C should be considered powerful, more than fast. Part of that power is that it doesn't try to stop you from going so fast it's unsafe. But that's just one way you can choose to use your power.
emilfihlman
4 days ago
>therefore lacks any guard rails you'd expect in a programming language
This is simply not true. Guardrails are enforced by the compiler, and both gcc and clang have a myriad of flags to make C safe, not to mention Fil-C.
xyzsparetimexyz
4 days ago
How is it high level assembly? Have you written much assembly recently?
jkrejcha
3 days ago
C is very much a "high level/portable assembly" type language still and there's really no sign that it'll change from that. Even if it has ostensibly has abstract semantics, many operations map to 1 or a few assembly instructions and much C code, even when not strictly conforming (as all but the most trivial examples are), is conforming enough that it's portable amongst most relevant targets
For example, I kinda know that the code
for (size_t i = 0; i < 64; i++) {
// ...
}
...will map to something that roughly that, on x86 will (in most cases) probably do a compare and jump, etc, for the loop body, vectorization and some other optimizations notwithstanding. I know a similar thing will happen on PPC, ARM, etc.This relationship breaks down a bit with a lot of higher level languages where what you want to occur is higher level. This can be both a blessing and a curse; it can enable easier opportunities for optimization but may also may make automatic things downright pessimizied with very very very large effort and expenditure to get things close to usable.
xyzsparetimexyz
3 days ago
No, you don't know what that code will do. Depending on the inner block, it'll most likely be vectorized. Like I said, it's significantly higher level than assembly.
jkrejcha
2 days ago
I don't really agree here. Setting aside the question of how often a compiler can vectorize a loop, because I do think it's not totally relevant here, as you still don't really have the language builtin stuff that other languages do.
You really do have to write the code that iterates over a list and applies a transformation, you can't just do
[x + y for a.x, a.y in b]
...in C, you have to iterate over the array. And you don't tend to have that much to help you. Most dialects of C don't have exceptions for instance (unless you invent your own). And in general, most of the time, non-trivial loops just... won't autovectorize and it can be a bit finnicky to nudge it in the right direction.Take, for example, Ghidra. It has a feature to decompile blocks of code into C(++). Other reverse engineering tools follow suit. Even in C, it's very possible to model assembly instructions that don't have a 1-to-1 mapping to a particular language construct as a function call (and this is what these do).
But, there is a reason that, even with all of the architectural differences in the world, whether it be x86, x86-64, PPC, ARM, RISC-V, Xtensa, MIPS, etc, that you can provide a mapping that goes in 1 way (from source to object code) and also the other way (from object code to """source"""). It'd be much more difficult to do that with other languages, especially in an idiomatic fashion.
vor_
4 days ago
That change is happening. Microsoft has been rewriting parts of Windows in Rust, Linux is accepting Rust code, and Apple is using Swift for core parts of their OSes.
stodor89
4 days ago
> I'll await your Rust ports of Windows, Linux and MacOS then.
Unironically this. Like most game developers, I was extremely sceptical of Rust, based on opinions I've read on the internet. Ugliest syntax I've ever seen, and "safety" features are irrelevant and just get in my way. Compile times are glacial. Tons of direct and indirect dependencies needed.
But then I got to use it professionally for a year or so, and I was MINDBLOWN by how much less stuff I have to keep in my working memory at all times. And libs like tokio and actix-web were so well-designed that I actually enjoyed reading the code in my free time. Fighting the borrow checker? I had like five such instances in the first month, understood what it wants and why, and it never bothered me again. Compiles were indeed slow, but I went from "if it complies the first time around, I'm probably missing something" to "if it compiles the first time around, it's most likely correct".
Turns out, I had significantly underestimated what Rust brings to the table, while focusing on stuff that wasn't really that important once you get used to it.
Nowadays I'm back to gamedev. I'm happy about that, because my year in cloud/edge dev felt like we were consistently solving the wrong problems. But I do wish my current team was more open to giving Rust a chance. It solves so many actual problems, and is being dismissed with reasoning like "sorry, I don't have programming socks". And by very smart people! WTF is this timeline?
whytevuhuni
3 days ago
The Blub Paradox [1].
Granted I doubt how true that is, I always understood the benefits of languages like Haskell and Ada/SPARK, it's just that pragmatically speaking I want beginners in my team to be able to code too.
elabajaba
4 days ago
Clearly you just need to buy those team members some nice programming socks so they can finally enjoy rust.
Dylan16807
4 days ago
Computers have gotten more than an order of magnitude faster since safer languages got into the same speed and memory ballpark as C, but we keep wasting that speed. The model T of memory safety was Java 31 years ago. (I'm not sure what lisp is in this analogy.)
jdm2212
4 days ago
They're working on it for Linux: https://rust-for-linux.com/
akersten
4 days ago
It's not a fair take in the sense that replacing the backbone of lead solder plumbing and paint in 1960's wasn't a fair take, and plenty of us are still awaiting the lead-free replacements.
That doesn't mean we shouldn't do it.
KronisLV
3 days ago
> I'll await your Rust ports of Windows, Linux and MacOS then.
I’d love to have that happen within the next century. I might not be around for it, but I’d say that humanity deserves software that has fewer memory issues.
gtowey
3 days ago
The thing is, I'm not even against it. The point of the sarcasm was to say that the most massive projects on which everything is built are in C-flavored languages so the claim that it's not fit for large projects is absurd. And to say that replacing those foundations is going to take time. I would love memory safety in those, but it is going to take time to build something as battle-tested.
rpdillon
4 days ago
The entire compute world was built on top of C and C++. Saying they're not fit for purpose doesn't seem correct. I think what you're really saying is they're not an optimal choice from a safety perspective.
> All of these need to be ported to Rust or another memory-safe language ASAP to prevent mayhem.
Seems like hyperbole... It might be ideal if we could snap our fingers and suddenly have rust ports, but I feel like you're discounting the effort that goes into doing that properly.
Which brings me to an interesting point. We have a web engine written in Rust. It's Servo. If the Rust port is so important to do as soon as possible to avoid mayhem, why aren't companies picking up Servo and using that?
hn_submit
4 days ago
I assure you that Microsoft knew for years that there were thousands if not tens of thousands of memory related bugs lurking in Windows. But their policy was "don't fix" (and "don't look") unless a remotely exploitable vulnerability was making headlines. Because every minute a developer spends finding and fixing bugs is a minute he can't spend on adding new features customers will pay for.
Luckily one of the perks of A.I. is that it makes large scale code migrations feasible in a timely manner.
davidjade
4 days ago
And I can assure you that there were a number of MS research developed tools for finding memory bugs that have been used for decades at MS. There was never a don’t look / don’t fix policy while I was there. Quite the contrary.
hn_submit
4 days ago
Was there ever a time, apart from the short monthlong stint in 2001 after Blaster, when Microsoft developers worked on fixing memory related bugs?
Automated tools (before the advent of A.I.) can only get you so far. The bugs being found by A.I. today could've been found by eyeballs if companies thought it worthwhile.
davidjade
20 hours ago
When these tools were set up, on every code change you had to run these tools and deal with the output of anything it thought was a memory bug - part of the dev cycle before you could commit your code.
Did you have to scan the code looking for memory bug yourself with your eyeballs too? Yes, at every code check in you went through a paired peer code review before checking code in no matter your dev level. So two sets of eyeballs would look at every change.
So yes, we had to look for bugs in multiple ways no matter the type of bug on every single code change.
Then the testers would run all these tools and look at the output too (I was there when each org still had SDE Testers).
Did bugs still get missed? Of course, just like today even with today's new tools.
dingaling
4 days ago
> Saying they're not fit for purpose doesn't seem correct.
I'll quite happily say they were never fit for purpose. C had a role in bootstrapping early software development in the absence of anything better but once Lisp, Delphi, Smalltalk and Java arrived on the scene then it, and its equally footgunnable variants, should have been pushed to the margins where hardware constraint was the primary consideration.
Writing a browser in C++ in the 21st century was ridiculous and irresponsible.
aenis
4 days ago
Ekhem. When Chrome was announced there wasnt Rust. And Java was a programming language for slow moving systems, with many a flaws and its own classes of footguns.
I dont think they had much of a choice in 2008. Now? Sure. I bet a rust port is in the works.
floil
4 days ago
This is correct (I worked on chrome in 2008) it's important to remember that chrome's renderer was webkit, an existing c++ stack.
Chrome's stability innovation was to run different tabs in different processes, and the security innovation was then to sandbox those processes.
Rust would have been super nice but it wasn't an option then, and of course let's remember that Rust was developed by Mozilla specifically with the goal of making safer browsers.
rustfreeforme
4 days ago
[dead]
fluffybucktsnek
3 days ago
Quite frankly, this post is massive set of unsubstantiated claims.
For starters, no one said the only problem with Chromium is C++. But it certainly contributes with some of the problems (specially those related to security). And, no, these bugs don't come from "noob programmers." They come from experienced engineers.
Then you just mention that removed some "unnecessary and unwanted" code. According to what standard? You? Would be nice if you went into specifics and provided some benchmarks. Instead we are forced to take the word that a user "rustfreeforme" (wonder which biases they have) made an polished fork, instead of, possibly, mangling the code in such a way that just benefits them and screws other people.
Finally, Rust doesn't: make the code more complex than C++, specially if using the STL; doesn't make compilations slower, as C++ and Rust compilation times are on par (and keep in mind Rust is very unoptimized here, where as C++ is slow by design).
rustfreeforme
3 days ago
[dead]
fluffybucktsnek
3 days ago
> Oh no, it seems my one brief post wasn't long and detailed enough to immediately and totally convince some Random Doubter on HN, therefore my 'claims' are 'unsubstantiated.'
No, you just didn't cite any actual data, only assertions. Don't come with this excuse of "busy day", you had enough time to create an HN solely for spewing anti-Rust nonsense.
Keep in mind, HN is a place for intellectual discussions, not for dumping your pet peeves. If you don't actually have anything actually productive to say, it's preferable to omit yourself before the mods or the flags do that for you.
> Nah. It doesn't.
Then try to prove it. I already cited a source elsewhere, which you just ad hominem'ed. The burden of proof is now on you.
> It's definitely not possible for fluffybucktsnek to just take my word here. I wonder what biases he or she might have.
Yeah, what biases does the name "fluffybucketsnek" indicates? "Rust free for me" doesn't sound as impartial in this discussion. It just sounds like you came here for an ideological battle.
> Yes, you should just assume that's what must have happened, and then move on, blissfully unaware of how wrong you are.
I didn't assume anything. If anything, I kind of wish you did/could prove me wrong. You could, at least, post the code of your fork.
Instead, you need us to assume that all your claims, none of which has any sources, are true. All I did was show a different possibility.
> Sure it does. There is extra machinery/interfacing for all the extra Rust crap bolted on, and it gets more and more complex over time as they integrate more of the crap.
Every FFI introduces some manner of complexity, specially when one language (Rust) is more strict than the other (C++). I don't say C is complex because JNI is a hassle.
> Furthermore they vendor the entire Rust compiler, library, etc, all of which has to be compiled first before the browser.
That just seems like a Chromium project issue, not a Rust one. It's weird that for issues with C/C++ in Chromium, you blame the project itself, but for Rust, you blame Rust. Just like you don't have to vendor LLVM, you don't have to vendor Cargo nor Rustc along with the project itself. Even for compile times, similar strategies for cutting C++'s work for Rust as well.
wbl
3 days ago
You have chronology backwards. Lisp predates C by 14 odd years. Pascal was contemporaneous.
raverbashing
4 days ago
Well we make work with the tools we have
It worked well enough, maybe "fit for purpose" is a stronger word
rpdillon
4 days ago
Makes sense, but strangely, no one has responded to my question about why Servo hasn't been picked up, if Rust is such an important factor in browser engine implementation. People are calling using C and C++ "ridiculous" and "irresponsible" and "not fit for purpose". And yet, no one's using the alternative that's sitting right there?
fluffybucktsnek
3 days ago
Because Servo is unfinished, and companies have different priorities. For instance, Microsoft could've have been strict and formally checked code for Windows since the inception of constraint checkers, but they chose other priorities. Now they're are slowly trying to integrate Rust to help reduce security bugs.
raverbashing
3 days ago
You know what's funny?
Windows was built in C when "C was not guaranteed to win", hence why they have weird things like Pascal calling convention etc
rustfreeforme
4 days ago
[dead]
fluffybucktsnek
3 days ago
People who believe in total unsuitability would be acting silly indeed. But most would agree that writing code on languages that provide better and safer tooling is a positive.
Sure, the main Rust compiler currently depends on LLVM, which is currently written in C++. But the rustc team might choose to follow a similar path to Zig and replace LLVM, or LLVM might get rewritten in Rust.
Finally, while most bugs are logical, the most damaging ones, security bugs, are primarily related to undefined behavior.
rustfreeforme
3 days ago
[dead]
fluffybucktsnek
3 days ago
The problem is that you think Rust programmers despise C or C++. We don't. We just think there are better alternatives for modern development. In fact, a lot of Rust programmers were experienced C or C++ programmers.
And then you say:
> [...] your belief system.
What do you mean by that? What beliefs? This just sounds like projection.
> Please do so at the earliest opportunity, so that your language can actually become an alternative to C++.
It already is an alternative to C++. The fact that LLVM is written in C++ doesn't change the fact that you can write software that otherwise would be written in C++ or C, in pure Rust without writing a single C or C++ source nor header file.
> False. Nonsense. Not true.
https://www.chromium.org/Home/chromium-security/memory-safet...
rustfreeforme
3 days ago
[dead]
fluffybucktsnek
3 days ago
> YOUR ENTIRE WORLD IS BUILT ON C/C++.
What a reductive view of reality. That's like saying our entire world is built on assembly. That's just missing the point.
> Saying Rust is the replacement to C/C++ is like saying Python is the replacement to C/C++. No, not quite.
With analogy such as these, I see where the "No, not quite" comes from. For starters, we can write actually low-level Rust code enough to write kernels without needing to interface with C code, only raw assembly. I don't think Python can do that.
> I don't go to Google for advice on how to design software, thanks.
Good thing they weren't giving advice, but reporting that most security vulnerabilities came from just bad memory access, which contradicts your counter assertion. None of that is subjective. Whether you think they are the ideal programmers or not is irrelevant.
azakai
4 days ago
You can also take the opposite conclusion from this: C++ is now viable because LLMs can catch the security bugs.
I'm obviously not entirely serious here, but I think this is true to some extent: the number of memory safety bugs in a codebase is finite. Once you have a way to find them, you can drive that number down to zero.
C++ has become a far safer language thanks to LLMs - at least if you run the LLMs before you are attacked.
rhdunn
4 days ago
C++ has had smart pointers for memory (and other resource) management for a long time now (see e.g. the Windows ATL classes for working with COM objects and resources).
There are a number of challenges that make browsers more challenging (even in memory safe languages like Swift and Rust).
1. Back references/pointers like `parentElement` to other objects in the graph that create dependency cycles (where traditional/simple reference counting will prevent the objects being deallocated).
2. Interacting with (and creating resources in) a garbage collector when running/evaluating JavaScript code.
3. Just-in-Time (JIT) compilation of JavaScript and other complicated interpretation-compilation pipelines that can allocate and transfer objects between the different stages.
mbac32768
4 days ago
Actually, if you implement a JavaScript runtime at all your choice is either too slow for modern web users or `unsafe` everywhere. Runtime values are often simultaneously either words that encode immediates or pointers to heap blocks and doing this the proper way blows up time and space. Doing it the fast way means you have `unsafe` everywhere and Rust's lifetime model can't help you at all. Everyone chooses the fast way.
Maybe Rust let's you encapsulate the unsafe a little better than C++ but the wins are going to be surprisingly small. If you had to build it today you'd maybe use Rust but the case for rewriting an existing C based runtime in Rust is not that strong.
Also for things like interpreter loops the absence of computed goto in Rust stable is a real performance killer. Explicit tail calls (the `become` keyword in nightly) work but maybe you don't want your big rewrite to rely on that.
throwaway2037
3 days ago
Assume that you are writing a green field project in C++. If you never use "naked pointers" and always use std::unique_ptr and std::shared_ptr, will it not reduce nearly all memory related bugs? I don't have a lot of experience with them, but I found it dramatically reduced memory related bugs. I'm a very average C++ programmer, and those templates helped me greatly. Do you think it would help Chrome/ium to use (more) std::unique_ptr and std::shared_ptr?
Orphis
3 days ago
Chrome uses those already, and a few other pointer types that are fit for purpose.
For example, lot of C++ objects are tied to a garbage collected object in JS, so you need something special to hold a reference in C++ code to those, and prevent them from being garbage collected.
Another example, shared_ptr is fine if you eventually drop the reference count to 0, but in JS, you will have cycles, so the reference count will never get there. And that's one of the problems the garbage collector deals with, it checks cycles and connectivity to mark a group of objects to be released together. So you will have a special life-cycle for those objects. Another responsibility if that you can't really use the destructor there or you might trigger a delete storm and block the thread. So the garbage collector will destroy objects in batches when the page is idle no to create stuttering (jank).
lelele
3 days ago
> If you never use "naked pointers" and always use std::unique_ptr and std::shared_ptr, will it not reduce nearly all memory related bugs?
It will, as long as the code uses them correctly all the time, including when refactoring. In the end, that's still manual memory management.
tonfa
3 days ago
At a minimum you'd also need to enable runtime bound checking for span/vector accesses (I think chrome did that).
zik
3 days ago
> Most if not all of the bugs being uncovered are memory related
I checked the stats. 73% were memory management related issues, mostly use-after-free.
The rest were logic errors of various sorts.
wilg
4 days ago
This seems an awful lot like confirmation bias. Web browsers are themselves extremely complicated.
Also, this doesn't address why the rate increased, which is the interesting part!
deterministic
18 hours ago
> C and C++ are simply not fit for purpose when large scale software projects are concerned
The world runs successfully on C and C++. Ignoring that fact and claiming that Rust will magically remove all bugs is BS^2.
bschoepke
4 days ago
Rust certainly helps for certain classes of errors but doesn't help at all for logic errors or incompletely understood requirements or occasional need for hacks due to business needs.
hn_submit
4 days ago
Why is everyone always referring to logic errors when pushing back against Rust? No programming language ever invented (or to be invented) will fix logic errors made by developers.
Logic errors are "out of scope" for Rust or any other programming language.
Aeolos
4 days ago
The Rust type system helps you catch logic errors at compile time. Same with Haskell or Ocaml.
astrange
3 days ago
Note: when people say this about Haskell they mean "it has ADTs".
rustfreeforme
4 days ago
[dead]
fluffybucktsnek
4 days ago
Wrong. For starters, a good typing system absolutely helps catching logic errors at compile time.
rustfreeforme
3 days ago
[dead]
whytevuhuni
3 days ago
Yes, except imagine the distance in correctness between Assembly and C, and triple it. Less so compared to C++ of course.
The sentiment of "if it compiles it probably works" for languages like Rust and Haskell is there for a good reason.
rustfreeforme
3 days ago
[flagged]
whytevuhuni
3 days ago
> * laugh track deafening *
No shallow dismissals please, tell me why you think I'm wrong.
> Rust is not a major advance over C/C++
Rust adds the borrow checker (and especially with non-linear lifetimes it's an implementation like the world has never seen before, not even in Cyclone). That alone raises it leaps above both C and C++.
But even without it, it still has a Hindley Milner type system (which most people considered superior to multiple inheritance), it has Sync/Send traits, the concept of UnwindSafe, proper destructive moves and affineish types, proper sum types and matching, sane iterators, lack of UB on uninit/overflow/etc, a sane module system, hygienic macros, and that's just the things I was able to pull of the top of my head right now.
Not to mention, the design of its stdlib is absolutely lovely compared to what C++'s stdlib has become, and it focuses on correctness much more than most other popular languages.
rustfreeforme
3 days ago
[dead]
whytevuhuni
3 days ago
> Tell me why you think you're right.
The more verification you do, the more likely it is for a program to be correct. Lean towards Assembly, and you get less correctness, but lean towards Ada/SPARK, and you get more.
Rust is a notoriously difficult language specifically because it adds some limited verification features, going further along that correctness continuum than C. I didn't think that could even be disputed.
The "if it compiles it probably works" feeling most Rust programmers experience is proof that those verification features work, too.
> In time you will learn about all of the faults and flaws in Rust
I've programmed enough safe Rust and unsafe Rust that I'm now very familiar with most of its flaws, and yes, it has many. I'm also familiar with C and C++'s flaws, and they're so, so much worse.
> after you've suffered the pain of trying to rewrite the entire universe in it
My goal has never been to rewrite the universe in Rust. Battle-tested software is fine to stay as-is, unless it needs constant updates and new features, where most memory bugs appear.
With that said, a couple years ago, at work, our team finished migrating a couple of performance-sensitive services from C++ to Rust, and not only were they both successful, but they became 5x and 10x faster respectively, because it's so much easier to do direct memory reference stunts that would've been possible, but crazy via C++'s std::span and lambdas.
> I know exactly what the successor to C/C++ looks like, and it's not Rust.
What does it look like?
> Blah blah blah. Most of that is just added runtime complexity that I could add to C if I wanted
Everything I listed is compile-time complexity. I'm not sure how you can add any of it at runtime without extra runtime costs. Or are you talking about modifying the C language?
We might argue over whether that complexity is worth it, for sure, but once again: "if it compiles it probably works" is a very common sentiment with Rust.
But also, what you're saying sounds very much like the Blub Paradox [1]:
"As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub."
[1] https://wiki.c2.com/?BlubParadox
> Most of it is wankery, the sort of stuff that 20-somethings salivate over
I'm not sure how that is relevant to what I said? I have 30 years of experience with C, and have read the C specification cover to cover, plus more recently some 15 years of C++ experience in parallel at work. I still use all 3 languages today.
> Again, the actual successor to C/C++ looks nothing like Rust.
What does it look like?
fluffybucktsnek
2 days ago
+1 for the Blub Paradox. First time I'm hearing it.
fluffybucktsnek
3 days ago
> In time you will learn about all of the faults and flaws in Rust, after you've suffered the pain of trying to rewrite the entire universe in it just to fix one single class of problem you are obsessed about--inevitably introducing many new bugs in the process, because that always comes with the territory.
Good thing Rust doesn't just fix that one class of problems, but also provides better tooling to fix other classes too. Classes of problems that could be fixed with the other features of Rust mentioned later like the Hind...
> Blah blah blah. Most of that is just added runtime complexity that I could add to C if I wanted, but why would I?
...the vast majority of these features don't even run at compile time. Some of them can't even be implemented in C. For starters, show me an example of a Hindley Milner type system implemented for C (how can someone improve a strictly compile time feature, static typing, with a runtime implementation is beyond me). Or proper destructive moves in C or C++.
> Ada is the language to emulate, [...]
Good thing Rust also takes from Ada.
> Again, the actual successor to C/C++ looks nothing like Rust.
And that would be...?
rustfreeforme
3 days ago
[flagged]
Aeolos
3 days ago
It is obvious that you are just trolling, but for other readers: our production app went from 50-100 unexplained sentry errors in typescript to 0 sentry errors in rust.
The language absolutely helps fix logic errors.
It's something that becomes immediately clear as soon as you start using the language in earnest.
fluffybucktsnek
3 days ago
> Wow, what a magical language! [ waves hands vigorously ] will fix all the problems which are inevitably introduced by auto-porting from one language to another, or by manually rewriting everything from scratch. Rust doesn't obey the same laws of the software universe as other languages, it seems. Or is this a "just use magic AI bro", type situation?
Nope, that's just your own prejudices speaking. We already cited features (seen in and inspired by other languages) and you handwaved them away with "I don't care". You are the one fixated on C and C++. You are a C evangelist, if I were to make a guess. And that's on you.
> In the latter case, why don't I just use the to auto-magically solve my C/C++ problems, rather than rewrite the entire universe from scratch? You know, like Google claims to have done for Chromium C++ sources in this very news article?
You certainly can. But to spin this the other way around: in lieu of the Bun case, why not use it to rewrite the project in Rust, Zig, D or any language of your choice (yes, even C)? Given the role harnesses have in keeping agents in check, it seems plausible that languages with stricter safety features help agents avoid common issues.
> This is the type of shit noobs are always wringing their hands about as they need maximum guardrails to cover for their ineptitude.
You seem to be forgetting that proper software engineering is just as much about managing developers and their skills as the actual code structure. If a tool helps noobs produce better quality code, specially ones without as many vulnerabilities, why not employ it? Also, it's not like experts are immune to mistakes either.
fluffybucktsnek
3 days ago
> It could compile and still have 10,000 logic errors.
It could. Switch that to C or C++ and the amount of logic bugs is likely going to triple.
> Rust is not a major advance over C/C++, only an incremental and quite limited one, [...]
"Nothing ever happens." I guess you could consider borrow checking, an actual module system, type classes, enum variants, compiler-integrated macros, async/await, etc. to be just small increments. (Theoretically, you can reimplement most of this in C++, like std::variant, but they don't integrate well into the language - having to declare a type just to use std::visit is certainly not as simple as using match).
> [...] which will require decades of rewriting perfectly good code to gain its dubious benefits, in the process introducing numerous other errors.
"Introducing numerous other errors"? Would be interesting to see an citation on that. From what I've seen, these "new errors" were already present in the original "perfectly good code", except the original also had instances of undefined behavior and logic errors from poor type modeling.
> But don't take my word for it [...]
Why would anyone other than your friends take your word? You could have substantiate your claims with actual evidence.
> [...] after the hype has worn off [...]
Which already did. Nowadays, I see more posts about Zig and Fil-C.
>[...] left with the sad mess that is Rust.
I went to read your comment history to see if you elaborated on this "sad mess" of Rust, but you didn't. How about you do it here?
margorczynski
4 days ago
It basically completely eliminates the most common class of errors which are bugs related to memory management. Hard numbers and statistics show that every application with enough complexity will be riddled with those.
It is simply impossible, even for the smartest human minds, to manage this kind of complexity. And this is a fact.
uecker
4 days ago
Somehow, magically, some people managed to write C software that I now use for three decade with not a single crash in all this time.
vor_
4 days ago
What software would that be, and how do you know there have never been memory-related bugs and vulnerabilities in it?
uecker
4 days ago
Basically all C programs I use, shells, editors, terminals, etc. But I do not claim that there "never has been a memory-related bug" but that it is not "riddled with" memory-related bugs, which I would expect would have manifested in at least one segfault over all these years, which I did not observe.
rustfreeforme
4 days ago
[flagged]
whytevuhuni
3 days ago
Many Rust proponents are experienced C programmers (me as an example).
We speak of the horrors of C/C++ precisely because we've seen both sides (3 sides more specifically), and can compare.
rustfreeforme
3 days ago
[dead]
slopinthebag
4 days ago
That's like saying a condom isn't 100% effective so you just use the pull-out method instead.
Ar-Curunir
4 days ago
It does help for logic errors too, with, eg, sum types and traits and abstraction.
Also better defaults.
ls-a
4 days ago
blaming bugs on C++ has got to be the most leetcode thing I've heard in my life
jeong_jeong
4 days ago
You make a false equivalence between being an idiot/“didn’t know what they were doing” and not knowing how to properly manage memory. Also, why do you think the devs who worked on google chrome weren’t idiots?
Some of the most important and safety critical large scale projects in the history of humanity had/have manual memory management. If you think the effort of doing it correctly is not worth it for certain projects, that may be a reasonable opinion. But the idea that humans cannot write correct C/C++ programs is in direct contradiction to historical fact.
thin_carapace
4 days ago
if you go around pulling out logic flaw arguments and then proceed to commit logic flaws yourself, it isn't a good look man. the quoted statement was "beyond most intelligent individuals" which contradicts your assertion that the argument was stated as "humans cannot write correct C". anyway I do find it ultra amusing how software engineers believe software engineering is the backbone of programming, when in reality it is merely the flesh. we landed men on the moon long before Rust was even zygotic. for all its benefits, the argument to use memory safe languages ultimately serves to benefit large corporations who can faster generate profit by faster churning out code.
rustfreeforme
4 days ago
[flagged]
user
4 days ago
user
4 days ago