Hacker News new | ask | show | jobs
by bluejekyll 652 days ago
I think you need to consider the intention of why you would want to write base components of FreeBSD in Rust. It’s not to make a Rust operating system with its own new features, it’s to maintain and develop on an in existing system with current users, fixing bugs, offering an upgrade path that’s generally backward compatible with existing usage. New features in Rust, old features probably kept in C, unless they are highly problematic.
1 comments

Specifically, rust was designed and created for this use case. It’s the language created to rewrite Firefox in a memory safe language, component by component. This means rust is uniquely capable of integrating into C/C++ code bases, unlike for example go. So it makes sense to do exactly that - take existing projects and slowly migrate them to a memory safe version.
Which percentage of Firefox is now written in Rust? If the project it was started for still isn't totally migrated, it makes sense for others to remain skeptical. There's value in simplicity, like having to use a single language for a projet instead of two.
I don't see why this is a reason to be skeptical. Firefox is a huge codebase. Substantial chunks of it have been rewritten using Rust while maintaining the entire app and adding features. This is entirely the plan: You can slowly, as you touch parts, migrate the codebase.

Firefox (and many other projects) was already a mix of multiple languages - it uses C, C++, Javascript, ... and now Rust. And while there is value in having less languages to deal with, there is equally value to use multiple languages and apply them where you see major benefit. For example, replacing exposed and high-risk components (image/file parsers for example) with a language that de-risks those implementations. Like all of the things in software engineering, this is a tradeoff. It may not make sense for your application, but it can make sense for others.

Of the 32,373,275 lines in Firefox that tokei reports, 3,439,065 is Rust. 5,740,010 is in C (C + C Headers). And 5,643,721 is C++ (C++ + C++ Headers). 7,343,459 is JS.

Using the "Code" column to ignore comments and blanks.

This is based on the mozilla-central-78a5d30a370f bundle.

(Also, holy crap it took tokei 10m to run this analysis).

I don’t think the relative % of rust has changed a lot in the past few years though, has it? After they got the obvious low lying fruit it slowed down dramatically didn’t it?
It's a good question but I have no plans to write a script that walks mercurial history and plots the relative percentages of the code based on language.

If you find the time and urge I'd be interested to know the results.

1 line of rust != 1 line of C