Live data from Hacker News

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

github.com

31–40 of 152 posts

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

#31
post #2

Last week I read the very good 'How to build an operating system from scratch' [1], and I'm glad I did. It meant that I could burrow into the files on this github project and understand exactly what was going on. One day, when I finally have some free time, I am totally going to do this myself. --- [1] https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures...

Check out the broken thorn tutorials on the subject. They are far more complete.

I will!

I'm guessing you mean these..?

http://www.brokenthorn.com/Resources/OSDevIndex.html

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

#32

Earlier quoted context omitted.

No No No! Don't apologize, its a great question! And to be fair I'm absolutely against "cargo cult" programming, and my point was actually that when you are doing C++ in this type of environment, you can't always stick to a hard set of rules or the conventional wisdom. When I say guidelines, I mean just that, and not a rigorous law you MUST adhere to. As an example: When I was working on a project for a very constrai…

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!".

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

#33

Earlier quoted context omitted.

Totally agreed with your comment until that: > as long as you have a disciplined team and sane coding guidelines Is it not possible at all anymore to just hire people actually understanding what they are doing? Or cargo cult is here to stay? I am sorry - please don't take that as a personal attack, but explaining people that C++ can actually be used in OS development by mindlessly sticking to some rules doesn't seem…

It's more that certain features can be way more expensive than they look. e.g. say you're working on an embedded system, and you want a string, so you do: std::string s = "fnord"; At first it seems to work fine --- but you firmware image's RAM requirements have just gone up by 32kB, and a week later there's a crisis when adding another feature causes the system to stop linking because the RAM address space is full. W…

I do of course understand what you mean.

> At first it seems to work fine

It so happens that I have been working in OS- and low level areas for many years, and independently am also a pretty early adopter of C++. I have a reflex of routinely giving a quick glance to the link map, and am frequently dumping assembly for areas of code I have doubts in.

All this to say that reading 'it seems to work fine' in the context of OS development kind of provokes a skin reaction in me.

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

#34
post #15

Earlier quoted context omitted.

The problem with C++ is more about collaboration than with the language. It's harder to misuse C than C++. When you have a large group of people contributing, proper usage matters. Everything Linus rants about is improper usage.

On the other hand smart pointers (which I think didn't exist when linus wrote this?) and RAII make C++ harder to misuse than C.

I think it's more about the feature surface. C++ is a gigantic language while C is fairly limited. I actually like C++ when I'm the only one writing it, but my experience has always been that for complex use cases (large) c++ code bases tend to always evolve to a mess of complexity, even with expert programmers.

But yeah, smart pointers alone help a lot with writing tidy c++...

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

#35
post #31

Earlier quoted context omitted.

Check out the broken thorn tutorials on the subject. They are far more complete.

I will! I'm guessing you mean these..? http://www.brokenthorn.com/Resources/OSDevIndex.html

They are pretty good indeed to begin with. However, the best resource there is is clearly osdev.org, both the forums and the wiki are full of information!

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

#36
post #3

An OS in C++? But Linus said... http://harmful.cat-v.org/software/c++/linus

Does this actually use classes and other features of C++? Scanning a few files on Github I see namespaces being used but not much else. Very impressive either way - I was just curious how C++ was leveraged.

I'm using a few classes and some class hierarchy as well. I've reimplemented std::vector and std::string and a few other features from the STL and use them both in kernel space and user space (the STL is not standalone, need the glibc and I didn't want to port everything). I'm using quite some templates in the library part. I'm using auto from C++11 and a few constexpr functions. I have disabled exceptions and RTTI. I'm using RAII principle as much as possible (but this can be improved a lot still). I'm using references when I can remove pointers.

On the other hand, a lot of code is clearly very close to C. When you're doing some low-level things, parsing memory structures, paging, ... there are not a lot of features from C++ than can help. Moreover, there is a lot of code that could profit from some refactorings:P

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

#37
post #34

Earlier quoted context omitted.

On the other hand smart pointers (which I think didn't exist when linus wrote this?) and RAII make C++ harder to misuse than C.

I think it's more about the feature surface. C++ is a gigantic language while C is fairly limited. I actually like C++ when I'm the only one writing it, but my experience has always been that for complex use cases (large) c++ code bases tend to always evolve to a mess of complexity, even with expert programmers. But yeah, smart pointers alone help a lot with writing tidy c++...

Brainfuck has a limited surface. That doesn't mean it isn't hard or error-prone.

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

#38

Earlier quoted context omitted.

Aren't large parts of Windows written in C++ ?

I'm pretty sure it is! ( I'm also pretty sure that for a subset of the HN crowd, you may have just proven Linus's point :-P )

I think even HN readers must accept that the Windows kernel is rock solid. Maybe even better than Linux - Windows even gracefully handles graphics drivers crashing and can restart them virtually seamlessly. Linux just panics.

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

#40
post #34

Earlier quoted context omitted.

On the other hand smart pointers (which I think didn't exist when linus wrote this?) and RAII make C++ harder to misuse than C.

I think it's more about the feature surface. C++ is a gigantic language while C is fairly limited. I actually like C++ when I'm the only one writing it, but my experience has always been that for complex use cases (large) c++ code bases tend to always evolve to a mess of complexity, even with expert programmers. But yeah, smart pointers alone help a lot with writing tidy c++...

There was a time that C++ was considered a gigantic language. Just as there was a time that Common Lisp was considered so large that it collapsed under its own weight.

Many languages, including "simple" Java, are about as large as C++ right now ( https://channel9.msdn.com/Events/GoingNative/GoingNative-201... , around the one-hour and fifteen minute mark). To be honest, one thing that makes working in C++ relatively hard is the fact that C++'s standard library is significantly smaller than the competition. You have to do more yourself.

Post reply on HN