Why Java for Blockchain

Here’s why PegaSys chose Java for its new Ethereum client.

Faisal Khan
ConsenSys Media
5 min readSep 24, 2018

--

deve

PegaSys is the protocol engineering team at ConsenSys. Sign up for the PegaSys newsletter to get the latest updates on Ethereum 2.0.

What’s the first thing that comes to your mind when someone says Java? If you’re not feeling too kind, you might think “old.” Others might think sturdy, safe, or reliable. For us, Java means “enterprise.”

Java is versatile and undoubtedly popular, but it might seem a surprising choice for something as cutting-edge as an Ethereum client. After all, the most popular clients are written in Go and Rust, and new clients are being added in languages like Elixir and Nim, which each bring various pros and cons from their respective programming models.

The PegaSys team chose Java because our mission is to build performant Ethereum clients and tools that enterprises can use in production environments. Java is a logical fit to us for a number of reasons, from the size and maturity of its development community to more technical and Ethereum-specific reasons such as maintenance, speed, and extensibility that make it the best language for a large application such as an Ethereum client.

Enterprises are still adding Java programmers in large numbers. Source: Coding Dojo, 2017.

The Java community has size and staying power

When we set out to write a new Ethereum client built to meet enterprise needs, the size and maturity of the Java ecosystem made the decision a no-brainer. As an open source project, we wanted to attract a large, active group of developers to contribute to our work. Statistics abound on the community’s size. Oracle estimates that there are over ten million Java developers, and the language’s share among job postings (above) shows that enterprises are still actively building with it. Java also has staying power. Even as high-level languages like Python have spread like wildfire and JavaScript becomes more common for back-end developers, Java’s share in the developer community has not eroded (below) like some other languages it is often compared to (C#, C++).

Python has seen exponential growth, but is not eroding Java’s share. Source: Stack Overflow.

That staying power is likely a product of the maturity of the ecosystem. Monitoring and deployment tools such as Java Mission Control or JMX are widely available and well understood, which makes the lives of anyone managing applications much easier. By using Camel or the Spring Framework, basically anything can be integrated into a Java stack. And although blockchain is a breakthrough technology, IT environments often have lots of hoops to jump through to deploy tools in production, and so the availability of multiple options for integrating to existing applications is a critical piece to broadening adoption without getting stuck in red tape. Logging, GC tuning, and runtime management often take time to build processes around, and not every enterprise will want or be able to use Docker to get around these hurdles.

Java is easier to maintain

There are Ethereum-specific reasons for using Java as well. Java might require writing more code up-front, but it will likely save time and effort in the long run: Ethereum clients are large, complicated applications, and refactoring and maintaining code is easier with a static, typed language like Java. The Java Virtual Machine (JVM) gives us flexibility to take advantage of other opportunities, such as using Scala or Kotlin, which may prove interesting as other blockchain companies’ experiments with functional programming play out. The JVM also grants code portability, and is well-supported across a variety of platforms including desktop, mobile, and embedded.

Java is fast

With its mature just-in-time (JIT) compiler and modern Garbage Collection (GC) algorithm, Java can be as fast as Go or C and much faster than Python or Ruby. This is important for an application that requires major throughput. Powerful high performance enterprise applications like Apache Cassandra and Kafka run on Java, proving its case as a language of choice for large, distributed systems.

Java supports pluggability

A core tenet of our Pantheon client development has been pluggable architecture. This is the bread and butter of Java — there is already a library for almost anything, including many cryptographic constructs we seek to employ. Despite the up-front cost of well-structured code, the number of Java libraries, the strong typing, and wide adoption of interfaces/class hierarchies ensure a pluggable architecture.

Java can meet future certification needs

In the Enterprise space, one of the biggest areas where pluggability is going to really matter at the code-level (vs. a network API level) is cryptography. Java has already had much enterprise investment in the certification of cryptographic modules, and in most major JVMs. As enterprises get more serious about implementing blockchain in production environments, there will be critical questions around the constructs used and whether they meet cybersecurity standards such as NIST. Being able to plug new constructs in as standards evolve and cryptography security is broken/created will be an ongoing advantage.

Pantheon: An Ethereum Java Client

We believe Java is the right choice for Pantheon, and will help drive adoption of Ethereum in the enterprise space. We’ll continue to explore and use other languages such as Go across projects, but Java will continue to be core to our model to meet enterprise goals. If you’re as enthusiastic about that mission as we are, reach out about joining our team and sign up for our Enterprise Ethereum Hackathon in Prague following DevCon4.

Special thanks to Avery Erwin of ConsenSys, Vijay Michalik, Matthew Halpern, Matt English, and Adrian Sutton of PegaSys, and Peter Broadhurst of Kaleido in helping to write this post.

Disclaimer: The views expressed by the author above do not necessarily represent the views of Consensys AG. ConsenSys is a decentralized community with ConsenSys Media being a platform for members to freely express their diverse ideas and perspectives. To learn more about ConsenSys and Ethereum, please visit our website.

--

--

Faisal Khan
ConsenSys Media

Faisal works on strategy and business development for PegaSys, the protocol engineering group at ConsenSys.