Speculative: Rust for base system components

Damjan Jovanovic damjan.jov at gmail.com
Mon Dec 31 09:52:20 UTC 2018


On Mon, Dec 31, 2018 at 8:37 AM Alan Somers <asomers at freebsd.org> wrote:

> On Sun, Dec 30, 2018 at 10:38 PM Eric McCorkle <eric at metricspace.net>
> wrote:
> >
>
> >
> > == Go ==
> >
> > Go is not really a "systems language" in the sense that C or Rust are.
> > It isn't a replacement for C so much as a replacement for python.
> >
> > What's more, it is almost universally disliked by people with a
> > background in programming languages (I am one of those).  There's a
> > couple of reasons for this.  First, it omits a number of features that
> > modern languages *really* should include, parameterized types (generics)
> > being one of the most glaring.  Beyond that, it completely ignores
> > anything produced by modern PL research (unlike Rust, which benefits
> > from that work).  Second, one of its main design parameters was "it
> > should compile fast".  This as a design constraint basically guarantees
> > that you can't do anything interesting in compilation, which rules out
> > both advanced type systems as well as serious optimization.
> >
> > Unlike Rust, which offers substantial security and stability benefits
> > through its type system, Go would do little more than just change the
> > syntax of a bunch of code.  Moreover, it's likely that there would be
> > performance consequences, given the design constraint of fast
> compilation.
>
> I think there's a common misconception that Go and Rust are similar
> just because they were invented at about the same time and they share
> some superficial syntactial similarities.  But Go is much less
> suitable for an OS.  It's a memory-managed language, like Java.
> Remember when Java was the hot new thing, and people predicted that
> OSes would be written entirely in Java, and microprocessors would be
> redesigned to execute JVM bytecode directly?  It never happened,
> because Java just isn't suitable for low-level work.  Neither is Go.
> Rust is.
>
>
ARM chips could (and some did) have the Jazelle DBX extension to run Java
bytecode in hardware. There are Java editions used on SIM cards and Blu-ray
disks, so it certainly has low-level editions. It's Java SE that is heavy:
7 threads and 50 MB RAM for a hello world application, last time I checked.

In this regard, Go is much lighter: 2 threads and 1 MB RAM for a hello
world. Go has unsigned types, structure embedding, excellent
interoperability with C, and the ability to compile into shared libraries
which are loaded and called from C, so it is a lot better for low-level
programming than Java. Having said that, the number of architectures
supported by Go is fairly limited, and languages with automated garbage
collection are unusable for kernel development.

I would like to see more Rust (or a similar language) in systems
development.

Damjan


More information about the freebsd-hackers mailing list