Ruby

  • Ruby is an interpreted, high-level, general-purpose programming language.
  • Ruby is dynamically typed and uses garbage collection.
  • It supports multiple programming paradigms, including procedural, object-oriented, and functional programming.

  • The term pure object-oriented programming implies that all of the data types in the language are objects and all operations on those objects can be invoked by message passing.
  • Multiple variables referencing the same object is called aliasing
  • dup

  • a = (b = 1 + 2) + 3
  • nil

  • Class names, module names, and constants should start with an uppercase letter.
  • Class variables start with two “at” signs (@@).
  • Local variables, method parameters, and method names should all start with a lowercase letter or with an underscore (_).
  • Global variables are prefixed with a dollar sign ($), while instance variables begin with a single “at” sign.

  • Unstructured programming Complex code: Difficult to read and write. • Poor evolvability. • Poor maintainability. • Poor reusability.

  • Structured programming Allowed (some) abstraction from the underlying machine. • Poor evolvability. • Poor maintainability. • Poor reusability.

  • Procedural programming Allows functional decomposition of a problem. • Top-town design and stepwise refinement allow the problem to be broken down into (manageable) subproblems. • Modular composition is made possible as solutions to subproblems can be coded into units of functionality (procedures and functions) or components

  • Object-oriented programming Encapsulation + Polymorphism + Inheritance • Provides linguistic mechanisms to support functional decomposition along the notion of class. • Allows us to view computation as a set of collaborating objects. • Classes allow us to hide implementation details beneath interfaces.
Written on December 17, 2020