Ethereum High-Level Languages
The EVM is a virtual machine that runs a special sort of code called EVM bytecode, analogous to our computer’s CPU, which runs machine language like x86_64. Though it’s possible to program smart contracts directly in bytecode, EVM bytecode is quite unwieldy and really difficult for programmers to read and understand. Instead, most Ethereum developers use an application-oriented language to write down programs, and a compiler to convert them into bytecode.
Despite the fact any application-oriented language might be adapted to write down smart contracts, adapting an arbitrary language to be compliable to EVM bytecode is sort of a cumbersome exercise and would generally cause some amount of confusion. Smart contracts drive in a highly forced and minimalistic execution environment. Additionally, a special set of EVM-specific system variables and functions must be available. As such, it’s easier to create a sensible contract language from scratch than it has to form a general-purpose language suitable for writing smart contracts. As a result, a variety of special-purpose languages have emerged for programming smart contracts. Ethereum has several such languages, alongside the compilers needed to supply EVM-executable bytecode.
Even though authoritative programming is more commonly employed by programmers, it is often very difficult to write down programs that execute exactly needless to say. The power of any part of the program to vary the state of the other makes it difficult to reason a few program’s executions and introduces many opportunities for bugs. Declarative programming, by comparison, makes it easier to know how a program will behave: since it’s no side effects, any part of a program is often understood in isolation.
In smart contracts, bugs literally cost money. As a result, it’s critically important to write down smart contracts without unintended effects. To try to do that, we want to be ready to clearly reason about the expected behavior of the program. So, declarative languages play a way bigger role in smart contracts than they are doing in general-purpose software. Nevertheless, as you’ll see, the foremost widely used language for smart contracts (Solidity) is imperative. Programmers, like most humans, resist change!
At present support high-level programming languages for smart contracts include;
A functional (declarative) programing language, with Lisp-like syntax. it had been the primary application-oriented language for Ethereum smart contracts but is never used today.
A procedural (imperative) programing language with a syntax almost like Python. Also can be wont to write functional (declarative) code, though it’s not entirely freed from side effects.
A more recently developed language, almost like Serpent and again with Python-like syntax. Intended to urge closer to a pure-functional Python-like language than Serpent, but to not replace Serpent.
An afresh developed language, influenced by Erlang, with explicit state transitions and without iterative flows (loops). Intended to scale back side effects and increase audibility. Very new and yet to be widely adopted.