4 ms·
> Heck, the author praises Rust and it's memory safety, but then proceeds to criticise Rust compiler because, as he puts it, the compiler will stop you from doi
by tsimionescu 8y ago
> Heck, the author praises Rust and it's memory safety, but then proceeds to criticise Rust compiler because, as he puts it, the compiler will stop you from doing unsafe studf again and again. Isn't that the whole point? Or is anyone expecting that your memory corruption problems will magically cease because you write your same old memory allocation and access bugs in Rust instead of C or C++?
I think the biggest problem with advanced type systems and complex compiler checks is that they are only desirable when you know the code you're writing is the the right one. A lot of the time, you're exploring a solution and don't care about edge cases, since you're not sure you've even found the right happy path. At this stage, you don't really care if your code is handling all required inputs, if it doesn't have leaks etc. - you just want to run it and see whether it at least sometimes produces the right output. At this stage, you're often fighting the compiler.
Once you know that you're on a good path, then you start caring about safety and all the other bits, and the compiler starts becoming a trusted friend.
It would be really interesting to have a system that supported both modes, e.g. starting from Rust but setting a flag to turn borrow checker errors into warnings or something similar. I'd bet that would change many people's perspectives, like the author of this article.
- viraptor 8y ago> It would be really interesting to have a system that supported both modes, e.g. starting from Rust but setting a flag to turn borrow checker errors into warnings or something similar. https://github.com/thepowersgang/mrustc https://github.com/thepowersgang/mrustc kind of does that. It assumes the input code is valid at the moment. But if you want to experiment first, you have other language pairs you could use. Python + typed Cython, or Ruby + Crystal, or other options...
- larzang 8y agoI actually find strong typing speeds up green-field development rather than hampering it, because it cuts down on the little avoidable things that inevitably creep in when you're trying to architect and evaluate and code all at the same time. The kinds of things that make you smack yourself in the face for an hour wasted by the most trivial mistakes. In addition to my own personal experience this has been incredibly well illustrated to me because I'm overseeing two junior JS devs right now where one starts any new code with "any" types and tries to make Flow happy later and the other starts with real types. The former has a LOT more "this isn't working and I have no idea why, help" moments.
- reificator 8y ago> I actually find strong typing speeds up green-field development rather than hampering it, because it cuts down on the little avoidable things that inevitably creep in when you're trying to architect and evaluate and code all at the same time. The kinds of things that make you smack yourself in the face for an hour wasted by the most trivial mistakes. I want to agree with you on this statement, but I don't think your anecdote supports it. > In addition to my own personal experience this has been incredibly well illustrated to me because I'm overseeing two junior JS devs right now where one starts any new code with "any" types and tries to make Flow happy later and the other starts with real types. The former has a LOT more "this isn't working and I have no idea why, help" moments. To me it just sounds like the second junior has a stronger understanding of the language/type system. Some people come into junior positions because they've learned enough to pass a CS course. Some come into junior positions because they've spent their whole life programming in some way or another and want to get some professional experience on their resume. (And everything inbetween of course) Now, trying to push the Any dev toward specifying types upfront and watching the results might give you better evidence, and better performance to boot.
- tsimionescu 8y agoI don't have a problem with strong types, I agree with you. Dynamic types are usually too much hassle even for prototypes. I was talking more about stuff like Rust's borrow checker or dependent type systems.
- pdkl95 8y ago> you just want to run it and see whether it at least sometimes produces the right output Then use a dynamic language like ruby or python and enjoy not only data type freedom, but also features like easy introspection and code manipulation at runtime. Protyping and experimentation in a REPL is much faster, easier, and memory safe. If you are just experimenting, why are you wasting time and effort on e.g. C++'s complex type system? If you don't care about memory leaks, why waste any effort on memory management when the garbage collector can handle that for you? > starting from Rust but setting a flag to turn borrow checker errors into warnings Experience suggests the "we'll do it right in the next version" argument leads to "prototypes" being shipped as the "next" (only) version. The difficulties imposed by Rust is the goal. Actually writing correct and safe code is inherently a difficult problem. Rust is trying to force programmers into actually addressing that problem. Writing similarly correct and safe C++ is also time consuming and difficult. The difference is C++ lets the programmer shift that work and expense onto the user in the form of time-wasting crashes and expensive security vulnerabilities.
- kiriakasis 8y agoAlso I think that with enough .clone(), raw pointers and `unsafe` you can avoid almost all borrow checkers errors.
- tsimionescu 8y agoI never said anything about a release - I'm not even thinking about code you would commit. I'm talking about the kind of coding where you're exploring a new feature on your own machine - essentially doodling in an IDE instead of on paper. It makes no sense to me to make such code 'correct' - I don't even know if its useful to any extent, why would I care about its correctness?