Why Ruby


There are dozens of popular programming languages. Which language is best suited for beginners is the subject of myriad blog posts and debates. Many experts theorize that a simple markup language, such as HTML, is an appropriate starting point. Others claim it's best to start with a scripting language like Python or Ruby. While there is no absolute answer there are many reasons that make Ruby an excellent choice.

Why learn Ruby first?

Ruby is an approachable computer language. Many of the commands read like natural English. For example, the code 3.times { print "Hello! " } prints the word "Hello!" to the screen three times. It offers a clean, terse syntax that is intuitive and non-restrictive. It's a modern programming language that aims toward programmer happiness. It's object-orientation allows for higher levels of abstraction such as meta-programming.

Writing Code is Easier

  • Lines terminate without needing semicolons
  • Extra whitespace is ignored by the Ruby compiler
  • Code indentation is optional
  • The syntax rules are more relaxed

Yukihiro "Matz" Matsumoto developed Ruby during the mid 1990's in Japan. He intentionally designed Ruby for programmer productivity following the principles of good user interface design. While other languages were designed with compilation in mind, Ruby was designed with the developer in mind. This speaks to the flexibility of the language. New users can begin learning and become productive almost immediately. Compared to other languages there is a lower barrier to entry.

Ruby borrows the best parts of other langagues, including Perl, Python, and Smalltalk, while providing genuine object orientation and simplier ways of manipulating data. In Ruby, methods manipulate data. Methods in Ruby are similar to functions in JavaScript. Developers can use the languages built-in methods or create their own for greater customization. Ruby's built-in methods are appropriately named, concise, and generally act the way you would expect. For example, the method "reverse" in the code: puts "hello".reverse prints olleh to the screen.

Why Object Oriented Programming (OOP)

We naturally think of things as objects with attributes and behaviors. This determines how we interact with them. We think of a car as a thing, a chair as a thing, even a thought as a thing. It’s interacting in the abstract, and it’s why OOP can boost speed and efficiency when developing applications. Learning to think of things in terms of objects is a designing paradigm that provides powerful and meaningful ways to write programs.

Modeling applications after objects isn't the only way to develop programs or web apps. An alternative to OOP is FP (Functional Programming). The functional programming paradigm is centered around writing functions in a declarative style. This contrasts the imperative, also known as procedural, style of OOP. These two paradigms are different ways of thinking about and writing applications. They are alternative styles. One is not ultimately "better" than the other. In fact, most programs, even most languages, consist of a combination of object orientation and functional programming.

For beginners, OOP tends to make more sense. It's more relatable, analogous to real world examples and thus easier to understand. Moreover, writing imperatively and modeling applications on real world objects is more fun!

In order to follow along with the code in this book you'll either need Ruby installed on your local machine or a cloud-based IDE (Integrated Development Environment). In the next chapter, we'll discuss the different options for installing and setting up Ruby.

If you're interested in bookmarking the Ruby documentation, this book uses Ruby version 2.4.0, which can be found at Ruby-Doc.

results matching ""

    No results matching ""