Release of the Ruby programming language 3.1

Ruby 3.1.0 has been released, a dynamic object-oriented programming language that is highly efficient in program development and incorporates the best features of Perl, Java, Python, Smalltalk, Eiffel, Ada and Lisp. The project code is distributed under the BSD ("2-clause BSDL") and "Ruby" licenses, which refers to the latest version of the GPL license and is fully compatible with GPLv3.

Main improvements:

  • Added a new experimental in-process JIT compiler, YJIT, created by the developers of the e-commerce platform Shopify as part of an initiative to increase the performance of Ruby programs that use the Rails framework and call a lot of methods. The key difference from the previously used MJIT JIT compiler, which is based on method processing and uses an external C compiler, is that YJIT uses Lazy Basic Block Versioning (LBBV) and contains an integrated JIT compiler. Thanks to LBBV, JIT compiles only the beginning of the method at first, and compiles the rest after some time, after the types of variables and arguments used are determined during execution. When using YJIT, a 22% performance increase was recorded in the railsbench test, and a 39% performance increase in the liquid-render test. YJIT is currently limited to support for unix-like operating systems on systems with x86-64 architecture and is disabled by default (to activate, specify the "--yjit" flag in the command line).
  • Improved performance of the old MJIT JIT compiler. For projects using Rails, the default maximum cache size (--jit-max-cache) has been increased from 100 to 10000 instructions. Stopped not using JIT for methods with more than 1000 instructions. To support Zeitwerk of Rails, JIT-generated code is no longer discarded when TracePoint is enabled for class events.
  • The package includes a completely rewritten debug.gem debugger that supports remote debugging, does not slow down the debugged application, supports integration with advanced debugging interfaces (VSCode and Chrome), can be used to debug multi-threaded and multi-process applications, provides a REPL code execution interface, offers advanced tracing capabilities, can record and replay snippets of code. The previously proposed debugger lib/debug.rb has been removed from the base distribution.
    Release of the Ruby programming language 3.1
  • Implemented visual highlighting of errors in call back trace reports. Error marking is provided by the built-in and default gem error_highlight. You can use the "--disable-error_highlight" setting to disable error highlighting. $ ruby ​​test.rb test.rb:1:in " ": undefined method "time" for 1:Integer (NoMethodError) 1.time {} ^^^^^ Did you mean? times
  • The shell of interactive calculations IRB (REPL, Read-Eval-Print-Loop) implements automatic completion of the input code (as you type, a hint is displayed with options for continuing input, between which you can navigate with the Tab or Shift + Tab key). After selecting a continuation option, a dialog box is provided next to it, showing the documentation associated with the selected item. The Alt+d keyboard shortcut can be used to jump to the full documentation.
    Release of the Ruby programming language 3.1
  • The language syntax now allows hash literal values ​​and keyword arguments to be skipped when calling functions. For example, instead of the expression "{x: x, y: y}", you can now specify "{x:, y:}", and instead of "foo(x: x, y: y)" - foo(x:, y: )".
  • Stabilized support for single-line pattern matching (ary => [x, y, z]), which no longer have the experimental flag.
  • The "^" operator in pattern matching can now contain arbitrary expressions, for example: Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a #=> ? [[3, 5], [5, 7], [11, 13]]
  • Parentheses are allowed in single-line pattern matches: [0, 1] => _, x {y: 2} => y: x #=> 1 y #=> 2
  • The RBS type annotation language, which allows you to define the structure of the program and the types used, added support for specifying the upper bound of type parameters using the "<" symbol, added support for generic type aliases, implemented support for collections for managing gems, improved performance and implemented many new signatures for built-in and standard libraries.
  • The TypePro static type analyzer, which generates RBS annotations based on code analysis without explicit type information, has added experimental support for integrated development environments (for example, an add-on has been prepared for integrating TypePro with the VSCode editor).
  • Changed how multiple assignments are handled. For example, the components of the expression "foo[0], bar[0] = baz, qux" used to be processed in the order baz, qux, foo, bar, and now foo, bar, baz, qux.
  • Added experimental support for memory allocation for strings using the VWA (Variable Width Allocation) mechanism.
  • Updated versions of built-in and standard library gem modules. The net-ftp, net-imap, net-pop, net-smtp, matrix, prime and debug packages are built in.

Source: opennet.ru

Add a comment