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)weakexplicit with optional implicit typing (by using auto in C++11)nominalstatic [TS 2]
C* weakexplicitstatic
C# weak [TS 3] implicit with optional explicit typingnominalstatic [TS 4]
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 [2] 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 3] explicitnominalstatic
Dart strong [3] 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 [4] 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 [5] [6] static
Haxe strongimplicit with optional explicit typingnominal (subclassing) and structuralstatic with optional dynamic typing
Io strongimplicitdynamic
icon strongimplicitdynamic
ISLISP strongdynamic
J strongdynamic
Java strong [7] explicitnominalstatic
JavaScript weakimplicitdynamic
Julia strongimplicit with optional explicit typing [8] 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 3] explicitnominalstatic
Modula-3 weak [TS 3] 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 [9]
OCaml strongimplicit with optional explicit typingnominal for records, [10] structural for objects [6] [11] static
Object Pascal strongexplicitnominalstatic
Opa strongimplicit with optional explicit typingstructuralstatic
Oxygene weakimplicitstatic
Oz-Mozart strongimplicitstructuraldynamic
Pascal weak [TS 3] 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 [12] 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 3] 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. 1 2 3 4 5 6 It is almost safe, unsafe features are not commonly used.
  4. with optional dynamic type (see dynamic member lookup)
  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

Related Research Articles

OCaml is a general-purpose, high-level, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

Java and C++ are two prominent object-oriented programming languages. By many language popularity metrics, the two languages have dominated object-oriented and high-performance software development for much of the 21st century, and are often directly compared and contrasted. Java's syntax was based on C/C++.

<span class="mw-page-title-main">C++</span> General-purpose programming language

C++ is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programming language, it has since expanded significantly over time; as of 1997, C++ has object-oriented, generic, and functional features, in addition to facilities for low-level memory manipulation for systems like microcomputers or to make operating systems like Linux or Windows. It is usually implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Embarcadero, Oracle, and IBM.

ECMAScript is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is standardized by Ecma International in the document ECMA-262.

In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type to every term. Usually the terms are various language constructs of a computer program, such as variables, expressions, functions, or modules. A type system dictates the operations that can be performed on a term. For variables, the type system determines the allowed values of that term.

In computer programming, duck typing is an application of the duck test—"If it walks like a duck and it quacks like a duck, then it must be a duck"—to determine whether an object can be used for a particular purpose. With nominative typing, an object is of a given type if it is declared as such. With duck typing, an object is of a given type if it has all methods and properties required by that type. Duck typing may be viewed as a usage-based structural equivalence between a given object and the requirements of a type.

In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an expression from one data type to another. An example would be the conversion of an integer value into a floating point value or its textual representation as a string, and vice versa. Type conversions can take advantage of certain features of type hierarchies or data representations. Two important aspects of a type conversion are whether it happens implicitly (automatically) or explicitly, and whether the underlying data representation is converted from one representation into another, or a given representation is merely reinterpreted as the representation of another data type. In general, both primitive and compound data types can be converted.

In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors. Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that is, some facilities are type-safe and their usage will not result in type errors, while other facilities in the same language may be type-unsafe and a program using them may encounter type errors. The behaviors classified as type errors by a given programming language are usually those that result from attempts to perform operations on values that are not of the appropriate data type, e.g., adding a string to an integer when there's no definition on how to handle this case. This classification is partly based on opinion.

In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments.

Programming languages are used for controlling the behavior of a machine. Like natural languages, programming languages follow rules for syntax and semantics.

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under an MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

Memory safety is the state of being protected from various software bugs and security vulnerabilities when dealing with memory access, such as buffer overflows and dangling pointers. For example, Java is said to be memory-safe because its runtime error detection checks array bounds and pointer dereferences. In contrast, C and C++ allow arbitrary pointer arithmetic with pointers implemented as direct memory addresses with no provision for bounds checking, and thus are potentially memory-unsafe.

FriCAS is a general purpose computer algebra system with a strong focus on mathematical research and development of new algorithms. It comprises an interpreter, a compiler and a still-growing library of more than 1,000 domains and categories.

<span class="mw-page-title-main">Gilad Bracha</span> American software engineer

Gilad Bracha is a software engineer at F5 Networks, and formerly at Google, where he was on the Dart programming language team. He is creator of the Newspeak language, and co-author of the second and third editions of the Java Language Specification, and a major contributor to the second edition of the Java Virtual Machine Specification.

<span class="mw-page-title-main">Go (programming language)</span> Programming language

Go is a statically typed, compiled high-level programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. It is syntactically similar to C, but also has memory safety, garbage collection, structural typing, and CSP-style concurrency. It is often referred to as Golang because of its former domain name, golang.org, but its proper name is Go.

Gosu is a statically typed general-purpose programming language that runs on the Java Virtual Machine. Its influences include Java, C#, and ECMAScript. Development of Gosu began in 2002 internally for Guidewire Software, and the language saw its first community release in 2010 under the Apache 2 license.

In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed. However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages. For this reason, writers who wish to write unambiguously about type systems often eschew the terms "strong typing" and "weak typing" in favor of specific expressions such as "type safety".

Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications.

Gradual typing is a type system that lies inbetween static typing and in dynamic typing. Some variables and expressions may be given types and the correctness of the typing is checked at compile time and some expressions may be left untyped and eventual type errors are reported at runtime.

References

  1. Aldor User Guide (PDF). Aldor.org. 2002. pp. 40, 61. Retrieved 3 June 2021.
  2. "Type Inference Crystal". Crystal Language Reference. Retrieved 3 June 2021.
  3. "The Dart type system". dart.dev. Retrieved 2020-04-08.
  4. The Go Programming Language Specification
  5. 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.
  6. 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.
  7. Sheng Liang, Gilad Bracha. Dynamic class loading in the Java virtual machine. Volume 33, Issue 10 of ACM SIGPLAN Notices, October 1998.
  8. "Types · the Julia Language". Archived from the original on 2018-07-24. Retrieved 2018-07-24.
  9. Developer.apple.com Archived June 10, 2009, at the Wayback Machine
  10. "Record · Reason". reasonml.github.io. Archived from the original on 2020-03-31. Retrieved 2020-04-13.
  11. "Structural type system", Wikipedia, 2019-03-29, retrieved 2020-04-13
  12. "rust-lang/rustc-dev-guide". GitHub. Retrieved 2020-04-08.