Home * Programming * Languages * Ruby

Ruby is an language written by Yukihiro “Matz” Matsumoto [1], with the following characteristics:

It has been developed since 1993 and was first published in 1995. It began to attract a lot of popularity because of the Ruby on Rails Framework. The TIOBE Index has Ruby under the TOP 20 languages with half about the popularity of C#.

Ruby has been designed to be extremely intuitive. Nearly everything works in ruby. Just two examples: You can use brackets or not or you can determine the size of an array via .size or via .length. Research articles show that languages like Ruby or Python have about the highest expressiveness of all languages (reference). This means that you need to write about 4-6 times less expressions or lines compared to C or C++.

And this makes "high level" languages perfect suitable for chess programming except the engine:
  • Disadvantage: Ruby is pure OO. This means that even numbers like 5 are an object. This in turn means that Ruby has a reputation to be hot but with a weak performance. In fact recent performance comparisons show that Ruby 1.8.6 is about 28 times slower then C++ and Ruby 1.9.1 is 18 times slower then C++. So perhaps you should not write the engine in Ruby if you want a strong engine.
  • Advantage: The high expressiveness make is perfect suitable for everything around the engine because you have little code that is perfect readable.

For example the reflection features allow you to implement a simple pluggable selector to catch UCI commands and call the respective UCI-methods of a class (here myuci) that implement the UCI handling. And this all in two lines:
if myuci.respond_to?(uci_cmd)
  method = myuci.method(uci_cmd)
  method.call(uci_line)
end

So, although most chess programmers prefer to have no language break and use C or C++ for the complete program it might be worth a thought to wrap languages like ruby or python around a fast language. From Ruby you can call e.g. C, C++ and Java and it might be interesting to research how this works together (e.g. how to handle time management).

Forum Posts


External Links


References

  1. ^ Ruby - a programmer's best friend
  2. ^ 2 Moves Engine Book by Lyudmil Tsvetkov, CCC, December 07, 2013

What links here?


Up one Level