Ruby

toc
 * Home * Programming * Languages * Ruby**


 * Ruby** is an language written by [|Yukihiro “Matz” Matsumoto], with the following characteristics:
 * extensible
 * [|object oriented]
 * interpreted (scripted)
 * has very much metaprogramming features
 * [|reflective]

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: code if myuci.respond_to?(uci_cmd) method = myuci.method(uci_cmd) method.call(uci_line) end code

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=
 * [|Re: 2 Moves Engine Book] by Miguel A. Ballicora, CCC, December 08, 2013 » Opening Book

=External Links=
 * [|Ruby - a programmer's best friend]
 * [|Ruby from Wikipedia]
 * [|Ruby on Rails from Wikipedia]
 * [|Ruby on Rails]
 * [|RubyGems from Wikipedia]
 * [|Ruby-Doc.org: Documenting the Ruby Language]
 * [|comp.lang.ruby] The Ruby dynamic OO programming language
 * [|Eight Queens Problem In Ruby]
 * [|Ruby Language]
 * [|Self-reproducing programs in Ruby]
 * [|Ruby Hints - Beuth Hochschule für Technik Berlin] by Stefan Edlich

=References= =What links here?= include page="Ruby" component="backlinks" limit="40"
 * Up one Level**