Saltar al contenido ForoHackers

Ruby: start here

Ruby
#565 · Ophuscado · · Denunciar

Ruby is a dynamic, object-oriented language designed to make programmers happy. It reads almost like prose, treats everything as an object and bends easily into small domain-specific languages. It is known for web development, scripting and tooling, and for a culture that values readable code, testing and convention over configuration.

Key concepts

  • Everything is an object: numbers, strings and classes all respond to messages.
  • Blocks and iterators: code passed to a method, the heart of loops, callbacks and resource handling.
  • Open classes and modules: classes can be reopened, and modules add shared behaviour as mixins.
  • Duck typing: what matters is what an object responds to, not its class.
  • Metaprogramming: methods can be defined, intercepted and inspected at run time.
  • Gems and bundler: libraries are packaged as gems, with dependencies pinned per project.

Vocabulary

  • Symbol: a lightweight, immutable name such as :id, used for keys.
  • Mixin: a module whose methods are added to a class.
  • Proc and lambda: objects that wrap a block of code.
  • Idiom: the habitual Ruby way to write something, such as each rather than a counting loop.

What to study, in order

  1. Basic syntax, strings, arrays and hashes, in the interactive shell.
  2. Methods, blocks, and the Enumerable methods such as map and select.
  3. Classes, modules, mixins and how method lookup works.
  4. Write a command-line tool with tests, and package it as a gem.
  5. Metaprogramming in small doses: define methods dynamically and read a library's source.
  6. A web application with a framework, once the language is comfortable.

Related tags

#interpreters #web-frameworks #backend #testing

Inicia sesión o únete para responder.