Chapter . Runtime Complexity of Ruby Language Constructs

Ruby is a highly dynamic language: Almost all language entities are first-class citizens in that they can be created, changed, and destroyed at runtime. This comprises classes, modules, methods, constants, and class and instance variables. Only local variables are second-class citizens in Ruby: Whether a name refers to a local variable is determined at parse time.

Not surprisingly, this flexibility has implications in terms of performance: It is impossible to bind a given name to a fixed memory address (or to a fixed relative offset in a relocation table) at program load time. Thus, whenever a name is used in Ruby code, the Ruby interpreter needs to search for the object to which the code ...

Get Addison-Wesley Professional Ruby Series Writing Efficient Ruby Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.