4 ms·
> you can get some very good performance Compared to... ? > I appreciate golang's simplicity when I need to review other people's code or dig into third party
by atilaneves 7y ago
> you can get some very good performance
Compared to... ?
> I appreciate golang's simplicity when I need to review other people's code or dig into third party libraries.
See, I don't. Every for loop has to be inspected to see if it's one of the 99.9% cases where it's a map, reduce, or filter. For loops can't be chained. Error handling takes up over half of a function. An algorithm library can't be written because of the lack of generics.
Switching to Python, I'd much rather read:
[x for x in xs if x % 2 == 0]
Than:
res = []
for x in xs:
if x %2 == 0:
res.append(x)
3 lines of boilerplate to do 1 line of work. Pass.
Then there's the fact that everything is mutable in Go, so I have to track every and all variables in case they change.
All in all, for me, reviewing code written in it is harder, not easier.
- RodgerTheGreat 7y agoIn K, I'd much rather read (~2!)#x (Not (~) modulo 2 (2!) filter (#) of x.) Or perhaps more idiomatically, x@&~2!x (x indexed (@) where (&) not (~) modulo 2 (2!) of x.) Reading a python comprehension requires awkward skipping around, and composing them together is a mess. APL-style uniform precedence is something I wish more languages imitated. Still, anything's better than an endless sea of for loops.
- yellowapple 7y agoI'm disappointed that these are not valid Perl programs (the first is a syntax error, and the second complains about an array where an operator is expected).
- teyc 7y agoThe Python expression closely represents how it is done in maths. {x∣x∈N,x<10}