📜 ⬆️ ⬇️

Corda: Kotlin

When someone looks at the Corda code, they immediately notice that it is written in Kotlin, a new programming language from JetBrains, which can be compiled under JVM and in Javascript. It was an unusual choice, and in this article I want to share some of the reasons for this decision and the experience of our "year with Kotlin in production".


Why Kotlin?


This solution can be divided into two parts:


  1. What platform to use? JVM, .NET, Node, Python / Ruby, Go, Haskell or something compiled (in machine code)?
  2. What language should I use if I chose JVM? Java? If not, then why? And if not, then which is different: Scala, Ceylon, Clojure, Kotlin, Python, Ruby, Javascript, or Haskell (because they all have a JVM implementation).

The reasons for choosing JVM as a platform are well known in the enterprise application environment and there is little point in stopping there. Suffice it to say that if you need a scalable, thread-safe, cross-platform runtime environment with garbage collection , and with a lot of well-documented libraries that solve basic business problems, then the choice is reduced only to JVM and .NET.


At the beginning of work on Corda, the project had no name and it was difficult to imagine that it would develop into a product in the future. In fact, when the project, which became Corda, began in December 2015 (on my first day at work), the plans were not to create a new corporate distributed accounting system. Corda began as a set of prototypes for exploring new ideas and requirements in which the Consortium’s Architecture Working Group was interested, particularly related to the limited visibility of the data and the data model providing scalability of the “array of unspent transaction outputs (UTXO set)” along with the programmability of the imperative smart contracts of Ethereum as a whole.


Due to the fact that it was not clear whether these prototypes would turn into something, or simply serve as information for other products on the market, we had a difficult choice. On the one hand, we wanted to quickly and efficiently explore algorithms and data structures. On the other hand, there must remain the potential for creating a large corporate product and quickly hiring people for it.


Java definitely met these requirements, but the lack of modern features in the language significantly reduces productivity, and, more hiddenly, the morale of the developers.


Dynamic typing was not considered - the benefits of correctness, development tools and performance provided by static typing are too great to be neglected.


Languages ​​that are fundamentally different from the most popular ones were also not considered, since we wanted to be able to hire financial experts. And, although creating a team around a Haskell-like language is quite possible , the search for a person with serious banking experience and lazy (pure) functional languages ​​from a random London resident seemed risky. In addition, the very nature of the product implied that our “users” were in fact plug-in developers and applications that use the platform, and there is no point in requiring them to learn completely new paradigms and tools. Our choice of language should not limit users too much.


As a result, these requirements left us with Kotlin, Scala and Ceylon. These languages ​​are quite similar and quite interesting. We chose Kotlin for the following reasons:



If it were not for Kotlin, we probably chose Scala: Kotlin was inspired in many ways and both are good languages.


Our year with Kotlin


What is the year of working with a new language in the context of a corporate application?


The most important thing was, no doubt, to hear from colleagues that they really enjoyed working with him. The programming language is a personal matter, and people usually have a definite opinion on this matter. If you, as the first task in the new job, ask someone to learn a new language and do not even warn about it in advance, then there is always the risk that a colleague will simply hate him and rather find him annoying rather than increasing his productivity. But this is not the case.


Below are some of the problems that often emerge in a post-Java / C # corporate development environment, and which we ourselves have encountered:



Findings?


We do not regret: the choice of a young language at the start of this project was at least a risk, but balanced. He did a good job for us and we would not change our choice.


')

Source: https://habr.com/ru/post/422549/


All Articles