5 ms·
My current favourite task queue is http://p3rl.org/Minion http://p3rl.org/Minion and I mention this not in a spirit of competition but because the pg queries to
by mst 5y ago
My current favourite task queue is http://p3rl.org/Minion http://p3rl.org/Minion and I mention this not in a spirit of competition but because the pg queries to be found in the source code of https://metacpan.org/dist/Minion/source/lib/Minion/Backend/Pg.pm https://metacpan.org/dist/Minion/source/lib/Minion/Backend/P... are IMO truly beautiful and worthy of the "great artists steal" treatment.
- setr 5y agoI’m reading through that file and I’m not finding anything particularly interesting — the queries all look… reasonable — though I’m also struggling to imagine what I would consider a beautiful query Anything specific worth calling out?
- mst 5y agoI suspect as much as anything else this is a case of "any piece of code I can read through and not have a viscerally negative reaction to part of it that makes me want to rewrite it to within an inch of its life counts as beautiful to me". Certainly, very little of my own code passes that test after I've not looked at it for a week.
- aidos 5y agoEDIT: I was understandably being downvoted for saying that the code could be more readable. On reflection, the sql is good, and it's the Perl-ness that I had a bit of a reaction to. I'll leave my questions here in case people would like some food for thought anyway. - what's with the mixture of styles (q{sql}, sql with '?', sql with '$1', sql with '\$1' etc)? - what's the use case for a right join, when left joining is the norm? - in the $stats query, inactive_workers isn't actually inactive_workers and instead it's patched based on active workers afterwards. For me, the jumping of inconsistent column selections on each line makes it hard to see that. (If someone just copied the sql into psql to run it, it would be wrong, but not obviously) - Maybe it's not fair, because I have sqlalchemy to improve readability, but this whole thing where the variables aren't obvious in a blob of sql could definitely be easier to read
- mst 5y agoI see where you're coming from finding the perlish string formatting weird, I guess I barely even notice that part and was assuming incorrectly it would be everything else about the perl that would bother people. So I guess that while you perhaps did have suboptimal judgement in your initial reply you very much weren't alone and I should remember to be more careful about that going forwards.
- gurjeet 5y agoSorry to be that guy, but your comment is pointless, so I had to downvote it. While the beauty is in the eye of beholder, and you may be correct, or have high standards, praise coming from the likes of @mst should be taken seriously. People may have seen code that can stand in for sh?t, so it makes them appreciate simple niceties like good formatting, good and concise logic, etc. BTW, I have to agree with @mst on this one; even though perl is very low on my scale of pleasantness for languages, the SQL in that code is beautifully written.
- aidos 5y agoI think your comment here is reasonable and you were unfairly downvoted by others missing the deleted context in my original comment. I’ve upvoted you partly on those grounds, and partly to get you back to 1337 :)
- gurjeet 5y agoHah. I was bummed when I lost my leet score, especially because it was lost towards the wrong direction. Thank you!
- mmcgaha 5y agoI agree with you on the right/left join issue. I don't think I have ever used a right join. But then again I don't use greater-than signs either so maybe it is me.