Imperative languages ​​with static, structural typing, and global output type

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

+4
source share
3 answers

OCaml is the only thing I know that can be mandatory / object oriented, statically typed, garbage collection and support for global type inference and structural typing, although this is essentially a functional language.

Scala is not a functional language, such as OCaml, but a required / object-oriented language that supports structural typing but does not have the type of output type you are looking for . However, it still supports functional constructs.

If "non-functional" you mean a language that does not support functional programming at all, then I do not think that it exists.

+1
source

OCaml is no longer the only competitor. In recent years, a number of structurally typed imperative languages ​​have appeared:

  • F # , like OCaml , is a multi- paradigm language that supports complex pattern matching and both imperative and functional programming. Derived from OCaml, the two languages ​​are actually so similar that the prohibiting minor differences are practically compatible with the source code . The main advantage of [dis?] Is that it runs on .NET.
  • Go is the favorite of the original Unix / Plan 9 / Inferno team since joining Google, based on their decades of work on compilers for these systems. Go supports structural polymorphism in the sense that composition of an object is its primary mechanism for imprinting, and the interfaces of this method should not be explicitly implemented.
  • Haxe is a derivative of ActionScript designed to compile on a large number of platforms, including C ++ (!). It supports fully structural types and enumerations (equivalent to OCaml unions) together with a hierarchy of C # class objects and has a complex macro system.
+1
source

There is also Crystal, but it is in the preliminary alpha stage:

https://github.com/manastech/crystal

0
source

Source: https://habr.com/ru/post/1442419/


All Articles