Ruby: From Basics to Expert
Four levels, twelve lessons, every example runs in your browser
Ruby was designed to be pleasant to read and write, and it takes that further than most languages: there are no primitives, almost everything is an expression with a value, and much of the syntax turns out to be ordinary method calls wearing a disguise.
Overview
It remains a strong choice for web applications and for the kind of scripting that would otherwise be a mess of shell, and it is one of the better languages to learn object-oriented design in, precisely because it refuses to let you treat anything as not-an-object.
Introduction
No Ruby and no previous programming are assumed. If you come from another language, the thing to unlearn is in Level 1: Ruby has no primitives and almost no statements, and once you take the one rule seriously - everything is an object, nearly everything returns a value - the syntax stops looking like a collection of special cases.
Each level is three lessons and a Level Check quiz, finishing with an Expert Exam. Every example runs in the browser at the version this course teaches; press Try yourself and it opens in the compiler, where you edit on the left and read the output on the right. Nothing is installed and nothing is sent to a server.
Every example runs in the browser, at the version this course teaches. Nothing is installed and nothing is sent to a server.
By the end you will be able to read the Ruby that libraries are written in, not just the Ruby that uses them: a method that takes a block and yields to it, an object that is Enumerable because it defines one method, a lazy sequence over something infinite, and the metaprogramming that frameworks use - with a clear view of when not to.
What you will be able to do
- Explain why only false and nil are falsy, and what that breaks
- Replace loops with the Enumerable method that says what you meant
- Model a domain with immutable value objects and mixins
- Rescue the failures you expect and let the rest travel
- Match on the shape of data instead of nesting nil checks
- Arrange an application so the rules can be tested without setup
What each level covers
4 levels · 16 lessons
-
Level 1 - Basic
The one rule that makes the rest of the syntax make sense: everything is an object, and nearly every expression returns a value. From there, truthiness and the three kinds of equality - which is where the surprises are - control flow used as an expression rather than a statement, and the two collections, arrays and hashes, with the Enumerable methods over them.
4 lessons 40 min of reading
Start with Values, Types and Objects → -
Level 2 - Intermediate
Text, time and the class machinery. Strings against symbols, and why the difference matters more than it looks; Time and Date without the usual mistakes; classes, modules and mixins, which is how Ruby shares behaviour instead of inheriting it; and raising deliberately, with the exception hierarchy and ensure.
4 lessons 45 min of reading
Start with Strings, Symbols and Time → -
Level 3 - Advanced
The three things that make Ruby libraries feel the way they do. Blocks, procs and lambdas as an interface rather than a trick; building your own Enumerable and going lazy, so a sequence can be infinite and still finish; and metaprogramming, which is honest about both what it buys and when a plain method would have been better.
4 lessons 49 min of reading
Start with Blocks, Procs and Lambdas → -
Level 4 - Expert
Modelling and measuring. Pattern matching with case/in, which is the modern way to take apart a nested structure; where the time and the memory actually go, found by measurement rather than instinct; and arranging an application so a change stays in one place.
4 lessons 57 min of reading
Start with Pattern Matching and Modelling Data →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- No prior Ruby
- Some experience of any programming language helps but is not required
Common questions
- What does the Ruby: From Basics to Expert course cover?
- It is 4 levels and 16 lessons: Level 1 - Basic; Level 2 - Intermediate; Level 3 - Advanced; Level 4 - Expert. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 191 minutes of reading and exercises - roughly 3.2 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- No prior Ruby. Some experience of any programming language helps but is not required.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Explain why only false and nil are falsy, and what that breaks. Replace loops with the Enumerable method that says what you meant. Model a domain with immutable value objects and mixins. Rescue the failures you expect and let the rest travel. Match on the shape of data instead of nesting nil checks. Arrange an application so the rules can be tested without setup.