Tezos Programming Languages
Tezos ecosystem offers many opportunities for developers, application builders and smart contract creators.
In 2019, more than 1000 programmers were trained to develop on the Tezos blockchain. Educational, training and research activities continue, Tezos teams all around the world contribute their efforts and Tezos Ukraine is not an exception. In 2019 we conducted the First Eastern European Hackathon, and as a result, several strong teams emerged and they are developing on the Tezos blockchain.
Many languages exist in Tezos ecosystem and in future there will be even more. As explained by Arthur Breitman in a recent interview, Tezos’ core itself, is built on a functional programming language and a lot of people involved in Tezos ecosystem tend to like functional programming. These people are programming language gurus and they like to create new languages, because that’s what they know and what they like to do.
However, Tezos Ukraine saw a glaring need in that non-technical newcomers to the Tezos world might be lost in the variety of programming languages involved, so we decided to write a basic article about them so that getting started would be much easier.
OCaml — the language of Tezos protocol
The Tezos protocol is written in OCaml, a general-purpose industrial-strength programming language with an emphasis on expressiveness and safety. OCaml was created in 1996 and it has a large standard library, which makes it useful for many of the same applications such as Python or Perl. It has robust modular and object-oriented programming constructs that make it applicable for large-scale software engineering.
OCaml is a free and open-source software project managed and maintained by the French Institut e for Research in Computer Science and Automation (INRIA).
In the early 2000s, elements from OCaml were adopted by many languages, notably F# and Scala (one more language popular in blockchain development).
Many top projects use OCaml, including Facebook, Bloomberg, Docker, Wikipedia and others.
Michelson — the language of smartcontracts in Tezos
Michelson is a brand-new programming language introduced to the world by L.M Goodman (Arthur Breitman) in the Tezos Whitepaper in 2014. It is an open-source functional programming language designed for Tezos smart-contract development.
Michelson is the low-level, domain-specific, stack-based programming language which is used to write smart contracts on the Tezos blockchain. Michelson was designed to facilitate formal verification, allowing users to prove the properties of their contracts.
Even experienced Tezos developers say that at first sight, Michelson is a strange language. It doesn’t include features like polymorphism, closures, or named functions. It seems to be underpowered compared to a language like Haskell or OCaml. Its stack is not always easy to deal with, and there is no standard library. But the main advantages are that Michelson is introspectable and provides readable bytecode.
Tezos developers wanted to start with a small core language in which everyone is confident and add features as good use cases are created for them. In fact, few people write code on Michelson, as there are other various high-level languages available for programming smart contracts on Tezos. With such new languages like LIGO, SmartPy, Morley/Lorentz the development experience is much easier, so programmers can focus on the content of their smart contracts, rather than on the implementation.
LIGO is a friendly Smart Contract Language for Tezos, which provides a strong, static type system and easy integration. LIGO is Polyglot — it provides you an opportunity to code in your language. As for now 3 syntax (languages) are supported and it’s possible to add your own syntax.
● PascaLIGO — a syntax inspired by Pascal which provides an imperative developer experience.
● CameLIGO, — OCaml inspired syntax that allows you to write in a functional style.
LIGO takes the approach of replicating the structure used by languages from a particular paradigm. It is packaged in a Docker container, so that no particular installation instructions are required.
More languages will be added to LIGO, and the community is actively working on it. For example Madfish Solutions created Solidity to Ligo transpiler, and they were awarded a Tezos foundation grant for this development.
LIGO web-site with tutorials, docs and all the necessary information are available. It is also possible to try code in LIGO online at: https://ligolang.org/
SmartPy is a high-level smart contract language that enables developers to use Python to write smart contracts, which then are compiled to Michelson.
Users benefit from the full power of Python to iterate over data structures, call other libraries, pre-compute parameters while ultimately targeting a powerful yet limited language Michelson.
SmartPy has an amazing online editor with templates, where you can write, run, and test contracts.
SmartPy.io is an in-browser development platform with advanced capabilities to develop, test, and prove properties of smart contracts. All development takes place in a browser — from Python programming to Michelson contracts generation, testing, and analysis.
Python is considered a relatively easy language to learn and it has existed for a long time, which allows SmartPy to bring more Python developers into the Tezos ecosystem.
Baking Bad, a Tezos-focused team of developers, crypto-enthusiasts created PyTezos — Python SDK for Tezos, and also several Tezos dev tools: ConseilPy — Python toolkit for Conseil blockchain indexer, PyTzKT — Python toolkit for TzKT blockchain indexer. You can check all these tools at the Baking Bad web-site.
SmartPy web-site: http://smartpy.io/
SmartPy Telegram group
SmartPy course from Blockmatics
Morley/Lorentz provides a library to write Tezos smart contracts in Haskell. The project is under development and the documentation is limited, but you can check it here and follow along with their development: https://hackage.haskell.org/package/morley
Archetype is a domain-specific language (DSL) for developing smart contracts on the Tezos blockchain with a specific focus on security and formal verification of contracts. It is an open-source project developed in OCaml. Archetype offers a completely different way of writing smart contracts on Tezos with its own set of instructions and treating contracts as a state machine.
Archetype website: https://archetype-lang.org/
Albert is an intermediate smart contract programming language compiled to Michelson. Like the main Tezos language, Albert as a name was chosen in honor of the physicist Albert Michelson.
It is an imperative language with variables and records, abstracting the Michelson stack. The intent of Albert is to serve as a compilation target for high-level smart contract programming languages.
Albert language website: https://albert-lang.io/
As you see, there are many languages in the Tezos ecosystem. Hence there are multiple ways and opportunities to develop on Tezos. If you cannot decide where to start or what to learn first — the best way is to interact with the Tezos Developer Community who are already using particular languages and are involved in Tezos-related projects.
Follow our Social Networks: