Hacker News new | ask | show | jobs
by ho_schi 1317 days ago
Please stop calling for a rewrite with the next language which is currently in trend. Use the right tool which fits your purpose. An example to learn: https://news.ycombinator.com/item?id=31089216

Lessons:

    * Serious bugs doesn't care in which language the error happens
    * C++ implementation was safe
    * Java implementation was unsafe
    * Test-Coverage would help...
PS: I don't say Rust is good/bad. C++ is good/bad. Or is good/bad. Neither about Java.
2 comments

>Serious bugs doesn't care in which language the error happens

This just isn't true.

Buffer overflows are not possible with bounds checking.

Using a language that provides containers with bounds checked access methods would have prevented this. This isn't a point of debate or something, it's a fact.

C is virtually the only language that doesn't provide a safe way to access elements.

C++ provides bounds checking with std::array, std::vector and std::string using the "at()" methods. All Rust containers are checked by default. Pretty much every other language also is checked by default as well. All of these language's could have prevented this error and the other buffer overflow errors which there are tons of.

Sure but you wouldn't be reading a password into a std::array or std::vector in C++, you'd be reading into a std::string or possibly something like a std::stringstream. And both of those containers will handle sizing and reallocation for you.

If your point is that C++ lets you do unsafe things then yes, of course it does. But so does Rust.

I think you may be misinterpreting my comment a bit, I did not mean that C++ was bad here, but rather a large improvement.

My point was that in C++ (and others) you can completely prevent this entire class of errors by using the standard containers. std::string, just like std::vector and std::array provide the checked access methods which will prevent buffer overflows when used.

Almost every language other than C lets you access elements of a container safely, and oftentimes even the default methods for access are safe! In C++ there are compiler flags that make operator[] safe by default for all of the std containers too.

sudo has long history of bugs that would be impossible in Rust in the first place.

Yes, given enough care and effort you might write code that will not have those bugs, but not having a possibility (aside from unsafe{}) to have them in the first place is usually better approach.

Like, yeah, it is a dumb meme but in this case not without merit.