Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror

Comment Re: Full Parity with C (Score 1) 111

It's not about your code not sucking though. It's about you having to repeat the same hundred lines of buffer management code over and over again, and one day you make a tiny mistake. Not in logic flow, not in interop with external systems, but in blocking out memory for a string function. So incredibly basic an operation that the compiler should be able to do it for you, especially since in Rust it *does*. If "your code just shouldn't suck" is an argument, why are you writing C and not assembly? Also, even if you never actually use the foot-guns, the language being safe can have other benefits too - in many scenarios Rust is faster than C. It was explained to me like this: a pro tennis player can hit the ball at a hundred miles an hour, but that is nothing special; anyone can do that. It'll just end up out of bounds, though. We hit slower because we need to hit at speeds we can control the ball at. A tennis player can *control* the ball at a hundred miles an hour. Similarly, since the Rust compiler knows that nothing weird can possibly happen in safe code, and because it doesn't need to specify the memory layout of anything by default, it can make all sorts of crazy optimizations if it wants to, and does. Move array of structs to struct of arrays, pass by value instead of by reference of vice versa, etc. C can never be this optimized for the same reason JNI is a huge slowdown: for all you can *try* to keep it safe, anything can still modify anything at any time, and when a potentially unsafe operation is severely restricted in how it can be optimized around in Rust, *every* operation is an unsafe operation in C.

Comment Re: Real parity means no memory management. (Score 3, Informative) 111

I see you have never bothered learning anything about Rust. Rust allows manual unsafe access to memory, but clearly partitions where it occurs via unsafe blocks. You can write the parts that do pointer offsetting or whatever in unsafe functions, write safe functions that use them in unsafe blocks and ensure their safety, and then reuse them everywhere in safe code with zero worries about memory safety. It's not a new concept - something as high level as C# can do this too. The thing that's broken about C isn't that you can invoke undefined behavior easily, it's that you can do it in your memory manipulation code just as easily as you can in your regular logic code.

Slashdot Top Deals

Is your job running? You'd better go catch it!

Working...