Page 1 of 2
To object or not to object...
Posted: Tue Jan 15, 2008 12:38 pm
by dudeman
I've been programming in C/C++ for a few years now and I have only recently begun looking in to OS development. Following the advice of many here and some of the tutorials (which are primarily written in C) I'm beginning to wonder:
Is it ever completely neccessary to write something in C++ as opposed to the more procedural C?
The question hit me during my last school programming project where I was designing a Karnaugh-Map-Solver.
No matter how I structured my program, it became very clear that i didn't need to design any user-defined-objects to solve the maps. Simply using procedural methods and arrays was more than sufficient.
Prehaps the only REAL benefit to using objects is for the programmers and not the programs --meaning: it may be easier to organize parts of your program with classes, easier to read through lines of code that use classes, etc.
Am I missing the point of user-defined-objects?
My world has been completely turned on its head...
Posted: Tue Jan 15, 2008 1:38 pm
by Candy
The point is to make bigger projects clearer and to be able to put logic away behind what it should look like for you.
Of course, some people invert the thought and hide the nice algorithms behind a horrible interface but the idea is sound.
Posted: Tue Jan 15, 2008 2:20 pm
by Tyler
Any lesser featured language that is powerful enough, can achieve the same goal. I could use the assembly language of a stackless system, or at least one without a built in CALL function to build programs comparitable to C ones. I could work on the same programs to build equivelant functionality to C++ software, and even emulate the class concept through a series of control procedures. Most programming paradigms are designed for the benefit of the developer, whether it be for structure, speed or other reasons.
Re: To object or not to object...
Posted: Tue Jan 15, 2008 3:48 pm
by Alboin
dudeman wrote:Is it ever completely neccessary to write something in C++ as opposed to the more procedural C?
I would suggest you look into how compilers work, and learn assembly. You'll realize that all languages produce, more or less, the same assembly code. (Not 'exactly' the same, but you get the idea.)
To note: Any language can do objects, even C. Albeit in C, they are either less intricate (ie. a struct and functions to manipulate the struct.) or large intricate frameworks. (eg. GTK)
...
Watch out for overzealous OOP!
Re: To object or not to object...
Posted: Wed Jan 16, 2008 1:12 am
by Solar
dudeman wrote:
Prehaps the only REAL benefit to using objects is for the programmers and not the programs --meaning: it may be easier to organize parts of your program with classes, easier to read through lines of code that use classes, etc.
Am I missing the point of user-defined-objects?
No, you got it 100% right.
Posted: Wed Jan 16, 2008 8:14 am
by binutils
i would recommend c. :)
that is enough. oop in c is possible.
otherwise, if you involved in it industry, i recommend java or c# or mfc than c++. :)
Posted: Wed Jan 16, 2008 8:29 am
by Solar
Jesus, can we stop these language wars, please? It's getting really tiresome.
"OOP in C is possible." You can mimic OO in C, if you e.g. program your own virtual function pointers, remember to call your constructors manually, and rape the vararg mechanism into something resembling function overloading. C is not object-based, let alone object-oriented.
MFC isn't a language but a class library.
As to why C# and Java can't go everywhere C++ goes (and vice versa), see any of the hundreds other language flamefests on this board.
If you don't like C++, fine, don't use it. If you want to discuss shortcomings of the language, feel free to do so, although comp.lang.c++.moderated or a C++ committee member is probably a better place to take this.
But if all you have is an axe to grind or some time to kill, take a second and contemplate if not posting might make the world a better place.
Posted: Wed Jan 16, 2008 9:07 am
by binutils
Solar wrote:
1. "OOP in C is possible." You can mimic OO in C, if you e.g. program your own virtual function pointers, remember to call your constructors manually, and rape the vararg mechanism into something resembling function overloading. C is not object-based, let alone object-oriented.
2. MFC isn't a language but a class library.
sorry, both of them i disagree.
1. But c++ is written in c after all.
2. it is framework, not just another library.
Posted: Wed Jan 16, 2008 9:17 am
by Laksen
As already said in the thread, it's never necessary to use OOP, but it depends on your preferences
I for one, enjoy OOP. I find it get's the job done faster and more elegantly for me. My kernel is now completely object oriented and will continue to be so
Posted: Wed Jan 16, 2008 9:17 am
by Tyler
binutils wrote:Solar wrote:
1. "OOP in C is possible." You can mimic OO in C, if you e.g. program your own virtual function pointers, remember to call your constructors manually, and rape the vararg mechanism into something resembling function overloading. C is not object-based, let alone object-oriented.
2. MFC isn't a language but a class library.
sorry, both of them i disagree.
1. But c++ is written in c after all.
2. it is framework, not just another library.
Sorry, but your wrong on both.
1. Metal Gear Solid is written in C/C++, but i'd like to see you shoot virtual terrorists in it with a Playstation controller, without writing a single line of code to control the action.
2. Framework is just a name, it is a library of classes.
Posted: Wed Jan 16, 2008 9:24 am
by JamesM
1. But c++ is written in c after all.
C++ is not "written" in any language. It is a language itself. Perhaps what you meant to say was that "The GNU C++ compiler is written in C". Which would be correct, because G++ is a front end addon to the GNU compiler collection which, as you stated, is written in C. But there is no reason why g++ *can't* be written in c++, c.f. Javac is written in java (@see bootstrapping).
I'm not certain what language the microsoft c++ compiler is written in - it could possibly be c++.
Posted: Wed Jan 16, 2008 9:25 am
by binutils
Tyler wrote:binutils wrote:Solar wrote:
1. "OOP in C is possible." You can mimic OO in C, if you e.g. program your own virtual function pointers, remember to call your constructors manually, and rape the vararg mechanism into something resembling function overloading. C is not object-based, let alone object-oriented.
2. MFC isn't a language but a class library.
sorry, both of them i disagree.
1. But c++ is written in c after all.
2. it is framework, not just another library.
Sorry, but your wrong on both.
1. Metal Gear Solid is written in C/C++, but i'd like to see you shoot virtual terrorists in it with a Playstation controller, without writing a single line of code to control the action.
2. Framework is just a name, it is a library of classes.
1. i don't know Metal Gear Solid, but it seems only available on ms windows or playstation1/2?
2. Perhaps
Posted: Wed Jan 16, 2008 9:33 am
by Solar
binutils wrote:
2. Perhaps
Pray, show me code
written in MFC. Not C, C++, C# or anything
using MFC, but the
language MFC. (Which was the original point.)
Posted: Wed Jan 16, 2008 12:27 pm
by Colonel Kernel
Smalltalk FTW!
(This is now my default response to all language pissing contests.)
Posted: Wed Jan 16, 2008 12:56 pm
by Solar
No nononono... LISP it must be!