Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  @sorted = map  { $_->[0] }
            sort { $a->[1] cmp $b->[1] }
            map  { [$_, foo($_)] }
                 @unsorted;
Sometimes boring isn't as good as awesome. My first reaction to the Schwartzian Transform was, "Computers can do that!?" Figuring out what this thing did, and how it did it, made me a better programmer.


I completely agree. Interesting and awesome code is how you grow as a programmer. And it's the interesting code that can really make your program shine.

When I see an interesting bit of code it's still a warning sign though. Because for every time the Schwartzian Transform was implemented well, 100 programmers reimplemented it badly in a language where .sort_by(func) already existed.


But yikes, please don't put that into production!

Given a stack trace pointing to that single line of code with an exception, could you immediately figure out what had gone wrong? Would you know what to fix before you even had the code up in the editor?

That's something you can do with well-written production code. It's not particularly sexy to look at, but it's built for debugability.

Split that little kernal of awesome into 7 distinct lines that your CS101 nephew can explain back to you. Then it's ready to go live.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: