Difference between revisions of "Motoko (programming language)"
From Internet Computer Wiki
Diego.prats (talk | contribs) |
Diego.prats (talk | contribs) |
||
Line 40: | Line 40: | ||
# polymorphism by erasure | # polymorphism by erasure | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==References== | ==References== |
Revision as of 17:38, 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]:
- Motoko takes inspiration from several programming languages, including Java, JavaScript, C#, Swift, Pony, ML, Haskell.
- Object-oriented, functional, and imperative
- Objects as records of members
- async/await for sequential programming of asynchronous messaging
- Structural typing with simple generics and subtyping
- Safe arithmetic (unbounded and checked)
- Non-nullable types by default
- JavaScript-like syntax but statically typed and sane
Semantics[1]
- call-by-value (like Java, C, JS, and ML; unlike Haskell and Nix)
- declarations are locally mutually recursive
- parametric, bounded polymorphism
- subtyping as subsumption, not coercion
- no dynamic casts
- no inheritance
Implementation
- implemented in OCaml (leverages
wasm
library) - simple reference interpreter
- less simple compiler to WebAssembly
- multipass with typed IR in each pass
- uniform representation, unboxed arithmetic
- two-space gc, gc between messages
- polymorphism by erasure