|
|
|
|
|
by ahoge
4974 days ago
|
|
>I think people waste a lot of time giving types to APIs and obscure the intention of the code What do you mean? Adding types to the surface area (arguments and return types) removes a lot of friction. I'm using jQuery for a couple of years. I still have to look at its docs almost every day I use it. Today, I had to check if the "selector" argument of "children()" is optional (spoiler: it is). Also, having the type annotations there makes the intention so much clearer. The name and the type of the argument is usually all you need to figure out what it does. I really like that about Dart. |
|
The API designers end up creating a multitude of APIs to deal with different type parameters and so on, to get their "generics" right and so on.
It makes the APIs look like Java APIs more than they jQuery ones.
Part of the problem is that the designers really want to get the types of classes and so on right on their parameters and return types. The types go beyond the primitives.
I've been able to watch it unfold and it's rather painful. The result looks less like a scripting language API and more like a C# collection of libraries, for better or for worse.