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

Totally agreed about #1 and exceptions. In that defintion of DumpBinary, each bit of error handling takes three extra lines. Speaking of "cognitive load". Whereas here's what it'd probably look like in Python, with exception handling (assuming binary.write() raised IOError on error, which they should).

   class Gopher:
       def dump_binary(self, writer):
           """Write this Gopher to given writer, raise IOError on error."""
           binary.write(writer, binary.LittleEndian, len(self.name))
           writer.write(self.name)
           binary.write(writer, binary.LittleEndian, self.age)
           binary.write(writer, binary.LittleEndian, self.fur_color)
I can see the argument for Go-style explicit error handling, but having this as the first best-practice example just doesn't sit right or sell it very well.

Edit: Okay, I guess I should have read the next slide before commenting. Still, the "one-off utility type" is longer and more complex than the original error handling (so I wouldn't do it unless you're using it elsewhere as well).



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

Search: