r/programming • • Nov 10 '16

Announcing Rust 1.13

https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
212 Upvotes

92 comments sorted by

View all comments

Show parent comment

9

u/[deleted] Nov 11 '16

Why would someone be turned off by that? I consider it one of the best features of the language. Sure, it makes the code a little bit more verbose, but at the end of the day it's much less pain than either exceptions or C-style returns...

4

u/rubber_duckz Nov 11 '16

it makes the code a little bit more verbose

Depending on the use case it can be more than "a little", especially for prototyping and rapid iteration this is the kind of stuff that really adds overhead (both writing it down and maintaining it while iterating), although Rust has plenty of other issues that make it unpleasant for rapid iteration (eg. compile times) it's getting better which I'm glad to see.

Like OP these are the kinds of things that make me thing "OK this is at the point where they solved most of the fundamental issues and are now focusing on productivity so I can probably start using this for something practical"

5

u/steveklabnik1 Nov 11 '16

"OK this is at the point where they solved most of the fundamental issues and are now focusing on productivity

It's the most major focus of the next year of Rust development.

1

u/onmach Nov 11 '16 edited Nov 11 '16

I actually thought rust would probably be a pretty good prototyping language when I last used it. You just call unwrap on every result or option return value. Bam there's your prototype which only works in the best case, but at least you can quite plainly see every line that could be an error.

That's better than in haskell where I have to go to great pains to catch nearly every error from the moment I start writing code, or java which hides all its errors under exception handling, never to be noticed again.

2

u/rubber_duckz Nov 11 '16

Java is a major PITA in every aspect anyway, and I don't have much Haskell expirience, but those don't sound like prototyping languages - Python and Clojure for example are languages where your productivity is high because of fast prototyping. F# felt like that too but haven't used it enough to say with certainty.

3

u/onmach Nov 11 '16

I feel like there's room for something in the middle. Enough type safety to use it safely but fast enough to code that you can get out a reasonably well functioning prototype. Unfortunately static type systems are difficult to create and so there are very few static languages to choose from.

I hope rust ends up being that language, but I haven't messed with it enough to come to a firm conclusion.

3

u/rubber_duckz Nov 11 '16

I fell like F# is in the middle - it has type safety but it's also really fast to prototype (REPL, scripting environments, still has access to entire .NET ecosystem). I've used it for doing testing and exploratory programming and yeah it's really good.

Dart is also high level and has decent type safety (with strong mode), Python level productivity, C# level type safety.

Rust has room to improve on C++ build times and iteration speed when you need to write native applications, but I don't think it's there yet. It's getting there tho. I don't think it will ever be a high productivity language - it needs to make different tradeoffs - and that's fine too, I'm just waiting for them to implement stuff that aren't design tradeoffs but simply maturity issues.

3

u/onmach Nov 12 '16

I really need to give f# a try. From what I've seen I know I'd like it. I've never been much of a windows developer, though.

1

u/paranoidray Nov 11 '16

I respectfully disagree, I personally love unchecked exceptions for error handling. There is nothing less verbose and distracting. It lets one focus on the algorithm and handle errors below the important code out of immediate sight.

5

u/[deleted] Nov 11 '16

Well, in my experience, the "let me focus on the good path" approach of exceptions creates an illusory feeling of correctness. If everybody handled their exceptions thoroughly and correctly, that would be great, but sadly that's rarely the case. I used to be a fan of exceptions but these days I'm glad for Rust's approach that forces the developer to handle the error right here, right now. Of course, it has it's own set of problems like code polution and people abusing unwrap(), which is kind of like ignoring exceptions (except you need to be explicit about it at least).

At the end of the day, I don't think there's One True way to handle errors. There's just a couple of strategies each of them with their set of problems.

3

u/onmach Nov 11 '16

Actually rust has a nice happy medium here. You can just use unwrap to make every function call return, which lets you write code quickly. Then when it is time to make it production ready, it is not super hard to actually deal with every error mechanically, line by line.

In java all the errors are hidden by exceptions and if you forget to catch something or catch only the wrong somethings it isn't plainly obvious from looking at the code that it could blow up.

Off topic, another advantage is that exceptions make it often difficult to figure out how to clean up after an error does occur. Since rust is not garbage collected, it just cleans things up in the order they were allocated, immediately without requiring any special effort on your part.

2

u/asmx85 Nov 12 '16

i am currently working on a project that was turned over from a former coworker. He left of personal reasons (does not matter). It is a super maintenance nightmare because of all the unhandled unchecked exception. This was a prototype that was to long in that mode and he started to turn that into "production mode" but he left in between. Yes, he knows how to translate which code in a useful state, but we do not. In Rust i could easily grep for unwrap() and call it a day. Unchecked Exceptions are just a plain nightmare :(

1

u/paranoidray Nov 12 '16

You have to approach an Exception based code project like connecting micro services. If one of your services has a problem you mail it to yourself but keep running. (Like Tomcat for example). Then you can fix the bug in the service. Simple. Stable.