4 ms·
> before but soon got annoyed with obvious errors that would only show up once you run a program. From what I gather you are comparing static vs dynamic typing
by johnisgood 8y ago
> before but soon got annoyed with obvious errors that would only show up once you run a program.
From what I gather you are comparing static vs dynamic typing, and I agree. I do not use Python because I prefer a subset of errors caught at compile-time. However, it is silly to make it sound like that this is somehow limited to Rust. You could just as well have used Go or OCaml and feel "refreshed" because obvious errors would have been caught at compile-time.
> The predictable nature of Rust
Again, given the context, it is static vs dynamic typing. This is not something limited to Rust. In case you were not talking about static typing and its pros, could you please tell me what kind of official formal proof tools exist for Rust that makes it predictable?
- c3534l 8y agoI assumed borrowing and lifetimes were part of his experience as well.
- atoav 8y agoSure, and I find both not very hard as a concept. The hard thing is not understanding the concepts but learning what this implies for your coding style, especially when you come from a garbage collected language like Python. Both concept can at times give you hard to solve tasks, but it usually is because the problem you are trying to solve is hard and you cannot just naively hack away without thinking long and hard about it. Other than that I learned liking the borrow checker and lifetimes because you will get a incredible narrow scope of which variables can matter when — which makes debugging much easier
- jhrmnn 8y agoAnd with something like Mypy, you can get most of the benefits of static typing even in Python, if you want to. But Rust has so much more to offer, such as memory ownership.
- atoav 8y agoI didn’t know mypy, but I am going to check it out, thanks!
- matthewmacleod 8y agoThat’s one aspect of the errors that are avoided, but there are many others too - some of which aren’t solved by other languages. Go, for example, will happily nail through all of your obviously null pointers with gay abandon. The Rust ownership model prevents other classes of bugs. It’s not a panacea—and to be blunt, I find Rust more work than it is worth for the sort of projects I typically work on. But any tools which can eliminate whole error categories are worth looking at for sure!
- johnisgood 8y agoI was responding to the issue I quoted, which really is just a matter of using a programming language with static typing. :) > some of which aren’t solved by other languages You only mentioned null pointers, so I will go with that. In Ada, you can have access types (pointers) that are guaranteed to not be null, and accessibility rules of Ada prevent dangling references to declared objects or data that no longer exists, so this particular issue is solved by a language other than Rust. Please feel free to give me other examples of errors or issues that you may believe is not solved by languages other than Rust. https://www.adaic.org/resources/add_content/standards/05rat/html/Rat-3-2.html https://www.adaic.org/resources/add_content/standards/05rat/... > But any tools which can eliminate whole error categories are worth looking at for sure! I agree. That is why I think Ada/SPARK is awesome! :P
- galangalalgol 8y agoAda is awesome, and if compiler writers had been more timely it might have taken hold. Rust solves the same problems without a runtime, and about 3 times the performance. Granted it looks like c++ and ocaml made a particularly ugly child.
- johnisgood 8y agoWhich problems are you referring to? You can do everything that has been mentioned without Ada's RTS, you can also disable all run-time checks. You can use static analysis tools (there are many, and available for free), for example, you can formally verify the correctness of the program, no run-time checks required.
- gameswithgo 8y ago>could you please tell me what kind of official formal proof tools exist for Rust that makes it predictable? I feel like you aren't really asking a question, that your intent was really to lecture someone, but in case you really are: * a borrow checker * option types So OCaml would catch a similar set of obvious errors, though Rust would also catch all data races at compile time, as the borrow checker does that as well as prevent memory mistakes.
- johnisgood 8y agoNo, I was really curious. My bad if it looked like I was trying to lecture. I do not think that I have the necessary knowledge in this topic to do that. :) > a borrow checker What exactly do you mean? How does it differ from any other language's type system? > would also catch all data races at compile time In Ada/SPARK, you can formally verify tasks, too. Please take a look at https://docs.adacore.com/spark2014-docs/html/ug/en/source/concurrency.html#preventing-data-races https://docs.adacore.com/spark2014-docs/html/ug/en/source/co... if you have some time! > prevent memory mistakes. Which mistakes are you referring to specifically? I need to know so I can have a meaningful response to it, but all I can say right now is that Ada/SPARK does the same.
- Yoric 8y ago> What exactly do you mean? How does it differ from any other language's type system? If you're familiar with affine types, this is basically what Rust's borrow checker implements. If you're not familiar, it's a bit complicated to summarize on Hacker News. You should try it out, because it lets you guarantee statically entire classes of properties that non-academic languages struggle with. > In Ada/SPARK, you can formally verify tasks, too. Please take a look at https://docs.adacore.com/spark2014-docs/html/ug/en/source/co.. https://docs.adacore.com/spark2014-docs/html/ug/en/source/co.... if you have some time! I'm not an expert in Ada, but yes, that's pretty similar to some of the properties Rust will let you check out of the box. edit My memory of Ada was incorrect.
- Manishearth 8y ago
- atoav 8y agoSorry if I angered you. I never claimed that Rust was the only language that has these properties. My experience was is: I have never seen a language/environment where these rules were so well thought out, so well communicated and so well enforced. The package managment works like a charm, the module system (since edition 2018) is the best I have seen etc. These are all subjective – I am a film/philosophy student who codes and I never received any formal education on any CS related topic. I was speaking about why Rust feels sound to me. Good chances Haskell will look sound to me too, very good chance I might check out more CS topics. No hard feelings please.
- johnisgood 8y agoIt is fine, and no it didn't anger me, so no need to apologize, really. :) > I never claimed that Rust was the only language that has these properties. Yeah, that is my mistake. Sorry for misunderstanding you! > I never received any formal education on any CS related topic Same here actually! :P > No hard feelings please. Not at all! I understand that you like coding in Rust, and that is completely okay with me, and even if it was not, that should not deter you from continuing what you are doing.
- outworlder 8y agoThis is not only static vs dynamic typing. Rust provides a set of abstractions seldom found elsewhere. The borrow checker, for instance. It is more a question of semantics.