1.9 Incompatibilities with 1.8
block parameters
local variables only in pipe
blocked scoped
#The following will not work in 1.9
# all will be errors
ary.each{|$var| ... }
ary.each{|obj.attr| ... }
ary.each{|a2[0]| ...}
# in 1.9 gives warning, but does not alter x because the scope is limited
# the inside of the block.
x = 15
loop{|x| x = 10; break}
p x #=> 15
strings
# no longer enumerable
# lines? chars? bytes? : multiple implemenations/uses are ambiguous
# use the following to remove ambiguity:
"foo\nbar".each_line
"foo\nbar".each_char
"foo\nbar".each_byte
# or can use enumerator
"foo\nbar".lines.each{...}
"foo\nbar".chars.each{...}
"foo\nbar".bytes.each{...}
m17n - unicode
# 1.8 code based on bytes
# 1.9 is now encoding aware
# strings are now character based
# can specify encoding (similar to Python)
-* coding: UTF-8 -*-
** will not work with UTF-16 yet
** can specify file encoding:
open(path, "r:UTF-8"){|f|
...
}
2.0 will be targeting scalability but is vaporware now.
Some Features are Gone:
- VERSION and friends
- Kernel.to_a
- Kernel#getc
- Object#type
- Hash#index
- ENVindex
- Symbol#to_int
- Removed Array and Hash #indices, #indexes
# A lot of new features...
- Lamdba by ->
- ->(x){x*2}.(2) # => 4
- ->(x=5){x*2}.() # => 10
- lambda{|x=5| x * 2} # Error
- method invocation by .()
- multiple Splats in argument list
- mandatory arguments at the bottom
- chain enumerators
- ary.map.with_index{|x,i| ... }
- ary.find.with_index{|x,i| ... }
e1 = [1,2,3,4].each
e2 = [10,11,4].each
loop{
p e1.next + e2.next
}
# prints 11, 13, and 7
# silent exception because e2 reaches end of sequence
YARV
Developed by Koichi Sasada
Bytecode Interpreter
Will run other languages. Optimized for Ruby
Core performance improvement max 50 times faster
Benchmarks 2..10 times faster
Improves Core only
Using Same Library
Using Same GC
Programs will NOT run 50 times faster.
Streamlined internal data use to reduce memory consumption.
Answers to some of the questions asked by the attendees.
- Some features of 1.9 will be added into 1.8 if possible.
- Official specification coming which is a joint effort between:
- Ruby Core dev team
- JRuby team
- Rubinius team
- Oniguruma is the regex expression engine
- Continuations can be used but must be required in 1.9 (require 'continuations').
- Matz states they are dangerous.
- 1.9 does not use any specific encoding.
- 2.0 will have named parameters. Very primative compared to Python
If you picked up on something important I missed, please let me know.

0 comments:
Post a Comment