A presentation I gave at the London Ruby User Group (LRUG) in December 2007 about the changes in the ruby programming language in the soon to be released 1.9 version.
Note that Ruby 1.9 was still in development at the time I wrote this talk, so it's possible the stuff I say in it is completely inaccurate with respect to any currently released version of Ruby 1.9.
2. What is it?
• The last odd-numbered release before
Ruby 2.0
• “Wild &RubyConf Ideas”
Weird
- Matz, 2005
• More open development
• http://www.rcrchive.net/
7. YARV
3 Things It Means To Us
1. New developer
• not matz-bound
2. Better Performance
• in places
3. Native threads
• vs. green threads
8. Other Changes
Module#*_instance_methods
Enumerable#first(n) Limit input Enumerable#cycle Method#name
String#bytes Symbol#=== matches strings Removed Exception#to_str Array.try_convert Module#class_variable_defined?
$SAFE and bound methods String no longer an Enumerable String#upto Enumerable#inject (#reduce) without a block Hash#to_s is equivalent to Hash#inspect
Method#owner Non-blocking IO Enumerator#rewind String#partition, #rpartition Arity of blocks without arguments
Struct#inspect Enumerable#group_by Process.daemon IO#lines String#lines
Array#[m,n] = nil places nil in the array GC.stress, GC.stress= Range#include? Fiber: coroutines/micro-threads Array#nitems
Hash#_compare_by_identity, #compare_by_identity? Object#=~ Enumerable methods called without a block Method#receiver Enumerable#count
Mandatory arguments after optional arguments allowed String#encoding #to_path in File.<blah> Module#const_defined?, #const_get Dir.exist?
New File and Dir operations ?c semantics Array#to_s is equivalent to Array#inspect Method used for splat arguments: #to_splat Regexp#=== matches symbols
#class_variable_{set,get} Block argument to Array#index, Array#rindex String#ord #instance_exec Zero-length symbols allowed
IO.try_convert Semantics for Hash#each and Hash#each_pair Deprecated: StringScanner Proc#yield Deprecated: Kernel#getc
New literal hash syntax Block local variables Binding#eval Range#min, Range#max send doesn't always call private methods anymore
Deprecated: Object#type Numeric#upto, #downto, #times, #step BasicObject Process.exec IO#bytes
Enumerable#reduce proc is now a synonym of Proc.new Integer#pred Deprecated: Kernel.to_a Multiple splats allowed
Kernel#require Enumerator#with_index StringIO#readpartial Dir.[], Dir.glob Enumerable#each_with_index
Passing blocks to #[] Module#attr is an alias of attr_reader News semantics for block arguments String.try_convert Symbols: restriction on literal symbols
Regexp.try_convert Deprecated: File.exists? Deprecated: Hash#index Method#hash, Proc#hash IO#ungetc, StringIO#ungetc
IO#getc Block arguments are always local Deprecated: Symbol#to_int Extra subclassing check when binding UnboundMethods Equality of exceptions
Deprecated: Removed Array and Hash #indices, #indexes Enumerable#find_index Symbol#to_proc Integer#odd?, #even? .() and calling Procs without #call/#[]
Deprecated:VERSION and friends Symbol#intern Timezone information preserved on Marshal.dump/load Block arguments Kernel#define_singleton_method
Process.setrlimit Hash#select Kernel#open Array#pop, Array#shift Array#product
IO#initialize now accepts an IO argument String#force_encoding Symbol methods similar to those in String Kernel#singleton_methods, Kernel#methods Regexp#match, String#match
Math#log and Math#log2 Array#combination String#unpack with a block defined? and local variables Newlines allowed before ternary colon
String#hash Numeric#scalar?, Complex#scalar?
quot;One-char-widequot; semantics for String#[] and String#[]= Enumerator#each #module_exec
String#each_char Enumerable#min_by, #max_by Numeric#fdiv SystemStackError Enumerable#drop
Range#cover? Arguments to #[] Integer(nil) raises TypeError Enumerable#minmax, #minmax_by Symbol#encoding
Deprecated: ENV.index Proc#lambda? String#start_with?, #end_with? String#clear Numeric#div
__method__ and __callee__ Object#tap Hash.try_convert Array#permutation Enumerable#zip
New format in Time#to_s String has encoding-awareness Enumerable#take NameError Class variables are not inherited
IO & StringIO #getbyte, #readbyte Class of singleton classes Kernel#instance_variable_defined? New syntax for lambdas printf-style formatted strings (%)
18. String
• Encoding aware
• methods are char, not byte, based now
• open(‘blah.txt’, ‘r:utf-8’)
• # -*- coding: utf-8 -*-
• Bye Bye: $KCODE and jcode
• No longer an Enumerable
19. Enumerable
• Enumerable::Enumerator part of
core
• Enumerable methods without a block
• [1,2,3].map.with_index {|item,
idx| ...}
• #inject without block
• [1,2,3].inject(:+) #=> 6
20. Symbol
• Symbol#to_proc
• [”matz”, “koichi”].map(&:upcase)
#=> [“MATZ”, “KOICHI”]
• Treated more like Strings
• #encoding, #empty?, #upcase,
#[], #match, etc...
• #===
21. IO
• Non blocking IO
• Limit input in read/get methods
• Oddness: doesn’t appear to be encoding
aware
22. Misc.
• BasicObject at top of class hierarchy
• Class variables (@@woo) not inherited
• proc is now Proc.new instead of
lambda
• Proc#yield a method for yield keyword
• send shouldn’t invoke private methods
24. How do I get it?
• Wait till Christmas?
• http://svn.ruby-lang.org/repos/ruby/trunk
• Tiger users - upgrade your bison
• Windows binaries available