Haskelling Bitcoin

The case for Bitcoin development in Haskell

Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. Currently there are only a handful of Bitcoin libraries developed in Haskell with more than 5 stars on GitHub, while there are hundreds of (redundant) libraries developed in imperative programming languages. Haskell has certain properties that makes it an excellent programming language for developing Bitcoin applications. At the same time, Haskell is underutilized in its use in developing secure and scalable Bitcoin applications.

Bitcoin applications are safety-critical thus it is important to follow strict development practices. Haskell being a pure functional language along with its powerful type system makes reasoning about programs and formal verification relatively easier than programs written in an imperative language.

Many Bitcoin applications are targeted towards the increasing mainstream market so scalability is essential. Since Moore’s Law began to slow down to a halt, chip-makers began developing multi-core chips to support the exponentially expanding demand for computation. The challenge lies in having the skills required to develop applications that utilizes those multiple cores. Haskell, by being a pure functional language, isolates side-effects. Isolating side-effects makes parallel programs written in Haskell arguably easier to reason about.

Haskell is the language of choice for skillful hobbyists. There is a reason why it’s the most popular weekend language. The below figure shows the differences between the frequencies of occurrences of question tags in the weekdays and weekends.

The fact that many programmers use Haskell on the weekend provides a good supply of professional programmers to be hired to work on full-time Haskell projects.

Haskell is a great hiring strategy. Iterating the above point, the interest among hobbyist in Haskell provides potential for good hires. One major headache to companies in the hiring process is filtering through the sheer number of low-quality applications. There is just too much potential for false negatives and false positives during the hiring process. Many companies that implemented this strategy have seen good results. One of which is Galois, Inc whose management model is quite intriguing.

Bitcoin companies could lure Haskell enthusiasts into Bitcoin with the availability of jobs in the ecosystem. I for sure want those guys in Bitcoin!

Blockstream chose Haskell as the language of choice to generate Simplicity, their new low-level bitcoin scripting language. If you are a Haskell developer this news alone should get you super excited about getting into bitcoin scripting and smart contracts!

Many know the famous tweet by Hal Finney.

Not one week have passed since the genesis block is mined for Hal Finney to start running it

But a few noticed the tweet that precedes it immediately.

Learning Haskell on a new year, only a few days away from the launch of the first bitcoin software

Finney saw the obvious logical next step in bitcoin development ;)

The current state of software development in Haskell

However, Haskell is used by relatively few programmers. The below chart compares the number of five-star repositories for the top three most common languages to Haskell, keeping in mind the ratio for the number of repositories for each language to the total number of repositories of the four languages. There were a total of 360,000 repositories.

This figure shows the ratios for the number of repositories on GitHub with more than 5 stars for each language to the total number of repositories for the four of them

We can see a similar distribution for five-starred Bitcoin projects. Which totaled 887 repositories.

This figure shows the ratios for the number of bitcoin-related repositories on GitHub with more than 5 stars for each language to the total number of repositories for the four of them

Why is the general usage of Haskell so low in software development? Many reasons could be contributing to the underutilization of Haskell in software development. Just to name a few:

Misconception about Haskell being suitable only for academic research. This is partly due to Haskell’s development history.

Steep learning curve and a painful learning process. Programmers love the quick feedback they get during development. Be ready to start from scratch even as a seasoned programmer without prior exposure to the functional paradigm.

Online resources do a bad job explaining for several reasons.

For more on Haskell

Start with this meta-tutorial. Then check out this great curation from the author of “Haskell Programming from first principles”. Typeclassopedia is a superb reference for learning Haskell’s standard type classes, a concept that might be a struggle initially but many developers grow to love. The School of Haskell offers a platform for learning Haskell and crowd sourcing Haskell learning materials. Also check out The Haskell Cast if you want some listening material.

For more on Bitcoin