3 ms·
Why allow programmers to make mistakes? For a philosophical counterpoint: Why allow anyone to do anything that might possibly be incorrect, harmful, or otherwi
by userbinator 10y ago
Why allow programmers to make mistakes?
For a philosophical counterpoint: Why allow anyone to do anything that might possibly be incorrect, harmful, or otherwise perceived by some to be negative?
I've looked at a lot of the talk surrounding "safe/secure languages", "safe/secure programming", etc., and yet every time I've heard people preach about the benefits, I feel like I just vehemently disagree. At a very deep and fundamental level, I feel like somehow we are sacrificing something more important in the pursuit of this "safety", this seemingly overpowering desire to make everything completely safe, mindlessly constricted, and stifling. It's not just software; the whole "war on terrorism" irks me in the same way. I imagine a "completely safe" world, the ones these "safe software" proponents appear to be striving for, would be rather dystopian.
A quote that immediately comes to mind is: "Freedom is not worth having if it does not include the freedom to make mistakes."
- burntsushi 10y agoThat's a great quote, and it's one that Rust---as a a memory safe language---completely embraces. You have the freedom to do anything you want. Some of those things simply require you to type "unsafe."
- pekk 10y agoForgive me for being cheeky, but just as Rust requires you to type "unsafe," C also requires you to opt in by typing "cc". My serious point is that in practice, the example of C shows that if it is available and people understand that it is "performant" then you will see it all the time, including in libraries you are forced to use.
- burntsushi 10y ago> Forgive me for being cheeky, but just as Rust requires you to type "unsafe," C also requires you to opt in by typing "cc". This isn't an accurate analogy at all because I can compile thousands of lines of Rust code without even thinking about needing to use `unsafe`. How many lines of C code can you compile without `cc`? > My serious point is that in practice, the example of C shows that if it is available and people understand that it is "performant" then you will see it all the time, including in libraries you are forced to use. Except this is already demonstrably false in the Rust ecosystem.
- Sean1708 10y agoWell sure if you compile your C one statement at a time, somehow I doubt you do though.
- srean 10y ago"UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things."
- Retra 10y agoFreedom is not worth having if you squander it by making easily avoidable mistakes, either. The point is to make mistakes that lead somewhere. I.e., mistakes that we can't yet write programs to easily prevent. And there is no shortage of mistakes available for you to make, so don't worry about that.
- caconym_ 10y agoPeople rely heavily on software in many aspects of their lives. They entrust it with their personal information, their money, and in many cases their physical safety. Engineers building software and companies selling it are ethically obliged to make a good faith effort to prevent defects that might betray their users' trust and cause harm. Languages designed to enhance the safety and security of software written in them are one tool that can be used in this effort. Are engineering standards for public buildings evil because they stifle architects' freedom to design whatever crazy structures tickle their fancy? Should power tools not include safety features like blade guards because their users' freedom to accidentally kill or maim themselves must be held sacrosanct? Probably to both questions, the reasonable answer is "no". If you're building something for yourself, and offer it to others only with clear warnings, then go nuts and make all the mistakes you want. Nobody's saying you can't do that; that sounds rather dystopian, a society where pointer arithmetic is illegal! But you can't treat a project people are meant to trust and rely on as your personal art project.
- userbinator 10y agoAre engineering standards for public buildings evil because they stifle architects' freedom to design whatever crazy structures tickle their fancy? The physical analogy is good because even there one can see that there are different standards --- and, unlike what the "safe software" community seems to promote, engineers are not doing the equivalent of making every building strong enough to withstand a nuclear war and calling anything less "unsafe". This also brings up another difference with software: the "absoluteness". In the physical world, no security is perfect. Locksmiths exist, and with enough determination, essentially anything can be broken into. But in the software world, with good encryption, that can never occur. Provably correct software can be employed for effectively unbreakable DRM and un-rootable/jailbreakable user-hostile devices, of which there is (fortunately) no similar real-world analogy I can think of. Nobody's saying you can't do that; that sounds rather dystopian, a society where pointer arithmetic is illegal! Given that there are attempts at even prohibiting Turing-completeness[1][2], I would not be surprised if that eventually happens. As it is, I'm sure there are already people who would consider you suspicious if you write software in an "unsafe" language, and from there it is not far to complete prohibition. "The road to hell is paved with good intentions." [1] http://boingboing.net/2012/08/23/civilwar.html http://boingboing.net/2012/08/23/civilwar.html [2] http://boingboing.net/2012/01/10/lockdown.html http://boingboing.net/2012/01/10/lockdown.html
- rtpg 10y agoYou can still be clever in Rust. You just have to try harder and explicitly say "I'm trying to be clever" here. You might make a mistake, of course. But if you need it, the option is there. There is no philosophical beauty in typos or off by one errors. You are not being stifled when your compiler points out to you that, no, "coutn" is not a variable currently in scope. If we have a static proof that what you just did will never work, why would you still want to do it? And if you had a reason, you still have a way to do it. If you're trying to be clever, you need to prove that you know what you're doing.
- imtringued 10y agoThere is no need for another unsafe fast language. There is also no need for another safe slow language. We already have enough of those. Rust's purpose is to find a middle ground between those extremes.
- jdmichal 10y agoExcept we're not talking about limiting your freedom of expression. I'd challenge you to give me an example of a program that you can't express in Rust, with the obvious exception of silly and obviously unsafe things like "read from a random memory address". Which, by the way, was deemed so unsafe that the operating system itself will probably kill that program dead. (I can think of one excellent answer off the top of my head that requires `unsafe`.) We're talking about eliminating a class of programmer error through static analysis. (If you're writing a large C program, you arguably should be using static and runtime analysis tools on it anyway.) This is no different than using a strong type system. Yes, it limits your "freedom", but sending a "banana" to a `sine` function is nonsense anyway. Well, it also ends up that reading 10 bytes into a five byte array is also nonsense, and we now have tools to detect that nonsense and tell you that it is, in fact, nonsense.