Search code examples
type-inferencestatic-typingimperative-programmingstructural-typing

Imperative languages with static, structural typing and global type inference


I know of languages like Haskell being statically typed and having type inference. But are there non-functional languages that have global type inference, the equivalent of something like C with type inference and structural typing.


Solution

  • OCaml is the only one I know which can be imperative/object-oriented that is statically typed, garbage collected and supports global type inference and structural typing, though it is essentially a functional language.

    Scala isn't a functional language like OCaml but an imperative/object-oriented language that supports structural typing, but does not have the kind of type inference you're looking for. It still supports functional constructs, though.

    If by "non-functional" you mean a language that doesn't support functional programming at all, then I don't think there is one.