Why Ruby?

The first version of Zold is implemented in Ruby, a semi-object-oriented programming language. It was my personal decision to choose Ruby, even though I’m pretty fluent in Java, JavaScript, C++, and PHP. “Why Ruby?” is the question I’ve been hearing since the first day of our Telegram group. Here is the summary of my reasoning.

First, Ruby software is very easy to deploy. Zold is distributed as a Ruby “gem” hosted at Rubygems. In order to install a new version of it, together with all dependencies, you just need to run, from the command line (either Unix, OSX, or Windows):

$ gem install zold

Java, for example, doesn’t have (to my knowledge) a package manager with the same functionality.

Second, Ruby is a very compact language. It is much weaker, compared to Java and C++, in terms of its object-orientation, but if used right its code can be clean and at the same time very concise. In Java, I believe, the source code we have now would take 3-4 times more lines.

Moreover, thanks to its brevity, Ruby is a perfect language for experimenting. Zold, as you can see in its Git history, was not created in one step. We had a number of initial releases, which didn’t really work. It was necessary to experiment and re-write. Ruby is a perfect tool for that, since it takes less time to say in Ruby what I want to say, compared to Java or C++.

Third, Ruby is perfectly covered by Rubocop, its de facto static analyzer, which we use to its full capacity. All rules from the analyzer are enabled and only a very small subset of them are slightly suppressed.

There are a number of drawbacks with Ruby, of course. First of all, it is slow. Well, certainly slower than Java and, of course, C++. Second, it’s single-CPU even though it’s multi-threaded. In other words, we can’t use all CPUs as easily as we do that in Java. Third, it’s not object-oriented enough to guarantee disciplined development for the long term.

I believe that in time, when the Zold protocol is stabilized, the network of nodes is large enough, and as the software community around Zold grows, we will be able to create parallel implementations of Zold software in other languages.