Introduction to Ruby Programming

An introduction to the programming language designed for developer happiness.

Scroll down...





Ruby is the language "designed for programmer happiness" and it will be the focus of our back-end efforts. Unlike HTML and CSS, which simply dictate how webpages are rendered by the browser, Ruby is a scripting language, meaning that it can actually tell a system what to do. Ruby is often (though not exclusively) used to build web applications so it commonly "lives" on the web server.

In this lesson we'll introduce you to Ruby since you're going to become such good friends. Over the next few lessons and assignments, you'll have plenty of opportunity to learn the language and to practice programming with it. Our number one goal is to get you to the point where you feel comfortable writing Ruby scripts to solve programming challenges. Those building blocks will prepare you to continue learning how to design full applications with Ruby as part of the intensive program.

About Ruby

Ruby was initially released back in the end of 1995 by Yukihiro "Matz" Matsumoto in Japan as a more purely object-oriented alternative to Python and a derivative of Perl. That's actually right around the same time as the much more popular Java came out.

Ruby was an interesting language for many reasons, not least of which was its origin in Japan and the involvement of a strong mailing list community during its development. The language was more popular than Python in Japan but it took a few years for it to emerge as a strong factor in the English-speaking development community.

Part of the philosophy of Ruby is that it should follow the Principle of Least Astonishment (POLA), meaning that a programmer should just be able to "do" things that seem to make sense. The language was designed not to optimize the computation time of the computer itself (as so many others had), but to optimize the joy and productivity of the developer by providing him or her with an intuitive and concise syntax.

The history of Ruby cannot ignore what is perhaps its most significant moment -- the release in 2004 of the Ruby on Rails framework. "Rails", built by David Heinemeier Hansson using Ruby, was meant to give programmers a cleaner and more productive framework for quickly building websites than anything that existed at the time in PHP or Java. It boxed up most of the common and repetitive tasks involved in building web applications and prescribed a very particular set of best-practices in a way that promoted ease-of-use.

Web developers loved Rails and its growing popularity since then has significantly driven the adoption of Ruby as a language. Startups in particular appreciated the focus on programmer productivity because it allowed them to rapidly produce and iterate on their web applications. By so doing, the end product is more likely to suit the client or the user's needs, making your first mission as an engineer a success.

A decade after the release of Rails and two decades after Ruby, both Ruby and Rails continue to be very popular among both experienced developers and beginners. This is relevant to you because the community that has grown around Ruby is particularly supportive of beginners and there are a wealth of resources available for you on the web. The strength of this community is one of the major justifications for using it as an introduction to programming.

What Ruby Can Do

Now that you know where Ruby came from, what is it actually good for?

Ruby is a full service language. With it, you can do pretty much anything you could with any other language. You can read and modify files on your local file system, build your own web server, connect with databases, or perform complex computations.

Ruby is also an object-oriented programming language, meaning that it packages everything from numbers to variables to classes to methods up as "objects". That allows you to confidently ask these objects questions and pass them around your programs at will, something you'll find very useful once you dig into the language.

In addition to being object-oriented, Ruby is also very high level -- it compresses what might otherwise take dozens or hundreds of lines of code in other languages like Java or C into just a few by using its collection of helper methods and its simple syntax. You don't need to worry about putting semicolons at the end of every line or even using parentheses when they aren't needed. It's a syntax that can take a moment or two to pick up for beginners, but once you figure out what's missing (e.g. a parenthesis), it will really speed up your development time.

If you have some familiarity with programming already, basic Ruby is pretty darn close to Python. In some ways, they sort of resemble romance languages -- once you've learned one, it's not terribly hard to pick up another because they tend to follow many of the same conventions, just using different "words". Python is generally taught in colleges and is used a fair bit for more data-intensive and processor-heavy applications.

In the end, the best quality of Ruby is that it makes your life easy as a programmer by being straightforward and intuitive. There's a bit of a learning curve to understand the assumptions it makes, but you'll get past that and start enjoying the sparseness of its syntax (particularly if you've dabbled with anything lower level or in mobile).

Ruby may not be as blazing fast for computations as lower level or scientific computing languages, but its focus on productivity helps you produce the right product quicker, and, as you might have noticed, that's sort of a theme around here.

Putting this Course in Context

Over the next several sections and units, we'll help you learn Ruby and give you a chance to use it to solve problems. The relevance of this material will depend on exactly which back-end track you choose to take during our Core Curriculum:

If you are planning to take our Ruby/Rails back-end track, this course is required knowledge and should be completed prior to beginning our core curriculum.

If you are planning to take our JavaScript/Node back-end track, consider this course and optional detour into the Ruby language.

Regardless of whether it is required, we recommend that you at least take a peek at Ruby. It's a strange little language but wonderfully friendly and helpful once you get to know it.

Let's get started!

Sign up to track your progress for free

There are ( ) additional resources for this lesson. Check them out!

There are no additional resources for this lesson just yet!

Sorry, comments aren't active just yet!

Next Lesson: A Taste of Ruby