Live data from Hacker News

Rewrite Everything in Rust

robert.ocallahan.org

1–10 of 242 posts

Re: Rewrite Everything in Rust

#3
It's certainly possible to incrementally rewrite an OS distribution in Rust, or even smaller projects like glibc.

Anyone want to set up the infrastructure so it's easy to take a library or a .c file and start hacking, and see if you still get a working OS in the end? I suppose part of the problem is defining "working OS" -- I'm not sure I know of any great test suites that check to see that a GNU/Linux distribution continues to in GNUy/Linuxish ways, which is usually what you want for a large-scale rewrite project.

Re: Rewrite Everything in Rust

#5
If a given piece of software has been largely written using certain patterns or conventions, then it is often possible for a syntactic rewrite engine to be able to match those patterns, then output idiomatic code patterns in the target language.

This may well be applicable to kernels and other constituents of an OS.

Re: Rewrite Everything in Rust

#6
post #2

I have actually started to do this to see for myself how much work it would be http://blog.dkhenry.com/2016/02/17/deciding-to-rewrite-getad...

Thanks for doing this...

I think the way to tackle a rust glibc rewrite:

Step 0 - write a code generator that just generates rust code that call the C versions of glibc symbols ( based off of the publicly exposed API in the library files). Get test suite to run

Step 1 - Make that rust code generate a 100% drop-in replacement fro the C symbols (maybe this requires injecting version numbers)

Step 2 - write the `getaddrinfo` replacement in Rust

???

Step 4 - have all of glibc ported

EDIT: Does anyone know of any gotchas with linking that would cause this to happen? Seriously considering taking a day off to do step O.

Re: Rewrite Everything in Rust

#7
How practical is rust for small processor IoT applications? Like the ESP8266 we saw recently?

https://news.ycombinator.com/item?id=11148129

They often have horrible security, but are very small programs when you use them as wifi temperature sensors or similar. They are good targets for rewrites and greenfield applications. Right now it seems like ardunio C++ or some scripting language is the target.

Re: Rewrite Everything in Rust

#8
post #7

How practical is rust for small processor IoT applications? Like the ESP8266 we saw recently? https://news.ycombinator.com/item?id=11148129 They often have horrible security, but are very small programs when you use them as wifi temperature sensors or similar. They are good targets for rewrites and greenfield applications. Right now it seems like ardunio C++ or some scripting language is the target.

Rust is a great choice in theory for anything with an LLVM target, but the libcore "bare metal"/"no standard library" ecosystem is pretty immature, and there are likely to be bugs (like the compiler generating binaries that are too large, etc). If you'd like, please try it out and file any issues you find :)

Re: Rewrite Everything in Rust

#9
I think this misses the real problem. So many pieces of foundational software like glibc and OpenSSL are understaffed, underfunded, and plagued by terrible code. Go read glibc getaddrinfo: it's a mess!

Rewriting the software in Rust would not solve these problems any more than rewriting it in C++ would. A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that nobody has time to fix.

We need to have incentives for maintaining this foundational software.

Re: Rewrite Everything in Rust

#10

If a given piece of software has been largely written using certain patterns or conventions, then it is often possible for a syntactic rewrite engine to be able to match those patterns, then output idiomatic code patterns in the target language. This may well be applicable to kernels and other constituents of an OS.

Isn't that just what a compiler is, where the target language is machine code?
Post reply on HN