Live data from Hacker News

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

github.com

121–130 of 152 posts

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

#121
post #94
post #92

Earlier quoted context omitted.

BeOS is the reason I learned C++. I don't recall exactly, but either I didn't understand how or there was no other option but C++ if one wanted to hit the BeOS API. Pity Be Inc. got shafted so bad by MS monopoly abuse. They had zero vendors willing to put their OS on a box and resell it because MS threatened the vendors with pulling their right to sell Windows if they did. This wasn't particular to Be, but to any oth…

Yeah, still have my Be CDs stored somewhere. However regarding Microsoft, I actually think that vendors were as guilty as Microsoft. They could have chosen not to take Microsoft's discount and try to sell alternative OSes, even if it meant having to face a few challenges. The one that takes is as guilty as the one that gives.

I disagree: there is a lot of competition between PC builders so this ´discount' isn't really optional and Microsoft should have been heavily punished, for offering this discount.

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

#122
post #94
post #92

Earlier quoted context omitted.

BeOS is the reason I learned C++. I don't recall exactly, but either I didn't understand how or there was no other option but C++ if one wanted to hit the BeOS API. Pity Be Inc. got shafted so bad by MS monopoly abuse. They had zero vendors willing to put their OS on a box and resell it because MS threatened the vendors with pulling their right to sell Windows if they did. This wasn't particular to Be, but to any oth…

Yeah, still have my Be CDs stored somewhere. However regarding Microsoft, I actually think that vendors were as guilty as Microsoft. They could have chosen not to take Microsoft's discount and try to sell alternative OSes, even if it meant having to face a few challenges. The one that takes is as guilty as the one that gives.

I disagree: there is a lot of competition between PC builders so this ´discount' isn't really optional and Microsoft should have been heavily punished, for offering this discount.

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

#123
post #79

Earlier quoted context omitted.

>>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 abst…

>I don't know what kind of programming you do, but he is talking mainly about kernel programming. This specific rant was about using C++ in git. BTW I work in what could be called soft realtime systems. > But I think, C++ is more suited for applications programming, where efficiency is not a prime concern and abstraction-costs are justified. If efficiency is not a prime concern, using C++ is hardly justified. > [...]…

>>If efficiency is not a prime concern, using C++ is hardly justified.

Well, yes and no. Yes, I agree with you as C++ gives you more control than most other high level languages out there, e.g. more control over how you manage your memory. I can hardly imagine someone writing kernel in managed languages, like, Java.

No, I don't agree with you because sometimes, when very low-level aspects of machine also become prime efficiency concern, using C++ is hardly justified. See my point about C++ not forcing any abstractions on you, given at the end.

It reminds me what someone once half-jokingly said about C and assembly: "C gives you all the power of assembly language with the same ease of use".

In the kernel world, it becomes a joke, as the level of abstraction provided by C is very high as compared to the one provided by assembly language (e.g. mainly due to struct, union and cleaner subroutine syntax) and the cost of this abstraction is extremely low.

The benefits of using C are tremendous: e.g. code portability and readability.

>>Nor does C++.

Yes, but when you don't use any non-c abstraction provided by C then it reduces, almost entirely, to C (barring templates).

Templates are extremely good mechanism to provide abstraction (especially as compared to inheritance) but their cost (e.g. cost in terms of code bloat and in terms of the cognitive load if one actually wants to dig deeper and see/tweak the generated code to investigate/address some performance issues) seems prohibitive at least in the performance sensitive kernel programming.

The kernel hackers have found a neat-but-not-so-neat way around it: by using C macros. Macros are in fact C's templates. I am not saying macros lead to cleaner code and so on but when you compare them to C++ templates, their cost-benefit equation in the kernel programming world seems justifiable.

>>and that's perfectly fine, if one feels more productive in a certain language, more power to him, but please let's not spread FUD.

I agree with you whole heartedly about one's choice of language. I personally would have chosen C++ and even Python over C to implement an application like git or its parts.

Not to play advocate for Linus here (he doesn't need a half-witted advocate like me), but he seemed to be spreading FUD about C++ because, supposing C++ were allowed, he seems to feel that many people will start using its abstractions without being aware of their costs. It's very easy to get tempted to use available abstractions and if the abstractions start leaking (as he pointed out) then fixing the code that relied on those abstractions becomes a difficult issue.

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

#124
post #55

Earlier quoted context omitted.

The OSDev wiki is the best think to hit the internet since sliced bread (with cats faces pushed through them?) but it's far from a tutorial. It's a wiki. While it is one of the best repositories of knowledge on the subject of low level development, it's not a step by step guide. In the same way I don't recommend that people read Wikipedia to learn about human history I'd also not recommend reading osdev to learn abou…

What would be a good step-by-step tutorial in your opinion?

Let me plug in my own tutorial :) https://github.com/cfenollosa/os-tutorial

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

#125

Earlier quoted context omitted.

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…

In your string example (and in RTOS/C++ programming in general) couldn't you just change the default allocator to not use heap memory ? Then continue using std::whatever ? of course you'd have to keep a very close eye on your memory pool, but wouldn't this be one way to solve the problem ?

Quite a lot of embedded architects would say that allocation should never happen at all. That rules out the STL and much modern C++ style.

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

#127
post #118
post #104

Earlier quoted context omitted.

> Anyone is welcome to prove him wrong. Apple and Microsoft already did.

Please provide some links.

Mac OS X IO Kit driver framework:

https://developer.apple.com/library/mac/documentation/Device...

NeXT Driver Kit:

http://www.nextop.de/NeXTstep_3.3_Developer_Documentation/Op...

Windows 10 Windows Driver Frameworks:

https://github.com/Microsoft/Windows-Driver-Frameworks

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

#128
post #121
post #94

Earlier quoted context omitted.

Yeah, still have my Be CDs stored somewhere. However regarding Microsoft, I actually think that vendors were as guilty as Microsoft. They could have chosen not to take Microsoft's discount and try to sell alternative OSes, even if it meant having to face a few challenges. The one that takes is as guilty as the one that gives.

I disagree: there is a lot of competition between PC builders so this ´discount' isn't really optional and Microsoft should have been heavily punished, for offering this discount.

Funny this thing to blame just the side that gives but not the one that accepts.

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

#129
post #106

Earlier quoted context omitted.

> C is the first language that both stayed out of your way and also provided reasonable productivity features If we ignore the history of computers outside AT&T....

Example? Standard language that never required a trip to assembly language for system level programming? On IBM's, PL/I didn't cut it that regard. On a UNIVAC you could do a lot of system programming in FORTRAN, but only because there were a zillion proprietary extensions that accessed system programming primitives. BASIC on a Commodore 64 had PEEK() and POKE() but that doesn't count either, very non-standard. FORTH?…

FORTH? Nope... still asm at the bottom.

I call shenanigans!

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

#130

Earlier quoted context omitted.

Example? Standard language that never required a trip to assembly language for system level programming? On IBM's, PL/I didn't cut it that regard. On a UNIVAC you could do a lot of system programming in FORTRAN, but only because there were a zillion proprietary extensions that accessed system programming primitives. BASIC on a Commodore 64 had PEEK() and POKE() but that doesn't count either, very non-standard. FORTH?…

FORTH? Nope... still asm at the bottom. I call shenanigans!

Either my sarcasm detecter is broken today, or you've never read the source code of a FORTH system. Or perhaps you are commenting that FORTH doesn't have high-level programming constructs -- but of course FORTH allows meta-programming, so you roll your own.
Post reply on HN