Home > Articles > Programming > General Programming/Other Languages

Ruby: The Last Eight Years

  • Print
  • + Share This
Hal Fulton, author of The Ruby Way, points out some of the extensive changes Ruby has experienced in less than a decade. By paying attention to why and how programming languages evolve, we can learn from experience and past mistakes, deliberately changing the language (and especially our usage of it) for a better future.
Like this article? We recommend

If you're a software developer, in particular one skilled in Ruby, you probably have noticed a great many changes over the last eight years. But why should we care? Shouldn't we be concerned about where things are now, rather than where they used to be?

I'd argue we need to be aware of both. In a fast-paced world of changing technology, history is still important—perhaps more important than ever. We need to know how we got where we are, how long it took, what blind alleys we investigated, how much effort really was involved. So, yes, I claim it's worth a little time reflecting on the last eight years in the Ruby world.

Why specifically eight years? That's roughly the length of time between the second and third editions of The Ruby Way. The third edition hit the shelves in March 2015 (in electronic form as well, naturally). During those intervening years, computing in general has seen significant changes. In the case of Ruby, I'd argue that the language's evolution has been almost overwhelming.

This book's history began with the first edition in 2001, when it was the second English-language Ruby book ever published, following Programming Ruby: The Pragmatic Programmer's Guide (the beloved "Pickaxe book"). Early in the decade, Ruby was barely known in the U.S.; I had known of it only three years. The book was written roughly to version 1.6.2 of Ruby. In the entire world, only one Ruby conference had been held at that point.

By 2006, Rails had been around for about a year. At that time, we were using version 1.8.4 of Ruby. In October 2006, someone (not I) posted on ruby-talk that the second edition of The Ruby Way was "coming soon."

At the time, I thought moving from the first edition to the second was painful. Overhauling the book was quite a bit of work. But moving from the second edition to the third was much, much harder. What changed? Well, consider where we were in 2006—not just with regard to the Ruby language itself, but also the community, the libraries and tools, and the overall ecosystem.

Ruby itself, born in 1993, was finally a teenager. With the sixth international Ruby conference behind us, Ruby 1.9 was still a dream of the near future. The comp.lang.ruby newsgroup (at that time mirrored to ruby-talk) was six years old, and the web-based Ruby Forum was less than a year old. Ruby groups were scattered around the world—England, Korea, Australia, Canada, the U.S., and others. There were "hoedowns" and codefests here and there, as well as several nascent Rails groups. Jim Weirich announced version 0.9 of RubyGems.

We had our second Google Summer of Code. A new tool called "Mongrel" was in version 0.3 by the end of the year. There was no real Rubinius nor even a real JRuby yet. The libraries and tools that have arisen (and even died out) since then are numerous—templating solutions, web-related libraries and frameworks, database adapters and NoSQL solutions and ORMs, as well as bindings to popular applications and many other useful creations. I can't get into all of those changes here.

What about the language itself? Changes encompassed core methods and classes (both added and deleted), updated behavior of the interpreter, and actual syntax revisions such as the following:

  • A "character" in Ruby was basically an integer ASCII code. If you indexed into a string, you also got an integer.
  • Character encodings were crude, and Japanese was understandably treated specially (honoring the $KCODE variable). Unicode support was spotty, especially in regular expressions.
  • Block formal parameters didn't have to be local variables; for example, they could be instance variables. Block-local variables specified with the semicolon notation (;) had not been introduced yet.
  • It was permissible to use a colon to separate a when-clause from its expression, instead of a semicolon, then, or a newline. The same was true of the if statement.
  • Strings didn't have each_line, each_char, or each_byte. They had the each iterator, which iterated by lines, historically confusing some people.
  • Block parameters worked differently then; at one point, Matz said that variable shadowing was his "biggest regret" in the design of Ruby. If you gave a block parameter the same name as an existing local variable, the local variable changed along with the parameter.
  • Hashes were hashes in a stricter sense. Iterating over the keys produced a sequence that was reproducible but not predictable. Today, of course, the core data structure is still a true hash, but the keys are maintained in insertion order.
  • In older Ruby versions, a symbol was actually stored as a Fixnum (and internally it still is). For a while after that, Fixnum had a to_sym method, which we no longer have.
  • We didn't have BasicObject then. Sometimes there was a need for a more "barebones" object without so many methods coming from Object and Kernel; BasicObject grew from Jim Weirich's creation BlankSlate, which used undef_method to strip methods from an ordinary object.
  • Instance method names returned by instance_methods were strings, not symbols. We verified the existence of a method not by method_defined? but rather by calling include? on the array of method names.
  • We don't use the encoding comment now because it's a little old-fashioned. We didn't use it then because it hadn't been introduced yet. All program text was assumed to be ASCII.
  • Thread safety was even more problematic then than it is now. Ruby had strictly green (non-native) threads. Ruby threads were originally based on continuations, which are no longer a feature. There were no fibers in Ruby then.
  • The so-called "hash rocket" (=>) was the only notation for hashes. Symbols were not a special case, as they are now with the colon (:) transposed to the end of the symbol. The "comma notation" for hashes was syntactically legal at that time, though it was rarely used.
  • A common hack was to add a to_proc method to Symbol. It wasn't part of the core. The same is true of the tap method in Object.
  • Calling to_s on an array gave a string with the elements jammed together. It didn't punctuate with commas.
  • The "stabby lambda" syntax (->) didn't exist yet. Ordinary blocks did not accept default parameters or the "star" operator (also called "splat" or "unary unarray").
  • Lambdas could be called via call or [] but not by yield or by the .() notation. Blocks could not be passed into lambdas at all.
  • In method formal parameter lists, a "splatted" parameter had to appear at the end. The same was true of parameters with default values. Now the parser and interpreter are smarter about figuring out the edge cases.
  • Method definitions could not be nested. Now, in effect, an ordinary method definition can happen at runtime (without define_method).
  • Enumerators (for "on demand" iteration) didn't exist, and naturally there was no to_enum method. An iterator called without a block didn't return an enumerator object. Methods such as each_with_index were commonly used.
There's more. The inject method has been simplified; so has the notation for literal complex numbers. The break keyword now takes a value (a very useful feature once you grasp the concept). The \p notation has been added to regular expressions. I could go on.

Are you impressed yet? We haven't finished. Those were just the changes that went into the 1.9 versions, and the list isn't exhaustive. Here are some more:

  • Version 2.0 introduced keyword arguments, %i for creating arrays of symbols, the prepend method (for extending classes in a new way), and the __dir__ pseudo-variable with the directory name of the currently executed file.
  • "Lazy evaluation" features were added to Enumerable, Enumerator, and Range. The to_h method became a standard way of converting to a hash. The regex engine was changed to Onigmo (a fork of Oniguruma) for improved features and performance. For debugging, DTrace and TracePoint were added.
  • In 2.1, keyword arguments were improved a little. Refinements (introduced experimentally in 2.0) became a full-fledged language feature. Garbage collection was greatly optimized and is now controllable with more precision. For reflection purposes, ObjectSpace has seen numerous improvements. There have been small changes in the String, Bignum, Rational, and Symbol classes.
  • The 2.2 enhancements were much more incremental in nature, with changes in Binding, Dir, Enumerable, Float, File, String, and other classes.

When I began the third edition of The Ruby Way, I was targeting Ruby 1.9. This in itself was an incredible chore, since the changes were so massive and all-encompassing. But while this revision was in progress, Ruby 2.0 was released, and I tried to update the book again (with help from Russ Olsen and Andre Arko). When Ruby 2.1 was imminent, I tried to update yet again. Obviously, such updates are never-ending, until someday Ruby has completely stagnated.

As Dave Thomas said, "If it's in print, it's out of date." So although I tried hard to modernize the book, it still contains errors and omissions. Please help identify them!

I hope this article doesn't sound like just a shameless plug to buy the book; it's also my effort to instill a greater sense of history into the Ruby community. We live in a society with many people who care nothing about history, whether we are talking about a hundred years or a hundred days. That issue goes far beyond the computing world.

In the real world, existing applications and legacy code can't keep pace with our tools and environments as well as we might like. We need to understand the requirements and expectations under which code was written—even if it was years ago. We need to understand the hacks and workarounds so that we can avoid such things in the future.

I also would argue that we need to recognize fashions and trends in the computing world that don't always correlate to efficiency, practicality, or necessity. If we remember the last twenty times we jumped onto a bandwagon that went nowhere, we might be more cautious next time. In short, we need to understand the past in order to cope with the present and create the future.

In the computing world, we don't really measure time in years so much as months. What tools will we be using in 2023? Either we learn to keep up with new technology and trends, or we become irrelevant. The future isn't entirely in our control, but parts of it are. Let's learn from the past in order to help shape the future properly.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020