Ruby Fundamentals
Ruby is an object-oriented, dynamically typed programming language. You write expressions, send messages to objects, organize code into methods, classes, and modules, and distribute reusable code as gems managed by Bundler.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Ruby Fundamentals
Ruby is a programming language where the running values are objects and most work is a method call sent to one of them. That sounds like an invitation to anthropomorphize a String. Resist the urge. The useful part is that a program can be understood as values receiving behavior, returning new values, and occasionally doing something noticeable, such as writing a file.
The first useful mental anchor is assignment. A variable is a name that refers to an object. Giving the same Array two names does not create an Array twin in a tiny hat. It creates two ways to reach the same object. Mutation changes that shared object, while an ordinary assignment only changes which object a name refers to. This explains a surprising number of later bugs without requiring a séance with the debugger.
The second anchor is the block, which is behavior handed to a method. A collection method can use that behavior to visit, transform, filter, or combine its values. Keep the block small enough that its purpose stays visible. When it starts carrying policy, branches, and failure handling, give that work a named method. Ruby is concise, but a compressed decision is still a decision that somebody must read.
Then comes the method boundary. Parameters, return values, mutation, and
errors all need to be visible there. Ruby returns its last expression by
default, and only nil and false are falsey. An empty Array and zero are
not secret requests to take the other branch. Check the condition that you
actually mean.
Ruby also has gems, packaged code managed in a project through a Gemfile and Bundler. The lockfile records the selected dependency graph, so changing it changes the program's operating conditions. Treat that change as code, test the result, and keep the language boundary separate from a framework's habits.
For the detailed map, read the Intro when an object, method, module, or exception needs its full explanation. Use the Slides when the relationships need to fit on one page. Keep the Cheatsheet nearby while writing code. The practice reference and exercise turn these ideas into commands and observable results. The quiz is where the innocent-looking details wait with a clipboard.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.ruby-lang.org/en/documentation/
Supports
- Official Ruby documentation hub, reference manual, learning resources, tools, and editor ecosystem
- Ruby as a language with documentation for released versions
- https://www.ruby-lang.org/en/about/
Supports
- Ruby origin, public release history, language philosophy, and general-purpose positioning
- https://docs.ruby-lang.org/en/master/syntax.html
Supports
- Ruby syntax, literals, assignment, scope, control expressions, classes, modules, and methods
- https://docs.ruby-lang.org/en/master/syntax/methods_rdoc.html
Supports
- Method definitions, return values, arguments, keyword arguments, scope, and method naming conventions
- https://docs.ruby-lang.org/en/master/syntax/exceptions_rdoc.html
Supports
- Exception hierarchy, begin rescue ensure flow, and narrow error handling
- https://docs.ruby-lang.org/en/master/Enumerable.html
Supports
- Enumerable collection traversal, transformations, filtering, reductions, and lazy enumeration
- https://guides.rubygems.org/what-is-a-gem/
Supports
- Gem packaging, gemspec metadata, installation, and RubyGems ecosystem
- https://guides.rubygems.org/getting_started/
Supports
- Gemfile declarations, bundle installation, dependency resolution, and Gemfile.lock
- https://www.ruby-lang.org/en/news/2009/01/30/ruby-1-9-1-released/
Supports
- Ruby 1.9.1 release date and the stable Ruby 1.9 series
- https://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/
Supports
- Ruby 2.0 stable release, keyword arguments, Module prepend, and lazy enumeration
- https://www.ruby-lang.org/en/news/2017/12/25/ruby-2-5-0-released/
Supports
- Ruby 2.5 release date and language/runtime changes
- https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
Supports
- Ruby 3.0 release date, Ractor, Fiber Scheduler, RBS, TypeProf, and performance direction
- https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
Supports
- Ruby 3.2 release date and continuing runtime and language evolution
- https://github.com/markets/awesome-ruby
Supports
- Curated discovery of Ruby tooling including code analysis, testing, type checking, development tooling, and runtime implementations
- https://rubocop.org/
Supports
- Ruby static analysis and style enforcement
- https://rspec.info/
Supports
- RSpec behavior-focused testing framework
- https://sorbet.org/
Supports
- Sorbet gradual type checking for Ruby
- https://shopify.github.io/ruby-lsp/
Supports
- Ruby language server features for editor tooling
- https://pry.github.io/
Supports
- Pry interactive runtime inspection and debugging
- https://www.jruby.org/
Supports
- JRuby Ruby implementation on the Java virtual machine
- https://www.graalvm.org/ruby/
Supports
- TruffleRuby implementation on GraalVM
- https://mruby.org/
Supports
- mruby embeddable lightweight Ruby implementation
- https://rubygems.org/
Supports
- RubyGems package hosting and discovery
- https://bundler.io/
Supports
- Bundler dependency-management project
- https://docs.ruby-lang.org/en/master/language/options_md.html
Supports
- Ruby command-line execution with -e and syntax checking with -c
- https://shopify.engineering/adopting-sorbet
Supports
- Shopify engineering experience adopting gradual typing in Ruby, including production NameError observations and contract benefits
- https://shopify.engineering/adventures-in-garbage-collection
Supports
- Shopify Ruby garbage-collection tuning through logging, metrics, hypotheses, tests, and measured retention or reversal of changes
