The Ruby Programming Language

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 6 people | Log in to rate

Ranked #46,285 in Tech & Geek, #836,138 overall

Ruby is the programming language that supersedes many others. Ruby is built with C, retaining all the power of C, because it provides the easiest access to C of almost all the other high level languages, including many tools that are available to C extensions developers.

Alan Kay thinks that a good programming language will have its environment developed in itself. So he considers that Smalltalk is a good example of such a language. On the other hand, Ruby and C make their own environment. If Smalltalk is good from a meta-language point of view, Ruby and C too are very interesting, though some people would consider C too low level, but they are right, and that's why Ruby provides itself and another layer between itself and C that's used for C extensions creation. This other layer is written in C, still, but makes available the high level constuctions of Ruby and makes available the tools with which Ruby is created, like dynamic arrays, garbage collection, etc. So I contend that Ruby and C have their meta-tools, thanks very much.

Some people say that Ruby is not as powerful as Lisp and Smalltalk. I dispute that notion. Ruby has C. Ruby is C. Ruby has tools that have been created with C. But Ruby is the highest interface to C that I have ever seen: closures, dynamic evalatuation of code, etc. How can these other languages beat the combination of Ruby and C? They can't! Ruby goes way beyond C. Ruby has borrowed many characteristics of other programming languages, including Lisp, Smalltalk, Unix shell tools, Perl, Python, C, etc. We don't need no stinking little language, for we have the most powerful combination ever: Ruby and C.

Some basic C tutorials for people who want to use it with Ruby include How C Programming Works (which I much prefer), and C Tutorial (which is under-construction still, so give him feedback if possible).

Some Ruby C extension programming tutorials / articles that I like include Extending Ruby with C and Extending Ruby.

Ok, but what really makes Ruby so different? It's because it's not limited in what it can do. It has a very flexible syntax, which can be used to create other languages, even, and people do. These languages enjoy all the power of Ruby and C, but extend them with easier methods and libraries, making it more direct to use them which means that they are easier to use. People have given the name of Domain Specific Languages to these languages, because they tackle a domain in the best way that they can, which means freedom of creativity while solving certain problems once and for all. Ruby is perfect for DSL, while other languages aren't as perfect for DSLs. The reason is that since the beginning Ruby has been created without the focus on performance or other less-heroic goals. People who focus too low, get a result too low as well. Ruby has focussed on easy of use for Matz himself, who is the creator of Ruby. It means that Ruby was not created with children in mind. Nor was it created with the goal of running it on 486 systems. Ruby was created as I would create a language: for me to use it. Ruby is unlimited in what it can do. And that's good. It means that Ruby has a greater chance of being future-proof. The development of Ruby prefers easy of maintenance over complex performance code. And that's good!

 p "Hello World"

That's a little "Hello World" version. And it shows the "p" command, which is used to print a value on the screen, but using its string representation, which means that "p" is used for debugging purposes many times. I use it all the time. Besides getting one of the shortest "Hello World" examples of all programming languages, you get to know one of the most important tools when debugging Ruby code. I remember that one famous Computer Science icon preferred to use "print" for debugging C code. I prefer "p" for debugging Ruby code. "p" is power.

 What's the main drawback to Ruby that many people consider? Many people consider Ruby slow. But every benchmark to date is too simple to represent real life problems. Java could be faster than Ruby, and it needs to be faster, because many Java libraries and tools use XML parsing, runtime evaluation of code, layers and layers of abstraction, etc. And Java needs to be way faster when doing lots of more work than a simple version in Ruby would need. The Java performance has a huge price in its development and in its use. Ruby has a different focus, and that's why Ruby can compete against Java and win many times. Have you ever heard that we shouldn't compete against someone else in their own game? It's to hard to beat them. We should just keep the calm and do what we are best at, and that means keeping things simple enough so they don't become a burden. Let other people carry the burden that they want. If they want to dig a hole under their feet, that's their problem. I have learned what I want from a programming language, and that means Ruby, Ruby, Ruby. I want interpretation for development at least. I want file independence, meaning that almost every file should be runnable independently, because it makes things easier to develop and test. And the list goes on...

What about Python? Python is relatively good. But Python is limited and complex. Maybe not complex in the language level, but complex in the Python maintenance development. I find that the Ruby extensions are much easier to develop, compile, install, than the Python ones. For instance, Ruby's ODBC is a dream  to compile and install. I am used to it. Also, Ruby has many other database libraries that are easy to  use/compile/install, like Firebird (FireRuby, Interbase), MySQL (pure Ruby, C extension), PostgreSQL (pure Ruby, C extension), Oracle, KirbyBase (database in pure Ruby), BerkeleyDB, SQLite, etc.

The main sites for Ruby news that I use include RubyForge, the site which hosts many projects of Ruby, and the Ruby Application Archive (RAA), which links the new versions of Ruby libraries.

The sites with references of the main Ruby APIs is http://www.ruby-doc.org/. And the main site of Ruby is http://ruby-lang.org/en/.

Ruby has support of many Web Frameworks, GUI libraries, Object Relational Mappers (ORM), etc. I recommend Ruby-GTK2 for cross-platform GUI. And FXRuby as a good alternative with focus on Windows looking. 

Ruby 2.0, YARV, Rite, is coming along nicely. SASADA Koichi is the man behind the  initial efforts for creating Ruby 2.0, and now they have started the integration with the current version of Ruby from CVS trunk. 

You can find some blogging guys at RedHanded, Artima Buzz and everywhere on the Internet.

 What do we need in Ruby? We need commercial tools developers who could create great solutions based on Ruby, like GUI designers, IDEs, more refined libraries, etc. Don't be one more in Java or .Net. Be one of the few in Ruby. Provide solutions, not problems. :-) We don't need Eclipse in Ruby. Eclipse is too big. Visual Studio.Net is too big. We need smaller tools. We don't need "better" tools. We just need "tools". Ruby is "better" already.

Andy Hunt's "Why Ruby?": http://www.toolshed.com/blog/articles/2006/02/09/why-ruby .

Ruby Books on Amazon 

Programming Ruby: The Pragmatic Programmers' Guide, Second Edition

Amazon Price: $23.91 (as of 11/29/2009) Buy Now

Ruby In A Nutshell

Amazon Price: $16.47 (as of 11/29/2009) Buy Now

The Ruby Way

Amazon Price: $39.99 (as of 11/29/2009) Buy Now

by jpedrosa

I have used many programming languages, but no one that made me re-think the way programming languages could be used like Ruby has. I came to know Rub... (more)

Explore related pages

Create a Lens!