Why CLARITY is better than SOLIDITY for building your next decentralized application

Ezra Kewa
5 min readAug 26, 2021
Artwork by Benny Cage

In this article, we will be going over some of the major differences between the Ethereum blockchain network and the Stacks blockchain network. Specifically, technical differences between the programming languages of the two ecosystems and the many benefits you get by choosing to build your apps (or smart contracts) on the Stacks network instead of on Ethereum. But first a bit of history and a high-level overview:

Ethereum was effectively launched in 2015 and allows anyone to deploy permanent and immutable decentralized applications onto it, with which users can interact. It adopted some of the positive aspects of the Bitcoin network while improving on others and fixing some of its flaws.

This was made very clear in the different design philosophies of the two blockchains — bitcoin is more of a store-of-value while Ethereum is more of a platform that introduced the innovation of allowing programmers to create apps that live on that platform.

This led to the explosion of decentralized programs like games, exchanges, financial products, NFTs and so many different creative use-cases. Many other networks and projects followed suit leading to the evolution of the internet into what is known as Web 3.0.

Unlike centralized applications such as Google and Facebook, web3 apps return control over things like privacy, user data, and profits back into the hands of individuals and programmers. Anyone, anywhere in the world can build, deploy and control their apps and smart contracts free from the extreme oversight of corporations and government. You can read more about Web 3.0 here.

While this was good news and has brought in tremendous advantages to end-users, a major downside to this is that Bitcoin and Ethereum both use a proof-of-work algorithm to create (or mine) their respective cryptocurrencies. This mining process depends on very specialized hardware to run profitably and this consumes astronomical quantities of electricity which by extension is significantly hazardous to the environment.

So even though Bitcoin ushered in the world of cryptocurrencies and Ethereum introduced the world to decentralized apps, they both have their weakness and flaws. Bitcoin has a very limited programming language because it was designed to function mainly as ‘digital gold’, so to speak, while Ethereum has a broad programming language but very expensive transaction fees and programs that have suffered many design flaws and security breaches.

In contrast to these two networks, the Stacks blockchain was created to side-step these major issues while taking advantage of the positive aspects of the Big Two. It is both a digital currency and an application ecosystem with major investors in Silicon Valley and around the world. It uses the proof-of-transfer mining mechanism which basically recycles bitcoin to create STX, its native coin, making it very eco-friendly. And its programming language is superior to that of Ethereum in many ways.

Now Solidity is the programming language used to write smart contracts on the Ethereum blockchain, whereas Clarity is the language used to write smart contracts for the Stacks 2.0 blockchain.

Solidity was initially proposed in 2014 by Gavin Wood and eventually developed by the Ethereum project’s developer team. It is the dominant player and incumbent in the crypto space.

Even though Clarity was launched in April of 2020, it has already seen a massive explosion of adoption and experimentation. Hundreds of Clarity programs are already available on GitHub, with community members writing more every day.

The beauty of the Stacks network is that its proof-of-transfer consensus mechanism allows developers to essentially recycle Bitcoin’s Proof-of-work and its inherent security to open new opportunities to build robust decentralized applications, Defi products, DAOs(decentralized autonomous organizations), and much more.

Now let’s look at some of the major differences between the two programming languages and why Clarity is the superior option.

The first and probably the most important distinction is that Solidity is Turing-complete while Clarity is deliberately NOT.

Now you might be asking what is Turing completeness exactly?

Well in a Turing-complete language like Solidity you can write something called infinite or unbounded loops. This means that you might not be able to explore all possible executions pathways without actually executing the code. You might not be able to catch all possible errors at the time of development until you run the program.

But in Clarity, you can statically analyze all possible pathways and outcomes. This allows developers to catch bugs before implementing and deploying their Smart contracts thereby avoiding a whole host of issues in the future.

Though Turing-completeness gives the benefit of rare data manipulation, in the long run, it can cause dangerous complications that can hurt your programs, smart contracts, and transactions. Smart contracts are very powerful applications — this makes Turing-completeness a double-edged sword in the wrong hands. (WITH GREAT POWER COMES GREAT RESPONSIBILITY :)

The DAO hack of 2017 abused a recursive call design flaw called re-entrance. Re-entrance is when a problem (or deliberate bug) gets caught in a piece of code triggering massive computational problems. This resulted in a loss of over 30 million Eth.

Re-entrance is what necessitated the introduction of the very expensive gas fee system on Ethereum and this leads us to the next major distinction between the two languages: Decidability.

Clarity is a decidable language, meaning contracts written in it can have their functions determined(decided) and transactions fees can be guaranteed unlike contracts written in Solidity on Ethereum where gas(transaction) fees dynamically fluctuate based on a variety of factors and if you don’t have sufficient gas your program gets terminated.

Clarity is an interpreted programming language whereas Solidity is not. In Clarity, contracts are written in human-readable form and are accessible to any professional auditor or casual onlooker. The code deployed onto the Stacks 2.0 blockchain is WYSIWYG or “What You See Is What You Get” and prevents the surfacing of the compiler bugs. Whereas in Solidity, the source code is not published, only the compiled version of the source code is published to the blockchain. This causes difficulty in auditing the code once pushed unto the chain.

Another major difference between the two languages is that Clarity publishes the source code of the contract, whereas Solidity publishes the compiled contract via the Eth Virtual Machine.

Also security-wise, Clarity uses postconditions on tokens. A postcondition is a condition or instruction that must always be true just after the execution of some section of code or after an operation. This allows users to proactively defend their assets from theft or destruction.

These advanced programming features and the fact that the Stack ecosystem is witnessing massive worldwide adoption make it the perfect vehicle and the perfect time for your decentralized project.

As a programmer looking to enter the world of decentralized applications, I can’t think of a better language to build your programs in than Clarity or a better blockchain to work with than Stacks. Check it out at clarity.tools today!

--

--