6 ms·
Wow, this code is so easy to read. Even though I might not use this package as I don't have any Go project in my pipeline, reading the code was a nice learning
by uniclaude 10y ago
Wow, this code is so easy to read.
Even though I might not use this package as I don't have any Go project in my pipeline, reading the code was a nice learning experience and just demystified a few things about image processing for me.
Go might not be one of my favorite languages, but its readability is just great (or maybe this codebase isn't idiomatic Go?).
- deleted 10y ago[deleted]
- IshKebab 10y agoAgreed, that is definitely one of the nice things about Go. Compared to something like Haskel, to pick an extreme example, it is so easy. Part of that is because there aren't any 'higher level' functions so you are forced to write everything out as explicit loops. Often a bit tedious but it is definitely easier to see what exactly is happening when reading the code. Side rant on Haskel: I really wanted to get into it, but when you see function signatures like this: add :: Integer -> Integer -> Integer You have to wonder what pipe they are smoking. I'm sure someone is going to tell me there is an obscure compsci reason why it couldn't have been this: add :: Integer, Integer -> Integer But that is just stupid, sorry.
- NhanH 10y agoWhat exactly is your complaint? That function signature wasn't written in the way you wanted? You could always just mentally read a->b->c->d as a,b,c->d and use it accordingly. Since you're touting the simplicity of Go, I can describe a reason why the function signatures is written like that: a,b,c->d would be a special case of a->b->c->d (multi-arity function without currying, I guess?), so it's not needed.
- Lio 10y agoI'm no expert but isn't the reason so that you know that it's a series of curried functions? If it was written as add :: Integer, Integer -> Integer that would imply that it was a single function taking 2 arguments and that if you called it with only 1 argument it would fail instead of returning you a curried add function (a bit like partial application but not exactly).
- mbel 10y agoI'm sure someone is going to tell me there is an obscure compsci reason why it couldn't have been this: [...] This "obscure" reason is actually one of the core features of the language and one of the reasons it's called Haskell. A thing that you are going to use all the time writing Haskell. The reason is called currying: https://en.m.wikipedia.org/wiki/Currying https://en.m.wikipedia.org/wiki/Currying
- tome 10y agoIt could have been add :: (Integer, Integer) -> Integer but then you couldn't write add 1 and use it as a function. And that would be just stupid, sorry.
- dpc_pw 10y agoIt's just a matter of syntx. After all it's rather common for people to want to do partial application to non-first argument: http://stackoverflow.com/questions/4553405/how-can-i-bind-the-second-argument-in-a-function-but-not-the-first-in-an-elegan http://stackoverflow.com/questions/4553405/how-can-i-bind-th... So something like: add 1 _ or whatever (I'm not Haskeller so hard for me to judge what exact syntax) would do. And then add _ 1 would be easily possible too.
- tome 10y agoAbsolutely, but then what would add _ (minus 1 _) mean? Not the same as let f = minus 1 _ in add _ f and things would get very weird very fast.