Many different computer programming languages are employed in cryptocurrency programming.

In this article, we take a look at cryptocurrency projects and the languages they employ.

We briefly discuss each language while highlighting their main characteristics, learning difficulty and how they are deployed in different crypto software projects.

Haskell

Haskell is the world’s only widely adopted general purpose purely functional programming (FP) language. There are other purely functional dialects, but they’re usually limited to domain-specific applications.

It is unique in the fact that it does not allow any exceptions to the functional programming paradigm, unlike mixed functional/object-oriented languages like Scala and OCaml. This functional purity makes Haskell a favorite language of mathematicians, logicians and FP enthusiasts. Cryptographers usually come from these fields of study, so Haskell is slowly growing within the cryptocurrency development field.

Purely Functional

Why is the purely functional paradigm desirable in cryptocurrency and blockchain software development? There are many reasons for this, but we’ll approach some of the most important ones.

Firstly, purely functional programming means that data is immutable and only functions can manipulate input and produce a different output. In Haskell you cannot say that a variable is equal to the number 3 and then say it is equal to the number 10. Once a “variable” (a constant, to be precise) is named in Haskell, it will always mean the same thing. This is a very special trait in decentralized systems. The blockchain itself is immutable and when you have millions of users processing data simultaneously it is important to guarantee immutability so that the parallel processing of this data will produce the same result no matter where it happens. Millions of nodes process blockchain transactions at the same time and they all must reach the same consensus. Therefore functional programming’s data immutability is a very desirable trait in parallel decentralized applications.

Formal Software Verification

Secondly, most formally verified software systems, like the Coq proof assistant, are written in functional programming languages. This is due to the fact that formal verification uses mathematical concepts and functional languages are very close to mathematical principles. In fact mathematicians usually feel at home working with FP, especially when they apply programming concepts that are directly derived from algebraic structures like monads, partial functions, set theoretical concepts and so on.

Steep Learning Curve

The Haskell learning curve is steep, especially for non-math oriented folks. Experienced object oriented or structured programmers with long time experience in these paradigms usually face difficulties learning Haskell. Some Haskell tutorials begin by saying “forget all that you had learned about programming before” and this is no understatement. Haskell requires a completely different view of software development than that used on most other popular programming languages.

Cardano ADA uses the Haskell programming language for its core technology.

Javascript

Javascript (JS) is an all purpose scripting language that derived its syntax from Java. (It is otherwise not related to Java in any way.) JS was developed for the Netscape Navigator web browser back in the 1990’s. It was meant to make web pages more dynamic and was initially used for very trivial jobs like animating button pushes and other graphic gimmicks of the time. There was a brief battle between Javascript and Java Applets, but the former won and Java Applets are now only used in very niche-specific applications.

Loosely Typed

Javascript faced ups and downs in popularity and suffered its share of criticism over time, especially concerning its all too loose type system which allowed numbers to become other types of values in implicit conversions which sometimes produced non intuitive results.

Most the criticism faded away when Google adopted Javascript and decided to develop it into what we know as JS today.

Enter Node.js

Google’s Javascript engine was later extracted from the Chrome browser and was made into a standalone JS interpreter, sparking a whole new community of developers around the Node.JS project.

Node became as fast or faster than other programming languages and Javascript became a serious alternative to other server-side programming environments. Facebook fueled the JS fire with React.JS, a front-end framework and Google also offers their own front-end solution with Angular.JS. The jQuery library made browser DOM programming very simple and gained millions of users.

Easy to Learn

The Javascript learning curve is very shallow. It is an easy language to learn. This has drawbacks of course, as it is also very easy to shoot your own foot with JS because of its loose type system which allows numbers, strings, objects and everything else to be intermixed and used ex-changeably with lots of implicit conversions happening in the background.

In the cryptocurrency universe, when you hear Javascript you might as well say Ethereum. Although many large scale crypto projects use Javascript, Ethereum was the first to deploy a complete front-end written in Javascript insted of Bitcoin’s C++ (which until then was used by most coins). Newer cryptocurrencies all use Javascript in one way or another.

OCaml

OCaml is a functional programming language derived from ML.

As we mentioned in the section about Haskell, functional programming languages usually can be formally verified. In fact, the Coq proof assistant, used for formal software verification, can produce 100% guaranteed correct OCaml code.

OCAml is Turing-complete and can be used for any kind of programming, from system-level development to data-driven business system backends.

The Tezos cryptocurrency is written in OCaml and has some formally verified components.

If you wish to extend or modify Tezos, you may want to learn OCaml.

OCaml Learning Curve

OCaml can be difficult to learn, especially if you’ve never programmed in a functional language before.

The same observations we made about Haskell are valid here. In fact most functional programming languages are similar in concept. To program in a functional paradigm, you must “unlearn” a lot of what is taught in imperative language theory.

Other than that, OCaml is a clean and elegant language that is definitely worth including in your arsenal.

Rust

Rust is a relatively new systems-level programming language that is beginning to gain ground in cryptocurrency development.

Some of the new Cardano components, such as the jormungandr full node implementation, are written in Rust.

Rust is meant to be low level while incorporating modern language features. Its main application are is to substitute C++ as the de-facto low level systems development language.

Systems written in Rust do not have to manually manage memory and pointers. But, unlike Java, Rust does not require a runtime virtual machine. The memory management strategy is compiled along with Rust programs, such that there’s very little runtime overhead. For this reason, Rust is ideal for cryptocurrency development, as cryptographic routines can be implemented in a fast and secure language.

Rust Learning Curve

Rust is relatively hard to learn.

Like C++, it is meant for systems development. It therefore includes many levers and switches that you must learn to work with in order to write efficient programs.

At a basic level its syntax looks a lot like a mix between C and Scala. You can program basic Rust solutions without knowing the entire language.

As you delve deeper into the language features, Rust begins to show its true power and versatility. That’s when it begins to differentiate itself from other languages.

Here you’ll find a list of cryptocurrencies written in Rust.

Go

Go is a systems programming language developed by Rob Pike at Google.

In fact Go is named that way because it’s a prefix for Google. It is a low level programming language that aims to be very fast, to offer modern concepts but to remain close to the machine.

The Go language is well suited for cryptographic programming, which usually requires proximity with the computer hardware in order to exploit its optimizations.

Steep Learning Curve: Systems Language

The Go learning curve can be steep. It looks fairly familiar to C-style language programmers but that’s only superficially. Developers aiming to enter the Go field should prepare to learn a lot of new basic concepts before becoming well versed in the language.

Go is the language used in the ubiquitous geth Ethereum client.

Solidity

Solidity is a Turing-complete language designed specifically for smart contract development.

Its syntax is very similar to Javascript, but the language also incorporates some aspects of Python and C++.

Ethereum was the first system to deploy Solidity through its EVM technology (Ethereum Virtual Machine).

Easy to Learn

Solidity is relatively easy to learn.

Its syntax is intuitive, especially if you’re familiar with C-based languages like Java or Javascript. Solidity also does not have pointers or complex memory management requirements. The EVM takes care of all the memory handling for us.

The biggest challenge in developing smart contracts is not the language itself, but the smart contract logic. Very subtle details in smart contract design can allow attackers to steal funds (see The DAO hack).

Solidity is used in Ethereum, Ethereum Classic and most cryptocurrencies forked from these.

freeCodeCamp offers a crash course to get you started programming Solidity:

Java

Although not very big in the cryptocurrency universe, Java is the world’s most popular programming language according to the TIOBE index.

Brief History of Java

Java was created by James Gosling, a famed engineer who worked at Sun Microsystems, as a replacement for C++. Initially (internally at Sun) it was called Project Oak, but was later renamed to Java for the public release.

The first publicly available version of the language launched in 1995 and caused an earthquake in the world of software engineering. Java adopted the C++ syntax with modifications, allowing C++ programmers to migrate more easily.

Its initial motto was “Write once, run anywhere” which, for many years, was true only in part since Java wasn’t very stable on several platforms. To allow Java programs to run anywhere, Sun introduced the Java Virtual Machine. This virtual computer was a layer of compatibility between the machine and Java programs.

Bytecode: Write Once, Run Anywhere

A Java program was not compiled to the physical computer’s language, but to an intermediary language called bytecode.

Bytecode generated once could be interpreted by any Java Virtual Machine, anywhere. But this interpretation step was very slow and made Java gain an early fame for sluggishness and software bloat. Java based editors like Eclipse were slower than Emacs and other native editors, early Java based programs like JBuilder were also very slow.

Later this was optimized by using JIT (Just in Time Compilation) and other tricks to make Java programs almost as fast as native software. Today, with the parallelization and other optimizations available in most modern CPUs, Java performance is almost on par with native code.

Strong Community

Java has a gigantic community behind it, the Apache Foundation produces tens of amazing projects based on Java and all these libraries can be used freely in your projects. It is indeed an amazing language with a brilliant community behind it.

IOTA uses Java for its reference implementation.

TRON also uses Java.

C++

We left this biggie for last. C++ may as well be the mother of all cryptographic projects. It is, of course, the language used by Bitcoin Core and every first generation crypto either adapted C++ code itself or translated the Bitcoin C++ ideas to other languages (which is how the GPU code that killed CPU Bitcoin mining came to be).

Early in the history of cryptocurrencies, sparked by Bitcoin of course, most projects were implemented in C++ with front-ends written using the ubiquitous Qt framework. The best mining software and most native wallets were all written in C++ in the early days of crypto.

Big Language

C++ is a very complex language.

Some folks approach it as a “sophisticated C”, in which case it’s perfectly fine to write C programs in C++ since the former is a subset of the latter.

Any C program will compile just fine under a C++ compiler, which leads a lot of developers to mix these two languages. But do not fool yourself. The C++ semantics are a lot more complex than C.

C++ allows for multiple inheritance, which itself can be a trap for new developers and should be used very carefully when designing class hierarchies.

Steep Learning Curve

Having said that, the C++ learning curve can be very steep.

If you use it like C then starting to produce working programs can be quick. But once you dive into the intricacies of C++, especially modern C++, prepare to devour quite a few books before you fully grasp the intricacies of this language.

C++ in Cryptocurrency Development

Cryptocurrency projects which use C++ include Bitcoin and, as mentioned before, most first generation coins forked off of, or which were based on concepts from, Bitcoin.

Ripple uses C++. Other projects which use C++ include Dogecoin, Litecoin, Bitcoin Cash, Dash, Monero, EOS, and the C++ Ethereum client eth.

Stellar uses the C language, which we will include under the C++ umbrella for the purpose of this article.

Conclusion

Several other programming languages are used in cryptocurrency development but here we’ve covered the main ones. We hope this brief tour through the main programming languages used in cryptocurrency programming will help guide you to learn more about software development in this exciting new field!

If you like this article, please share on your favorite social media and don’t forget to follow us on Twitter!

—

Programming Languages Collage: Daniel Iversen @ Flickr