Operators
editSee Operator (computer programming).
Programming language | Nonalphanumeric operator symbols | Alphanumeric operator symbols | Prefix | Infix | Postfix | Precedence | Associativity | Overloading | Programmer-defined overloading | Programmer-defined operator symbols |
---|---|---|---|---|---|---|---|---|---|---|
ALGOL 68 | +* ** * / % %* %? - + < <= >= > = /= & -:= +:= *:= /:= %:= %*:= +=: :=: :/=:
(All operators have bold Alphanumeric equivalents, c.f. next column. Some have non ASCII equivalents, c.f. below.) ¬ +? ? ^ v ? ? ? ? ?? ?* ? ? ? ? ? ? ?:= ?:= ??:= ?*:= %?:= :?: |
not abs arg bin entier leng level odd repr round shorten i shl shr up down lwb upb lt le ge gt eq ne and or over mod elem minusab plusab timesab divab overab modab plusto is isnt | Yes | Yes | No | Yes (prefix operators always have priority 10) | Infix operators are left associative, prefix operators are right associative | Yes | Yes | Yes |
C | () [] -> . ! ~ ++ -- + - * & / % << >> < <= > <= == != ^ | && || ?: = += -= *= /= %= &= ^= |= <<= >>= | sizeof | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
C++ (more) | sizeof typeid new delete throw decltype static_cast dynamic cast reinterpret_cast const_cast | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | |
Java | new instanceof | Yes | Yes | Yes | Yes | Yes | Yes | No | No | |
Haskell | + - * / ^ ^^ ** == /= > < >= <= && || >>= >> $ $! . ++ !! : Many more in common libraries | The function's name must be put into backticks | Yes | Yes | No | Yes | Yes | Yes, using Type classes | Yes | |
Pascal | * / + - = < > <> <= >= := | not div mod and or in | Yes | Yes | No | Yes | Yes | Yes | No | No |
Seed7 | {} [] -> ** ! + - * / << >> & >< | = <> > >= < <= <& := +:= -:= *:= /:= <<:= >>:= &:= @:= | conv varConv parse conj div rem mdiv mod times mult in not and or digits lpad rpad lpad0 | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Eiffel | [] + - * / // = /= | not and or implies "and then" "or else" | Yes | Yes | No | Yes | Yes | No | Yes | Yes |
Prolog | spy nospy not is mod | Yes | Yes | Yes | Yes | Yes | No | No | Yes | |
Lisp | Lisp defines all functions and symbols as operators.[1] Following the definition in this page, Lisp has no operators. | Yes (operators are regular functions) | No | No | No | No | No | No | Yes | |
Smalltalk | (yes - Up to two characters[2]) | Alphanumeric symbols need a colon after the keyword | No | Yes | Yes | No | No | Yes | Yes | Yes |
Perl | -> ++ -- ** ! ~ \ + - . =~ !~ * / % < > <= >= == != <=> ~~ & | ^ && || ' | print sort chmod chdir rand and or not xor lt gt le ge eq ne cmp x | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No |
Ternary comparsion operator
editComparison of programming languages (operators, ternary comparsion)
Type systems
editThis 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.
Language | Type safety | Type expression | Type compatibility and equivalence | Type checking |
---|---|---|---|---|
A+ | strong | dynamic | ||
ActionScript 3.0 | strong | implicit with optional explicit typing | static | |
ABC | strong | |||
ABAP | strong | nominal | static | |
Ada | strong[TS 1] | explicit | nominal | static |
Agda | strong | nominal | static | |
Aldor | weak | partially implicit[3] | static | |
Alef | strong | static | ||
ALGOL 58 | strong | explicit | static | |
ALGOL 60 | strong | explicit | static | |
ALGOL 68 | strong | explicit | structural | static & tagged unions |
ALGOL W | strong | static | ||
Alice | strong | implicit with optional explicit | static | |
Alma-0 | static | |||
AmbientTalk | strong | dynamic | ||
AMOS BASIC | static | |||
AngelScript | strong | static | ||
APL | strong | dynamic | ||
AppleScript | weak | dynamic | ||
Arc | dynamic | |||
Assembly | ? | ? | ? | ? |
AutoHotkey | typeless | — | — | — |
AutoLISP | dynamic | |||
Ateji PX | strong | explicit | nominal | static |
AWK | weak | implicit | dynamic | |
B | typeless | |||
Ballerina | strong | structural | static | |
Bash | ? | ? | ? | ? |
BASIC | strong | explicit | nominal | static |
BCPL | typeless | |||
BeanShell | strong | nominal | dynamic | |
BLISS | typeless | — | — | — |
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-- | weak | static | ||
C++ (ISO/IEC 14882) | weak | explicit with optional implicit typing (by using auto in C++11) | nominal | static[TS 2] |
C* | weak | explicit | static | |
C# | weak[TS 3] | implicit with optional explicit typing | nominal | static[TS 4] |
C shell | ? | ? | ? | ? |
Caml | strong | implicit with optional explicit typing | static | |
Cecil | dynamic with optional static typing | |||
Clean | strong | implicit | static | |
Ceylon | strong | static | ||
Chapel | implicit with optional explicit typing | static | ||
CHILL | strong | static | ||
ChucK | strong | |||
Cilk | weak | explicit | static | |
Claire | strong | implicit with optional explicit typing | dynamic with optional static typing | |
Clean | strong | ? | ||
Clojure | strong | implicit with optional explicit typing | dynamic | |
CLU | strong | |||
COBOL | strong | explicit | nominal | static |
Cobra | strong | explicit with optional implicit typing | static with optional dynamic typing | |
CoffeeScript | implicit | dynamic | ||
ColdFusion (CFML) | strong | implicit | dynamic | |
COMAL | strong | |||
Common Lisp | strong | implicit with optional explicit typing | structural for implicit typing, nominal for explicit typing | dynamic, some static checking(depending on implementation) |
Component Pascal | strong | static | ||
Cool | strong | explicit | static | |
CORAL | strong | static | ||
Crystal | implicit with optional explicit typing[4] | structural | static | |
Cuneiform | explicit | static | ||
Curl | strong | nominal | ||
Curry | strong | implicit with optional explicit typing | static | |
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 |
Dart | strong[5] | gradual typing | nominal | static with optional dynamic typing |
Dylan | strong | dynamic | ||
Eiffel | strong | nominal | static | |
Elixir | strong | implicit | dynamic | |
Erlang | strong | implicit | dynamic | |
Euphoria | strong | explicit, implicit with objects | nominal | static, dynamic with objects |
F# | strong | implicit | nominal | static |
Forth | typeless | — | — | — |
Fortran | strong | explicit[TS 5] | nominal | static |
Gambas | strong | explicit | nominal | |
GLBasic | strong | explicit. Non-explicit declarations available through project options | nominal | static |
Gleam | strong | implicit with optional explicit | nominal | static |
Go[6] | strong | partially implicit (local type inference) | structural | static |
Gosu | strong | partially implicit (local type inference) | nominal (subclassing) and 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 | nominal[7][8] | static |
Haxe | strong | implicit with optional explicit typing | nominal (subclassing) and structural | static with optional dynamic typing |
Io | strong | implicit | dynamic | |
icon | strong | implicit | dynamic | |
ISLISP | strong | dynamic | ||
J | strong | dynamic | ||
Java | strong[9] | explicit | nominal | static |
JavaScript | weak | implicit | — | dynamic |
Julia | strong | implicit with optional explicit typing[10] | 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 | ||
Mercury | strong | static | ||
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 | — | — | — |
Neko | dynamic | |||
Nemerle | strong | implicit | nominal | static |
NetLogo | strong | implicit | dynamic | |
NetRexx | strong | implicit with optional explicit | dynamic with optional static typing | |
newLisp | implicit | dynamic | ||
NEWP | strong | static | ||
Newspeak | dynamic | |||
NewtonScript | dynamic | |||
Nial | dynamic | |||
Nim | strong | partially implicit (type inference) | static | |
Nickle | strong | |||
Nu | dynamic | |||
Oberon | strong | explicit | nominal | static and partially dynamic[TS 6] |
Objective-C | strong | explicit | nominal | dynamic with optional static typing[11] |
OCaml | strong | implicit with optional explicit typing | nominal for records,[12] structural for objects[8][13] | 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 | ||
PHP | weak | implicit with optional explicit typing | nominal | dynamic |
Plus | strong | explicit | structural | static, dynamic (optional) |
Prolog | dynamic | |||
Pure | dynamic | |||
PureScript | strong | implicit with optional explicit typing | nominal | static |
Python | strong | implicit (with optional explicit typing as of 3.5) | nominal | dynamic |
R | implicit | dynamic | ||
Raku | partially implicit[TS 7] | dynamic with optional static typing | ||
REBOL | strong | implicit | dynamic | |
Rexx | typeless | —, implicit wrt numbers | — | static+dynamic wrt numbers |
RPG | weak | static | ||
Ruby | strong | implicit | — | dynamic |
Rust | strong | explicit with optional implicit typing[14] | mostly nominal | static |
S | dynamic | |||
S-Lang | strong | implicit | dynamic | |
Scala | strong | partially implicit (local type inference) | nominal (subclassing) and 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 | static |
Standard ML | strong | implicit with optional explicit typing | structural | static |
Tcl | dynamic | |||
TypeScript | ? | optional | structural | static |
Unicon | strong | implicit | 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 and equivalence | Type checking |
Notes
edit- ^ 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
References
edit- ^ "The Common Lisp HyperSpec".
- ^ Goldberg, Adele. "Smalltalk-80: The Language and its Implementation, p. 27, ISBN 0-201-11371-6" (PDF).
- ^ Aldor User Guide (PDF). Aldor.org. 2002. pp. 40, 61. Retrieved 3 June 2021.
- ^ "Type Inference Crystal". Crystal Language Reference. Retrieved 3 June 2021.
- ^ "The Dart type system". dart.dev. Retrieved 2020-04-08.
- ^ The Go Programming Language Specification
- ^ 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.
- ^ 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.
- ^ Sheng Liang, Gilad Bracha. Dynamic class loading in the Java virtual machine. Volume 33, Issue 10 of ACM SIGPLAN Notices, October 1998.
- ^ "Types · the Julia Language". Archived from the original on 2018-07-24. Retrieved 2018-07-24.
- ^ Developer.apple.com Archived June 10, 2009, at the Wayback Machine
- ^ "Record · Reason". reasonml.github.io. Archived from the original on 2020-03-31. Retrieved 2020-04-13.
- ^ "Structural type system", Wikipedia, 2019-03-29, retrieved 2020-04-13
- ^ "rust-lang/rustc-dev-guide". GitHub. Retrieved 2020-04-08.
Dependent types
editSee Dependent types.
Language | Actively developed | Paradigm[fn 1] | Tactics | Proof terms | Termination checking | Types can depend on[fn 2] | Universes | Proof irrelevance | Program extraction | Extraction erases irrelevant terms |
---|---|---|---|---|---|---|---|---|---|---|
Agda | Yes[1] | Purely functional | Few/limited[fn 3] | Yes | Yes (optional) | Any term | Yes (optional)[fn 4] | Proof-irrelevant arguments (experimental)[3] | Haskell, JavaScript | Yes[3] |
ATS | Yes[4] | Functional / imperative | No[5] | Yes | Yes | ? | ? | ? | Yes | ? |
Cayenne | No | Purely functional | No | Yes | No | Any term | No | No | ? | ? |
Gallina (Coq) |
Yes[6] | Purely functional | Yes | Yes | Yes | Any term | Yes[fn 5] | No | Haskell, Scheme, OCaml | Yes |
Dependent ML | No[fn 6] | ? | ? | Yes | ? | Natural numbers | ? | ? | ? | ? |
F* | Yes[7] | Functional and imperative | No | Yes | Yes (optional) | Any pure term | Yes | Yes | OCaml and F# | Yes |
Guru | No[8] | Purely functional[9] | hypjoin[10] | Yes[9] | Yes | Any term | No | Yes | Carraway | Yes |
Idris | Yes[11] | Purely functional[12] | Yes[13] | Yes | Yes (optional) | Any term | Yes | No | Yes | Yes, aggressively[13] |
Matita | Yes[14] | Purely functional | Yes | Yes | Yes | Any term | Yes | Yes | OCaml | Yes |
NuPRL | Yes | Purely functional | Yes | Yes | Yes | Any term | Yes | ? | Yes | ? |
Perl 6 | Yes | Functional and imperative | No | No | No | Any term[15] | No | No | No | No |
PVS | Yes | ? | Yes | ? | ? | ? | ? | ? | ? | ? |
Sage | No[fn 7] | Purely functional | No | No | No | ? | No | ? | ? | ? |
Twelf | Yes | Logic programming | ? | Yes | Yes (optional) | Any (LF) term | No | No | ? | ? |
Xanadu | No[16] | Imperative | ? | ? | ? | ? | ? | ? | ? | ? |
Duck typing
editComparison of programming languages (types, duck typing)
Cite error: There are <ref group=fn>
tags on this page, but the references will not show without a {{reflist|group=fn}}
template (see the help page).
- ^ "Agda download page".
- ^ "Agda Ring Solver".
- ^ a b "Announce: Agda 2.2.8".
- ^ "ATS2 downloads".
- ^ "email from ATS inventor Hongwei Xi".
- ^ "Coq changes in Subversion repository".
- ^ "F* changes on GitHub".
- ^ "Guru SVN".
- ^ a b Aaron Stump (6 April 2009). "Verified Programming in Guru" (PDF). Retrieved 28 September 2010.
- ^ Adam Petcher (1 April 2008). "Deciding Joinability Modulo Ground Equations in Operational Type Theory" (PDF). Retrieved 14 October 2010.
- ^ "Idris git repository".
- ^ "Idris, a language with dependent types - extended abstract" (PDF).
- ^ a b Edwin Brady. "How does Idris compare to other dependently-typed programming languages?".
- ^ "Matita SVN".
- ^ "Types and Subtypes".
- ^ "Xanadu home page".