- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I believe it's because it comes back as an
Option<T>
, Rust's way of expressing types which may be null: https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrapAdmin
I have a bad feeling somebody was a little too impressed with things like LINQ and vectors (lists). This looks like that was their hammer and everything is of course a nail.
Admin
That
unwrap()
call isn't there to get the results out of a vector, it extracts theOk
variant value out of aResult
enum. If it is anErr
variant instead, it will "panic" and immediately and unstoppably crash the entire program. This is Rust's standard way of error handling, instead of throwing and catching exceptions. For reference: https://doc.rust-lang.org/std/result/enum.Result.htmlAdmin
First (but only in bigendian)
Admin
I love the "Naive" implementation from this line: "we wouldn't want to use the naive version". Naive just seems more appropriate then "Native".
Admin
You would know better than me, but I actually appreciate the Rustiness of the "library" version. Apart from the endian bug, of course.
It's a nice standard Schwartzian Transform sort of thing, with added exception-handling goodness, as you say.
Of course, it's an absurd way to implement the actual requirement (plus it's broken), but it's one of those rare WTFs where the design and (most of) the implementation are really quite nice. Bit of a shame that the result is up shckreek. Could do with some tests in the crate, I feel.
Admin
I don't think "naive" is a typo. If there were a native version, then she wouldn't have needed to use a crate or write her own version. A naive implementation (of anything) generally refers to the first approach that comes to mind, without regard for optimizations or possible edge cases.
Admin
"If all you have is a three-headed hammer, everything looks like three nails." — D_Coder.
Admin
uhhhhh uh huh uh. uhhhhhhhhhhhh.
So I got this ... ... grate. Or gutter. Or drain .... uh huh. uh huh.
And this can of spray paint. ... ... uh huh. huh huh huh.
And I need to ... ... uhhhhh.... uh huh ... uh huh ... uhhhhhhhh "coat a path to each intersection member" huh huh huh huh .... you said "sex member"
Damn it. Let's just poke holes in a piece of cardboard and cut it up with a chainsaw again. uh huh uh huh. ... ... ... this is gonna be cool.
Admin
I've always liked the idea of describing "perfectly cromulent" Python as "pythonic." Perhaps, in like manner, we could describe this "perfectly cromulent" Rust as "rustic."
Is that an apt description? It is now ...
Admin
Since when does TDWTF pick on random hobbyist projects on github that were never meant for production use? Is this how you make OS more welcoming to people?
Oh and by the way, the details of this story make it easy to track down the original library, and "Jenna" (actually John - wonder why you chose to misgender him?) was extremely rude to the original library creator who admitted to being a hobbyist coder who made his library for fun and no longer maintained it. Try to be less of an asshole to people, "Jenna."
Admin
@Sole Purpose of Visit ref:
I think a better term for cromulent Rust is "Rustolean". Rhymes with Tyrolian and, yes, Rust-o-leum. ;)
Admin
This person Haskells.
Admin
I know Rust developers are sometimes referred to as "rustaceans".
Admin
Or Oxidised?
Admin
Which is why we should write "naive" as "naïve", always. To prevent everyone from thinking it's a typo and should read "native".
Admin
Believe it could be either an Option or a Result, which anyway adds to the complexity of the API, given that probably the procedure could never return null or fail entirely...
Admin
I love this one. Having had arguments with a few people who have claimed that Rust ensures that code is bug free and fast, the whole set of performance horrors and outright incorrect behaviour is just a wonderful counterpoint. There are a whole range of bugs other than memory handling, and getting them wrong can just as easily lead to disaster. Numeric code is particularly notorious for being tricky that way, and often has stuff in it that is seriously non-obvious.
Admin
Based on the comment thread on the original issue ( https://github.com/blakehawkins/zdex/issues/8 ), I would say that the poster was very arrogant and far from constructive.
Admin
The DailyWTF might try some basic due diligence rather than just regurgitating a single account. A schoolchild would do a better job here.
From the original issue (https://github.com/blakehawkins/zdex/issues/8) it's also clear "Jenna" has their own z-indexing crate that they are pushing, so I'm not sure I buy the premise.
I've actually had the pleasure of working with the library author, and like many people, I know he writes tonnes of experimental and throwaway code just for fun (which I think was part of what made him good at his job). I haven't confirmed it, but I suspect that this is a case of that. His production code is of quite a different nature, and was typically high quality and performant (and he wrote software in a realm where this really mattered).
In any case, this is all pretty poor, and I'm really not sure what "Jenna" is trying to achieve here.