Difference between revisions of "Motoko (programming language)"

From Internet Computer Wiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Summary==
 
==Summary==
  
The Motoko programming language is a new, modern and type safe language for developers who want to build the next generation of distributed applications to run on the Internet Computer blockchain network. Motoko is specifically designed to support the unique features of the Internet Computer and to provide a familiar yet robust programming environment. As a new language, Motoko is constantly evolving with support for new features and other improvements.<ref name="mo">https://smartcontracts.org/docs/language-guide/motoko.html</ref>
+
The [https://internetcomputer.org/docs/current/motoko/main/motoko Motoko programming language] is a new, modern and type safe language for developers who want to build the next generation of distributed applications to run on the Internet Computer blockchain network. Motoko is specifically designed to support the unique features of the Internet Computer and to provide a familiar yet robust programming environment. As a new language, Motoko is constantly evolving with support for new features and other improvements.<ref name="mo">https://smartcontracts.org/docs/language-guide/motoko.html</ref>
  
 
The Motoko compiler, documentation, and other tooling is [https://github.com/dfinity/motoko open source] and released under the Apache 2.0 license.
 
The Motoko compiler, documentation, and other tooling is [https://github.com/dfinity/motoko open source] and released under the Apache 2.0 license.
Line 40: Line 40:
 
# polymorphism by erasure
 
# polymorphism by erasure
  
==Syntax==
 
 
==Language Features==
 
 
===Expressions===
 
 
===Blocks and declarations===
 
 
===Control flow===
 
 
===Primitive types===
 
 
===Functions===
 
 
===Composite types===
 
 
==Platform features==
 
 
==Type system==
 
 
==Language Extensions==
 
 
==Adoption==
 
 
==Class declaration example==
 
 
==Development==
 
  
 
==References==
 
==References==

Latest revision as of 17:39, 12 January 2024

Summary

The Motoko programming language is a new, modern and type safe language for developers who want to build the next generation of distributed applications to run on the Internet Computer blockchain network. Motoko is specifically designed to support the unique features of the Internet Computer and to provide a familiar yet robust programming environment. As a new language, Motoko is constantly evolving with support for new features and other improvements.[1]

The Motoko compiler, documentation, and other tooling is open source and released under the Apache 2.0 license.

History

Motoko development started in 2018. Its first open release was in Q3 2019[2].

Design Intent

Key design points[1]:

  1. Motoko takes inspiration from several programming languages, including Java, JavaScript, C#, Swift, Pony, ML, Haskell.
  2. Object-oriented, functional, and imperative
  3. Objects as records of members
  4. async/await for sequential programming of asynchronous messaging
  5. Structural typing with simple generics and subtyping
  6. Safe arithmetic (unbounded and checked)
  7. Non-nullable types by default
  8. JavaScript-like syntax but statically typed and sane

Semantics[1]

  1. call-by-value (like Java, C, JS, and ML; unlike Haskell and Nix)
  2. declarations are locally mutually recursive
  3. parametric, bounded polymorphism
  4. subtyping as subsumption, not coercion
  5. no dynamic casts
  6. no inheritance

Implementation

  1. implemented in OCaml (leverages wasm library)
  2. simple reference interpreter
  3. less simple compiler to WebAssembly
  4. multipass with typed IR in each pass
  5. uniform representation, unboxed arithmetic
  6. two-space gc, gc between messages
  7. polymorphism by erasure


References