logoalt Hacker News

lelanthran • today at 7:38 AM • 4 replies • view on HN

> As things currently are, I've needed to patch under-fire my PHP, Python, and Ruby applications like 3 times each in the last couple years.

> Conversely, I've had to do zero patches under-fire for the much more complicated rust applications I run.

All those languages are memory-safe, so I'd expect similar failure rates.

As all of those languages are memory-safe, what is your explanation for why Rust applications had fewer CVEs?


Replies

rspeele • today at 8:27 AM

A language is only as memory safe as its runtime and external library interop calls. There are many more lines of code written in C executing when running a Python, Ruby, or PHP program than an equivalent Rust program.

Obviously Rust still makes plenty of calls to code that was written in C like libc or the operating system hosting it. But the other 3 do that and have tons of C in their runtime and stdlib on top of it.

Yoric • today at 8:38 AM

Memory safety is just the start.

For instance, it's much harder to end up with a SQL injection in Rust than in PHP. Similarly, the Rust type system is pretty good at modelling advanced protocols, so it's also harder to attack the lower layers.

antonvs • today at 9:32 AM

The large C dependencies of those other languages is a big reason, as someone already mentioned.

But Rust is also type-safe, with an extremely strong type system by mainstream standards. Used well, that’s an enormous benefit for robust and secure systems.

imtringued • today at 8:57 AM

The power of Option<T> and Result<T, E>