Comparison of programming languages by type system

Last updated

This is a comparison of the features of the type systems and type checking of multiple programming languages.

Brief definitions

Language Type safety Type expression Type compatibility and equivalence Type checking
A+ strongdynamic
ActionScript 3.0strongimplicit with optional explicit typingstatic
ABC strong
ABAP strongnominalstatic
Ada strong [TS 1] explicitnominalstatic
Agda strongnominalstatic
Aldor weakpartially implicit [1] static
Alef strongstatic
ALGOL 58 strongexplicitstatic
ALGOL 60 strongexplicitstatic
ALGOL 68 strongexplicitstructuralstatic & tagged unions
ALGOL W strongstatic
Alice strongimplicit with optional explicitstatic
Alma-0 static
AmbientTalk strongdynamic
AMOS BASIC static
AngelScript strongstatic
APL strongdynamic
AppleScript weakdynamic
Arc dynamic
Assembly ????
AutoHotkey typeless
AutoLISP dynamic
Ateji PX strongexplicitnominalstatic
AWK weakimplicitdynamic
B typeless
Ballerina strongstructuralstatic
Bash  ? ? ? ?
BASIC strongexplicitnominalstatic
BCPL typeless
BeanShell strongnominaldynamic
BLISS typeless
Boo strongimplicit with optional explicit typingstatic with optional dynamic typing
Bro strongimplicit with optional explicit typingnominalstatic
C weakexplicitnominalstatic
C-- weakstatic
C++ (ISO/IEC 14882)strongexplicit with optional implicit typing (by using auto in C++11)nominalstatic [TS 2]
C* weakexplicitstatic
C# strong [2] implicit with optional explicit typingnominalstatic [TS 3]
C shell  ? ? ? ?
Caml strongimplicit with optional explicit typingstatic
Cecil dynamic with optional static typing
Clean strongimplicitstatic
Ceylon strongstatic
Chapel implicit with optional explicit typingstatic
CHILL strongstatic
ChucK strong
Cilk weakexplicitstatic
Claire strongimplicit with optional explicit typingdynamic with optional static typing
Clean strong ?
Clojure strongimplicit with optional explicit typingdynamic
CLU strong
COBOL strongexplicitnominalstatic
Cobra strongexplicit with optional implicit typingstatic with optional dynamic typing
CoffeeScript implicitdynamic
ColdFusion (CFML)strongimplicitdynamic
COMAL strong
Common Lisp strongimplicit with optional explicit typingstructural for implicit typing, nominal for explicit typingdynamic, some static checking(depending on implementation)
Component Pascal strongstatic
Coolstrongexplicitstatic
CORAL strongstatic
Crystal implicit with optional explicit typing [3] structuralstatic
Cuneiform explicitstatic
Curl strongnominal
Curry strongimplicit with optional explicit typingstatic
Cython strongimplicit with optional explicit typingnominal (extension types) and structural (Python)dynamic with optional static typing
D weak [TS 4] explicitnominalstatic
Dart strong [4] gradual typingnominalstatic with optional dynamic typing
Dylan strongdynamic
Eiffel strongnominalstatic
Elixir strongimplicitdynamic
Erlang strongimplicitdynamic
Euphoria strongexplicit, implicit with objectsnominalstatic, dynamic with objects
F# strongimplicitnominalstatic
Forth typeless
Fortran strongexplicit [TS 5] nominalstatic
Gambas strongexplicitnominal
GLBasic strongexplicit. Non-explicit declarations available through project optionsnominalstatic
Gleam strongimplicit with optional explicitnominalstatic
Go [5] strongpartially implicit (local type inference)structuralstatic
Gosu strongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Groovy strongimplicit with optional explicit typingdynamic with optional static typing
Harbour strongimplicit with optional explicit typingdynamic
Haskell strongimplicit with optional explicit typingnominal [6] [7] static
Haxe strongimplicit with optional explicit typingnominal (subclassing) and structuralstatic with optional dynamic typing
Io strongimplicitdynamic
icon strongimplicitdynamic
ISLISP strongdynamic
J strongdynamic
Java strong [8] explicitnominalstatic
JavaScript weakimplicitdynamic
Julia strongimplicit with optional explicit typing [9] structural for implicit typing, nominal for explicit typingdynamic
Joy strongdynamic
Kotlin strongpartially implicit (local type inference)nominalstatic
LabVIEW strong
Lua strongimplicitdynamic
Maple strongdynamic
Mercury strongstatic
Mathematica strongdynamic
MATLAB M-codestrongdynamic
Modula-2 weak [TS 4] explicitnominalstatic
Modula-3 weak [TS 4] explicitstructuralstatic
MUMPS (M)typeless
Neko dynamic
Nemerle strongimplicitnominalstatic
NetLogo strongimplicitdynamic
NetRexx strongimplicit with optional explicitdynamic with optional static typing
newLisp implicitdynamic
NEWP strongstatic
Newspeak dynamic
NewtonScript dynamic
Nial dynamic
Nim strongpartially implicit (type inference)static
Nickle strong
Nu dynamic
Oberon strongexplicitnominalstatic and partially dynamic [TS 6]
Objective-C strongexplicitnominaldynamic with optional static typing [10]
OCaml strongimplicit with optional explicit typingnominal for records, [11] structural for objects [7] [12] static
Object Pascal strongexplicitnominalstatic
Opa strongimplicit with optional explicit typingstructuralstatic
Oxygene weakimplicitstatic
Oz-Mozart strongimplicitstructuraldynamic
Pascal weak [TS 4] explicitnominalstatic
Perl 5implicitdynamic
PHP weakimplicit with optional explicit typingnominaldynamic
Plus strongexplicitstructuralstatic, dynamic (optional)
Prolog dynamic
Pure dynamic
PureScript strongimplicit with optional explicit typingnominalstatic
Python strongimplicit (with optional explicit typing as of 3.5)nominaldynamic
R implicitdynamic
Raku partially implicit [TS 7] dynamic with optional static typing
REBOL strongimplicitdynamic
Rexx typeless—, implicit wrt numbersstatic+dynamic wrt numbers
RPG weakstatic
Ruby strongimplicitdynamic
Rust strongexplicit with optional implicit typing [13] mostly nominalstatic
S dynamic
S-Lang strongimplicitdynamic
Scala strongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Scheme strongimplicitdynamic (latent)
Seed7 strongexplicitnominalstatic
Simula strongstatic [TS 8]
Smalltalk strongimplicitdynamic
Swift strongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Standard ML strongimplicit with optional explicit typingstructuralstatic
Tcl dynamic
TypeScript  ?optionalstructuralstatic
Unicon strongimplicitdynamic
Visual Basic strongimplicit with optional explicit typingnominalstatic
Visual Basic (.NET) weak [TS 4] explicitstatic
Visual Prolog strongpartially implicitnominalstatic
Wolfram Language strongdynamic
Windows PowerShell strongimplicitdynamic
XL strongnominalstatic
Xojo strongexplicitnominalstatic
XPath/XQuery strongpartially implicitnominaldynamic with optional static typing
LanguageType safetyType expressionType compatibility and equivalenceType checking

Notes

  1. Unsafe operations are well isolated by a "Unchecked_" prefix.
  2. with optional dynamic type casting (see dynamic cast)
  3. with optional dynamic type (see dynamic member lookup)
  4. 1 2 3 4 5 It is almost safe, unsafe features are not commonly used.
  5. Optionally, typing can be explicitly implied by the first letter of the identifier (known as implicit typing within the Fortran community).
  6. dynamic checking of type extensions i.e. inherited types
  7. explicit for static types
  8. optional for formal and virtual procedures

References

  1. Aldor User Guide (PDF). Aldor.org. 2002. pp. 40, 61. Retrieved 3 June 2021.
  2. https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/
  3. "Type Inference Crystal". Crystal Language Reference. Retrieved 3 June 2021.
  4. "The Dart type system". dart.dev. Retrieved 2020-04-08.
  5. The Go Programming Language Specification
  6. Löh, Andres. "Why does Haskell not have records with structural typing?". Stack Overflow. Archived from the original on 2016-03-14. Retrieved 2020-04-13.
  7. 1 2 King, Alexis (2020-01-19). "No, dynamic type systems are not inherently more open". lexi-lambda.github.io. Archived from the original on 2020-03-01. Retrieved 2020-04-13.
  8. Sheng Liang, Gilad Bracha. Dynamic class loading in the Java virtual machine. Volume 33, Issue 10 of ACM SIGPLAN Notices, October 1998.
  9. "Types · the Julia Language". Archived from the original on 2018-07-24. Retrieved 2018-07-24.
  10. Developer.apple.com Archived June 10, 2009, at the Wayback Machine
  11. "Record · Reason". reasonml.github.io. Archived from the original on 2020-03-31. Retrieved 2020-04-13.
  12. "Structural type system", Wikipedia, 2019-03-29, retrieved 2020-04-13
  13. "rust-lang/rustc-dev-guide". GitHub. Retrieved 2020-04-08.