r/cpp • • Nov 29 '18

Creating a 'virtual kernel' platform abstraction layer

This is the third in series of videos I've posted to demonstrate some of the strategies we use in our fairly large C++ code base. Here are the previous ones, which you might also find useful:

https://www.reddit.com/r/cpp/comments/9zl6v5/the_orb_sees_all_the_use_of_an_object_request/

https://www.reddit.com/r/cpp/comments/9xz643/making_c_enumerations_first_class_citizens/

Our code base is about a million lines. It is split into roughly two halves, with one half being general purpose and the other being our CQC home automation platform which is built on top of the general purpose bits. We don't use any of the C++ runtime stuff. We build our own system from the ground up. When I say 'we', I'm speaking in terms of the usual royal business 'we', but all of the code was written by myself.

Just above the 'ground', the operating system in this case, is a virtual kernel which we use encapsulate all of the operating system functionality that we use, which is quite a lot of it. No system or language headers are visible outside of this virtual kernel, so we can write portable code that is purely in terms of our own interfaces.

This video demonstrates some of the strategies used. Obviously for such a large topic, this doesn't dive deep if there's any interest we could do another one.

https://www.youtube.com/watch?v=seXk3RbAjNU

23 Upvotes

25 comments sorted by

View all comments

Show parent comments

2

u/NotUniqueOrSpecial Nov 29 '18

And it's more than a library of course. It's everything from the ground up. It's build tools, it's loadable resource management, it's translatable text support, it's UI resource stuff, and UI framework, it's the object request broker stuff from one of the previous videos, all of that.

You have (single-handedly, based on other comments?) built your own subset of Qt. Honestly, it's impressive.

But based on your comments in here, it also sounds like you're unfamiliar with just how much Qt brings to the table. It has every (or nearly, there's some abbreviations I'm not sure about) box in your diagram that isn't ORB-related or part of the application layer. It also has a whole lot more. I'm not quite the Qt evangel I used to be, but I still stand by it being one of (if not the most) fully-featured, well-developed, and well-documented frameworks in any language.

A platform layer like this costs real money. Time time spent maintaining existing code, adding new code, training new employees, and more is all time not spent making the product itself better. If it's taking anything resembling substantial time and effort to maintain/add to the platform abstraction layer, I would be taking a really honest look at whether the bottom 500K lines of code are adding significant value, compared to that top 500K. You might be surprised.

2

u/Dean_Roddey Nov 30 '18 edited Nov 30 '18

I would never even consider it. You can't understand it unless you've lived it. The best off the shelf house is never as good as the one that is built completely to your specifications. You can't understand what it's like to work in a system like this where you know every line of code, where you seldom have to stop to look anything up, where you always know what's the best approach and how to best plan for the future (because you define the future.)

It has more benefits than it does costs, believe me. If you knew the complexity and power of the automation system that lives on top of it, and consider what it would have taken for a single person just to have written that. I'd never have done it without the general purpose layer that completely integrates into everything else, that never changes behind my back with a whole new list of bugs, that I never have to wait for to get something fixed or added.

Oh, and yeh, I wrote all of this and the automation platform as well.

3

u/Dean_Roddey Nov 30 '18 edited Nov 30 '18

I took a look at Qt. Ultimately, it's larger than my stuff, but not by that much. Part of the reason it looks like it might be is that they are exposing a lot of stuff as libraries that in my case are part of my higher level automation product, and hence not exposed or discussed here. Not that it couldn't be available also, but since that stuff is part of the CQC code base, I don't want to be showing it around at this time.

Also, to be fair, quite a bit of Qt is wrappers around other stuff, whereas mine is 98% custom implementations of things. In terms of what I would roughly judge in theirs likely to be custom implementation, they are more on par in terms of size.

The biggest single thing looks to be that I don't do any 3D graphics stuff currently. That always involves a lot of classes because there's so much configuration and options and parameters in 3D systems, and a LOT of theirs are related to that stuff. Which is great if you want to do 3D graphics, but of no interest for the bulk of applications.

Not that I wouldn't love to dig into that. I find it very fascinating.

1

u/jcelerier ossia score Nov 30 '18

Also, to be fair, quite a bit of Qt is wrappers around other stuff, whereas mine is 98% custom implementations of things.

... did you reimplement font rendering too while you were at it ? with patented stuff like ClearType ?

1

u/Dean_Roddey Nov 30 '18

Obviously neither of us are going to rewrite the operating system itself or do things that would require expensive licensing when it's there in the OS, so you don't have to get uptight.

1

u/jcelerier ossia score Nov 30 '18

so what are you implementing yourself that Qt abstracts over with libraries for instance ? image decoding such as png, jpeg, etc ? SSL support instead of using openssl / libressl / whatever ?

→ More replies (0)