Do you want to code Smart Contracts? Which language is the best choice?

Do you want to code Smart Contracts? Which language is the best choice?

Blockchain Open Source Software
June 20, 2018 by Leo Webb
5753
cryptography

There are a large number of programming languages that are used to write smart contracts. These languages serve different ecosystems which determine their key characteristics. This article presents the most popular and useful smart contract languages.

Languages for Bitcoin ecosystem

Bitcoin Script

Bitcoin Script is a simple scripting language that possesses certain characteristics: Forth-like, stack-based, reverse-polish, Turing Incomplete language.

  • Turing Incomplete. Bitcoin Script as Turing Incomplete language has limited functionality and can not make jumps and/or loops. Turing Complete languages are capable of solving any problem. Bitcoin Script doesn’t need to be Turing Complete, as complicated transactions have the potential to slow down the ecosystem.
  • Reverse Polish. In reverse polish systems the operators follow the operands.
  • Stack Based. The basic idea of the stack is LIFO, or Last In First Out.

There are two stack operations:

– Push – adding to the stack,

– Pop – removing from the stack.

The last item pushed into the stack is popped out first.

  • Forth-Like. Bitcoin Script is similar to the programming language “Forth”. When a transaction is validated, the input scripts are concatenated with the output scripts and evaluated. To be valid, all transaction scripts must be evaluated to be true.

Simplicity

Simplicity – a new programming language designed as an alternative to existing languages that are used to create smart contracts. The language is based on a sequential computation algorithm and offers several important improvements. The pinnacle factor is the extension of language capabilities. Simplicity is a Turing-Incomplete Language that provides the limitation of a recursive call, protection from endless loops and allows for static code analysis.

All this in combination creates more secure, efficient and functional code for smart contracts.

Other languages for Bitcoin blockchain

  • Ivy – a non-Turing complete, higher-level language that compiles to Bitcoin Script.
  • BitML – a calculus for Bitcoin smart contracts.

Languages for the Ethereum ecosystem

Solidity

Solidity is a contact-oriented, high-level language for implementing smart contracts.

It is a tool that is used to create a machine-level code that can be run on EVM. It is also a language with a compiler that takes a high-level human-readable code, and breaks it down into simple instructions that form the basis of any executable program of the microprocessor. Solidity allows to create and execute smart contracts without requiring centralized or trusted parties. This programming language resembles programming languages such as Javascript and C. Each contract contains state variables, functions and common data types.

eWasm

eWASM – a restricted subset of WebAssembly for Ethereum contracts. The WebAssembly (wasm) language was launched in 2015 by a team of developers from Google, Microsoft and Mozilla, and aims to provide developers with a single way of compiling code that will eventually become a web standard implemented across all browsers.

Using it, programmers can compile code for the browser, which is later executed inside the JavaScript engine. Instead of parsing the source code, which often takes a long time, WebAssembly can be decoded much faster.

These are the WebAssembly properties the Ethereum developers intend to use in their work. eWasm language allows the execution of scripts much faster, taking full advantage of potential hardware capabilities.

Other languages for Ethereum

Read more about Open source software and its development

Other blockchains

  • Michelson – a stack-based and strongly typed domain-specific language (Tezos).
  • Liquidity – a high-level, typed smart-contract language that strictly complies with Michelson security restrictions (Tezos).
  • Plutus – a pure functional language with user-defined data types and polymorphism (Cardano); compiles to (Plutus Core).
  • Rholang – a reflective higher-order process calculus language (RChain).
  • Obsidian – a state-oriented language with linear types.
  • Qtum smart contract language (QSCL) – language for the Qtum system.
  • Skilla – an intermediate level language for verified smart contracts.

More materials about Blockchain