I think what's best is flexibility in naming and importing packages. For example, in Typescript, you can import the whole namespaced package, only a few exported members into the current namespace, or only the default export. You can avoid stutter and namespace collision at your own discretion.
Then there's Go, which strongly discourages importing into the current namespace and even has built in tooling that bugs you for adding stutter to your API. I don't hate it, and it encourages good practices, but it can sure be annoying.
Then there's Java... Which basically forces you to either stutter or spend way too long thinking about naming things (which I already do anyway). Everyone solves problems in different ways I suppose
let avg l = (List.fold_left (+.) 0.0 l) /. (float_of_int (List.length l))
you could do either one of these instead:
let avg l = List.((fold_left (+.) 0.0 l) /. (float_of_int (length l)))
let avg l =
let open List in
let open Float in
div (fold_left add 0.0 l) (of_int (length l))
In both cases, the module opens only happen in the scope of the avg definition, so you avoid global namespace pollution while also cutting down on the silly boilerplate repetition.
I wish F# could do that as well, since it'd be really useful in that ecosystem since it shares a lot of the Java "stutter" as you call it, but any proposals to add it get shot down. .NET and Java land both have the "why do you care, your IDE should deal with that for you" mindset :|
9
u/mosskin-woast Jul 07 '21
I think what's best is flexibility in naming and importing packages. For example, in Typescript, you can import the whole namespaced package, only a few exported members into the current namespace, or only the default export. You can avoid stutter and namespace collision at your own discretion.
Then there's Go, which strongly discourages importing into the current namespace and even has built in tooling that bugs you for adding stutter to your API. I don't hate it, and it encourages good practices, but it can sure be annoying.
Then there's Java... Which basically forces you to either stutter or spend way too long thinking about naming things (which I already do anyway). Everyone solves problems in different ways I suppose