CAIRO : The Adoption of an Emerging Programming Language

This article is an overview of the evolution of the Cairo language since its genesis and the ecosystem being built around it. Then we will go through a set of relevant metrics and indicators to qualify its adoption.

Context

Since the rise of decentralized Finance in mid 2020, it became clear that the main challenge of blockchain technology was scalability. Ethereum, where DeFi was first established, had already proved to be decentralized and secure at that time, but the transactions got increasingly costly and slow . In this context, different scaling solutions emerged like zk-rollups, optimistic rollups, L2s and side chains.

In this article, we’ll give an overview of Cairo : a Turing-complete language for writing provable programs on a leading L2 scaling solution : StarkNet.

What is Cairo?

Cairo (CPU for Algebraic Intermediate Representation) can refer to the Von Neumann CPU architecture that was designed by StarkWare to generate STARK proofs for general computation integrity. Cairo more commonly refers to the general purpose Turing Complete programming language for writing STARK provable programs. It was first used by Starkware to power StarkEx : a scaling engine designed specifically for applications like DYDX, Immutable X, Sorare and DiversiFi. After achieving outstanding results on the Ethereum Mainnet with more than $615B in cumulative trading volume done with 98% less gas fees, they decided to release Starknet : a permissionless decentralized Ethereum Validity Rollup with the aim of achieving great scale for its computation, while preserving Ethereum’s composability and security.

The release of Starknet, or shall we say the democratization of STARKs, was in fact the moment where Cairo language started onboarding Web3 developers and builders with the creation of a whole Ecosystem. Appropriate dev tools and resources have been set up rolling out the carpet for all sorts of projects and communities to arise: DeFi protocols, Infrastructure, tooling, onchain gaming & NFTs, and other services are being built in Cairo and launched on the Starknet testnet. The next step will be the much anticipated launch on the main StarkNet network when it becomes permissionless and production ready.

What is unique about Cairo ?

There is no single method for comparing different programming languages, but a first angle of approach is the main use case. For instance, it is not relevant to analyze Python in contrast with JavaScript since Python is widely used for machine learning, task automation, data analysis and visualization while JavaScript is mainly used for web development.

The first language we would feel like putting Cairo in the same box with is Solidity, since Cairo is the native language for smart contracts on Starknet. However, unlike Solidity, Cairo can’t be defined as a smart contract language : it’s a general-purpose language that allows developers to write programs that can be executed to generate a “trace” (a table of finite field elements that have a meaning relating to the program, part of the Algebraic Intermediate Representation abbreviated to AIR). This trace is then sent to a Starknet prover (generally Starknet’s shared prover SHARP) that uses it in addition to mathematical methods and properties like FRI, LDE and Merkle trees to generate a STARK proof that can be verified later on by the verifier contract.

In this light, it would be suitable to put Cairo in the same category as Circom, Leo or Noir that are dedicated to creating provable programs : these programs are compiled to “ZK circuits”, the format required to generate SNARK proofs.

This comes down to comparing STARK and SNARK proofs. One of the main setup differences we can enumerate is the trusted setup that is required for generating SNARKs (which is not ideal due to the need for a trusted third party during the setup phase). STARKs are also considered post-quantum secure and use a collision resistant hash function unlike SNARKs. Moreover, coding in Cairo gives new optimization perspectives and functionalities such as account abstraction (externally owned accounts are replaced by contract accounts) and nondeterministic programming that can be extremely beneficial in terms of computational complexity (the amount of resources required to run a computation). Performance wise, the size of a STARK proof ranges from 45KB to 200KB while a SNARKS is 288 bytes. The algorithmic time complexity is also interesting to check : a quasi-linear complexity for both verifiers, while prover’s complexity is poly-logarithmic for STARKs and constant for SNARKs.

With that being said, the only system in production that offers L1 transactions that cost less than 1000 gas per transaction is starkEx thanks to the possibility of batching up to 600000 transactions in a single proof.

Practically speaking, Cairo has many specificities : the primitive type of variables is felt instead of  int type usually used, memory is write-once, no built-in loops but recursion only and  assert statements with an equals sign that act differently based on whether variables were initialized or not. You can get a clearer insight in the official Cairo documentation. All these particularities can be seen as obstacles for an easy transition from other programming languages, that is precisely why many efforts are made to facilitate this transition notably WARP (a tool that transpiles Ethereum smart contracts to StarkNet Cairo Contracts), tutorials like Starlings, crash courses and workshops.

The key takeaway here is that ZK technology is still in an early stage, which means that performance hasn’t unlocked its full potential yet as a lot of research and experimentation are still underway to optimize proving & verifying protocols and hardware.

Cairo’s adoption over time : some relevant metrics.

In this section, we will look into Cairo’s adoption over time through different lenses, trying to evaluate the pace at which it has earned interest.

StarkWare publicly introduced Cairo for the first time in august 2020, created the Cairo-lang GitHub repo in October of the same year before making a series of partnerships and engaging a full team to setup adapted development infrastructure, documentation and resources. Since then, a community of professionals and enthusiasts gathered around this emerging language inspecting its different aspects, helping each other through the learning process, creating projects and contributing to others projects.

Coding activity

More than 200 repositories on GitHub contain Cairo code. We unfortunately can’t get the exact number of repos since GitHub doesn’t recognize all files with “.cairo” extensions. Nevertheless, we should emphasize that most of these repos were created only since October 2021, and have multiple contributors who rushed this novel programming language learning to bring project ideas to life.

The Cairo-lang repo already has more than 770 stars, and 100 forks. Some of the most trending Cairo repos is Only Dust’s Starling repo that got more than 100 stars in one month.

We can get a clear insight on the number of Cairo devs by analyzing devs activity on discord servers dedicated for Cairo questions. On the Starknet Discord Server, there are more than 7000 members with a  “dev role” that are curious about Cairo, or that have already started building.

It is worth pointing out too that the number of StarkNet.JS library downloads has attained more than 43K in total, with an ever growing number of weekly downloads since October 2021.

Number of weekly starknet.js downloads
Number of weekly starknet.js downloads

Interest is also growing on the hiring market; the Starknet ecosystem website features a regularly updated list of job offers, including Cairo dev offers. Most projects building on Starknet post job offers on their websites or contact blockchain developers directly.

Onchain activity on Cairo powered protocols

Cairo’s adoption can also be quantified through analyzing onchain activity on both StarkNet Mainnet and testnet since it’s fully powered by Cairo language.

DefiLlama gives insightful curves about the total value locked per smart contract coding language. Cairo’s TVL went from $55m in November 2020 to $1,1B April 2022 (+2000%) thanks to StarkEx contracts . At that point, this amount represented 0,55% of the total DeFi TVL. Since then and due to market conditions, Cairo’s TVL went to $739M mainly locked in StarkEx-powered protocols in addition to 380 ETH and $150K Dai locked on the Starknet MainNet. However, this represents 1% of the market's TVL.

This growth in DeFi’s TVL shares shows the resiliency of Cairo-powered protocols thanks to the growing interest in Cairo and what it has to offer.

DefiLlama's Languages analytics
DefiLlama's Languages analytics
ETH and Dai locked in StarkGate
ETH and Dai locked in StarkGate

Onchain activity has flourished since the launch of Starknet to attain nearly 6 million transactions from more than 700K contracts deployed on the testnet, and more than 300K transactions from 130K contracts on the Mainnet.

This is definitely a powerful indicator that Cairo-powered applications are increasingly attracting users that constitute the end-point for what is being built. Starknet’s user base is testing the different live products out of interest, giving feedback and improving propositions as a gesture of support to application builders.

Projects building a Cairo powered product

On our Analytics twitter page, we regularly publish a StarkNet ecosystem landscape to follow all the new projects building in Cairo. In fact, we can’t properly evaluate the adoption of Cairo over time without looking at the number of projects being built on Starknet. At the beginning of February, the ecosystem consisted of 25 projects and 9 partners.

Starknet Ecosystem (February 2022, @ZK_Daily)
Starknet Ecosystem (February 2022, @ZK_Daily)

Only four months later, the ecosystem already counts around 150 projects. Each of these projects managed to create a community of thousands of early adopters, keeping track of the project's evolution both on twitter and discord.

Starknet Ecosystem (1st of July 2022, @Astralytica)
Starknet Ecosystem (1st of July 2022, @Astralytica)

A final gauge for Cairo’s adoption is going to be the number of initiatives, community events and meetups that are held to exchange knowledge about STARKs technology, CAIRO and the different protocols leveraging them.

Since the launch of Cairo, a number of conferences and workshops have been organized in many blockchain events in addition to summits and meetups dedicated to the StarkNet community. For instance, the latest big Cairo event was the Amsterdam Starknet Hackathon that had 170 participants who worked together for 24 hours straight to create  35 submissions including six winning projects.

Starknet House is also a great initiative currently led by the topology team. It is an online summer program for developers to learn how to build on StarkNet using Cairo. They organize 11 sessions to learn Cairo for attendees to be able to compete in the inaugural Global StarkNet House Hackathon in August.

You can find here a list of upcoming community events where you could learn more about Cairo and exchange with members from the ecosystem.

Cairo, an adopted Web3 language in the near future?

At this point, we hope it’s clear that CAIRO is a unique programming language and that most devs learning or using CAIRO are building applications on StarkNet. Given the rapid growth of its community of adopters, we can already start wondering if CAIRO is replacing Solidity. Will we have as many CAIRO devs in five years as the number of solidity devs we have today (more than 4000 monthly active Solidity devs according to Electric Capital Developer Report)? The answer to these questions is closely linked to the prosperity and development of the Starknet Ecosystem and projects building within.

CAIRO could even find other use-cases with StarkWare’s vision that goes beyond a simple L2 for scaling Ethereum. They consider setting up an L3 and even a layer on top to accommodate the “StarkNet Privacy”. There is also an open discussion to investigate the possibility of scaling other blockchains, ideally Bitcoin.

If you enjoyed this article and want to keep yourself updated about the growth of the StarkNet ecosystem, follow our StarkNet Analytics account: @Astralytica on Twitter.

Subscribe to Astraly
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.