Our back end focus will be on Ruby, the language designed for programmer happiness. What takes dozens of lines of code in Java or a hundred in C could take just a couple in Ruby because it prepackages lots of sneaky functions into easy-to-use convenience methods.
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 tends to be taught more in colleges and is used a fair bit for more data-intensive and processor-heavy applications.
But Ruby has a secret weapon that makes it the love of fast-iterating website producers – the framework Ruby on Rails (which we’ll cover in the next section on Frameworks). It has been optimized for being able to write code faster and with less headache, which allows you to iterate more frequently when building a website. 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.
In this lesson we’ll do a healthy introduction to Ruby and then, later on in the full Ruby course, you’ll get to understand it like the back of your hand.
A final note – you’ll be learning a bunch of new terminology and concepts here but don’t think they’re only applicable to Ruby. Most of it (like methods, classes, objects etc.) will pop up again in pretty much any other language you ever pick up.
Look through these now and then use them to test yourself after doing the assignment.
$ ruby ./yourfilename.rb):
Have a go at the next two problems too; feel free to move on to the next lesson though if you find it too challenging. The aim here is to increase your resilience to difficult problems and get you more exposed to how loops and methods are structured:
This section contains helpful links to other content. It isn’t required, so consider it supplemental for if you need to dive deeper into something.