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
AutoHotkey typeless
AutoLISP dynamic
Ateji PX strongexplicitnominalstatic
AWK ????
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
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
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 among compositesType 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 appeared about 10 years later and its syntax was based on C/C++.

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 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. Type systems formalize and enforce the otherwise implicit categories the programmer uses for algebraic data types, data structures, or other components.

Duck typing in computer programming 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 to be. In duck typing, an object is of a given type if it has all methods and properties required by that type. Duck typing can be viewed as a usage-based structural equivalence between a given object and the requirements of a type. See structural typing for a further explanation of structural type equivalence.

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.

<span class="mw-page-title-main">C Sharp (programming language)</span> Multi-paradigm (object-oriented) programming language

C# is a general-purpose high-level programming language supporting multiple paradigms. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are aimed to address criticisms of Java.

In computer science, a type system is a nominal or nominative type system if compatibility and equivalence of data types is determined by explicit declarations and/or the name of the types. Nominal systems are used to determine if types are equivalent, as well as if a type is a subtype of another. Nominal type systems contrast with structural systems, where comparisons are based on the structure of the types in question and do not require explicit declarations.

Haxe is an open source 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 the MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

TypeScript is a free and open source high-level programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large applications and transpiles to JavaScript. As it is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs.

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 with 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.

<span class="mw-page-title-main">Rust (programming language)</span> General-purpose programming language

Rust is a multi-paradigm, high-level, general-purpose programming language. Rust emphasizes performance, type safety, and concurrency. Rust enforces memory safety—that is, that all references point to valid memory—without requiring the use of a garbage collector or reference counting present in other memory-safe languages. To simultaneously enforce memory safety and prevent concurrent data races, Rust's "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust is popular for systems programming but also offers high-level features including some functional programming constructs.

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. The programming language is designed for client development such as for the web and mobile apps, and it can also be used to build server and desktop applications.

Gradual typing is a type system in which 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. Gradual typing allows software developers to choose either type paradigm as appropriate, from within a single language. In many cases gradual typing is added to an existing dynamic language, creating a derived language allowing but not requiring static typing to be used. In some cases a language uses gradual typing from the start.

<span class="mw-page-title-main">Angular (web framework)</span> Open source web application framework

Angular is a TypeScript-based, free and open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations. Angular is a complete rewrite from the same team that built AngularJS. Angular is a Single Page Application Framework which is used for creating Fast Web Applications. It uses concepts of SPA in which UI is delivered in the beginning of application request and later only data is requested which makes SPA applications fast.

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.