Reply to post: Re: Is there a reason we need YAPL?

Rust code in Linux kernel looks more likely as language team lead promises support

Richard 12 Silver badge

Re: Is there a reason we need YAPL?

Rust doesn't allow you to directly manipulate raw pointers, unless you explicitly say a block of code is "unsafe". "Unsafe" is a red flag to make you take extra care, and should be used very rarely.

You end up with the same code, as it's really just syntax to define sets of automatic checks.

Eg A C function that should have "if (ptr == null) fail;" at the top gets that autogenerated by Rust. The programmer cannot forget it or put it in the wrong place by mistake.

Which can sometimes result in slightly faster code: The Rust compiler can also notice that everything calling that has also said "must not be null", so it can put that the autogenerated check right at the beginning of the callstack, instead of the programmer writing it into every function "just in case" - much harder for the compiler to spot and optimize out.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon