Why Functional Languages Should Be Used for Blockchain Development

in #functional8 years ago (edited)

Introduction

Current blockchain protocols such as the Bitcoin and Ethereum blockchains use C++ and Go to implement their features. These languages at the end of the day are stateful languages and I believe that there is a lot to gain by building blockchains with functional languages such as OCaml, Erlang and Haskell.

Functional programming is built on principles of lamda calculus

Benefits of Functional Programming Languages

Immutability

Blockchain technology is built around the concept of immutability, the fact that you can't change a transaction, but most blockchain implementations are built using stateful languages. This can lead to a multitude of possible vulnerabilities and unintended side effects. Thankfully functional languages do not have mutable variables and once you set a value it cannot be changed.

Fault tolerance

Fault tolerance is the ability for a system to continue running even in the event of a failure. Erlang was used in the 1980s to handle millions of telephone call switches to ensure maximum availability, in a highly distributed large scale scenario Erlang ensured the Ericsson telecommunications company had 99.99% uptime per year. Languages such as C++ and Go do not provide fault tolerance which seems like a no-brainer for a blockchain implementation.

Easily parallelized, highly distributed

Functional programming enables one to create highly parallelized and distributed systems, partly because the aspect of immutability leads to a number of compiler optimizations. Coupled with built-in functions for iteration such as map and reduce there seems to be very little reasons to use C++ or any other stateful language for blockchain development.

Market validation

Tezos which is having their upcoming ICO, built their blockchain from the ground up and heavily use OCaml which is a popular functional language. The whole idea behind Tezos is a self-governing blockchain. You can learn more about their project and view the countdown to their ICO at their official site here. You can view their project's GitHub source code here.

Conclusion

I strongly believe that the future of blockchain development should be in functional programming. I hope you enjoyed this post.
Cheers
~Np

Sort:  

I agree.

What do you think of Clojure? and status.im using ClojureScript?

This http://blog.syrinx.net/the-resurrection-of-lll-part-1/
talks about a LISP like language called lll for writing smart contracts.

I would take it a step further, the future of programming should be functional programming :)

You can see its influence already. C++ 11, Java 8 and C# 3.5 was when these languages started to pull in lambda. C# is pushing more functional features with each release.

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.033
BTC 97689.92
ETH 3132.93
USDT 1.00
SBD 2.96