Re:Rust and Nix = easier Unix systems programming
by sickbeard on Thursday April 14, 2016 @10:30AM
(#11497004)
This has been proven to be wrong over and over again with the many variations of languages that came after C. Newer "safer" languages don't improve bugs
Re:Rust and Nix = easier Unix systems programming
by nickpsecurity on Thursday April 14, 2016 @12:34PM
(#11498132)
On contrary, empirical studies done in the 90's and such by the likes of Mitre Inc showed people using Ada and C++ were more productive than C developers while producing way less defects. That the language and libraries were designed specifically to counter hard-to-track issues were one of the reasons why. That languages would improve safety was known far back as MULTICS with PL/0 where it's prefixed strings and reverse stack prevented two of the most common crashes/hacks in UNIX/C land.
The evidence is on our side that well-design language significantly reduces number of defects in production code if other variables are equal.
Re:Rust and Nix = easier Unix systems programming
by kod on Thursday April 14, 2016 @10:34AM
(#11497043)
Where's this "proof" you speak of?
By contrast, strong static typing does in fact prove the absence of certain errors.
The point here is that the language's tools and APIs can significantly better drive the developer towards the safe/right solution, that's a large point of type theory and static type systems after all. In this case rust's type system is used to split out the various "result cases" and notify the developer upfront of the various cases to handle. The return type pretty much tells you how the function will behave and what you need to take care of as the caller.
That aside, why would you unwrap_or(default_value) if you're in a hurry when unwrap() is shorter (and you can later grep for "unwrap()" to find dodgy/hurried code, whereas unwrap_or is a perfectly legitimate recovery strategy).
> Now, if you're about to tell me that the examples above are totally stupid and no developer would do such a thing, then you know how I feel about the sloppy C versions. Doing a system call and not checking for error is totally stupid as well.
The issue being that even though you have a compiled statically typed language it's of absolutely no help in "checking for error", and interactions between syscalls can be hard to predict, not checking for fork(2)'s error isn't the end of the world... until you pass its result to kill(2) for instance (it might also give strange results if you pass specific pids to waidpid)