- 1 Haskell
- 3 Go
- 4 Java
- 5 C++
- 6 Conclusion
Many different computer programming languages are employed in cryptocurrency programming.
In this article we take a look at cryptocurrency projects, the languages they use and we briefly talk about each one. We attempt to present their main characteristics, probable learning curve and how they are deployed in different crypto software projects.
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.
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.
Easy to Learn
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.
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.
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.
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.
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.
Stellar uses the C language, which we will include under the C++ umbrella for the purpose of this article.
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