Linked by Thom Holwerda on Sun 26th May 2013 18:48 UTC
OSNews, Generic OSes "A tiny 32 bit kernel written in Rust. I was inspired to download Rust and try to do this after seeing zero.rs - a stub that lets Rust programs run almost freestanding. It paints the screen bright red and then hangs. That's it."
Thread beginning with comment 562998
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[6]: I clicked it, I liked it
by Neolander on Tue 28th May 2013 06:08 UTC in reply to "RE[5]: I clicked it, I liked it"
Neolander
Member since:
2010-03-08

For a real OS you'd want to setup the video mode properly, which would require assembly. You'd also need to get a memory map from the BIOS, which would require assembly. You'd need to remap the PIC chips, which would require assembly. You'd need to enable A20, which would require assembly. You'd need to scan physical memory for things (e.g. ACPI tables, etc), which would require assembly.

Then; you'd start the other CPUs, which would require assembly. Next comes memory management and scheduling, which typically involves atomic operations and/or lock-free/block-free algorithms, which would require assembly. Then there's the task switching code, which would require assembly. Of course there's also exception handling, IRQ handling, etc; which would require assembly.

Can you see a pattern here? If the "kernel" wasn't a trivial joke, you'd find Rust being used for glue and not being used for anything that's actually important; especially once you start micro-benchmarking and trying to get performance/scalability close to other OSs.

I disagree with that conclusion. What OSs mainly written in C or C++ show is that it is possible to write most of an OS' logic in another programming language, and only keep Assembly for the few operations that actually access hardware directly. Sure, these Assembly parts are vital, but so is the logic code: it is where all the interesting stuff is decided, and what differentiates one OS project from another one.

Of course, we can argue that some languages are better-suited for OS development than others. As an example, any language with heavy runtime requirements, or nondeterministic performance due to garbage collection, is probably a very poor fit unless such mechanisms are optional as in C++.

That may be the case or not in Rust, but you have not actually proven this point so far. In fact, the author of this code hasn't either, he has only shown that Rust code which does something trivial like moving memory around may have little actual runtime requirements, which is already something but not enough to showcase it as a good language for OSdeving.

Also, the fact that he has to define abort, memcmp, memcpy, malloc and free for the code to compile worries me. It means that some part of the OS binary somewhere requires these primitives, and will cause a random crash if it ever attempts to run them. But perhaps that's a result of someone not properly reading his compiler's manual...

So in summary, I agree with you regarding the feeling that this code does little to prove Rust's suitability for OS development, but I disagree with the arguments you use to prove your point.

Edited 2013-05-28 06:28 UTC

Reply Parent Score: 2

moondevil Member since:
2005-07-08

I disagree with that conclusion. What OSs mainly written in C or C++ show is that it is possible to write most of an OS' logic in another programming language, and only keep Assembly for the few operations that actually access hardware directly. Sure, these Assembly parts are vital, but so is the logic code: it is where all the interesting stuff is decided, and what differentiates one OS project from another one.


And Object Pascal, Modula-2, Ada, ...

Of course, we can argue that some languages are better-suited for OS development than others. As an example, any language with heavy runtime requirements, or nondeterministic performance due to garbage collection, is probably a very poor fit unless such mechanisms are optional as in C++.


10 years ago no one would believe you could do something like Unreal in JavaScript.

I think it is also a question how much the industry is willing to invest in such topics.

Also, the fact that he has to define abort, memcmp, memcpy, malloc and free for the code to compile worries me. It means that some part of the OS binary somewhere requires these primitives, and will cause a random crash if it ever attempts to run them. But perhaps that's a result of someone not properly reading his compiler's manual...


I think he just had them as stubs, because it was just a proof of concept. Of course in a real kernel similar functions need to be defined.

Reply Parent Score: 2

Neolander Member since:
2010-03-08

"I disagree with that conclusion. What OSs mainly written in C or C++ show is that it is possible to write most of an OS' logic in another programming language, and only keep Assembly for the few operations that actually access hardware directly. Sure, these Assembly parts are vital, but so is the logic code: it is where all the interesting stuff is decided, and what differentiates one OS project from another one."

And Object Pascal, Modula-2, Ada, ...

Indeed, many languages are potentially suitable for OS development although some are more suitable than others.

From my short look at it, Ada in particular could be a very interesting choice for OSdeving. Too bad so little Ada OS projects have survived to this day...

"Of course, we can argue that some languages are better-suited for OS development than others. As an example, any language with heavy runtime requirements, or nondeterministic performance due to garbage collection, is probably a very poor fit unless such mechanisms are optional as in C++."

10 years ago no one would believe you could do something like Unreal in JavaScript.

Then again, gamers have also come to expect quite a bit more than Unreal from games these days.

I think it is also a question how much the industry is willing to invest in such topics.

The industry seems to be satisfied with kernels from the 80s and the 90s and to focus on higher layers of the OS stack these days.

So if innovation is to come in the realm of low-level OS design in the next decades, it will probably be either from academia, hobbyists, or companies' fundamental research departments. Not from a team of people which actually have the goal of producing a product that can be sold.

"Also, the fact that he has to define abort, memcmp, memcpy, malloc and free for the code to compile worries me. It means that some part of the OS binary somewhere requires these primitives, and will cause a random crash if it ever attempts to run them. But perhaps that's a result of someone not properly reading his compiler's manual..."

I think he just had them as stubs, because it was just a proof of concept. Of course in a real kernel similar functions need to be defined.

Sure, but is there a subset of Rust which is formally guaranteed in writing to work forever without calling these functions ? Otherwise, these functions cannot safely be implemented in Rust, which noticeably means that the whole memory manager has to be written in another language like Assembly or C.

That would be a serious blow to Rust's suitability as an OS development language.

Reply Parent Score: 2