Hacker News new | past | comments | ask | show | jobs | submit login

> The entirety of gradual typing works by type inference

Is not a correct statement. You can use gradual typing with explicit type annotations or via inference, it makes no difference to the concept of gradual typing. Gradual typing itself is a way of handling the case of a language being both statically and dynamically typed and handling the interaction between the two portions.




Well, technically you can have gradual typing without inference. But you'll need to annotate every single value to get any matching out of it. If you do any language like that, the types will be only useful for documentation purposes.


> But you'll need to annotate every single value to get any matching out of it.

Ok, if we're taking "1 is an int" as type inferencing then, yes, every statically typed language, at least every mainstream one, has at least a small amount of type inference since we don't, in C for instance, have to annotate values. But C does not infer the types of its variables or functions, nor do you have to annotate them in every location where they are used. But that's not inference either, that's using the information determined by annotating the variables.

----------

My main point was that it's weird to say the entirety of gradual typing works by type inference. It works by permitting mixing statically typed and dynamically typed code together in one language. Whether the statically typed portion uses type inference or more "classical" type annotations is orthogonal to the way it works under the hood.


You can have an explicit "any" or "dynamic" type that can be used in place of a static type where you want dynamism. C# actually has this.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: