Ready to start your Web3 development journey?
→ Download our guide to developing smart contracts

What Is Composability and How Does It Accelerate Your Web3 Journey on Stacks?

As Naval succinctly put it, “open source means each problem only has to be solved once.” Every time a developer creates open-source code, it increases the efficiency with which other developers can build because that code can be reused. This core benefit of open source is at the heart of Web3 because by their very nature, blockchains are open-source technologies, and so are many of the applications on top of them.

Type
Deep dive
Topic(s)
Clarity
Published
April 20, 2022
Author(s)
Content Marketing Manager
What Is Composability?
Contents
Copy link

Creating open-source code that other developers can use and repurpose is at the heart of “composability,” an idea the Web3 community embraces wholeheartedly. If you want to build Web3 applications, composability provides access to the building blocks you need to jumpstart development.

Composability Transforms Code Into Building Blocks

In software development, composability refers to code's modularity and the ability for developers to take existing code and reuse it, repurpose it, or combine it with other code blocks to create something new. Think of it like building blocks. Composability accelerates innovation by enabling developers to build new use-cases on top of existing projects. The code of that new project, in turn, serves as yet another building block for someone else, leading to an ever-expanding library of code that developers can tap into to build their own ideas. Venture capitalist Chris Dixon describes it aptly when he wrote, “composability is the ability to mix and match software components like Lego bricks.”

In software development, composability refers to code's modularity and the ability for developers to take existing code and reuse it, repurpose it, or combine it with other code blocks to create something new.

Whether in Web2 or Web3, building any application from scratch is a daunting task because writing tens of thousands of lines of code is not easy. The difficulty in building software from scratch is the reason solutions such as WordPress for websites, Shopify for ecommerce, and a long list of other no- and low-code solutions have thrived in Web2. You don’t need to build certain features from scratch and go through a long and expensive R&D process. Instead, you can pay a fee and have an out-of-the-box solution ready to go.

In the world of Web3, we are seeing a renaissance period of composability, and in order for that composability to succeed, ecosystems have a need for interoperability and standards for how certain components of the network behave. For example, ERC-20 token standard describes how fungible tokens function on Ethereum, and ARC-0003 specifies the non-fungible token standard on Algorand. We have token standards at Stacks too.

With those standards established, anyone can build an application that involves fungible tokens or non-fungible tokens, and they can trust that any new tokens launched in the ecosystem will be easy to integrate into that application as long as they use the same token standard. It makes the entire ecosystem more composable because now all builders are using the same basic building blocks.

How Composability Accelerates Web3 Development

Blockchain technology is built on democratic ideals of equal access and equal opportunity. Anyone can set up a node or become a miner; anyone can contribute to development, and anyone can build atop these blockchains. To achieve those ideals, much of the technology is open source to create that open access. In Web3, this is an advantage and will accelerate development across the ecosystem. Here’s why.

Bypassing the Opacity of Web2

Much of the internet is built on open-source rails. Going back to its earliest days, CERN put the World Wide Web software in the public domain and then released it with an open license. Open source technology is also behind operating systems such as Linux and browsers like Mozilla. 

However, despite the open-source beginnings of the internet (which we still rely on today), we also saw a rise of closed-source ecosystems in Web2. Today, many companies treat code as proprietary IP, and companies often adopt aggressive patent enforcement methods to keep such code from the public domain. Other companies leveraged their network effects of user data to box out competition and to lock users into their ecosystem. 

In Web3, the ability to maintain those walled-garden businesses has been limited in an important way. Blockchains, by their nature, are open-source public databases. Everyone has access to the same user data. All accounts and all transactions are public, so in terms of building blocks, it’s not just the code that is composable (more on that in a moment), but the data too.

Developers are able to innovate and build off each other and have confidence that all the code is referencing the same exact database. No lag due to different databases syncing and no contradictory data sets. This is a critical feature that makes composability so successful in Web3: everything is built on the same foundation. As a result, composability is more effective and can happen more quickly across projects.

Developers are able to innovate and build off each other and have confidence that all the code is referencing the same exact database. No lag due to different databases syncing and no contradictory data sets.

Providing Building Blocks for New dApps

Through composability, developers can unlock accelerated and compounding innovation to build higher-order applications by writing fewer lines of code themselves. Thanks to composability, you can leverage large repositories of existing code to perform certain functions instead of having to rewrite that code yourself.

Even better, open-source smart contracts that execute a specific function are (surprise!) perfectly packaged for modularity. Building an app that needs a contract that handles asset swaps? There are contracts for that. Building an app that needs an NFT marketplace inside of it? There are contracts for that. And if you need to adjust them, take the original contract and release a v2 with the additional functionality you need.

Open-source smart contracts that execute a specific function are perfectly packaged for modularity.

This is how SushiSwap was built using Uniswap’s code. Instead of building the SushiSwap DEX from scratch, the SushiSwap team took Uniswap’s smart contracts and added a governance token and a liquidity mining program to Uniswap’s code. Now, governance tokens and liquidity mining have become core components in DeFi. The whole ecosystem benefited as a result of that example of composability.

Part of what’s so exciting about Web3 is how much of this innovation is happening in the public domain. Code is open and is often subject to review and critique from community members to improve security, functionality, and more.

Through composability, developers can reduce investments in time, resources, and costs by using existing code and focusing on their application-specific logic to build faster and deliver better products and experiences to users. 

Stacks’ Smart Contracts Enable Better Composability for Web3

Stacks enables better composability for Web3 by empowering developers to write and publish smart contracts for Bitcoin through Clarity. On Stacks, every smart contract deployed on the mainnet includes the executable, uncompiled, and human-readable source code.

Since the smart contract’s source code is publicly published on the blockchain, the Stacks blockchain effectively becomes a ‘GitHub for smart contracts,’ where developers can easily look at the code of any smart contract, verify that code, and use that code for new projects. 

On other blockchains, the code is often compiled, meaning it is not human-readable. This makes it harder to verify that the production code in a smart contract is the same as the source code for that contract, and you may be building your new application on a flawed contract. 

So, if you want to shorten the learning curve for building Web3 applications, Stacks gives you access to human readable code, so you can learn from the best and take from the best. By making the source code for every smart contract publicly available, it is easier for composability to take flight in the ecosystem. We are seeing that play out in the STX ecosystem already. The most popular NFT project Megapont Apes has become a defacto NFT contract for dozens of other NFT projects on Stacks.

By making the source code for every smart contract publicly available, it is easier for composability to take flight in the Stacks ecosystem.

Learn about the possibilities of Bitcoin DeFi in a conversation with Bitcoin educator Dan Held:

Managing the Downside of Composability Through Stacks

Composability is great, but a bug in a smart contract’s code can have a ripple effect that can wreak havoc on other projects that have used the code.

Poorly designed programming languages for smart contracts can result in hard-to-debug problems that make their way into production code. And when such code is used to build new applications, the problems deepen. Clarity reduces vulnerabilities common in other smart contracts and makes the code more secure.

By design, Clarity is a decidable language that allows for the complete static analysis of the entire call graph of a given smart contract before it is deployed. This helps developers simulate how the smart contract will behave and catch bugs before the smart contract gets deployed.

This doesn’t mean you won’t see composable software with a bug somewhere in it—audit smart contracts before building on top of them!—but the language is designed to help mitigate those risks and make it easier to reason with the logic of a smart contract and verify the code of other contracts in the ecosystem.

Get Inspired by What’s Already Built on Stacks

When you decide to build a Web3 application for the blockchain ecosystem through Stacks, you won’t be starting from scratch. There are already more than 3,000 smart contracts deployed on Stacks, and you can use their code to bootstrap your app.

Explore some of the smart contracts on Stacks to get started on your Web3 development journey today.

Explore Smart Contracts
Copy link
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories