What Is New in Ruby 1.8
Ruby 1.8.0 is a significant milestone that introduced major performance improvements and a host of new standard libraries. This release stabilized the language for production use and became the foundation for many years of Ruby development.
| Category | Key Changes |
|---|---|
| Performance | Hash algorithm improvements, faster eval, reduced memory usage |
| New Libraries | Added REXML, RSS, OpenSSL, StringScanner, IO-like String |
| Language & Syntax | New block parameter syntax, Dir.glob changes, new % notation |
| Windows Support | One-Click Installer, improved stability on Win32 platforms |
| Deprecations | $defout and $deferr variables are now obsolete |
How did Ruby 1.8 improve performance?
The core team focused heavily on optimizing the interpreter. The most impactful change was a new hash table algorithm that dramatically sped up lookups. This matters because hash operations are fundamental to almost every Ruby application.
Memory usage was also reduced across the board. The eval method and garbage collector saw significant speed improvements, making meta-programming and long-running processes more efficient.
What new libraries were added in 1.8?
Ruby 1.8 bundled several crucial libraries that are now considered essential. REXML provided a pure-Ruby XML processing solution, while the RSS library made handling feeds straightforward.
The addition of OpenSSL support was a game-changer for secure communications. We also got StringScanner for lexical scanning and an IO-like String class, which simplified many text processing tasks.
What syntax changes arrived with this version?
A new syntax for block parameters was introduced, allowing for more flexible argument handling. The Dir.glob method now returns sorted results by default, which was a breaking change for some existing code.
A new % notation was added for creating strings and regular expressions. In practice, the block parameter change was the most significant as it enabled new patterns for method chaining and iteration.
How was Windows support improved?
The introduction of the One-Click Installer made getting Ruby running on Windows trivial for the first time. This was huge for expanding Ruby's reach beyond Unix-based systems.
General stability on Win32 platforms was significantly enhanced. Many edge cases and bugs specific to Windows were ironed out, making it a viable development environment.
FAQ
Was Ruby 1.8 a breaking change from 1.6?
Yes, there were several backward-incompatible changes. The most notable was that Dir.glob now returns sorted results, which broke code relying on the unsorted order.
What happened to $defout and $deferr?
These global variables were deprecated. You should use $stdout and $stderr instead for controlling output streams in your programs.
Did Ruby 1.8 include native threading?
It continued to use green threads, not native OS threads. This meant threads were not truly parallel but were useful for I/O-bound operations.
Was Rails compatible with Ruby 1.8?
Yes, early versions of Ruby on Rails were developed on and for Ruby 1.8. This compatibility helped drive Rails' initial adoption and success.
What was the biggest performance win in 1.8?
The new hash algorithm was the most significant. Hash lookups became substantially faster, which improved performance across nearly all Ruby code since hashes are used everywhere.