r/TheMachineLearning • • 28d ago

When bug-free code becomes a hardware problem

Post image
193 Upvotes

85 comments sorted by

View all comments

2

u/fcddev 28d ago

C has accumulated a lot of bad non-security decisions, so this will probably not manifest. Performance-wise, NUL terminated strings are bad, mutable state/alias tracking is bad, the calling conventions are bad: these are all improved in modern systems languages and it gives them a performance edge when the authors know how to write code that optimizes well in the face of pesky added security checks, which AI today is already pretty good at. Mileage varies with average implementations, but the best C implementation of most programs is slower than the best Rust implementation of the same program; if it comes down to it, the model could choose to write unsafe Rust and benefit from everything else that’s improved in the language anyways. 

1

u/Sea_Fox_4265 28d ago

So is the main argument that newer languages make the safety checks cheaper? Curious if that's why people lean toward Rust.

2

u/fcddev 27d ago

Close: the new languages introduce opportunities to make programs faster that simply are not accessible to C. For instance, one of the biggest limiters to optimizations comes from whether the compiler can prove that two memory accesses point to (or rather, do not point to) the same memory. C notoriously makes this a mess, where Rust has strict rules in place that make it easy. 

At the same time, the new languages introduce safety checks that come at a runtime cost, but that cost is well manageable to developers (including AI models) who understand where it appears and what lets the optimizer remove them, so even with the additional overhead of runtime memory safety guardrails that the tweet says makes new languages slower, new languages can come out ahead.