2.0.0-p0 release [DRAFT!]¶
Hello all --
We are pleased to announce the release of Ruby 2.0.0-p0.
Download¶
ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2
SIZE: 10814890 bytes
MD5: 895c1c581f8d28e8b3bb02472b2ccf6a
SHA256: c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295fftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
SIZE: 13608925 bytes
MD5: 50d307c4dc9297ae59952527be4e755d
SHA256: aff85ba5ceb70303cb7fb616f5db8b95ec47a8820116198d1c866cc4fff151edftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.zip
SIZE: 15037340 bytes
MD5: db5af5d6034646ad194cbdf6e50f49ee
SHA256: 0d0af6a9c8788537efd8d7d2358ce9468e6e2b7703dacba9ebd064d8b7da5f99
What is Ruby 2.0.0?¶
Ruby 2.0.0 is the first stable release of the Ruby 2.0 series, with many
new features and improvements in response to the increasingly diverse and
expanding demands for Ruby. Some of the highlights:
Language core features
- Keyword arguments, which give flexibility to API design
- Module#prepend, which is a new way to extend a class
- A literal %i, which creates an array of symbols easily
- dir, which returns the dirname of the file currently being executed
- The UTF-8 default encoding, which make many magic comments omissible
Built-in libraries
- Enumerable#lazy and Enumerator::Lazy, for (possibly infinite) lazy stream
- Enumerator#size and Range#size, for lazy size evaluation
- #to_h, which is a new convention for conversion to Hash
- Onigmo, which is a new regexp engine (a fork of Oniguruma)
- Asynchronous exception handling API
Debug support
- DTrace support, which enables run-time diagnosis in production
- TracePoint, which is an improved tracing API
Performance improvements
- GC optimization by bitmap marking
- Kernel#require optimization which makes Rails startup very fast
- VM optimization such as method dispatch
- Float operation optimization
In addition, albeit as an experimental feature, 2.0.0 includes Refinements, which
adds a new concept to Ruby's modularity.
See also NEWS for more features, improvements and details.
We have also taken care with the 2.0.0 design to make it compatible
with 1.9. It will be easier to migrate from 1.9 to 2.0 than it was from 1.8 to 1.9.
(The notable incompatibilities are described later.)
In fact, thanks to the dedicated work of third parties, some popular
applications such as Rails and tDiary have been reported to work on the
release candidate version of 2.0.0.
We have also made documentation improvements which many rubyists have requested.
We have added a huge amount of rdoc for modules and methods.
2.0.0 will be around 75% documented while 1.9.3 was about 60%.
Also, we have added a description of Ruby's syntax. You can see:
ri ruby:syntax
Note that unlike 1.9.0, 2.0.0 IS a stable release, even though its TEENY is 0.
All library authors are strongly recommended to support 2.0.0.
As mentioned above, it will be comparatively easy to migrate from 1.9 to 2.0.
Ruby 2.0.0 is ready for practical use, and will absolutely improve your
Ruby life.
Enjoy programming with Ruby 2.0.0!
Notes¶
Introductory articles¶
Here are some introductory articles of 2.0.0 features by third parties:
- http://blog.marc-andre.ca/2013/02/23/ruby-2-by-example (comprehensive, recommended)
- https://speakerdeck.com/shyouhei/whats-new-in-ruby-2-dot-0 (comprehensive, recommended)
- http://el.jibun.atmarkit.co.jp/rails/2012/11/ruby-20-8256.html (brief, in Japanese)
- https://speakerdeck.com/nagachika/rubyist-enumeratorlazy (only Enumerator::Lazy, in Japanese)
The following articles are also helpful, but outdated with regards to refinement:
- http://rubysource.com/a-look-at-ruby-2-0/
- https://speakerdeck.com/a_matsuda/ruby-2-dot-0-on-rails
- http://globaldev.co.uk/2012/11/ruby-2-0-0-preview-features/
- http://www.infoq.com/news/2012/11/ruby-20-preview1
Also, the recent issue of "Rubyist Magazine" includes some articles that were
written by the feature authors themselves for introducing some new 2.0.0 features.
Though they will be written in Japanese, English translations are planned for the
future.
Incompatibility¶
There are five notable incompatibilities we know of:
The default encoding for ruby scripts is now UTF-8 [#6679].
Some people report that it affects existing programs, such as some
benchmark programs becoming very slow .Iconv was removed, which had already been deprecated when M17N was
introduced in ruby 1.9. Use String#encode, etc. instead.There is ABI breakage . We think that normal
users can/should just reinstall extension libraries.
You should be aware: DO NOT COPY .so OR .bundle FILES FROM 1.9.#lines, #chars, #codepoints, #bytes now returns an Array instead of
an Enumerator [#6670]. This change allows you to avoid the common
idiom "lines.to_a". Use #each_line, etc. to get an Enumerator.Object#inspect does always return a string like #ClassName:0x...
instead of delegating to #to_s. [#2152]
There are some comparatively small incompatibilities.
Status of Refinements¶
We have added a feature called Refinements, which adds a new concept to
Ruby's modularity. However, please be aware that Refinements is still an
experimental feature: we may change its specification in the future.
Despite that, we would like you to play with it and give us your
thoughts. Your feedback will help to forge this interesting feature.
Acknowledgment¶
A great many people contributed to 2.0.0.
Even an incomplete acknowledgment for only a few parts of contributions became too big to insert here.
Sorry but let me just add a link to the special thanks page.
http://bugs.ruby-lang.org/projects/ruby/wiki/200SpecialThanks
Thank you all!
こんにちは。Ruby 2.0.0-p0 をリリースします。
ダウンロード¶
ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2
SIZE: 10814890 bytes
MD5: 895c1c581f8d28e8b3bb02472b2ccf6a
SHA256: c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295fftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
SIZE: 13608925 bytes
MD5: 50d307c4dc9297ae59952527be4e755d
SHA256: aff85ba5ceb70303cb7fb616f5db8b95ec47a8820116198d1c866cc4fff151edftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.zip
SIZE: 15037340 bytes
MD5: db5af5d6034646ad194cbdf6e50f49ee
SHA256: 0d0af6a9c8788537efd8d7d2358ce9468e6e2b7703dacba9ebd064d8b7da5f99
Ruby 2.0.0 とは?¶
Ruby 2.0.0 は Ruby 2.0 系列の最初の安定版リリースです。
Ruby への要求の多様化・大規模化に対応するため、数多くの新機能や改善が
搭載されています。主要な変更点は以下のとおりです。
言語コア機能
- キーワード引数: API 設計の新しい柔軟性
- Module#prepend: クラス拡張の新しい方法
- シンボルの配列を簡単に作るリテラル %i
- dir: 実行中のファイルのあるディレクトリ名
- default UTF-8 encoding: 多くのマジックコメントが不要に
組み込みライブラリ
- Enumerable#lazy / Enumertor::Lazy: 無限の遅延ストリーム
- Enumerable#size: 遅延サイズ評価
- #to_h: Hash への変換メソッド
- Onigmo (鬼雲): 新しい正規表現エンジン (鬼車の fork)
- 非同期例外を安全にハンドリングする API
デバッグサポート
- DTrace サポート: 本番環境での実行時診断を可能にする機能
- TracePoint: 改善されたトレース API
性能改善
- bitmap marking による GC 最適化
- Rails の起動時間を大幅に短縮する Kernel#require の最適化
- メソッドディスパッチなどの VM 最適化
- 浮動小数演算の最適化
また、実験的機能としてではありますが、Ruby のモジュール性に対する新しい
概念となる refinement も提供されています。
新機能の詳しい情報については NEW ファイルもご参照ください。
2.0.0 の設計では 1.9 と互換であることに非常に注意を払っています。
1.9 から 2.0 への移行は、1.8 から 1.9 の移行より苦労しないと思います。
(大きめの非互換については後述します)
実際、サードパーティの献身的な活動によって、Rails や tDiary など、
いくつかの広く使われているアプリケーションが 2.0.0 の Release Candidate
版で動作することが報告されています。
長年の懸案であったドキュメント不足についても、rdoc が大幅に追加され、
1.9.3 のときはドキュメント率が 60% だったのに対し、2.0.0 では 75% と
なり、大きく改善しています。また、Ruby の構文の説明も追加されています。
ri ruby:syntax
で読むことができます。
TEENY が 0 ですが、1.9.0 と違い、2.0.0 は「安定版」リリースであることに
ご注意ください。ライブラリ作者には 2.0.0 をサポートすることを推奨します。
上述の通り、1.9 から 2.0 への移行は比較的容易なはずです。
Ruby 2.0.0 は実用可能な状態であり、あなたの Ruby 生活を確実に改善します。
Ruby 2.0.0 でプログラミングを楽しんでください。
注意点¶
紹介記事¶
サードパーティによる新機能の紹介記事があります。
- http://blog.marc-andre.ca/2013/02/23/ruby-2-by-example (包括的、おすすめ)
- https://speakerdeck.com/shyouhei/whats-new-in-ruby-2-dot-0 (包括的、おすすめ)
- http://el.jibun.atmarkit.co.jp/rails/2012/11/ruby-20-8256.html (概要のみ、日本語)
- https://speakerdeck.com/nagachika/rubyist-enumeratorlazy (Enumerator::Lazy のみ、日本語)
以下の記事も参考になりますが、refinement に関しての記述が古いです。
- http://rubysource.com/a-look-at-ruby-2-0/
- https://speakerdeck.com/a_matsuda/ruby-2-dot-0-on-rails
- http://globaldev.co.uk/2012/11/ruby-2-0-0-preview-features/
- http://www.infoq.com/news/2012/11/ruby-20-preview1
また、"Rubyist Magazine" の最新号で 2.0.0 の一部の新機能を紹介する記事が
掲載されています。
日本語で書かれていますが、後日英訳もされる見込みです。
非互換について¶
特筆すべき非互換を 5 つ把握しています。
デフォルトのスクリプトエンコーディングが UTF-8 になりました [#6679] 。
これは既存のプログラムに影響を与えることが報告されています。例えば、
ベンチマークプログラムが非常に遅くなるなど 。iconv が削除されました。元々 M17N が導入された 1.9 の時点で非推奨の
ものでした。String#encode などを使って書き換えてください。ABI 互換性がなくなっています 。通常のユーザは、拡張
ライブラリを再インストールするだけでよいはすです。「1.9 の .so,
.bundle ファイルをコピーするな」とだけ気をつけてください。#lines, #chars, #codepoints, #bytes メソッドが Enumerator ではなく
配列を返すようになりました [#6670]。この変更によって、"lines.to_a"
というイディオムを書く必要がなくなります。
Enumerator が必要な場合は #each_line などを利用して下さい。Object#inspect は #to_s を呼び出さず、常に #ClassName:0x... のような
文字列を返すようになりました。 [#2152]
他にも比較的小さな非互換があります。
refinements の扱い¶
Ruby のモジュール性に新しい概念を与える Refinement と呼ばれる機能を追加しました。
しかし、Refinement は「実験的機能」であることに注意してください。将来仕様が変化
する可能性があります。
それでも、ぜひお試し頂き、感想をお聞かせください。
あなたのフィードバックによってこの機能を進化させていきたいと思っています。
謝辞¶
2.0.0 は非常に多くの人々の貢献によって成り立っています。
貢献のごく一部の不完全な謝辞ですら、ここに掲載するには大きくなりすぎました。
special thanks のページヘのリンクを貼ることでその代わりとさせてください。
http://bugs.ruby-lang.org/projects/ruby/wiki/200SpecialThanks
以上です。