The origins of blockchain

The first blockchain was conceptualized and implemented as a core component of Bitcoin cryptocurrency. Blockchain relies heavily on cryptography and many cryptographic algorithms are computationally intensive. For a long time, before the blockchain era, only low-level languages offered performance characteristics sufficient for implementing algorithms in an efficient way. This has resulted in C and C++ becoming the most commonly used languages in cryptography.

Since Bitcoin has its origins in the cryptographic community, the choice of the language it’s implemented in (C++) is not surprising. Many cryptocurrencies, which appeared after Bitcoin, have started as clones of Bitcoin’s codebase, with some degree of modifications applied. Or they have been influenced and borrowed from Bitcoin’s code. This has resulted in C++ becoming widespread in early blockchain projects.

Evolving software industry trends…

In 1990s and early 2000s, object-oriented programming has taken over the world. Many software projects have been implemented in object-oriented languages like C++, Java and C#, leading to object-oriented approach establishing itself as the de facto standard in designing software.

In mid 2000s, the computer industry came to the realization that CPU speed improvements cannot continue forever and a major shift to multi-core machines started. Relying heavily on statefulness and mutability, object-oriented languages had to deal with the problems of multi-threading and shared mutable state.

These problems were one of the reasons for the functional programming paradigm to start getting traction, after being neglected for years, leading to the situation where all major object-oriented languages in existence today have started including features and paradigms from functional programming.

The benefits of functional programming

Although functional programming paradigms are being more and more embraced in object-oriented and imperative languages, the advantages of functional programming are fully experienced only when using languages designed with a functional programming mindset.

Some of the important features present in functional programming languages are:

Immutability — Assumes data cannot change once created, which conceptually aligns with blockchain ideas. Immutability makes parallel processing of data much safer and easier to reason about, which is a very important aspect, considering that multi-core machines are a standard nowadays, and will become even more important in the future.

Powerful type systems — Statically typed functional programming languages (e.g. Haskell, OCaml, F#, Scala) have very powerful type systems which can prevent many common simple errors already in the compilation phase. This alleviates the need for verbose unit testing and enables a focus on testing of important business rules.

Algebraic data types — Enables domain model design in a succinct and expressive way.

Pattern matching — Enables matching of the data, to known data structures, by decomposing it in a compact and declarative way, instead of performing imperative checks and manual extraction of values.

First class functions — Functional programming languages treat functions as any other data. Functions can be passed as arguments to other functions and can be composed on the fly to form more complex logic out of the simple building blocks, which are easy to test.

Software implemented in functional programming languages with strong type systems, can offer a much higher degree of correctness, and is less vulnerable to exploits than software implemented in unsafe low-level languages. Considering the purpose of blockchain software, this is a very important aspect.

All the benefits of functional programming languages mentioned above, did not go unnoticed in the blockchain circles. Many new innovative projects, considered to be new generation of blockchains, decided to use a functional programming language in their implementation. Here are some of them:

Cardano — implemented in Haskell

Tezos — implemented in OCaml

aeternity — implemented in Erlang

Zen Protocol — implemented in F#

So what language should we choose?

When choosing a programming language for a project, teams should avoid falling into the cargo cult trap by choosing a technology just because some other successful team is using it.

High quality software depends first and foremost on the developer’s skills. However, having a good tool can significantly help.

When we started out with the development of our blockchain and had to decide what technology to base it on, we took several programming languages into consideration. Having experienced the benefits of a functional programming approach before, we have decided to build our blockchain in F#, one of the most pragmatic functional languages, with great tooling support and exposure to the rich .NET ecosystem.

Coming soon — more technology explained…