Comparison of programming languages by type system
From Wikipedia, the free encyclopedia
|
|
It has been suggested that Comparison of type systems be merged into this article. (Discuss) Proposed since May 2016. |
This comparison of programming languages (type system) compares the features of type systems or their type checking for multiple programming languages.
Brief definitions
- A nominal type system means that the language decides whether types are compatible and/or equivalent based on explicit declarations and names.
- A structural type system means that the language decides whether types are compatible and/or equivalent based on the definition and characteristics of the types.
- Type checking determines whether and when types are verified. Static checking means that type errors are reported based on a program's text (source code). Dynamic checking means that type errors are reported based on a program's dynamic (run-time) behavior.
| Language | Type safety | Type expression | Type compatibility and equivalence | Type checking |
|---|---|---|---|---|
| ActionScript 3.0 | strong | implicit with optional explicit typing | static | |
| Ada | strong[TS 1] | explicit | nominal | static |
| Aldor | weak | implicit | static | |
| ALGOL 58 | strong | explicit | static | |
| ALGOL 60 | strong | explicit | static | |
| ALGOL 68 | strong | explicit | structural | static & tagged unions |
| APL | strong | dynamic | ||
| AutoHotkey | typeless | n/a | n/a | n/a |
| Ateji PX | strong | explicit | nominal | static |
| Bash | ? | ? | ? | ? |
| BASIC | strong | explicit | nominal | static |
| BLISS | typeless | n/a | n/a | n/a |
| BeanShell | strong | nominal | dynamic | |
| Boo | strong | implicit with optional explicit typing | static with optional dynamic typing | |
| Bro | strong | implicit with optional explicit typing | nominal | static |
| C | weak | explicit | nominal | static |
| C++ (ISO/IEC 14882) | weak | explicit | nominal | static[TS 2] |
| C# | weak[TS 3] | implicit with optional explicit typing | nominal | static[TS 4] |
| Clean | strong | implicit | static | |
| Clojure | strong | implicit with optional explicit typing | dynamic | |
| COBOL | strong | explicit | nominal | static |
| ColdFusion (CFML) | strong | implicit | dynamic | |
| Common Lisp | strong | implicit with optional explicit typing | dynamic | |
| Curl | strong | nominal | ||
| Cython | strong | implicit with optional explicit typing | nominal (extension types) and structural (Python) | dynamic with optional static typing |
| D | weak[TS 3] | explicit | nominal | static |
| Dylan | strong | dynamic | ||
| Eiffel | strong | nominal | static | |
| Erlang | strong | implicit | dynamic | |
| Euphoria | strong | explicit, implicit with objects | nominal | static, dynamic with objects |
| F# | strong | implicit | nominal | static |
| Falcon | strong | implicit | structural | dynamic |
| Forth | typeless | n/a | n/a | n/a |
| Fortran | strong | explicit[TS 5] | nominal | static |
| Gambas | strong | explicit | nominal | |
| GLBasic | strong | explicit. Non-explicit declarations available through project options | nominal | static |
| Go[1] | strong | implicit with optional explicit typing | structural | static |
| Gosu | strong | partially implicit (local type inference) | nominal (subclassing) and structural (structural) | static |
| Groovy | strong | implicit with optional explicit typing | dynamic with optional static typing | |
| Harbour | strong | implicit with optional explicit typing | dynamic | |
| Haskell | strong | implicit with optional explicit typing | structural | static |
| Haxe | strong | implicit with optional explicit typing | nominal (subclassing) and structural (structural) | static with optional dynamic typing |
| Io | strong | implicit | dynamic | |
| ISLISP | strong | dynamic | ||
| J | strong | dynamic | ||
| Java | strong[2] | explicit | nominal | static |
| JavaScript | strong | implicit | structural | dynamic |
| Julia | strong | implicit with optional explicit typing[3] | structural for implicit typing, nominal for explicit typing | dynamic |
| Joy | strong | dynamic | ||
| Kotlin | strong | partially implicit (local type inference) | nominal | static |
| LabVIEW | strong | |||
| Lua | strong | implicit | dynamic | |
| Maple | strong | dynamic | ||
| Mathematica | strong | dynamic | ||
| MATLAB M-code | strong | dynamic | ||
| Modula-2 | weak[TS 3] | explicit | nominal | static |
| Modula-3 | weak[TS 3] | explicit | structural | static |
| MUMPS (M) | typeless | n/a | n/a | n/a |
| Oberon | strong | explicit | nominal | static and partially dynamic[TS 6] |
| Objective-C | strong | explicit | nominal | dynamic with optional static typing[4] |
| OCaml | strong | implicit with optional explicit typing | structural (records are nominal) | static |
| Object Pascal | strong | explicit | nominal | static |
| Opa | strong | implicit with optional explicit typing | structural | static |
| Oxygene | weak | implicit | static | |
| Oz-Mozart | strong | implicit | structural | dynamic |
| Pascal | weak[TS 3] | explicit | nominal | static |
| Perl 5 | implicit | dynamic | ||
| Perl 6 | partially implicit[TS 7] | dynamic with optional static typing | ||
| PHP | implicit with optional explicit typing | nominal | dynamic | |
| Plus | strong | explicit | structural | static, dynamic (optional) |
| Prolog | dynamic | |||
| Pure | dynamic | |||
| Python | strong | implicit (with optional explicit typing as of 3.5) | structural | dynamic |
| REBOL | strong | implicit | dynamic | |
| Rexx | typeless | n/a, implicit wrt numbers | n/a | static+dynamic wrt numbers |
| RPG | weak | static | ||
| Ruby | strong | implicit | structural | dynamic |
| Rust | strong | implicit with optional explicit typing | static | |
| S | dynamic | |||
| S-Lang | strong | implicit | dynamic | |
| Scala | strong | partially implicit (local type inference) | nominal (subclassing) and structural (structural) | static |
| Scheme | strong | implicit | dynamic (latent) | |
| Seed7 | strong | explicit | nominal | static |
| Simula | strong | static[TS 8] | ||
| Smalltalk | strong | implicit | dynamic | |
| Swift | strong | partially implicit (local type inference) | nominal (subclassing) and structural (structural) | static |
| Standard ML | strong | implicit with optional explicit typing | structural | static |
| Tcl | dynamic | |||
| Visual Basic | strong | implicit with optional explicit typing | nominal | static |
| Visual Basic .NET | weak[TS 3] | explicit | static | |
| Visual Prolog | strong | partially implicit | nominal | static |
| Wolfram Language | strong | dynamic | ||
| Windows PowerShell | strong | implicit | dynamic | |
| XL | strong | nominal | static | |
| Xojo | strong | explicit | nominal | static |
| XPath/XQuery | strong | partially implicit | nominal | dynamic with optional static typing |
| Language | Type safety | Type expression | Type compatibility among composites | Type checking |
- ^ Unsafe operations are well isolated by a "Unchecked_" prefix.
- ^ with optional dynamic type casting (see dynamic cast)
- ^ a b c d e f It is almost safe, unsafe features are not commonly used.
- ^ with optional dynamic type (see dynamic member lookup)
- ^ Optionally, typing can be explicitly implied by the first letter of the identifier (known as implicit typing within the Fortran community).
- ^ dynamic checking of type extensions i.e. inherited types
- ^ explicit for static types
- ^ optional for formal and virtual procedures
- ^ The Go Programming Language Specification
- ^ Sheng Liang, Gilad Bracha. Dynamic class loading in the Java virtual machine. Volume 33, Issue 10 of ACM SIGPLAN Notices, October 1998.
- ^ http://julia.readthedocs.org/en/latest/manual/types/
- ^ Developer.apple.com Archived June 10, 2009, at the Wayback Machine.