Hacker News new | ask | show | jobs
by jiggawatts 1798 days ago
I don't want to use the phrase "can permit". Rust and C# have escape hatches, like the "unsafe" keyword. You can write pointer-based code in C#, but the language actively discourages it. The "happy path" is safe code. If you poke through the standard library, you'll notice that there's quite a bit of pointer arithmetic going on, either for interop or performance. On average though, 99.99% of C# code that has been written is safe[1], which is why total beginners can write an ASP.NET website, put it on the Internet, and not get hacked.

The problem with languages like C and C++ is that that the "happy path" is unsafe, unstructured, or an unexpected footgun. There's article after article written about how compilers do bizarre optimisations based on undefined behaviour.

Everyone writing a significant volume of C code is writing code littered with gotos, because as Linus said, it's the only terse way to handle error conditions in C. In C#, Java, and Rust there are structured and safe ways to handle errors (exceptions and the '?' operator). No need for liberally sprinkling code with goto.

Linus rightly makes the claim that "nothing is as good as C" at performance, or low-level control. In the past, this was entirely correct. But these days, even high-level VM-based languages like C# are acquiring features that give C++ a run for its money, and Rust is very close to C++ in performance but much safer.

[1] Memory safe at least. Most C# code is also unlikely to leak resources, unlike most C/C++ code.