Programming languages

Ruby

An expressive object-oriented language, known for Ruby on Rails and the convention over configuration approach.

What it is

Yukihiro Matsumoto (Matz) created Ruby in Japan, with a public release in 1995. The goal is to make programming enjoyable. In Ruby everything is an object, even numbers.

The language is dynamic, with powerful blocks, metaprogramming and readable syntax. The community develops the CRuby (MRI) implementation. Ruby 3 added Ractors, types via RBS and a faster JIT (YJIT).

Ruby on Rails (2004) made the language famous. Ruby is common in startups and SaaS today: Shopify, GitHub and Basecamp use it.

Use it when

  • Quickly building a web product or MVP on Rails.
  • The team values readable, expressive code.
  • Scripts, DSLs and tools (Homebrew, Fastlane, Jekyll).

Avoid it when

  • CPU-heavy computing and services with strict speed requirements.
  • Big data and ML: the ecosystem is far weaker than Python's.
  • Looking for a large job market: it is smaller than Java, JS or Python.

Key concepts

Blocks
Anonymous chunks of code passed to methods: each, map, select.
Everything is an object
Even 5.times and nil are objects with methods.
Metaprogramming
Code can create methods and classes at runtime (define_method, method_missing).
Gems and Bundler
Packages are called gems, dependencies are pinned by Bundler (Gemfile.lock).
Duck typing
What matters is not the type but whether the needed methods exist.

Example

A Struct and a select / map block chain.

Interview questions

  1. 1. What are a block, a proc and a lambda?

    A block is code passed to a method. Proc and lambda are function objects. A lambda strictly checks argument count, and its return returns from the lambda itself, not the enclosing method.

  2. 2. What does everything is an object mean?

    All values, including numbers, strings and nil, have a class and methods. Even classes are objects.

  3. 3. What is a symbol?

    An immutable unique identifier (:name) stored in memory once. Often used as a hash key.

  4. 4. What is Rails' convention over configuration?

    The framework has sensible defaults (table names, directory layout), so you configure only deviations. It speeds up starting and keeps projects uniform.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).