|
| 1 | +--- |
| 2 | +layout: news_post |
| 3 | +title: "Ruby 2.7.0-preview1 Released" |
| 4 | +author: "naruse" |
| 5 | +translator: |
| 6 | +date: 2019-04-20 00:00:00 +0000 |
| 7 | +lang: en |
| 8 | +--- |
| 9 | + |
| 10 | +We are pleased to announce the release of Ruby 2.7.0-preview1. |
| 11 | + |
| 12 | +A preview version is released to gather feedback for the final release planed to release on December. It introduces a number of new features and performance improvements, most notably: |
| 13 | + |
| 14 | +* Compaction GC |
| 15 | +* Pattern Matching |
| 16 | +* REPL improvement |
| 17 | + |
| 18 | +## Compaction GC |
| 19 | + |
| 20 | +This release introduces Compaction GC which can defragment a fragmented memory space. |
| 21 | + |
| 22 | +Some multithread Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed. |
| 23 | + |
| 24 | +The `GC.compact` method is introduced for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW friendly. [#15626](https://bugs.ruby-lang.org/issues/15626) |
| 25 | + |
| 26 | +## Pattern Matching [Experimental] |
| 27 | + |
| 28 | +Pattern matching, widely used feature in functional programming languages, is introduced as an experimental feature. [#14912](https://bugs.ruby-lang.org/issues/14912) |
| 29 | +It can traverse a given object and assign its value if it matches a pattern. |
| 30 | + |
| 31 | +```ruby |
| 32 | +case JSON.parse('{...}', symbolize_names: true) |
| 33 | +in {name: "Alice", children: [{name: "Bob", age: age}]} |
| 34 | + p age |
| 35 | + ... |
| 36 | +end |
| 37 | +``` |
| 38 | + |
| 39 | +For more details, please see https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7. |
| 40 | + |
| 41 | +## REPL improvement |
| 42 | + |
| 43 | +`irb`, bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It's powered by `reline`, `readline` compatible pure Ruby implementation. |
| 44 | +It also provides rdoc integration. In `irb` you can display the reference for a given class, module, or method. [#14683](https://bugs.ruby-lang.org/issues/14683), [#14787](https://bugs.ruby-lang.org/issues/14787), [#14918](https://bugs.ruby-lang.org/issues/14918) |
| 45 | +Besides, source lines shown at `binding.irb` and inspect results for core-class objects are now colorized. |
| 46 | + |
| 47 | +<video autoplay="autoplay" loop="loop" width="478" height="202"> |
| 48 | + <source src="https://cache.ruby-lang.org/pub/media/irb_improved_with_key_take2.mp4" type="video/mp4"> |
| 49 | +</video> |
| 50 | + |
| 51 | +## Other Notable New Features |
| 52 | + |
| 53 | +* A method reference operator, <code>.:</code>, is introduced as an experimental feature. [#12125]( https://bugs.ruby-lang.org/issues/12125), [#13581]( https://bugs.ruby-lang.org/issues/13581) |
| 54 | + |
| 55 | +* Numbered parameter as the default block parameter is introduced as an experimental feature. [#4475](https://bugs.ruby-lang.org/issues/4475) |
| 56 | + |
| 57 | +* A beginless range is experimentally introduced. It might not be as useful |
| 58 | + as an endless range, but would be good for DSL purpose. [#14799](https://bugs.ruby-lang.org/issues/14799) |
| 59 | + |
| 60 | + ary[..3] # identical to ary[0..3] |
| 61 | + rel.where(sales: ..100) |
| 62 | + |
| 63 | +* `Enumerable#tally` is added. It counts the occurrence of each element. |
| 64 | + |
| 65 | + ["a", "b", "c", "b"].tally |
| 66 | + #=> {"a"=>1, "b"=>2, "c"=>1} |
| 67 | + |
| 68 | +## Performance improvements |
| 69 | + |
| 70 | +* JIT [Experimental] |
| 71 | + |
| 72 | + * JIT-ed code is recompiled to less-optimized code when an optimization assumption is invalidated. |
| 73 | + |
| 74 | + * Method inlining is performed when a method is considered as pure. This optimization is still experimental and many methods are NOT considered as pure yet. |
| 75 | + |
| 76 | + * Default value of `--jit-min-calls` is changed from 5 to 10,000 |
| 77 | + |
| 78 | + * Default value of `--jit-max-cache` is changed from 1,000 to 100 |
| 79 | + |
| 80 | +## Other notable changes since 2.6 |
| 81 | + |
| 82 | +* `Proc.new` and `proc` with no block in a method called with a block is warned now. |
| 83 | + |
| 84 | +* `lambda` with no block in a method called with a block errs. |
| 85 | + |
| 86 | +* Update Unicode version and Emoji version from 11.0.0 to 12.0.0. [[Feature #15321]](https://bugs.ruby-lang.org/issues/15321) |
| 87 | + |
| 88 | +* Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. [[Feature #15195]](https://bugs.ruby-lang.org/issues/15195) |
| 89 | + |
| 90 | +* `Date.jisx0301`, `Date#jisx0301`, and `Date.parse` provisionally support the new Japanese era as an informal extension, until the new JIS X 0301 is issued. [[Feature #15742]](https://bugs.ruby-lang.org/issues/15742) |
| 91 | + |
| 92 | +* Require compilers to support C99 [[Misc #15347]](https://bugs.ruby-lang.org/issues/15347) |
| 93 | + * Details of our dialect: <https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99> |
| 94 | + |
| 95 | +See [NEWS](https://github.com/ruby/ruby/blob/v2_7_0_preview1/NEWS) or [commit logs](https://github.com/ruby/ruby/compare/v2_6_0...v2_7_0_preview1) for more details. |
| 96 | + |
| 97 | +With those changes, [6376 files changed, 227364 insertions(+), 51599 deletions(-)](https://github.com/ruby/ruby/compare/v2_6_0...v2_7_0_preview1) since Ruby 2.6.0! |
| 98 | + |
| 99 | +Enjoy programming with Ruby 2.7! |
| 100 | + |
| 101 | +## Download |
| 102 | + |
| 103 | +* <https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0-preview1.tar.gz> |
| 104 | + |
| 105 | + SIZE: 16020966 bytes |
| 106 | + SHA1: f968d0c6117a7767af0b354458195de1df628b93 |
| 107 | + SHA256: b61dba9ed01e855000111964363fbd691219ab3c567455434717ecba962747ea |
| 108 | + SHA512: 820ac03c08fd6e8283275a0d37caac9787afb85426bbb27e2105d8007bbc7ad6a35b2b40c8af81cdbb7a00347d44e92b5ff9b6e7f48f22d05584cedb85578409 |
| 109 | +* <https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0-preview1.zip> |
| 110 | + |
| 111 | + SIZE: 20283209 bytes |
| 112 | + SHA1: fc31cb0620962f0aa73c902edfc8523ec5b2a2ec |
| 113 | + SHA256: 59da2314822add396f68ce3e8e43e98843d41f4eab2354edc7f793a1ec3f3359 |
| 114 | + SHA512: e6726f21dc5e90f42e762a81cbf88caef325fe2d589d75a81d82663652695ed94b3be6e12fe238fc82e5caebb16e626456d9e9dfa4ecc6a55e532ba372b2d4de |
| 115 | +* <https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0-preview1.tar.bz2> |
| 116 | + |
| 117 | + SIZE: 14040553 bytes |
| 118 | + SHA1: 0a03aa856d87110e14a621d5bf7378de59a9d682 |
| 119 | + SHA256: b20c80adc1324c0ec87bf3f4a66b837771d7a30fc876d83e68e519c623cf0369 |
| 120 | + SHA512: 282d51ab6a76f40014e7c1738a1a02484e12bd52057db953e356b300974f5a1603a14dc23e436587870767213816c5adda335e6f8716de02c8fd853c85447250 |
| 121 | +* <https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0-preview1.tar.xz> |
| 122 | + |
| 123 | + SIZE: 11440260 bytes |
| 124 | + SHA1: c7297e4a9e81657a9c8731da8de2e2aa4d4879c3 |
| 125 | + SHA256: 540f11753f5805c1bf560c54a44d1ea04414217c7d319cac165de964e269399f |
| 126 | + SHA512: 78afd2b167658d0edb368a3f5f91446a5f6f63b451bfc1966af8964579bc74f6c6a2d227c8715ab742e97c6895ce4006b56ba0eed97b6effcd93555b43d90313 |
| 127 | + |
| 128 | +## What is Ruby |
| 129 | + |
| 130 | +Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993, and is now developed as Open Source. It runs on multiple platforms and is used all over the world especially for web development. |
0 commit comments