
First binding for Exonum: why we chose Java
The core of our framework for developing private Exonum blockchains is written in Rust, since this PL is focused on the safety of working with memory. However, along with many advantages, Rust has a number of features that complicate the "interaction" with it: its syntax is unusual for many developers, and the entry threshold is quite high.
To simplify the work with the Exonum platform and make it more accessible to the audience, we decided to write a binding library. The language for binding has become Java.
Why we chose Java, we tell under a cat. / Exonum

Exonum is our open source framework for developing private blockchains. The blockchain on Exonum is much faster than public blockchains and is capable of processing up to 5 thousand transactions per second. For comparison, in Ethereum this figure is several dozen , while Bitcoin has it even less .
Exonum uses a Byzantine consensus algorithm to protect data. It does not require mining and guarantees the correct execution of transactions, even if a third of the network nodes are compromised.
Exonum platform can be used in any areas: financial, technological, legal. In particular, the framework is suitable for creating digital rights management systems (demo canfound on the official website ) and the organization of voting ( demo ). In both cases, all processes that occur are as transparent as possible and are protected by cryptographic mechanisms.
Last year, using the Exonum platform, the State Land Cadastre of Ukraine was implemented. And before that, a land management project in Georgia was launched at Exonum. We are also negotiating with dozens of Fortune 500 companies and the European Union to implement our system in their business processes.
The core of Exonum is written in Rust. The choice is justified by the fact that this PL focuses on security and speed - it works faster on some tasks than Java, Go, C and C ++. At the same time, Rust guarantees memory security and prevents racing.when two threads try to access the same data.
The Rust compiler is designed to minimize the number of bugs caused by the influence of the human factor. For example, it eliminates several classes of errors at the expense of the concept of lifetime and possession.
All values in Rust have a "domain of ownership." When a name goes beyond this scope, the associated resource is freed. Here is one example code that is provided in the official Rust documentation:
If you “feed” it to the compiler, then it will generate an error:
This suggests that vec is unavailable because its domain of ownership has changed. Thus, “shoot yourself a leg” in the development process becomes much more difficult.
Rust offers a convenient and wide range of data types that can be combined with each other. This makes it possible to streamline sets of values in the code and restrict access to data, protecting them from unauthorized access.
These features are very important when working with smart contracts in Exonum. Thanks to them, the “smart” contracts of our framework have more performance and memory access security than, for example, Ethereum solutions.
In general, Rust is similar to other imperative languages (in particular, Rust syntax resembles C / C ++), but it represents a large number of innovative concepts. It has cycles, conditions, functions, but at the same time areas of ownership and types appear. Therefore, it may be difficult for those who have never worked with this PL to read programs on it.
At first they seem “foreign”. “Pain” adds an unusual memory management (compared to other languages) that makes Rust so secure. Last fall, the creators of Rust published a poll among 5 thousand members of the community. Almost a quarter of respondents said Rust was hard to work with.
As we have already noted, the task of the Rust compiler is to reduce the number of bugs in the code. The compiler is strict to the text of the program, but it displays options for troubleshooting. In this case, the compiler even shows warnings regarding the programming style.
This approach allows you to write reliable code (which is important when working with blockchains in general), but it also has a flip side to the coin. Sometimes you have to write programs in Rust so that the compiler “understands” that you are not performing prohibited memory operations. And since the language is still young and continues to evolve, there may not be any established practices. Therefore, as the developer of Exonum Ilya Bogdanov says, many patterns have to be found by the method of scientific poking.
The third reason for creating binders was the small Rust community. Although the community of this language is quite friendly, and its members are always ready to answer questions, the language “suffers” from a small amount of literature and libraries. However, it will be fair to note here that this problem is being gradually solved.
In recent years, Rust has been actively promoting Mozilla and Samsung , which has a positive effect on the number of libraries being developed and new “wrappers” for existing solutions from the C / C ++ world. Language “textbooks” also begin to appear gradually. Of those that already exist, it is worth highlighting the “ Foundations of Rust ” by Ivo Balbaert, an online guideon the official website and the recent book of one of the developers of the Rust project Steve Klabnik (Steve Klabnik) " Rust programming language ."
One of the main reasons that determined the choice was the huge community of this PL. According to a study conducted at the Stack Overflow site last year, Java is in third place in popularity (only JavaScript and SQL passed it). Of the 64 thousand developers surveyed, nearly 40% write in Java.
Due to the size of the community, this PL has acquired an extensive set of tools. This includes IDEs, analytical solutions, benchmark frameworks, etc. There are so many of them that some companies oblige developers to use only specific IDEs and frameworks to avoid splitting the work environment.
At the same time, Java has a simple syntax and has a Java Native Interface (JNI) that can workwith C Application Binary Interface (ABI). In addition, Java makes it possible to use other languages on the JVM stack: Scala, Kotlin, Clojure.
And finally, the Java machine is cross-platform: Java code is executed in byte code, which is interpreted and run on Windows, MacOS, Linux platforms. At the same time, the Java language is more tied to open source (compared, for example, with C #). The Java developer tools for the most part are free: they are both the JDK and the integrated development environments based on it - JDeveloper, NetBeans, Eclipse, etc. At the same time, you can find a huge number of open source projects on specialized resources (for example, on GitHub ). There are also many manuals on working with open source technologies.
The development of Java Binding has been long and complex (and still ongoing). We had to consider all the features that make Rust and Java so different.
For example, one of the challenges was organizing resource management. The point is that there is a Garbage Collector in Java, but not in Rust. It was removed in one of the earlier versions, as the developers came to the conclusion that they could provide the same level of reliability using a type system.
Java GC, although it has increased resource consumption (it forces all functions to return unused objects to it to avoid potential memory leaks), is quite convenient. Therefore, we needed to implement a resource cleaning mechanism that Java developers would like.
Another complication was associated with specific data structures presented in Exonum, - trees Merkle (Merkle trees). Exonum uses them to combine blockchain states into a single hash. This makes it possible to prove the authenticity of transactions without having to communicate with several complete network nodes. This functionality is important for the work of our light clients, therefore it also had to be interpreted in Java.
Java API almost completely repeats Rust API. This is done to make it easier for us to adapt the documentation and simplify the work for users. We have prepared a separate guide to configure and run the Exonum node with the Java Binding App.
To create servicesin Java, you can use the template project generator. You need to install Maven 3 and run the command:
You can use the interactive mode:
You will find a complete guide with examples of setting up a Java service in the documentation on the official Exonum project website. There are recommendations for starting the Exonum node in the repository on GitHub .

/ Exonum
While Java Binding is in alpha. We plan to release it as a full-fledged and ready-made feature in the near future. Now we are collecting feedback from users in order to track potential problems in the library and make corrections.
Work is also underway on documentation, writing example projects, SDKs to simplify integration with the application on the blockchain and improve UX in general. You can find the full roadmap of the project in the repository on GitHub .
There you can take all the sources to try Java Binding and write your Java service for Exonum. If you have any questions, please contact our development team at Gitter . They will tell and help as far as possible.
To simplify the work with the Exonum platform and make it more accessible to the audience, we decided to write a binding library. The language for binding has become Java.
Why we chose Java, we tell under a cat. / Exonum

A few words about Exonum
Exonum is our open source framework for developing private blockchains. The blockchain on Exonum is much faster than public blockchains and is capable of processing up to 5 thousand transactions per second. For comparison, in Ethereum this figure is several dozen , while Bitcoin has it even less .
Exonum uses a Byzantine consensus algorithm to protect data. It does not require mining and guarantees the correct execution of transactions, even if a third of the network nodes are compromised.
Exonum platform can be used in any areas: financial, technological, legal. In particular, the framework is suitable for creating digital rights management systems (demo canfound on the official website ) and the organization of voting ( demo ). In both cases, all processes that occur are as transparent as possible and are protected by cryptographic mechanisms.
Last year, using the Exonum platform, the State Land Cadastre of Ukraine was implemented. And before that, a land management project in Georgia was launched at Exonum. We are also negotiating with dozens of Fortune 500 companies and the European Union to implement our system in their business processes.
The core of Exonum is written in Rust. The choice is justified by the fact that this PL focuses on security and speed - it works faster on some tasks than Java, Go, C and C ++. At the same time, Rust guarantees memory security and prevents racing.when two threads try to access the same data.
The Rust compiler is designed to minimize the number of bugs caused by the influence of the human factor. For example, it eliminates several classes of errors at the expense of the concept of lifetime and possession.
All values in Rust have a "domain of ownership." When a name goes beyond this scope, the associated resource is freed. Here is one example code that is provided in the official Rust documentation:
fn use_vec() {
let vec = make_vec(); // завладеть вектором
print_vec(vec); // передать его print_vec
for i in vec.iter() { // продолжить использовать vec
println!("{}", i * 2)
}
}
If you “feed” it to the compiler, then it will generate an error:
error: use of moved value: `vec`
for i in vec.iter() {
^~~
This suggests that vec is unavailable because its domain of ownership has changed. Thus, “shoot yourself a leg” in the development process becomes much more difficult.
Why we decided to create binding
Noisy syntax
Rust offers a convenient and wide range of data types that can be combined with each other. This makes it possible to streamline sets of values in the code and restrict access to data, protecting them from unauthorized access.
These features are very important when working with smart contracts in Exonum. Thanks to them, the “smart” contracts of our framework have more performance and memory access security than, for example, Ethereum solutions.
In general, Rust is similar to other imperative languages (in particular, Rust syntax resembles C / C ++), but it represents a large number of innovative concepts. It has cycles, conditions, functions, but at the same time areas of ownership and types appear. Therefore, it may be difficult for those who have never worked with this PL to read programs on it.
At first they seem “foreign”. “Pain” adds an unusual memory management (compared to other languages) that makes Rust so secure. Last fall, the creators of Rust published a poll among 5 thousand members of the community. Almost a quarter of respondents said Rust was hard to work with.
Too demanding compiler
As we have already noted, the task of the Rust compiler is to reduce the number of bugs in the code. The compiler is strict to the text of the program, but it displays options for troubleshooting. In this case, the compiler even shows warnings regarding the programming style.
This approach allows you to write reliable code (which is important when working with blockchains in general), but it also has a flip side to the coin. Sometimes you have to write programs in Rust so that the compiler “understands” that you are not performing prohibited memory operations. And since the language is still young and continues to evolve, there may not be any established practices. Therefore, as the developer of Exonum Ilya Bogdanov says, many patterns have to be found by the method of scientific poking.
Small community
The third reason for creating binders was the small Rust community. Although the community of this language is quite friendly, and its members are always ready to answer questions, the language “suffers” from a small amount of literature and libraries. However, it will be fair to note here that this problem is being gradually solved.
In recent years, Rust has been actively promoting Mozilla and Samsung , which has a positive effect on the number of libraries being developed and new “wrappers” for existing solutions from the C / C ++ world. Language “textbooks” also begin to appear gradually. Of those that already exist, it is worth highlighting the “ Foundations of Rust ” by Ivo Balbaert, an online guideon the official website and the recent book of one of the developers of the Rust project Steve Klabnik (Steve Klabnik) " Rust programming language ."
Why choose Java
One of the main reasons that determined the choice was the huge community of this PL. According to a study conducted at the Stack Overflow site last year, Java is in third place in popularity (only JavaScript and SQL passed it). Of the 64 thousand developers surveyed, nearly 40% write in Java.
Due to the size of the community, this PL has acquired an extensive set of tools. This includes IDEs, analytical solutions, benchmark frameworks, etc. There are so many of them that some companies oblige developers to use only specific IDEs and frameworks to avoid splitting the work environment.
At the same time, Java has a simple syntax and has a Java Native Interface (JNI) that can workwith C Application Binary Interface (ABI). In addition, Java makes it possible to use other languages on the JVM stack: Scala, Kotlin, Clojure.
And finally, the Java machine is cross-platform: Java code is executed in byte code, which is interpreted and run on Windows, MacOS, Linux platforms. At the same time, the Java language is more tied to open source (compared, for example, with C #). The Java developer tools for the most part are free: they are both the JDK and the integrated development environments based on it - JDeveloper, NetBeans, Eclipse, etc. At the same time, you can find a huge number of open source projects on specialized resources (for example, on GitHub ). There are also many manuals on working with open source technologies.
Key challenges in developing Java Binding
The development of Java Binding has been long and complex (and still ongoing). We had to consider all the features that make Rust and Java so different.
For example, one of the challenges was organizing resource management. The point is that there is a Garbage Collector in Java, but not in Rust. It was removed in one of the earlier versions, as the developers came to the conclusion that they could provide the same level of reliability using a type system.
Java GC, although it has increased resource consumption (it forces all functions to return unused objects to it to avoid potential memory leaks), is quite convenient. Therefore, we needed to implement a resource cleaning mechanism that Java developers would like.
Another complication was associated with specific data structures presented in Exonum, - trees Merkle (Merkle trees). Exonum uses them to combine blockchain states into a single hash. This makes it possible to prove the authenticity of transactions without having to communicate with several complete network nodes. This functionality is important for the work of our light clients, therefore it also had to be interpreted in Java.
Java API almost completely repeats Rust API. This is done to make it easier for us to adapt the documentation and simplify the work for users. We have prepared a separate guide to configure and run the Exonum node with the Java Binding App.
To create servicesin Java, you can use the template project generator. You need to install Maven 3 and run the command:
$ mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=com.exonum.binding \
-DarchetypeArtifactId=exonum-java-binding-service-archetype \
-DgroupId=com.example.myservice \
-DartifactId=my-service \
-Dversion=1.0
You can use the interactive mode:
$ mvn archetype:generate \
-DarchetypeGroupId=com.exonum.binding \
-DarchetypeArtifactId=exonum-java-binding-service-archetype
You will find a complete guide with examples of setting up a Java service in the documentation on the official Exonum project website. There are recommendations for starting the Exonum node in the repository on GitHub .

/ Exonum
Future plans
While Java Binding is in alpha. We plan to release it as a full-fledged and ready-made feature in the near future. Now we are collecting feedback from users in order to track potential problems in the library and make corrections.
Work is also underway on documentation, writing example projects, SDKs to simplify integration with the application on the blockchain and improve UX in general. You can find the full roadmap of the project in the repository on GitHub .
There you can take all the sources to try Java Binding and write your Java service for Exonum. If you have any questions, please contact our development team at Gitter . They will tell and help as far as possible.