Live data from Hacker News

Thor – A minimalistic operating system in assembly and C++

github.com

71–80 of 152 posts

Re: Thor – A minimalistic operating system in assembly and C++

#71

Can an operating system be developed from scratch using a safe language such as Rust? If yes, why people still even think about doing it with unsafe languages?

You can write a kernel in pretty much every language. There are some experiments with Rust: http://www.randomhacks.net/bare-metal-rust/ There are several reasons to choose a language rather than another. I personally don't like Rust at all, so I don't see any reason to use it, neither do I see any advantage in using it. But that's only my opinion. A lot of osdev currently is made by hobbyist (not counting the handful…

Forget the experiments. Try this one:

https://www.redox-os.org/

Re: Thor – A minimalistic operating system in assembly and C++

#72
post #58

Earlier quoted context omitted.

We do know some prototype can boot. We don't know about operating system being in use in any environment for any purpose. Damn, we don't know could the browser engine written in Rust work or not, despite the fact writing a browser engine was the goal of Rust from the day one. By the way, network card driver can be written in LuaJIT (and perform well) too[1]. Shall we do it? [1] http://lukego.github.io/blog/2013/01/03…

> Damn, we don't know could the browser engine written in Rust work or not, despite the fact writing a browser engine was the goal of Rust from the day one. We kind of do at this point. It renders reasonably well, faster on some workloads than existing browsers. The majority of work still to do involves chasing down rendering bugs, and building a shell around it. That's a lot of work , but it's the sort of work that…

Kind of, indeed. Last time I've seen comparison of html5ever with plain C HTML parser, we suddenly realized it is painfully slow, 'uses the proof-of-concept DOM' and whatnot[1]. So we don't know. We've yet to see anything written in Rust used in production environment, just anything.

> Using LuaJIT as a network driver in some cases seems reasonable to me

Why don't we see LuaJIT zealots in every thread on every board in every discussion of something written in C or C++, I wonder?

[1] https://www.reddit.com/r/programming/comments/4snfz7/the_fir...

Re: Thor – A minimalistic operating system in assembly and C++

#73

The hobbyist OSes pop up a lot on Hackernews. Some are more full featured than others. What would say is the minimum feature set to be called a real OS?

At least for my operating systems class, the requirement was to be able to boot and run a text editor, usually Vi. Didn't stop some people from building one that could run Doom though.

Re: Thor – A minimalistic operating system in assembly and C++

#74
post #6

Earlier quoted context omitted.

It's a really annoying widespread opinion. I've been looking for people who really do write OSes in modern C++.

I don't write OSes in modern C++ at the moment (most of my day job is embedded Linux nowadays, go figure...) but I've seen a lot of sane, OS-level C++ code. Even C++ code that I have bad memories about (uh, Symbian) is partly justifiable. The only real beef I have with C++ is its complexity. As I did less and less high-level programming, I forgot about many of C++'s pitfalls and nowadays I'm always tiptoeing when I h…

The STL might be the best programming success story. It used to be awful, but now I rank it among the best standard libraries of any language.

Re: Thor – A minimalistic operating system in assembly and C++

#75

Can an operating system be developed from scratch using a safe language such as Rust? If yes, why people still even think about doing it with unsafe languages?

> If yes, why people still even think about doing it with unsafe languages? What you need for OS or embedded development is a language that doesn't get in your way. C doesn't get in your way. C is the first language that both stayed out of your way and also provided reasonable productivity features (over BCPL, B, and assembly). It was only recently that people have figured out how to come close to a "safe" language t…

> I guess a more direct answer to your question is that when you get down to the hardware, you have to deal with weirdo bit fields, volatile hardware registers, strange read/write ordering requirements, interlocks, and even some totally non-interlockable volatile stuff. C can do it (although I admit it uses language features not everyone sees every day).

I agree with you that building an entire OS to interface with hardware without using _any_ unsafe code is, by some definition of the word, impossible.

However that doesn't mean you must limit yourself to unsafe languages for the other 90% of the operating system code.

Re: Thor – A minimalistic operating system in assembly and C++

#76

Earlier quoted context omitted.

Ha. You posted this while I was writing my answer, and I see you (very nearly) used the exact same pair of examples that I did. This is possibly a hint as to where the pain points are... (Your post is better than mine, though.)

Haha, I was just about to reply to your comment with nearly the same thing! I think one day I may need to do a book on C++ for embedded folks. Chapter 1 will be "Please don't use std::string!".

Could hold true to the HLL guys as well. I seem to remember at least a couple of performance analyses of apps in a High-Level Language where string concatenation was killing performance.

Easy to do. Tough to always remember the impact of what's going on under the hood.

Re: Thor – A minimalistic operating system in assembly and C++

#77
post #72

Earlier quoted context omitted.

> Damn, we don't know could the browser engine written in Rust work or not, despite the fact writing a browser engine was the goal of Rust from the day one. We kind of do at this point. It renders reasonably well, faster on some workloads than existing browsers. The majority of work still to do involves chasing down rendering bugs, and building a shell around it. That's a lot of work , but it's the sort of work that…

Kind of , indeed. Last time I've seen comparison of html5ever with plain C HTML parser, we suddenly realized it is painfully slow, 'uses the proof-of-concept DOM' and whatnot[1]. So we don't know. We've yet to see anything written in Rust used in production environment, just anything. > Using LuaJIT as a network driver in some cases seems reasonable to me Why don't we see LuaJIT zealots in every thread on every board…

  > We've yet to see anything written in Rust used in production environment, just anything.
This is not true: https://www.rust-lang.org/en-US/friends.html

Re: Thor – A minimalistic operating system in assembly and C++

#78
post #46

Earlier quoted context omitted.

> Can an operating system be developed from scratch using a safe language such as Rust? We don't know. > If yes, why people still even think about doing it with unsafe languages? Because it works.

> > Can an operating system be developed from scratch using a safe language such as Rust? > We don't know. Sure we do. Redox[0] boots into a desktop environment with a filesystem, etc etc. What we don't really know is how performant/portable/etc you could make it if you put the same amount of manpower into it as went into .

See also https://github.com/helena-project/tock/

Re: Thor – A minimalistic operating system in assembly and C++

#79
post #8

Earlier quoted context omitted.

Yes, but his opinion counts more than some John Doe's as Linus supports his case with solid arguments.

'It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C' Solid argument that. His two other arguments: - infinite amounts of pain when they don't work (and anybody who tel…

>>Sorry, but I take it personally when me and my colleagues are called substandard programmers.

I don't know what kind of programming you do, but he is talking mainly about kernel programming. He is mainly criticizing the people who want to bring C++ in the kernel world. Anyone is welcome to prove him wrong.

But I think, C++ is more suited for applications programming, where efficiency is not a prime concern and abstraction-costs are justified.

Even in such cases, (e.g. git, which is an application program) an excellent programmer like Linus can be very well productive with C and does not need the (sloppy/non-sloppy) abstractions provided by C++.

>>You can abstract yourself in a corner in C as well. In C++ you are more likely to pay less for abstractions.

Agreed. But the point you seem to be missing is that C doesn't force any abstractions on you. The STL/Boost abstractions are much more inefficient.

Linus talks about these inefficient abstractions and that's a solid argument because C++ abstractions come with various sorts of hidden costs. (e.g. even name mangling can be a significant cost factor in Kernel.)

>>Considering that the linux kernel is strongly tied to the specific C dialect supported by GCC and is not portable at all, this argument is bullshit.

The issue of portability to different compilers is not an important concern for kernel programmers. If they find a particular tool (e.g. gcc with some C dialect) perfect for their purpose, why should they bother with other tools?

Remember, for Linux kernel programmers gcc is just a tool to produce their product, the kernel.

edit: added point about portability

Re: Thor – A minimalistic operating system in assembly and C++

#80

Can an operating system be developed from scratch using a safe language such as Rust? If yes, why people still even think about doing it with unsafe languages?

> If yes, why people still even think about doing it with unsafe languages? What you need for OS or embedded development is a language that doesn't get in your way. C doesn't get in your way. C is the first language that both stayed out of your way and also provided reasonable productivity features (over BCPL, B, and assembly). It was only recently that people have figured out how to come close to a "safe" language t…

Funny you should mention the Cortex-M :) https://github.com/helena-project/tock/ (written in Rust, just linked to it down thread as well)
Post reply on HN