{"id":47817,"date":"2024-12-25T13:31:41","date_gmt":"2024-12-25T13:31:41","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=47817"},"modified":"2024-12-25T13:31:41","modified_gmt":"2024-12-25T13:31:41","slug":"ruby-3-4-released-with-it-modular-garbage-collector","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/12\/ruby-3-4-released-with-it-modular-garbage-collector\/","title":{"rendered":"Ruby 3.4 Released with &#8216;it&#8217;, Modular Garbage Collector, Improved YJIT"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-45212\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/01\/ruby-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>Ruby, the free open-source high-level general-purpose programming language, released new 3.4.0 (then 3.4.1 with quick fix) today at Christmas!<\/p>\n<p>The release introduced <code>it<\/code> block parameter reference, which behaves very much the same as <code>_1<\/code>. As the <a href=\"https:\/\/bugs.ruby-lang.org\/issues\/20470\" target=\"_blank\" rel=\"noopener\">feature request<\/a> descripted:<\/p>\n<blockquote><p><i><code>it<\/code> is implemented as a special case of <code>getlocal<\/code> insn, not a method. <code>it<\/code> without an argument is considered <code>_1<\/code> or a normal local variable if defined. <code>it<\/code> is considered a method call only when it has any positional\/keyword\/block arguments.<\/i><\/p><\/blockquote>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/12\/ruby-it.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47818\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/12\/ruby-it-700x378.webp\" alt=\"\" width=\"610\" height=\"329\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/12\/ruby-it-700x378.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/12\/ruby-it-300x162.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/12\/ruby-it.webp 722w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>In Ruby 3.4, <b>the socket library now features Happy Eyeballs Version 2 (RFC 8305)<\/b>. Which, ensures minimized connection delays, even if a specific protocol or IP address is delayed or unavailable.<\/p>\n<p>This feature is enabled by default. Though, can be disabled either on a per-method basis by using the keyword argument <code>fast_fallback: false<\/code>, or globally by setting environment variable <code>RUBY_TCP_NO_FAST_FALLBACK=1<\/code> or calling <code>Socket.tcp_fast_fallback=false<\/code><\/p>\n<p>The release also <b>introduced modular garbage collector (GC)<\/b>. It can be enabled at build time by <code>--with-modular-gc<\/code> configuration option. To load at runtime, use the environment variable <code>RUBY_GC_LIBRARY<\/code>.<\/p>\n<p>The built-in garbage collector has been splitted. It can be built as a library and enabled by environment variable <code>RUBY_GC_LIBRARY=default<\/code>. While, there&#8217;s also an experimental GC library based on MMTk, which can be built then enabled by <code>RUBY_GC_LIBRARY=mmtk<\/code>.<\/p>\n<p>The new release also <b>switched the default parser from parse.y to Prism<\/b>. While the previous parser is available by using  <code>--parser=parse.y<\/code> command-line argument.<\/p>\n<p>The YJIT compiler has been improved with better performance on x86-64 and arm64 platforms, and less memory usage through compressed metadata and a unified memory limit.<\/p>\n<p>While, there are new <code>--yjit-mem-size<\/code> command option to unify memory limit (default 128MiB) to track total YJIT memory usage, and <code>--yjit-log<\/code> that enables a compilation log to track what gets compiled.<\/p>\n<p>Other changes in Ruby 3.4.0 include:<\/p>\n<ul>\n<li>Keyword splatting <code>nil<\/code> when calling methods is now supported.<\/li>\n<li>Block passing and keyword arguments are no longer allowed in index.<\/li>\n<li>Add <code>GC.config<\/code> to allow setting configuration variables on the Garbage Collector.<\/li>\n<li>Introduce <code>rgengc_allow_full_mark<\/code> GC configuration parameter.<\/li>\n<li>Add <code>Ractor.main?<\/code>, <code>Ractor.[]<\/code>, and <code>Ractor.[]=<\/code>.<\/li>\n<\/ul>\n<p>There are as well other core classes, standard library, API updates, and bug-fixes. See the <a href=\"https:\/\/www.ruby-lang.org\/en\/news\/2024\/12\/25\/ruby-3-4-0-released\/\" rel=\"noopener\" target=\"_blank\">official release<\/a> note for details.<\/p>\n<h3>How to Install Ruby 3.4.1<\/h3>\n<p>Ruby is available in App Center (or Ubuntu Software) as official Snap package, though NOT updated to the lastest at the moment of writing. <\/p>\n<p>If you can&#8217;t wait Snap or third-party package manager, then, you may download the source tarball from the link button below:<\/p>\n<div class=\"wp-block-buttons aligncenter\">\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-vivid-cyan-blue-to-vivid-purple-gradient-background has-text-color has-background\" href=\"https:\/\/cache.ruby-lang.org\/pub\/ruby\/\" target=\"_blank\" rel=\"noreferrer noopener\">Download Ruby (tarball)<\/a><\/div>\n<\/div>\n<p>And, here&#8217;s a <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2024\/01\/install-ruby-ubuntu-24-04\/\" rel=\"noopener\" target=\"_blank\">step by step guide<\/a> (Method 4) talking about how to build it from source.<\/p>","protected":false},"excerpt":{"rendered":"<p>Ruby, the free open-source high-level general-purpose programming language, released new 3.4.0 (then 3.4.1 with quick fix) today at Christmas! The release introduced it block parameter reference, which behaves very much the same as _1. As the feature request descripted: it is implemented as a special case of getlocal insn, not a method. it without an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":45212,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[2086,1600],"class_list":["post-47817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-programming","tag-ruby"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=47817"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47817\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/45212"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=47817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=47817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=47817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}