1425
Golang be like
(i.imgur.com)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Here's an example (first in Haskell then in Go), lets say you have some types/functions:
then you can make
for some reason <- in lemmy shows up as
<-
inside code blocks, so I used the left arrow unicode in the above insteadin Go you'd have these
Possible
type alias, Go can't do generic type aliases yet, there's an open issue for it)and with them you'd make:
In the Haskell, the fact that
Either
is a monad is saving you from a lot of boilerplate. You don't have to explicitly handle theLeft
/error case, if any of theEither
s end up being aLeft
value then it'll correctly "short-circuit" and the function will evaluate to thatLeft
value.Without using the fact that it's a functor/monad (e.g you have no access to fmap/>>=/do syntax), you'd end up with code that has a similar amount of boilerplate to the Go code (notice we have to handle each
Left
case now):