Ruby 3.3 programming language published

Ruby 3.3.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:

  • The main structure includes the Prism parser, implemented in the form of the libprism C library, used in the CRuby interpreter, and a gem package in the Ruby language, which provides a public API for top-down recursive parsing of code in the Ruby language, suitable for use in production projects instead of the Ripper parser. The advantages of Prism include good portability and flexible error handling in the code. To enable a new parser, you can use the “ruby —parser=prism” option or the RUBYOPT=”—parser=prism” environment variable. To parse the code in your programs, the Prism.parse(source) methods are available to obtain an AST representation of the code, Prism.parse_comments(source) to extract comments from the code, and Prism.parse_success?(source) to check for errors in the code.
  • Instead of the external Bison package, the Lrama project is used to generate parsers, which provides a Ruby implementation of the LALR algorithm, supports Bison-compatible grammar definitions (parse.y) used in CRuby, and implements advanced features such as error handling and parameterized rules (?, *, +).
  • Significant performance optimizations have been made to the YJIT JIT compiler, which is being developed by the developers of the Shopify e-commerce platform as part of an initiative to increase the performance of Ruby programs that use the Rails framework and call a lot of methods. Unlike the previously used JIT compiler MJIT, the new YJIT uses Lazy Basic Block Versioning (LBBV) instead of processing entire methods and is implemented in the form of an integrated JIT compiler written in the Rust language. With LBBV, JIT first compiles only the beginning of the method, and compiles the rest some time later, after the types of variables and arguments used are determined during execution.

    When testing the execution of the Optcarrot emulator, performance using YJIT is more than three times higher than running using the interpreter. The new version provides register allocation for virtual machine stack operations, expands the range of compiled calls with optional arguments, implements inline deployment of basic and specialized methods, and adds separate optimizations for the operations “Integer#*”, “Integer#!=”, “String#” !=", "String#getbyte", "Kernel#block_given?", "Kernel#is_a?", "Kernel#instance_of?" and "Module#===". Significantly increased compilation speed.

    Memory consumption for metadata storage has been significantly reduced and more compact code generation for the ARM64 architecture has been ensured. By default, the Code garbage collector (“-yjit-code-gc”) is disabled, which dynamically releases unused generated machine code, but leads to performance degradation during garbage collection. Added RubyVM::YJIT.enable method to control whether YJIT is enabled at runtime, without having to be run with a specific command line option or environment variable. The statistics displayed when specifying the “--yjit-stats” option have been expanded. Added performance profiling (--yjit-perf) and tracing modes (--yjit-trace-exits).

  • A new JIT compiler RJIT is proposed, written entirely in the Ruby language and replacing MJIT, but unlike the latter, it does not require a C compiler when used. RJIT only supports x86-64 architecture and Unix-like platforms.
  • Added the M:N thread scheduler, which allows you to use a limited number of operating system threads to process threads in Ruby code to reduce the overhead of creating and managing threads. By default, 8 OS threads are used (can be changed via the RUBY_MAX_CPU environment variable). Using the M:N scheduler can cause compatibility issues with C extensions, so it is disabled by default for the main Ractor class, but enabled for non-main ones. To force enable the “M:N” scheduler, set the environment variable RUBY_MN_THREADS=1.
  • The capabilities of the interactive computing shell IRB (REPL, Read-Eval-Print-Loop) have been expanded. Added irb:rdbg debugging mode, which is equivalent in its capabilities to the pry-byebug debugger. Added support for multi-page viewing of the output of the ls, show_source and show_cmds commands. Experimental support for automatic input completion has been implemented, taking into account data types. Commands are provided to change font color and style.
  • Calling the "it" method with no arguments in a parameterless block has been deprecated (for example, "[1, 2, 3].each { puts it }").
  • RubyGems and Bundler now include warning output if the gem packages abbrev, base64, bigdecimal, csv, drb, getoptlong, mutex_m, nkf, observer, racc, resolv-replace, rinda and syslog are specified in the “require” if they are not added to Gemfile or gemspec. In future versions of Ruby, these gems will be built into the core package.
  • Updated versions of built-in and standard library gem modules.

Source: opennet.ru

Add a comment