Smart contract programming languages allow developers to craft special programs for transferring digital assets in response to specific conditions. These smart contracts typically run on top of a blockchain to automate asset exchanges without the need for intermediaries.
One of the first smart contract languages was the Bitcoin Scripting Language. It is useful for ensuring parties get paid and for exchanging digital currency during a Bitcoin sale. However, it is not practical for more complex transactions.
What to look for in a smart contract language
Sanjiv Maewall, CTO of blockchain and digital assets at Deloitte Consulting, suggests developers assess characteristics such as security features, execution performance, developer community support, available tools and the relative ease of learning a language. Doing so can ensure that the language they choose provides a comprehensive, secure and efficient smart contract development environment.
"Familiarity with other languages additionally aids in picking up new smart contract languages rather quickly and allows for existing best practices to also be retained in the smart contract domain," Maewall said. Previous programming experience can also make it easier to understand important concepts in smart contract development. Knowledge of object-oriented programming, error handling and testing leads to more secure, reliable and efficient smart contracts.
Nicko Guyer, Hyperledger FireFly community lead and senior full stack engineer at Kaleido, a vendor of blockchain tools and platforms, recommends developers determine the type of blockchain they plan to use before picking a language. The blockchain should be selected based on the requirements of the particular project.
Even if the best language ends up being an unfamiliar one, you can probably get up and running quickly, particularly if you have prior programming experience. "If the best answer for your project is a language you don't know, don't be afraid to learn something new," Guyer said. "It's probably not as hard as you might think."
Here are nine smart contract languages that merit serious consideration.
C++ is one of the oldest development languages on the list. It was introduced by Bjarne Stroustrup in 1983 to add object-oriented features to the C programming language. It is also a compiled language, which makes it perform well, but the compilation process adds an extra step to the development process. C++ is supported by popular blockchain projects, including EOS, Stellar and Ripple. It can also be compiled into Wasm code. One concern is that C++ is not a memory-safe language, which can result in security issues arising from how a program uses memory. It also can result in longer programs than some of the newer smart contract-specific languages.
Clarity is a newer smart contract programming language introduced for the Stacks blockchain. It employs a framework for writing decentralized applications (dApps) that combine digital assets, data and identity in new ways. One novel feature is that Clarity is a non-Turing-complete programming language, which means it can't simulate every function of a Turing machine (a mathematical model of computation). Although Turing-complete languages allow greater flexibility, they can also be compromised by various smart contract hacks. Clarity's non-Turing-complete approach also makes it easier to perform a more thorough static analysis to identify security issues before deploying new smart contract apps. Clarity apps are also interpreted rather than compiled, which can make it easier to find and fix bugs after deploying an app.
James Gosling developed the Java programming language in the early 1990s as a replacement for C++. One of its most essential features was the ability to write once and run anywhere. A key innovation was a just-in-time compiler that allows Java applications to run on different processes and operating systems. Java can be used to write smart contracts on Corda, Ethereum, Hyperledger Fabric, IBM Blockchain and Neo. It has a large development community and a significant ecosystem of open source components.
Guido van Rossum created the Python programming language in the early 1990s. It supports a variety of application development concepts, such as object-oriented programming and structured programming. Users can employ modules to add functionality to existing apps. Python is one of the most popular languages for developing AI apps. One of its top benefits for smart contract developers is ease of use. However, it is an interpreted language, which can slow performance compared to other languages. Blockchain platforms that support Python include Ethereum, Hyperledger Fabric, Steem and Neo.
Vyper is a newer smart contract programming language that is similar to Python. It enables developers to create smart contract apps that run on top of Ethereum, which provides broad support for dApps. One key innovation is a focus on readability and auditability in smart contract development, which can make it easier to find bugs and help developers identify other problems sooner in the development process. A downside compared to Solidity is that Vyper supports fewer features, which improves security but can also limit functionality. Vyper also does not support object-oriented concepts like inheritance, which can slow development but also improve security.
9. Yul and Yul+
Yul is another smart contract programming language that is meant to improve performance and lower transaction costs compared to Solidity. Yul+ is a variant with features intended to make smart contract development more efficient; it also introduces new operators for describing complex smart contract concepts more efficiently. Developers must compile Yul and Yul+ apps, which can add development overhead and make it harder to identify problems after the apps have been compiled. However, the language itself is designed to be easier to read and understand before compilation. One purported benefit is better fine-grained control over how application processes drive fees for executing smart contracts. Yul apps can also complement Solidity to improve application development speed and flexibility.