# Why Cadence Stands Out

* * *

Cadence is the smart contract language written in Go. There are only four concepts to learn: variables, collection types (arrays and dictionaries), structs, and resources. Yet, once a smart contract is deployed, it enables not only financial management but also the creation of systems—such as unmanned vegetable stands or financial platforms for ride-sharing—in just a few dozen lines of code by updating and referencing data. You can even build features like game ranking systems in a similar amount of code.

* * *

The Cadence language is often referred to as a resource-oriented language. A party holding a resource can execute its internal methods, and the owner stores that resource in the blockchain's internal storage.

* * *

Non-resource types (variables, arrays/dictionaries, and structs) do not physically move, so they are not stored in any specific account's storage; instead, they are accessible to everyone. Resources, on the other hand, play a central role in smart contracts because, fundamentally, only their owner can invoke their internal methods; consequently, they are stored in the owner's storage.

* * *

When looking at smart contracts, one often sees a structure like the following.

```swift
contract A {

  access(all) resource  B {
    access(all) fun setRankingAndDeliverPrize() {
    }
  }

  init {
    self.account.storage.save(<- new B(), to: /storage/B)
  }
}
```

The smart contract deployer is represented as `self.account` within the smart contract. Since the `init` function executes only once—at the time of deployment—this type of code is used when the goal is to create a single, system-critical resource. In the example above, this means that only the smart contract deployer owns Resource B, and only that account can execute the contract's `setRankingAndDeliverPrize` method. Because this blockchain (Flow) supports scheduled execution, it enables fair, automated operations—such as recalculating rankings and distributing prize money to the top three teams every week.

* * *

### Regarding the deep technical relationship between the Flow team (Dapper Labs) and the original Diem/Libra team at Meta:

### Move & Cadence Shared Roots

While Flow and Libra/Diem were developed in parallel, the Dapper Labs team and Meta's crypto research team collaborated extensively through technical working groups in the 2018–2020 era.

Both teams shared the same fundamental thesis: **existing blockchains (like Ethereum's EVM) were structurally unsafe and poorly suited for mainstream consumer applications and NFTs.**

1.  **Resource-Oriented Architecture:** Meta created the **Move** language for Libra, while Dapper Labs created **Cadence** for Flow. Both languages adopted the "Resource-Oriented Programming" paradigm—a concept originally inspired by Rust's linear type system where digital assets are treated as physical objects in memory that cannot be duplicated, implicit-dropped, or re-entered.
    
2.  **Technical Exchange:** Engineers from Dapper Labs and Meta regularly cross-pollinated ideas regarding resource safety, access control capabilities, and account abstractions during the initial design phases of both languages.
    

### Why Instagram Supported Flow at NFT Feature Launch

When Meta launched its native NFT and digital collectibles feature on Instagram in May 2022, **Flow was chosen as one of the primary launch blockchains** alongside Ethereum and Polygon.

This choice was directly tied to those technical roots and operational history:

*   **Mass-Consumer Scaling:** Flow was designed specifically for high-throughput consumer apps (like *NBA Top Shot*), making it a natural fit for Instagram's massive user base without exposing users to high gas fees or network congestion.
    
*   **Shared Developer Philosophy:** Because Meta's internal crypto teams were already intimately familiar with Cadence's resource model and Flow's account architecture through their earlier Libra-era working groups, integrating Flow into Instagram's backend infrastructure was smooth and architecturally aligned with Meta's standards.
    
    * * *
    
    The Flow team frequently held working group sessions with Meta’s Libra (later renamed Diem) foundation, driven by a shared awareness of issues facing existing blockchains. However, it was the Flow team—not Meta’s development team—that ignited the NFT boom. The Cadence smart contract language, written in Go (a language ergonomically superior to Rust), is characterized by being easy to write and learn, making the process of programming enjoyable.
    
    * * *
    
    ### Demystifying Cadence: Why Resource-Oriented Programming Prevents Exploits at Compile Time
    
    In conventional smart contract environments like Ethereum’s EVM, digital assets (like ERC-20 tokens or ERC-721 NFTs) are represented as entries in a central database dictionary. To transfer a token, a contract modifies integer balances mapped to user addresses (`balances[from] -= amount; balances[to] += amount`).
    
    This pattern is prone to catastrophic vulnerabilities—such as **reentrancy attacks, integer overflows, and unauthorized balance manipulation**—because assets do not exist as real objects.
    
    Flow's **Cadence** solves this by introducing **Resource-Oriented Programming**.
    

### Three Technical Pillars of Cadence

1.  Linear Types & Assets as "Physical Objects"
    
    In Cadence, resources represent real-value assets. They are governed by linear typing rules derived from Rust:
    
    *   **Cannot be Copied:** A resource cannot be duplicated (`let clone = resource` throws a compile-time error).
        
    *   **Cannot be Implicitly Dropped:** If a resource is moved into a function scope, it must be explicitly moved into account storage or destroyed using the `destroy` keyword.
        
    *   **Must occupy exactly one location at any time.**
        

```swift
// Defining a Resource NFT
access(all) resource NFT {
    access(all) let id: UInt64
    init(id: UInt64) {
        self.id = id
    }
}

// Creating and transferring a resource
access(all) fun mintAndStore(account: &Account) {
    // Uses the move operator '<-' instead of equality '='
    let newNFT <- create NFT(id: 1001)
    
    // The asset MUST be moved to storage, otherwise the compiler throws an error
    account.storage.save(<-newNFT, to: /storage/MyNFT)
}
```

#### 2\. The Move Operator (`<-`)

To enforce that resources cannot be accidentally overwritten, Cadence uses the explicit move operator `<-` rather than the standard assignment operator `=`. This visually and syntactically alerts developers that ownership of an asset is being transferred.

#### 3\. Capability-Based Access Control

Instead of checking `msg.sender == owner` at runtime (a common source of authorization bugs in Solidity), Cadence uses **Capabilities**. Accounts issue unforgeable references to their private storage paths, delegating precise permissions (e.g., "read-only" vs. "deposit-only") without exposing the underlying asset.

* * *

The language itself is similar to Swift. Since the creator of CryptoKitties is a former Apple engineer who worked on Keynote around 2010, the language is highly compatible with Apple's development ecosystem.

You can write everything—including financial calculations, game data management (such as rankings), and asset distribution—within a single piece of code. Furthermore, simply by registering a resource to `self`, you can freely execute these processes from the backend.
