Ruby’s Elegance
Ruby is a genuine object-oriented scripting language designed from the ground up to support the OOP model.
Most modern languages incorporate aspects of object-oriented programming. Because Ruby was designed from the beginning to support OOP, most programmers feel it is elegant, easy to use, and a pleasure to program. Everything in Ruby is an object; there’s no exception.
While Ruby is object-oriented, you can also use Ruby to do procedural programming. But as you do, Ruby is secretly turning your nifty procedures into methods on a globally accessible object.
Throughout the development of the Ruby language, I’ve focused my energies on making programming faster and easier. To do so, I developed what I call the principle of least surprise. All features in Ruby, including object-oriented features, are designed to work as ordinary programmers (e.g., me) expect them to work. Here are some of those features:
- Interpretive programming
No compilation is needed; you can edit and feed your program to the interpreter. The faster development cycle helps you enjoy the programming process.
- Dynamic programming
Almost everything in Ruby is done at runtime. Types of variables and expressions are determined at runtime as are class and method definitions. You can even generate programs within programs and execute them.
- Familiar syntax
If you’ve been programming in Java, Perl, Python, C/C++, or even Smalltalk, Ruby’s syntax is easy to learn. The following simple factorial function illustrates ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access