Release of the Ruby programming language 3.2

Ruby 3.2.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 an initial port of a CRuby interpreter that compiles to WebAssembly intermediate code to run in a web browser or under standalone runtimes such as wasmtime. For direct interaction with the operating system when running separately, the WASI (WebAssembly System Interface) API is used. Among other things, a VFS binding on top of WASI is provided, which allows you to package the entire application in the Ruby language into a view in the form of a single wasm file. Running in a browser can be used to create tutorial and demo web services such as TryRuby. At the current stage of development, the port successfully passes the basic and bootstrap test suites, which do not use the Thread API. The port also does not support Fiber, Exceptions, or Garbage Collection.
  • The in-process JIT compiler YJIT, created 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, has been declared stable and ready for production use. 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. YJIT is available for x86-64 and arm64/aarch64 architectures on Linux, MacOS, BSD, and other UNIX platforms.

    Unlike CRuby, YJIT code is written in Rust and requires the rustc 1.58.0+ compiler to compile, so YJIT compilation is disabled by default and is optional. When using YJIT, a 41% increase in performance was recorded when running the yjit-bench test compared to using interpretation.

    Release of the Ruby programming language 3.2

  • Added additional protection against attacks that cause denial of service when processing external data in inefficient and long-running regular expressions (ReDoS). Significantly improved matching algorithm, which uses the memorization technique. For example, the execution time of the expression '/^a*b?a*$/ =~ "a" * 50000 + "x"' has been reduced from 10 to 0.003 seconds. The price of optimization is an increase in memory consumption, the consumption of which is about 10 times higher than the size of the input data. The second security measure is the ability to define a timeout (for example, "Regexp.timeout = 1.0"), for which the regular expression must have time to be processed.
  • The syntax_suggest mode is included to help diagnose the causes of errors associated with a missing or redundant "end" closing statement. Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ? 1 class Dog > 2 defbark > 3 end 4 end
  • Added the ability to mark arguments in case of errors related to types and arguments to the error location mode, for example: test.rb:2:in `+': nil can't be coerced into Integer (TypeError) sum = ary[0] + ary [1] ^^^^^^
  • Added new syntax for redirecting to other argument set methods: def foo(*) bar(*) end def baz(**) quux(**) end
  • Ruby_vm/mjit/compiler proposed - a variant of the old MJIT JIT compiler, rewritten in the Ruby language. Ensured MJIT execution in a separate process, instead of execution in the MJIT worker thread.
  • In Bundler 2.4, dependency handling uses the PubGrub version finder, also used by the pub package manager for Dart. The previously used Molinillo algorithm continues to be used in RubyGems, but will also be replaced by PubGrub in the future.
  • Updated versions of built-in and standard library gem modules.

Source: opennet.ru

Add a comment