Hacker News new | ask | show | jobs
by chimeracoder 4669 days ago
<nitpick type="obligatory">The name of the language is Go, not "Google Golang"</nitpick>

That said, this was, for me, the single weirdest thing to get used to when starting to program in Go, coming from a mostly Python/Java exception-style background. (I imagine it's easier if you're a C programmer).

However, once I got into the swing of it, I realized I really, really like Go's error handling, and I can't imagine going back to Python's exceptions voluntarily. Returning errors makes code much more readable, and it also reduces the risk of code suddenly failing because of an exception that got thrown somewhere that you can't even find easily.

Go also gets a more subtle point correct: errors are interfaces, not types, which means that you can use any type as an error, as long as it supports the "Error() string" method. This is irrelevant 99% of the time, but I've seen a few pieces of code which utilize this feature very effectively.

1 comments

I have to say, I much prefer people referring to it as Golang, otherwise it is impossible to search for.
this is honestly the most annoying thing about go for me. Really hard to do a quick google search for an answer to something!
I'm endlessly amused by the irony of a search engine company naming their projects unsearchable words. Many site search engines won't even consider terms less than three characters long.
Try "Django" with that new "Django Unchained" movie ;-)
For all these language issues, I generally preface the query with the language name. "Python3 Django", "Haskell Quickcheck", "C++ Boost", etc. It makes things so much easier for the search engine to give me Good Results (tm) when it has that extra bit of context.