{"id":151136,"date":"2025-01-05T17:31:55","date_gmt":"2025-01-05T17:31:55","guid":{"rendered":"https:\/\/linuxiac.com\/?p=151136"},"modified":"2025-01-05T17:43:54","modified_gmt":"2025-01-05T17:43:54","slug":"fish-shell-4-0-rust-is-coming","status":"publish","type":"post","link":"https:\/\/linuxiac.com\/fish-shell-4-0-rust-is-coming\/","title":{"rendered":"Fish Shell 4.0: Rust Is Coming"},"content":{"rendered":"\n<p><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">In a remarkable two-year effort, the maintainers of the popular <\/span><a href=\"https:\/\/fishshell.com\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">F<\/span>ish Shell<\/a> have officially released a <strong>beta of&nbsp;Fish 4.0<\/strong>\u2014this time <strong>written almost entirely in Rust instead of C++<\/strong>. What began in early 2023 as <a href=\"https:\/\/github.com\/fish-shell\/fish-shell\/pull\/9512\" target=\"_blank\" rel=\"noreferrer noopener\">a playful pull request<\/a> jokingly titled \u201c<em>Rewrite it in Rust<\/em>\u201d has now resulted in a full-fledged transition.<\/p>\n\n\n\n<p>Believe it or not, initially, nobody really expected this idea to escalate into a massive undertaking, especially given Fish had already been ported from pure C to C++ in its earlier days.<\/p>\n\n\n\n<p>Over time, however, practical considerations\u2014like improved tooling, easier maintenance, safer concurrency, and the appeal of learning or using a \u201ccool\u201d language\u2014prompted the maintainers to turn this tongue-in-cheek proposal into a serious endeavor. And here we are, with the first beta of Fish Shell 4.0 now a fact, fully Rust-based.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>The beta works very well. Performance is usually slightly better in terms of time taken, memory use has a slightly higher floor but a lower ceiling &#8211; it will use 8M instead of 7M at rest, but e.g. globbing a big directory won\u2019t make it go up as much. These things can all be improved, of course, but for a first result it is encouraging.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>During development, the team adopted a gradual approach, porting one subsystem at a time from C++ to Rust. They relied on a bridging tool called autocxx, which allowed them to call Rust components from within the legacy C++ codebase (and vice versa).<\/p>\n\n\n\n<p>In essence, Fish maintained partial Rust and partial C++ codebases until the last chunk of C++ finally disappeared in early 2024. This strategy kept fish testable and functional throughout the rewrite, thus allowing regular releases\u2014such as the C++-based <a href=\"https:\/\/linuxiac.com\/fish-shell-3-7-0-released\/\">Fish 3.7.0<\/a>\u2014while the overall Rust migration continued.<\/p>\n\n\n\n<p>The thing that many are probably asking now is why Rust? According to the maintainers, one of the most pressing reasons for this switch was the <strong>C++ tooling and community ecosystem<\/strong>, which can be challenging to navigate, especially for hobbyist or volunteer-driven projects.<\/p>\n\n\n\n<p>Concurrency also posed a major motivation; Fish\u2019s autosuggestions and syntax highlighting have long been recognized for their advanced thread usage, but implementing further multithreading in C++ proved tricky. Rust\u2019s promise of \u201cfearless concurrency,\u201d backed by the Send and Sync traits, offered a cleaner and safer path forward.<\/p>\n\n\n\n<p>Moreover, Rust boasts superior dependency management and intuitive compiler error messages. Instead of dealing with compiler mismatch woes\u2014where contributors needed to find or install the right C++ version\u2014Rust developers can simply run <code>rustup<\/code> and get a consistent environment right away.<\/p>\n\n\n\n<p>However, an unfortunate loss due to Rust switch being Cygwin (a compatibility layer that lets you run Linux tools and applications on Windows) support\u2014but developers are confident Fish\u2019s main user base (primarily Linux, BSD, and macOS users) remains well-covered.<\/p>\n\n\n\n<p>Lastly, here are some interesting facts for those who love statistics and precise numbers. Over roughly 14 months of development, the Fish maintainers produced over 2,600 commits by more than 200 authors, translating over 57,000 lines of C++ into around 75,000 lines of Rust.<\/p>\n\n\n\n<p>Going forward, the devs plan to refine Rust-based features, possibly revamping Fish\u2019s old quirks\u2014like UTF-32 string handling\u2014and continuing to streamline the build process. For more information, refer to the <a href=\"https:\/\/fishshell.com\/blog\/rustport\/\" target=\"_blank\" rel=\"noreferrer noopener\">official announcement<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Two years, 57k lines of C++, now 75k lines of Rust. Fish Shell 4.0 beta has been entirely rewritten in the Rust programming language.<\/p>\n","protected":false},"author":10,"featured_media":151139,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5],"tags":[5594,4137],"class_list":["post-151136","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","category-news","tag-fish-shell","tag-shell"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/151136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/comments?post=151136"}],"version-history":[{"count":0,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/151136\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media\/151139"}],"wp:attachment":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media?parent=151136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/categories?post=151136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/tags?post=151136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}