Speculative: Rust for base system components

Enji Cooper yaneurabeya at gmail.com
Mon Dec 31 17:36:22 UTC 2018


> On Dec 31, 2018, at 7:02 AM, Warner Losh <imp at bsdimp.com> wrote:

….

> TBH, there's a stronger case for python than rust: there's actual python
> scripts in the tree today that we have to install a port to use. And there
> the benefit, while not zero, is small and the effort is large compared to
> just dragging it in as a port, so it hasn't been done. It's another fast
> evolving language that requires multiple versions as well...
> 
> So write something that everybody wants, that must be in base, and that
> requires rust, and then we can have the conversation…

As someone who has been using python extensively over the past decade, I think that using python versions less than 3.7 without type hints to ensure that the data types are correct [1], mocked tests to ensure that the code functions and is tested, is the wrong path to make.

Rust is still a young language, but it has a number of benefits in terms of:
i. Being able to scale past JIT python. This fact doesn’t matter on workstations/servers, but it definitely matters on the low end with embedded systems and the upper end with distributed systems at scale (there’s a reason why a number of critical services at my previous longterm employment were written in C++, not python. Some argue Rust can outperform C/C++ [2]. C++ I can see (managed pointers were about an order of magnitude less performant in a microbenchmark I wrote for grabbing the time in the Linux kernel vs malloc in C using llvm36). However, outperforming C is up for debate.
ii. It is easier to grok than C++ (even the most recent versions of the C++ spec, the language is cryptic in areas).
iii. It is more reusable than C out of the box. How often do we need to rewrite common logic/routines in C and mimic an OOP language like C++ (see libarchive, pkgng)?

<offtopic>
At the end of the day, I think the key is that the FreeBSD project needs to start expressing more complicated subsystems in terms of OOP languages, like C++, Rust, etc, instead of expressing most of the code in C. I do think (for instance) a service management system would be a good candidate for modern C++ or Rust.
</offtopic>

Cheers,
-Enji

1. https://www.python.org/dev/peps/pep-0484/ <https://www.python.org/dev/peps/pep-0484/>
2. https://www.reddit.com/r/rust/comments/5urar1/is_rust_likely_the_next_fastest_language_after_c/ <https://www.reddit.com/r/rust/comments/5urar1/is_rust_likely_the_next_fastest_language_after_c/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20181231/237a9df3/attachment.sig>


More information about the freebsd-hackers mailing list