Hacker News new | ask | show | jobs
by sausagefeet 5204 days ago
Ii have not used Scala but I have found the opposite to be true in Ocaml and Haskell. The type definition of a function is quite often sufficient information to infer the usage. I think this is because of the type variables. Looking at the definition of fold in Ocaml, for example, it becomes very obvious what is the input output init and the signature of your function from the type where such information generally seems to be less clear in C-like languages.
2 comments

The point is not whether you have sufficient information to infer the usage. Do you have to infer the idiom at all? Usage is homomorphic with declaration in C, so this step is unnecessary.
I don't follow what you mean, I'm saying a list of function types contains vastly more useful information than a list of C function types.
The same is pretty much true with Scala.

The only exception where the signatures are really long and complex are parts of the collection infrastructure, because Scala developers tried to make it work as intuitively for users as possible: E.g. making non-collection classes support collection operations, always returning the most "precise" type, etc. etc, which is very hard and painful work not done in any other language to this day.

In the end while I hope signatures get shorter and more like the use case signatures already existing in documentation, I don't think it matters much.

Untyped languages have more or less no useful signature at all and they are still pretty much alive.