Few Annoying Things about Go
As promised, a few thoughts about Go that is annoying.
No Generics
Code generation is tightly coupled with the tool chain. When I need to use code generation, i.e., enums and mocks, the use case can be solved with generics instead.
No lambda syntax
Scala has a lambda syntax to make it easy to work with anonymous function objects
val numbers = Seq(1, 5, 2, 100)
val doubled = numbers.map(
n => n * 2
)
Java has a similar syntax
List<Integer> numbers = Lists.newArrayList(
1, 5, 2, 100
);
numbers.sort(
(n1, n2) -> n2 - n1
);
In these languages, the type signature of the anonymous function are inferred. For scala, the anonymous function is
inferred to have a single integer
as the input and a single integer
as output. For Java, the anonymous function is
inferred to have two Integer
s as the input and an int
as the output.
I really wish Go supported this. But it doesn’t.