Sooraj Profile picture
Jun 1, 2022 31 tweets 15 min read Read on X
#Ethereum's account-based model & smart contract based on Solidity is a marriage made in hell

Vasil-HFC Event is on the horizon

& its time to unleash synergies of #Cardano's EUTxO model & Plutus

Here's a thread on why EUTxO model & functional programming is what DeFi needs🧵👇
The ultimate goal of #Blockchain

Is to replace the corrupt & centralized traditional financial system

To create an inclusive global financial system to bank the unbanked

But are we going to do it with a system that is more problematic than what we have now?
#Crypto in general & DeFi has seen massive growth in the last decade

DeFi-exploits have also seen proportional or even bigger growth

This makes us realize the fundamental requirement of the system we want to be a part of

A blockchain architecture that offers safety & security
A blockchain architecture that is designed to host mission-critical DApps

And when it comes to simple & elegant design that offers safety & security

There are two examples out there

•UTxO model of #Bitcoin

•& functional programming with #Haskell
#Cardano combines both of these worlds

• By Extending #Bitcoin's EUTxO-model

#Cardano created the EUTxO-ledger architecture

• Powered by smart contracts based on Plutus

• Which in turn provides a safe, full-stack programming environment based on #Haskell
So why is the combination of

#Bitcoin's UTxO-ledger model & functional programming with #Haskell

A marriage made in heaven!!

When compared to something terrible like

#Ethreum's Accounts-based model & imperative programming based on Solidity
So to understand why #Cardano choose a fundamentally different architecture to #Ethereum

We should understand the synergies between

• UTxO-Model & functional programming

So let's dig a bit deeper !!

To understand the principles behind functional programming
So what is functional programming?

Functional programming is the process of building software

By composing pure functions

Which avoids 👇

• shared state

• mutable data

• & side-effects
So what are pure functions?

In the context of computation,

A pure function is analogous to a mathematical function

Which is the basis for all formal scientific reasoning

It is a function (a block of code)

that always returns the same result if the same arguments are passed
A function must follow four rules to behave like a function in math:

• It must always take an argument

• It must always return a value

• It must not depend on anything that changes

• It must not change anything by itself

A function with such properties is called "Pure"
Pure functions are "Stateless" and "timeless"

Meaning

Pure functions are easily parallelizable since they encourage immutable data structures

Which reduces the side-effects

That makes code hard to run on multiple processors
Just like #Bitcoin's UTxOs

Functions are also just mappings from inputs to outputs 

It does not depend on any state or data change during a program’s execution

There are no external states & side effects

This gives certainty & predictability to the behavior of the code
Haskell has 1st-class functions

A programming language is said to have 1st-class functions

When functions are no different from any other variable

Where,

•Functions can be used as arguments

•Can be returned as values from other functions

•& can be assigned to a variable
1st-class functions allow to abstract out

Any repetitive computation from the code

And ultimately enables to write functions that produce other functions

These functions are referred to as higher-order functions
Higher-order functions simply mean

Functions that are operating on other functions

Why is it useful?

1. Higher-order functions raise the level of abstraction

Meaning

It allows to abstract over actions & not just values

Thus, we don’t have to reason about lower-level details
2. Higher-order functions are key to parameterizing code by behavior

Meaning

It allows us to define common programming patterns

And write functions about functions

Having higher-order functions is where a lot of the benefits of functional programming come from
In a nutshell,

•Functional programming uses mathematics-like values & functions

•To yield results that have no outside influence & are well-evaluated throughout

•leading to a more parallelizable transparent & cleaner code

•That helps the user in debugging & maintenance
On the other hand

Programming in a dynamic environment with object-oriented programming

Results in the creation of huge "Dependency Hell"

Resulting in adding abstraction on top of abstraction to modularize complex systems

This results in a "shared mutable state/global state"
When submodules try to access the global state simultaneously

complexity arises & it results in a chaotic programming environment

Just like the Account model of #Ethereum

Where there's Global State & transactions fail in mid-script execution

After taking fees from the user
If we could use our common sense and consider the above-mentioned reasons

A pure functional programming language like #Haskell

should ideally be the go-to programming language for dApps

which are enabling financial transactions north of billions of dollars
Haskell is similar to the UTxOs of #Bitcoin

where the pure function is a mapping from input to output 

& #Ethreum's account model is similar to object-oriented programming

Accounts are similar to objects

where they send messages to each other in a dynamic & distributed setup
Although he had the knowledge of the Account-based model

When Satoshi invented #Bitcoin , he choose the UTxO-Model

Because the semantic model of the ledger stays simple

In a complex distributed and dynamic computing environment
The UTxO-model has very limited expressiveness of programmability

This limitation of #Bitcoin is what motivated Vitalik

To choose the Account-based ledger model for #Ethereum

But this resulted in the creation of a "Global state"

& this complicates the programming of dApps
#Cardano took a methodical approach

Extending #Bitcoin's UTxO model with scripts & arbitrary data

& by using #Haskell based Plutus programming language

Where the side-effect free nature of E-UTXO transactions

Maps perfectly into the pure-functional nature of Haskell functions
The arbitrary logic/scripts allow the E-UTxO model to have more expressiveness

The arbitrary data carries with it information about the state of outputs

which enables the contract state to be localized as the state is localized

There is no notion of a ''Global state''
In #Ethereum

to write a smart contract you write the on-chain code in solidity

then a Javascript code for the off-chain part that runs in the wallet

This is inconvenient

As you have to develop an ad-hoc integration between the two pieces of code

Which is Complex and Fragile
#Cardano's Plutus Platform uses Haskell for the off-chain & PlutusTX for the on-chain code

That compiles down to Plutus Core

Enabling the use of same syntax, compiler & data types in both parts of the code

Which translates into an integrated, compact & robust programming model
Meaning

Its a lot easier to reason about the behavior of a smart contract

While programming a smart contract in Plutus

It won't be too difficult to actually prove that

Code will behave exactly how it is supposed to

Enabling easily verifiable code for secure & safe dApps
We cant build the future of open global finance on platforms where multimillion-dollar hacks occur on a weekly basis

It has to be built on a platform

That has put enough work and thought

To build not only scalable but secure & safe dApps
#Cardano is melding the best of both worlds with E-UTxO-model

combining the elegant & simple architecture of #Bitcoin's UTxO-model

that maps perfectly into the pure-functional nature of Haskell functions

bringing

•safety

•security

•& scalability

To the #Blockchain world
If you found this thread valuable:

1. Toss me a follow for more threads on #blockchain technical deep dives

2. Here’s another thread on "EUTxO and Parallelism" that you may find useful :

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Sooraj

Sooraj Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @SoorajKSaju

Sep 20, 2023
If blockchains aspire to be the cornerstone of global finance

the dApps on these blockchains must be built with the rigor & reliability of safety-critical systems

Here's why VMs leveraging the Finite State Machines (FSM) model will be vital in building mission-critical dApps👇 Image
2/27
The current state of DeFi does not enable mission-critical dApps

Why is this the case?

Let's examine the Ethereum smart contract model,

which is a black box with an insurmountable amount of complexity

and serves as a fertile ground for exploits
3/27
An #Ethereum SC can be conceptualized as a black box deployed on the network by a dev

Within this black box is a miniature, general-purpose computer server running specific code

To interact with this, users or other apps can call its "methods" by sending a signed message Image
Read 27 tweets
Aug 23, 2023
To ensure security, PoS chains need a significant amount of capital

On the other hand

#Bitcoin, which operates on PoW, represents an idle asset with a market cap of HALF A TRILLION USD

Is it possible to secure PoS chains with #Bitcoin?

Yes & here's why its a game changer🧵👇 Image
2/26
PoS chains are based on the idea that they can enhance scalability & energy efficiency

while preserving the security of the ledger

This is achieved by allowing parties to extend the blockchain based on the amount of coins they own

instead of relying on computing power Image
3/26
Simply said,

PoW chains are secured by computation,

and PoS chains are secured by capital

In the current high-capital-cost environment, capital is often difficult to attract

especially for app-specific chains or Appchains in their bootstrapping phase
Read 27 tweets
Jun 22, 2023
Although #Cardano's architecture is fundamentally different from #Ethereum's

1st gen of dApps on #Cardano resembled EVM's account-based programming model

BUT

The future belongs to dApps that fully leverage the E-UTxO model of Cardano

Here's a thread on distributed dApps🧵👇
2/33
The E-UTxO model of #Cardano is fundamentally superior to Ethereum’s account-based model

This model enables the implementation of innovative, scalable solutions

that are virtually impossible to achieve using #Ethereum’s account-based approach

However,
3/33
Designs of most dApps on #Cardano, especially DEXs, closely resemble EVM's account-based programming paradigm

What we need are dApps that make innovative design choices & fully exploit the potential of E-UTxO model

That's the direction we're heading with distributed dApps
Read 34 tweets
Jun 17, 2023
In a world where

#Haskell fuels a mere 0.65% of internet projects & #Python dominates with 25%

the need for a #Python-based SC dev platform becomes increasingly pivotal for any #blockchain

Enter @OpShinDev: a game-changing tool for onboarding new developers to #Cardano🧵👇 Image
2/14
@OpShinDev is a Python-based solution,

leveraging one of the most commonly used programming languages

Its ambition is to enhance the accessibility & usability of blockchain development

without compromising the intricacies required for SCs on #Cardano
3/14
The defining feature of OpShin is its grounding in Python 3

Python's compatibility allows seamless integration with off-chain Python-based tools such as PyCardano

and lets developers utilize existing testing frameworks and IDEs (Integrated Development Environment) Image
Read 18 tweets
Jun 13, 2023
As it stands, the Haskell-Plutus platform serves as the primary tool for developing & deploying smart contracts on #Cardano

However, a novel programming language "Aiken" is emerging as a superior alternative

Discover what sets Aiken apart & why it's a game-changer for #Cardano Image
2/27
What is Aiken?

It is a pure functional programming language

tailored to offer developers a modern & efficient environment for constructing smart contracts on #Cardano

It is specifically designed to enhance UX by simplifying the process of creating dApps on #Cardano
3/27
Created specifically for the Cardano ecosystem,

Aiken simplifies SC development and deployment while focusing on accessibility and user-friendliness for developers

So let's take a look at the Key Features of Aiken👇
Read 29 tweets
May 2, 2023
Almost 90% of #Ethereum's L2 TVL is on rollups such as #Optimism & #Arbitrum

Which lack critical safety measures & are governed by multisigs

putting billions of user funds at risk

Here are the reasons why these rollups are ticking timebombs,

waiting to go up in flames🧵👇 Image
2/25
Primary factor hindering #blockchain's widespread adoption & competition with Web2 solutions is its lack of scalability

Currently, #blockchains are in a phase where they are exploring ways to scale

while maintaining decentralization & security

That's where rollups come in Image
3/25
Rollups are L2 solutions designed to improve blockchain performance & capacity

by processing transactions off-chain,

"THEORETICALLY" utilizing the security & #decentralization of L1 protocols

This is why #Ethereum developers have completely shifted their focus to rollups Image
Read 27 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(