Comparison of programming languages by type system

This is a comparison of the features of the type systems and type checking of 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.
LanguageType safetyType expressionType compatibility and equivalenceType checking
A+strongdynamic
ActionScript 3.0strongimplicit with optional explicit typingstatic
ABCstrong
ABAPstrongnominalstatic
Adastrong[TS 1]explicitnominalstatic
Agdastrongnominalstatic
Aldorweakpartially implicit[1]static
Alefstrongstatic
ALGOL 58strongexplicitstatic
ALGOL 60strongexplicitstatic
ALGOL 68strongexplicitstructuralstatic & tagged unions
ALGOL Wstrongstatic
Alicestrongimplicit with optional explicitstatic
Alma-0static
AmbientTalkstrongdynamic
AMOS BASICstatic
AngelScriptstrongstatic
APLstrongdynamic
AppleScriptweakdynamic
Arcdynamic
Assembly????
AutoHotkeytypelessN/AN/AN/A
AutoLISPdynamic
Ateji PXstrongexplicitnominalstatic
AWKweakimplicitdynamic
Btypeless
Ballerinastrongstructuralstatic
Bash????
BASICstrongexplicitnominalstatic
BCPLtypeless
BeanShellstrongnominaldynamic
BLISStypelessN/AN/AN/A
Boostrongimplicit with optional explicit typingstatic with optional dynamic typing
Brostrongimplicit with optional explicit typingnominalstatic
Cweakexplicitnominalstatic
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????
Camlstrongimplicit with optional explicit typingstatic
Cecildynamic with optional static typing
Cleanstrongimplicitstatic
Ceylonstrongstatic
Chapelimplicit with optional explicit typingstatic
CHILLstrongstatic
ChucKstrong
Cilkweakexplicitstatic
Clairestrongimplicit with optional explicit typingdynamic with optional static typing
Cleanstrong?
Clojurestrongimplicit with optional explicit typingdynamic
CLUstrong
COBOLstrongexplicitnominalstatic
Cobrastrongexplicit with optional implicit typingstatic with optional dynamic typing
CoffeeScriptimplicitdynamic
ColdFusion (CFML)strongimplicitdynamic
COMALstrong
Common Lispstrongimplicit with optional explicit typingstructural for implicit typing, nominal for explicit typingdynamic, some static checking(depending on implementation)
Component Pascalstrongstatic
Coolstrongexplicitstatic
CORALstrongstatic
Crystalimplicit with optional explicit typing[3]structuralstatic
Cuneiformexplicitstatic
Curlstrongnominal
Currystrongimplicit with optional explicit typingstatic
Cythonstrongimplicit with optional explicit typingnominal (extension types) and structural (Python)dynamic with optional static typing
Dweak[TS 4]explicitnominalstatic
Dartstrong[4]gradual typingnominalstatic with optional dynamic typing
Dylanstrongdynamic
Eiffelstrongnominalstatic
Elixirstrongimplicitdynamic
Erlangstrongimplicitdynamic
Euphoriastrongexplicit, implicit with objectsnominalstatic, dynamic with objects
F#strongimplicitnominalstatic
ForthtypelessN/AN/AN/A
Fortranstrongexplicit[TS 5]nominalstatic
Gambasstrongexplicitnominal
GLBasicstrongexplicit. Non-explicit declarations available through project optionsnominalstatic
Gleamstrongimplicit with optional explicitnominalstatic
Go[5]strongpartially implicit (local type inference)structuralstatic
Gosustrongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Groovystrongimplicit with optional explicit typingdynamic with optional static typing
Harbourstrongimplicit with optional explicit typingdynamic
Haskellstrongimplicit with optional explicit typingnominal[6][7]static
Haxestrongimplicit with optional explicit typingnominal (subclassing) and structuralstatic with optional dynamic typing
Iostrongimplicitdynamic
iconstrongimplicitdynamic
ISLISPstrongdynamic
Jstrongdynamic
Javastrong[8]explicitnominalstatic
JavaScriptweakimplicitN/Adynamic
Juliastrongimplicit with optional explicit typing[9]structural for implicit typing, nominal for explicit typingdynamic
Joystrongdynamic
Kotlinstrongpartially implicit (local type inference)nominalstatic
LabVIEWstrong
Luastrongimplicitdynamic
Maplestrongdynamic
Mercurystrongstatic
Mathematicastrongdynamic
MATLAB M-codestrongdynamic
Modula-2weak[TS 4]explicitnominalstatic
Modula-3weak[TS 4]explicitstructuralstatic
MUMPS (M)typelessN/AN/AN/A
Nekodynamic
Nemerlestrongimplicitnominalstatic
NetLogostrongimplicitdynamic
NetRexxstrongimplicit with optional explicitdynamic with optional static typing
newLispimplicitdynamic
NEWPstrongstatic
Newspeakdynamic
NewtonScriptdynamic
Nialdynamic
Nimstrongpartially implicit (type inference)static
Nicklestrong
Nudynamic
Oberonstrongexplicitnominalstatic and partially dynamic[TS 6]
Objective-Cweakexplicitnominaldynamic with optional static typing[10]
OCamlstrongimplicit with optional explicit typingnominal for records,[11] structural for objects[7][12]static
Object Pascalstrongexplicitnominalstatic
Opastrongimplicit with optional explicit typingstructuralstatic
Oxygeneweakimplicitstatic
Oz-Mozartstrongimplicitstructuraldynamic
Pascalweak[TS 4]explicitnominalstatic
Perl 5implicitdynamic
PHPweakimplicit with optional explicit typingnominaldynamic
Plusstrongexplicitstructuralstatic, dynamic (optional)
Prologdynamic
Puredynamic
PureScriptstrongimplicit with optional explicit typingnominalstatic
Pythonstrongimplicit (with optional explicit typing as of 3.5)nominaldynamic
Rimplicitdynamic
Rakupartially implicit[TS 7]dynamic with optional static typing
REBOLstrongimplicitdynamic
RexxtypelessN/A, implicit wrt numbersN/Astatic+dynamic wrt numbers
RPGweakstatic
RubystrongimplicitN/Adynamic
Ruststrongexplicit with optional implicit typing[13]mostly nominalstatic
Sdynamic
S-Langstrongimplicitdynamic
Scalastrongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Schemestrongimplicitdynamic (latent)
Seed7strongexplicitnominalstatic
Simulastrongstatic[TS 8]
Smalltalkstrongimplicitdynamic
Swiftstrongpartially implicit (local type inference)nominal (subclassing) and structuralstatic
Standard MLstrongimplicit with optional explicit typingstructuralstatic
Tcldynamic
TypeScriptstrongoptionalstructuralstatic
Uniconstrongimplicitdynamic
Visual Basicstrongimplicit with optional explicit typingnominalstatic
Visual Basic (.NET)weak[TS 4]explicitstatic
Visual Prologstrongpartially implicitnominalstatic
Wolfram Languagestrongdynamic
Windows PowerShellstrongimplicitdynamic
XLstrongnominalstatic
Xojostrongexplicitnominalstatic
XPath/XQuerystrongpartially 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. ^ a b c d e 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/ [bare URL]
  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. ^ a b 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.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Comparison_of_programming_languages_by_type_system&oldid=1308133048"