To object or not to object...
To object or not to object...
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...
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...
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...
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.)dudeman wrote:Is it ever completely neccessary to write something in C++ as opposed to the more procedural C?
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!
C8H10N4O2 | #446691 | Trust the nodes.
Re: To object or not to object...
No, you got it 100% right.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?
Every good solution is obvious once you've found it.
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.
"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.
Every good solution is obvious once you've found it.
sorry, both of them i disagree.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.
1. But c++ is written in c after all.
2. it is framework, not just another library.
Sorry, but your wrong on both.binutils wrote:sorry, both of them i disagree.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.
1. But c++ is written in c after all.
2. it is framework, not just another library.
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.
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).1. But c++ is written in c after all.
I'm not certain what language the microsoft c++ compiler is written in - it could possibly be c++.
1. i don't know Metal Gear Solid, but it seems only available on ms windows or playstation1/2?Tyler wrote:Sorry, but your wrong on both.binutils wrote:sorry, both of them i disagree.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.
1. But c++ is written in c after all.
2. it is framework, not just another library.
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.
2. Perhaps
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact: