Is Ruby a Programming Language? A Beginner’s Explanation

Separate Ruby, Rails, IRB and RubyGems, then use a reading-goal program to see how Ruby calculates values and makes decisions.

Written by Technically reviewed by Jim Freeze · Reviewed

Yes, Ruby is a programming language. You use it to write instructions that a Ruby implementation can execute: calculate values, make decisions, repeat work and read or write data. Ruby is general-purpose and object-oriented, and it is used for small scripts as well as larger applications.

The surrounding vocabulary causes much of the confusion. Ruby, Rails, IRB and RubyGems can appear in one tutorial, yet each has a different job. This guide separates those names before using a small Ruby example to show what “programming language” means in practice.

Is Ruby a programming language illustrated by a ruby gemstone connecting program instructions with a computed result
Ruby programs turn values and instructions into results, as the reading-goal example demonstrates.

Is Ruby a programming language or a scripting language?

Both descriptions can apply. A script is a program, often written to carry out a focused task. Calling Ruby a scripting language does not mean it can only handle short files or that its instructions are less real than those in a larger application.

The Ruby project’s source repository identifies Ruby as an interpreted, object-oriented programming language. “Interpreted” is a useful beginner description of how you commonly run Ruby source. The internals of a particular implementation can include additional compilation stages.

For learning purposes, keep the distinction between the language and the software that runs it. Ruby defines the syntax and behaviour you write against. A Ruby implementation supplies the machinery that executes your program. Checking ruby --version tells you about the implementation available in your terminal.

You do not need to choose between “real programming” and “scripting” before starting. A ten-line program that reliably checks an export can be useful software. Its size tells you little about whether its rules are correct.

Ruby, Rails, IRB and RubyGems

Ruby is the language. You write expressions, methods and other instructions using its rules. A file ending in .rb commonly contains Ruby source code.

Rails is a web application framework built with Ruby. It provides conventions and tools for building web applications. Our Ruby versus Ruby on Rails guide explains why learning one is related to, but different from, learning the other.

IRB is an interactive environment where you can try Ruby expressions and inspect their results. It suits quick experiments. A saved source file is often more convenient when you want to rerun several steps together.

RubyGems supports distributing and installing Ruby packages, called gems. A gem can provide a library or a command-line tool. Installing one adds software to your environment; it does not turn Ruby into a different programming language.

These layers explain why a tutorial might ask you to install several things. Its author may be assembling a particular application environment. That does not mean every Ruby program needs the same set of tools.

What does a Ruby program look like?

Here is a complete example. It checks whether a small reading target has been reached. Save it in a plain-text file named reading_goal.rb.

pages_read = 18
daily_goal = 20
remaining = [daily_goal - pages_read, 0].max

if remaining.zero?
  puts "Goal reached"
else
  puts "#{remaining} pages to go"
end

Open a terminal in the file’s folder and run ruby reading_goal.rb. The output should be 2 pages to go. This output and four behaviour checks passed with Ruby 3.2.3. You have asked Ruby to store two numbers, calculate a difference, choose a branch and print a message.

The array on the third line contains the calculated difference and zero. Its max method returns the larger value, preventing the remaining count from becoming negative. The code therefore has an explicit rule for a reader who goes beyond the target.

Change pages_read to 23 and run the file again. This time the output is Goal reached. That change demonstrates a basic property of a program: the same instructions can produce a different result when the input values change.

The values are fixed in the file to keep the example small. A later version could read them from a form or a file. That introduces another responsibility: checking that outside input really is valid numeric data.

What makes this programming?

The file contains operations and a decision rule. It does more than label a paragraph or describe how a heading should look. The machine follows the instructions to compute a result from the values you supplied.

Programming still requires precise syntax. The equals sign in pages_read = 18 assigns a value to a variable. The final end closes the conditional. Missing punctuation or a misspelled method can prevent the program from running as intended.

You will also encounter mistakes that produce valid but wrong results. If the goal should be twenty pages and you enter two hundred, Ruby cannot infer your intention. Testing expected behaviour matters just as much as getting the file to run without an error.

Check your understanding

Choose an example and predict the answer before expanding it. You can also edit the saved file and compare the actual output.

Does a Ruby script need Rails installed?

No. This reading-goal script uses Ruby’s built-in features. Rails is useful for a particular class of application work, but it is not required to calculate values or run an ordinary Ruby source file.

What happens when pages_read is exactly 20?

The difference is zero, so remaining is zero and the program prints Goal reached. Testing the exact boundary is useful: it checks that reaching the goal and exceeding it both follow the intended rule.

Is “18” the same value as 18?

No. Quotation marks make the first value a string containing text. The second is an integer. Substituting the string into this calculation causes a type error; Ruby does not silently treat it as the expected number.

How to begin learning Ruby

Start with a small file like the one above. Run it successfully, change one value and predict the next result. Then explain each line in ordinary language. If a line is unclear, isolate it in an interactive session instead of adding more code around it.

The official Ruby in Twenty Minutes tutorial introduces IRB and basic expressions. One useful detail is that an expression’s returned value and its printed output can differ. IRB shows results to help you inspect them; a saved program only displays what its instructions tell it to display.

After that first experiment, try our Ruby code examples. Work through one at a time and include an edge case, such as an empty collection or an exact numeric boundary.

Keep your first goal modest: write a program whose input, output and decision rules you can explain. Once that feels comfortable, methods, files, libraries and larger applications have a clearer place.