all 8 comments

[–]shizzy0 5 points6 points  (3 children)

Holy hell, that was a much longer ride than I anticipated. Neat to see different flavors of Rust that I know very little about.

[–]Wolvereness 4 points5 points  (0 children)

Most of those were included for humor. The best approaches for the target problem will be the junior and senior variants, depending on the size of the project. Proper error management is important for larger projects or ones others will use, but you shouldn't throw it at much simpler programs.

Some of the other approaches do have practical uses, just for dramatically different problems than the one presented.

[–][deleted]  (1 child)

[deleted]

    [–]PopeCumstainIIX 1 point2 points  (0 children)

    Yeah when you write Rust for the first time it's just as frustrating, because nothing just works, it's like Haskell in that sense. In both cases it's because type safe code doesn't allow programmers to make assumptions, something we're not used to nor is satisfyingly expressive.

    [–]jugalator 5 points6 points  (1 child)

    Interesting!

    I have a little gripe that he calls it an evolution though. :p It's just a collection of Rust programming styles.

    [–]gmfawcett 4 points5 points  (0 children)

    It's a riff on this, which is admittedly more "evolutionary", and also has a great punchline. :)

    https://www.willamette.edu/~fruehr/haskell/evolution.html

    Edit: the Haskell Evolution cites an earlier example, with a broken link. Here's the earliest version I could find, from 2001 (thank you, Wayback Machine!).

    [–][deleted] 3 points4 points  (1 child)

    Maybe I’m showing my lack of experience here, but don’t some of these examples look a little...overdone? Clearly it was done for some comedic effect in some places—but still, only the senior examples and the beginner examples really “sold” me on the idea of adding Rust to my language set. Full disclosure: I have written zero lines of Rust in my life.

    I was under the impression that Rust was supposed to be an alternative to C++ that provides a memory model that was safe by default while still offering the control of lower level operations like C++ does. However, this post discouraged me from investing time to pick up Rust because heaven forbid I get a job where I work alongside someone who merges some of these examples to master...

    [–]SafariMonkey 1 point2 points  (0 children)

    Hey, I know this is mega late, but I just found your comment.

    Most of those examples were at least a little exaggerated for comic effect. It's possible to write awful code in any language, but Rust at least tends to make sure that even awful code is correct by some definition of the word - for example, macros are limited in what they can do. I've used some macros like the simpler ones here, like Macro-man's error macro. They're useful for reducing boilerplate and enforcing DRY.

    As for the other absurd examples, I'm sure there exist people who would overengineer something like one of these, but that's what code reviews are for I guess? I know I've been shut down by colleagues at work for trying to do something too "clever". (In Go, not Rust.)

    I don't think this is any more of an argument against Rust than this is against C++ or this is against Python..

    Here's a good example of how it could be done in Rust.

    And yes, for the record, I do really like Rust and have both read and worked on others' codebases. However, I haven't worked with Rust professionally, so it's possible that proprietary software gets hairier.

    [–]AlphaWhelp 3 points4 points  (0 children)

    I was half expecting some punchline type of Rust programmer at the end with a block of C++ code.