News for hackers. Stuff that matters.
Re:I cannot consistently write safe C/C++ code by alfiedotwtf on Monday July 17, 2017 @06:48AM (#14787238)
Another scenario:

Option 1. Spends 5 years learning the ins and outs of systems programming, whilst using C++. Still writes unsafe code.

Option 2. Spends 5 years learning the ins and outs of systems programming, whilst using Rust. Zero unsafe code has ever been written.

Re:I cannot consistently write safe C/C++ code by falcolas on Monday July 17, 2017 @08:54AM (#14788003)
If you are writing systems code, you will be writing unsafe code; it's just how it works when you are working with the underlying kernel and hardware.

The best you can do is attempt to contain it within "unsafe" blocks, but as has been proven by others in the rust community already this will not save the rest of your "safe" code from crashing if you write a bug.

There have been memory safe languages for longer than c has existed; rust is just the latest.

Re:I cannot consistently write safe C/C++ code by ccommsxx on Monday July 17, 2017 @06:56AM (#14787288)
Again, the assertion that all code written in rust is automatically "safe" (let alone correct) is false unless you say what precisely you mean with "safe" in very specific terms. While there are some ways in which rust is "safe" while c-family languages are not, these cases are _subtle_ and you _will_ have to understand modern C++ first to see what they are.

But yes, rust could turn out to become a new widely accepted standard for systems programming some day and depending on whether you believe that or not, it might make sense to "invest" your time into it.

Re:I cannot consistently write safe C/C++ code by Rusky on Monday July 17, 2017 @12:59PM (#14790350)
These cases are not subtle at all. You can understand a good number of them with barely the knowledge from an Intro to Java class- iterator invalidation, data races, etc.

There is no need to understand the particulars of C or C++ to do or appreciate safe systems programming.

Re:I cannot consistently write safe C/C++ code by alfiedotwtf on Monday July 17, 2017 @07:12AM (#14787384)
I'm talking safe as in Rust's memory safety guarantees.
Re:I cannot consistently write safe C/C++ code by ccommsxx on Monday July 17, 2017 @07:29AM (#14787507)
As far as I understand, there is no accepted formal specification or even single source of truth for what the rust community thinks are the "rust memory safety guarantees". Only a large number of people that have completely convinced each other that "it's better than C++" with little proof and without even clearly defining their own semantics. Please correct me if I'm wrong here (a blog post does not qualify as a specification).

Relevant: https://github.com/rust-lang/rfcs/issues/1447

Re:I cannot consistently write safe C/C++ code by steveklabnik on Monday July 17, 2017 @11:41AM (#14789549)
It's a little more subtle than that: It's "safe code must be memory safe" and "unsafe code infects the whole module". The stuff you're talking about is "what exact invariants are unsafe code supposed to uphold". Because unsafe Rust is a superset of safe Rust, that being an open question does not mean that what's meant by "Safe Rust" inside of safe Rust is up for questioning.

Work on exactly what unsafe code is expected to do is ongoing.

Re:I cannot consistently write safe C/C++ code by Rusky on Monday July 17, 2017 @12:57PM (#14790329)
It's nowhere near that uncertain. "Memory safety" is hardly a subtle property and it's been well-understood since we figured out how to enforce it in garbage collected languages.

The only uncertain part is which rules unsafe code has to follow to maintain it- it currently comes down to "whatever LLVM optimizations won't break," which is in practice what C and C++ programmers deal with already. Things like your link are work to improve the situation beyond C and C++.

[dead]
Re:I cannot consistently write safe C/C++ code by sctb on Monday July 17, 2017 @04:13PM (#14791927)
Comments like these aren't OK on Hacker News, no matter what you're replying to.

https://news.ycombinator.com/newsguidelines.html