October 19, 2023

The Basics of Haskell, Plutus, and Marlowe (Cardano)

EMURGO

The-Basics-of-Haskell-Plutus-and-Marlowe-Cardano-1

For Cardano blockchain developers, it can be a little confusing at first due to the different languages of Haskell, Plutus, and Marlowe present in Cardano. This blog explains the differences between each one, the role each occupies, and how they build on each other when building on Cardano. 

As an open-source, decentralized blockchain with fast and secure transactions with predictable fees and other unique features, Cardano is one of the most versatile smart contract blockchains for developers to build dApps. Cardano is also the first public blockchain to be built upon scientific peer review and cryptographic research methods. With this in mind, Cardano delivers a multi-faceted smart contract platform to meet the varying Web3 demands of blockchain developers, enterprises, and entrepreneurs.

In Cardano, the computer language Haskell and the two domain-specific languages Plutus and Marlowe serve as programming tools to provide a multidimensional view to cater to different user demands. These languages each have a role to play when it comes to production development, but they also reinforce each other. 

More on each below.

What is Haskell?
The-Basics-of-Haskell-Plutus-and-Marlowe-Cardano-2

Haskell is a general-purpose, statically typed, purely functional programming language. It’s based on Lambda Calculus, an alternative to Turing machines, a formal mathematical system for expressing the notion of computations.

Haskell has been at the forefront of functional programming ever since its inception in 1990. It has seen a lot of adoption when it comes to building critical systems in the financial world and for different space agencies as it offers strong security properties when it comes to designing complex systems. 

In Cardano, Haskell is at the core of the entire network. 

The Cardano node was written in Haskell and most of the architecture that underpins the inner workings of the blockchain is all in Haskell code. Anyone looking to work at the lower levels of the network by necessity requires a strong knowledge of Haskell.

Of course, most Cardano blockchain developers won’t go that deep when creating dApps. Yet, Haskell plays an important role for them as well. As we said before, off-chain code is a major component of any dApp. This piece of a smart contract can be written in Haskell when using tools such as the Plutus Application Backend (PAB) from IOG or Atlas

 

Read more: Becoming an off-chain Cardano developer

 

Security and performance gains can be achieved when using Haskell for the off-chain code even though it’s not the only option as we have seen in previous articles in this series. 

Haskell is the language that supports the entire Cardano network. It’s a major component of the blockchain even for those blockchain developers not looking to use it when designing dApps. For this reason, a basic knowledge of the language is important for anyone jumping to Cardano.

What is Plutus?
The-Basics-of-Haskell-Plutus-and-Marlowe-Cardano-3

Plutus is a domain-specific language created to write on-chain code for Cardano. As we discussed previously, a dApp on Cardano is divided between on and off-chain code, the former also called a validator. 

The main language to write the on-chain portion of a smart contract is Plutus. The language borrows most of the syntax and properties of Haskell and also inherits many of the security features of its parent language. 

This means that having a basic knowledge of Haskell will not only help with writing Plutus code but also help reinforce the knowledge of both languages. Most of the principles that come from functional programming in Haskell are what make Plutus code secure when it comes to smart contracts. 

Concretely, Plutus is the language blockchain developers use to code the business logic the Cardano network needs to validate. The on-chain code is the set of rules that make dApps public and immutable, as it is this code that the nodes on Cardano execute when users interact with dApps. 

 

Read more: How to become an on-chain Cardano developer

 

The dApps on Cardano rely on Plutus to secure this business logic, prevent attacks from happening, and govern the behavior of crypto assets. It has enormous importance in the ecosystem for all of those reasons.  

The language Plutus will be the main tool for Cardano blockchain developers. It’s the most supported way to write validators and EMURGO, IOG, and the Cardano Foundation have spent a lot of time writing documentation for this language. 

It has the most support in the ecosystem and it will continue to improve as more features are added to support it. As Plutus is not an ecstatic product, but one that gathers continuous feedback from the community to further introduce improvements. 

What is Marlowe?
The-Basics-of-Haskell-Plutus-and-Marlowe-Cardano-4

Marlowe is another domain-specific language for Cardano. It’s also used to design validators (on-chain) and allow them to deploy this business logic to the network. The main difference between Marlowe and Plutus is that the former was created to be more friendly and intuitive using visual constructs instead of abstract pieces of coding logic. 

Marlowe uses a graphical interface where smart contract concepts such as transfer, amount, deposit, etc. are represented by graphical puzzle pieces. Each piece has a logical set of connections that are required for the logic to be valid. 

Image3

The interface can be used to create most of the basic financial applications found in blockchain technology. Plus, by using the logic of the system, more complex functionalities can be composed from the individual pieces. 

Marlowe was designed to allow projects to easily develop and deploy on-chain code. It aims to lower the barrier and open the power of blockchain to teams that may not have the ability to find a full-time Cardano blockchain developer. 

Additionally, the backend of Marlowe is also using the principles of Haskell. Any validator designed using Marlowe can be converted from the visual of pieces joined together to 100% valid Haskell code.

Image5

This makes it a powerful teaching tool for Haskell and by extension Plutus. Future students can freely compose a validator using the graphical interface and then transform that into code. That way they can see how the represented pieces translate to Plutus and use it as a reference. 

In this way, learning Marlowe reinforced Plutus and Haskell principles. All three major languages on Cardano interlink and build on top of each other.

Learn the skills to become a Cardano blockchain developer with EMURGO Academy
Blog CTA Banner EMURGO Academy Dark

Enroll now

Cardano founding entity EMURGO’s education unit, EMURGO Academy, has created specially tailored programs that aim to train future Cardano blockchain developers. These courses go through all the necessary Haskell principles, Plutus development, and real examples using Marlowe.

It’s designed to take programmers from other fields and give them the necessary tools to be competent Cardano developers. It exposes students to all the different domains in Cardano such as Cardano node, Cardano CLI, Plutus, off-chain code, and Marlowe. 

Enroll now with EMURGO Academy and start your journey to becoming a Cardano blockchain developer.

About EMURGO

Disclaimer 

You should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained herein shall constitute a solicitation, recommendation, endorsement, or offer by EMURGO to invest.

Related articles