5 ms·
Do Rust newbies also complain about the lack of exceptions like in Goland (myself included even understanding their reasons..) ?
by swah 11y ago
Do Rust newbies also complain about the lack of exceptions like in Goland (myself included even understanding their reasons..) ?
- pjmlp 11y agoNo because Rust offers a more natural way to deal with them, instead of ifs everywhere. Also known as railway programming in FP circles.
- platz 11y ago> railway programming in F# circles FTFY
- unmole 11y agoPretty sure pjmlp meant Functional Programming.
- platz 11y ago"Railway Oriented Programming" is a term coined by Scott Wlaschin, a prominent F# practitioner who popularized the term with helpful blog posts, slides, and speaking events. Outside of the F# community (i.e. those that have not seen Wlaschin's materials) however, the term is rarely used. The larger FP community has more more general terms they use instead for the whole class of patterns surrounding this.
- moonchrome 11y agoRust targets C++ programmers (Go seems to be targeting Python/Ruby web devs), the former are used to not using exceptions even when they exist in the language (for various reasons, some valid - some not so much :) )
- bad_user 11y agoRust's error handling is pretty good. First of all you see in the signature of the function that it can trigger an exception, so such a function will return Result<T, E> instead of just T. This is similar to Option, Either or Try in Scala, or to Maybe / Either in Haskell. To easily pipe such errors, Rust provides a try! macro, which just expands into a catch block. Rust is less functional than Haskell or Scala, so I don't know how that works out, but in FP languages it ends up working great. Also, compared with Go it isn't the same thing.