3.1. What's Ruby?

As briefly discussed in the first chapter, Ruby is a modern object-oriented programming language that was first released by its author, Yukihiro Matsumoto, back in 1995. Despite being older than C#, and just as old as Java, Ruby's recognition outside of Japan has been undeservedly very limited for many years.

Over the past few years, Ruby has been one of the fastest growing languages in the world. Rails made this popularity possible, but as many developers have discovered, Ruby is a language whose value stands on its own. And it's very much worth knowing independently from your interest in Rails.

Ruby is fully object-oriented (everything is an object), but it is also considered multi-paradigm, because it allows for a procedural style (useful for scripts) and has support for several elements that are typical of the functional programming world.

Clearly Ruby has been influenced by many languages, but it can be said that it combines an object model, which is heavily inspired by Smalltalk, with the immediacy, pragmatism, and text processing ability of Perl (which also influenced its syntax), plus the expressive nature of Lisp.

Ruby is often referred to as a scripting language, but what's more important is that it's a very high-level language that's both powerful and concise. It was created with the intention of being programmer-friendly, focused on simplicity and productivity, and as such it is often associated with the principle of least surprise (POLS). This principle implies that Ruby, unlike languages like C++, tends to be less confusing and more predictable for experienced developers (but also for beginners). Ruby code is therefore easy to read and to write, and it features an arguably elegant syntax.

If you head over to the official website at http://www.ruby-lang.org you'll notice that Ruby's tagline is A Programmer's Best Friend. An apt description in my opinion.

There isn't a universally accepted definition of strongly typed. Nevertheless it is generally fair to say that Ruby is both dynamically and strongly typed. What this means is that with Ruby you don't need to explicitly declare your variables' type, but at the same time, Ruby will only perform trivial automatic conversions for you (for example, you can't sum a string with a number directly, like you can in some other languages). Ruby adopts the so-called Duck Typing, which makes working with types less restrictive and allows for polymorphism independently from inheritance. Duck Typing is further explained in the next chapter.

Ruby implements native regular expression support, a large Standard Library, a wide array of third-party code and libraries, and is easily extensible in C. Like C#, Visual Basic, and Java, Ruby features automatic memory management through Garbage Collection. It also provides support for operator overloading, introspection, reflection, blocks, closures, and metaprogramming. If these terms don't make sense to you now, fear not. The foundations of what you need to know to use Ruby in your Rails applications are housed in this and the next chapter.

Last but not least, the main implementation of Ruby is a single-pass interpreter that's available for several platforms, and it's free software with a very liberal license.

But enough with notional descriptions, let's get started.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.39.144