neil wrote:
You have to do GUI using an object-oriented language (or at least object emulation in C for example) look for example at QT (C++) or GTK (written in C, but with many POO concepts (classes, objects, extension, ...).
Object-oriented programming has very little to do with specific languages; for instance, I think it's possible to do OOP in BASIC. (A total pain, prehaps, but possible!) A lot of the stuff I do in C could be considered object-oriented, and it's probably cleaner and faster than the equivalent C++ would be. I've never needed inheritance, so I've been able to avoid all the code (my own code and the compiler's generated code) that goes with it.
GUIs don't necessarily have anything to do with OOP, either. I've written GUIs for games and various projects that don't use any OO features like classes or inheritance. So, I don't think GUIs *need* to be implemented with OOP.
Personally, I try to avoid the term "object oriented" to begin with, because it's misleading and confuses people... even smart people who should know better.
carbonBased wrote:
With written OSs in both C and C++ and each have their advantage.
You can still write object oriented code in C, of course, but not quite in the same way. C also performs no name mangling and a lot of ppl understand it better.
C++ allows much more interesting language constructs, and (of course) OOP as it was (more-or-less) intended.
I basically agree with all of this; however, more experienced hackers think that using C++ in a kernel is probably a bad idea. This very issue has been debated several times on the linux-kernel mailing list. Every time someone drags it back into the discussion, it gets shot down: the lead developers believe that C++'s generated code and runtime support is too big, too slow and too flaky for a piece of software as stability- and performance-critical as the kernel.
kan wrote:
What i think is that since C++ is a Object Oriented Language, its the best choice for OS developement! We can think of each hardware device as a object, for eg: harddisk can be treated as a object, keyboard,mouse etc.
As I explained above, you don't need a so-called "object-oriented" language to do OOP.
Yes, the various parts of a computer can all be considered to be objects... but what's the value of that abstraction? There's not much point in turning everything into a universal "object". What properties will all objects have... shape, size, mass? Those aren't useful to us while we're trying to write operating systems.
Instead, we try to find meaningful, useful abstractions. For instance, in the Unix world, many things are abstracted as "files" -- byte streams. If we can write an OS that "considers" as many things as possible to be byte streams (byte sources, byte sinks or pipes), then we can connect our abstracted components together in lots of useful and interesting ways: echo keyboard input to screen, stream data from disk to network socket, et cetera.
Henery Spencer said, "Those who do not understand Unix are condemned to reinvent it, poorly." Heed these words. Some people don't like Unix, but it's survived for 30 years and is still very popular. On the technical side of things, some versions of Unix (like Linux and QNX) are beating the crap out of nearly every other OS out there. So, instead of trying to come up with something "cool" or "original" or "object-oriented" or "better than Unix", try to learn from Unix's successes (and mistakes), and implement what you learn in your OS projects.
kan wrote:
And even GUI developement would be great in C++!
Read my reply to Neil above. You don't have to write GUIs in C++; you don't have to write them using OOP either.
Further, doing a GUI directly in your kernel is a bad thing. Windows NT is an example; the GUI was integrated into the kernel, but this made the kernel very unstable, and opened up a ton of security holes. It's probably better to write your kernel first, and then implementing a GUI in userspace. For and example, check out the X Window System.
kan wrote:
But point here is to use C++ instead of C.
Why? Do you have a specific need or reason to use C++? Please read my replies above; there are considerable disadvantages with few (if any) advantages to using C++ instead of C.