Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 19-08-2006, 10:17 PM   #71
GrimFang4
Forum hobbit

 
Join Date: Jun 2006
Location: Strafford, United States
Posts: 31
Send a message via ICQ to GrimFang4
Default

<div class='quotetop'>QUOTE(Eagg @ Aug 19 2006, 08:46 AM) [snapback]249609[/snapback]</div>
Quote:
I find it amusing that on some boards, this one included, people still argue about oop vs procedural programing.
[/b]
We're discussing, not arguing, I believe. OOP vs. procedural does have merit in a discussion since both have uses.


<div class='quotetop'>QUOTE(Eagg @ Aug 19 2006, 08:46 AM) [snapback]249609[/snapback]</div>
Quote:
With todays' complexity of the applications and especially games there is simply no point to compare those both forms with each other, it's not about better or worse, it's about possible or impossible.

GrimFang4, on what facts do you base your opinion that oop will run slower than procedural.
The compiling/linking part might be slower, but then you have native code and the CPU doesn't care how it got created, imho.
[/b]

It's not just my opinion that OO programs run slower. Why are you just trying to refute my "opinion" with your "humble opinion" anyway? Defeats the purpose of labelling yourself humble. You can either look up the information yourself, test some code yourself, or sit back and listen (assuming you know what it's all about already). Object-oriented programming is deeply based on Pointers/References/Addresses. It can be seen logically that looking up a memory address and then checking a variable will take more time than just checking a variable. Then think about objects with object members. Following pointers to pointers to pointers, you'll be slowing your program down. It's not such a big deal as I mentioned before with our awesome computer capabilities, but it does make a difference. This is why linked lists are slower than arrays most of the time. Compilers do not make everything into some super great 'native code'. You'll notice that there are usually several ways to get an identical result when programming. When run, they probably won't take the same amount of time. Without optimizations, a compiler will take exactly what you give it and convert it to machine code.

When talking about "possible or impossible", it makes no difference. Every task procedural can do, OO can do and vice-versa. The problem indeed lies with complexity. Programs written procedurally can get out of hand way easier than those written in an OO style.

It almost seems like you already knew when you (puzzlingly) said this...

<div class='quotetop'>QUOTE(Eagg @ Aug 19 2006, 08:46 AM) [snapback]249609[/snapback]</div>
Quote:
This is how all natural and non-natural things in our nice universe develop. They start out simple and efficient (better say become efficient over some time) and then the next things build on them and increase the complexity by abstraction. The higher the abstraction the lower the efficiency, but you couldn't care less since you have no choice.
[/b]
__________________
GrimFang4 is offline                         Send a private message to GrimFang4
Reply With Quote
Old 19-08-2006, 10:50 PM   #72
Eagg
Forum hobbit

 
Join Date: May 2006
Location: ,
Posts: 29
Default

Let's take C and C++ for example.
Both have their uses today, C mostly at close to hardware development (sometimes together with ASM) and C++ mostly in application/game development.
So it is very likely to see an API/wrapper/library being written in C, but hardly any new "big" game, of course the game will make use of the API/wrapper/libraries.

Of course I know that everything possible in oop is also possible in procedural, but when you consider something possible or impossible to develop you need to take alot of things into account. The timeframe/man power a project needs to finish is a very important aspect and can make a project financially impossible (not profitable).
That is the reason I talk about complexity of programs and not the technical aspects of those.

I would never say that there is no use for procedural programming, I just think there is no use for such discussions.

About oop making programs run slower, I never claimed that I know that it isn't the case, it was just news to me and thought you could clear that up. That is the reason I added the "imho".

English is my third language and I may understand everything but when trying to express myself I might choose my words not perfectly fitting to its intended meaning (arguing) .

Don't try to "look down" on people judging by the way they write and their choice of words, over 93% of the world population does not speak English natively and there is always a difference between knowing a language and thinking in that language.
Eagg is offline                         Send a private message to Eagg
Reply With Quote
Old 20-08-2006, 02:00 AM   #73
carpetsmoker
Forum hobbit

 
Join Date: Aug 2006
Location: ,
Posts: 49
Default

Iowa:
If you're intrested in webdesign and programming, you might want try out PHP, PHP is designed for the web, it's easy to use, and you can probably have a functional application within a few days after starting with it
http://www.php.net

Quote:
Originally posted by GrimFang4

As for Java, it is a little slow. I don't consider that a good reason to put it off though because
[...]
2) Very few languages and almost no interpreted languages (like Perl) can match speed with C++ and that hasn't stopped great things from coming from each language
) Processor speeds have reached a level such that speed is not normally an issue unless you run stuff on old computers, and 4) Perfect speed doesn't matter very much if your application is not a video game.
Interpreted languages will never reach the speed of compiled languages like C, C++, ect.
Define "Old computer" pentium 1? 2? 3?
Many people (including myself) are using a pentium2 or 3, java simply runs slow on that, it depends a bit on the quality of the application though ... but don't try running azereus or something....
It took 8 frelling kilobytes to put a man of the moon, why should be have to use frelling GIGABYTES to write a frelling letter?
Many developers have TOTALLY lost touch with reality as far as speed is concerned, every expects that you're running a dual-core pentium 4 with some fancy quadro nvidia card.
This is simply not true.
There are more older pc's in use than newer pc's, and this will always remain true.
Like I said, most users need their pc to only write a letter and browse the internet.
My point in all this: SPEED MATTERS!
Not as much as it did 20 years ago, but it still matters, now we just need to get the software developers to see that...

Quote:
Originally posted by GrimFang4
I don't care much about portability, but I said that was a flaw of Java earlier. Maybe you don't understand fully what OOP is. OOP will be slower when running, but helps immensely when planning and writing a program. It can make deep concepts become intuitive. You said Java is an OO language, but all modern languages try to be. The point is that you don't have to use a complete OOP style to benefit from the inclusion of that ability in the language. Do you use objects? You had better!
I'm not saying that OOP can't be usefull.
Procedural programming can be just as effective, if used properly

Quote:
I find it amusing that on some boards, this one included, people still argue about oop vs procedural programing.[/b]
Actually, this is my second discussion on the subject today

Quote:
GrimFang4, on what facts do you base your opinion that oop will run slower than procedural.
The compiling/linking part might be slower, but then you have native code and the CPU doesn't care how it got created, imho.[/b]
try running a simple for loop 200.00 times in OO and in procedural

Quote:
Don't try to "look down" on people judging by the way they write and their choice of words, over 93% of the world population does not speak English natively and there is always a difference between knowing a language and thinking in that language.[/b]
Fully agree on this one

Anyway.
My disliking of OO is, offourse, also a matter of taste, I prefer traditional programming because it's simpeler, more direct, and more scalable, I know what you're thinking, OO is more scalable, this only aplies to certain situations.

C can be used to manage large and complex programs, take a look at the BSD family of operating system's, it's written almost enterly in C., It's generally considered to be one of the most stable and secure operating systems.
Windows, on the other hand, is written in Visual C++, and, well, do I really need to post the general opinion about windows...?
carpetsmoker is offline                         Send a private message to carpetsmoker
Reply With Quote
Old 20-08-2006, 02:41 AM   #74
Iowa
Game Wizzard

 
Join Date: Aug 2006
Location: Iowa City, United States
Posts: 290
Default

Wow...you've all been so helpfull...i'll remember that next time I want to know something about programming.
__________________
I did it for the lulz!
Iowa is offline                         Send a private message to Iowa
Reply With Quote
Old 21-08-2006, 08:07 AM   #75
STFM
Abandonia nerd

 
Join Date: Sep 2005
Location: ,
Posts: 96
Default

<div class='quotetop'>QUOTE(carpetsmoker @ Aug 20 2006, 12:00 PM) [snapback]249684[/snapback]</div>
Quote:

Anyway.
My disliking of OO is, offourse, also a matter of taste, I prefer traditional programming because it's simpeler, more direct, and more scalable
[/b]
Its all just a matter of personal taste. Personally I find OO simpler and more direct.
STFM is offline                         Send a private message to STFM
Reply With Quote
Old 21-08-2006, 09:11 AM   #76
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

<div class='quotetop'>QUOTE(GrimFang4 @ Aug 20 2006, 12:17 AM) [snapback]249673[/snapback]</div>
Quote:
Object-oriented programming is deeply based on Pointers/References/Addresses.[/b]
That's not the case. OO is a paradigm. Not an implementation. It's a way of creating an abstract model of the problem at hand, and if used with a decent data-modelling language (such as UML) it can greatly simplify program design.

For most corporate (non real-time) applications, the maintainiblity of a program and the short(er) development times outweigh by far the execution speed. That's is why Java (J2EE) is used a lot in that sector. As for the speed. The new JIT-compiler does a pretty good job and even 3D games in Java run quite smoothly. You should however, pick the language most suitable for the task and not stick to a single one.
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 21-08-2006, 08:28 PM   #77
Eagg
Forum hobbit

 
Join Date: May 2006
Location: ,
Posts: 29
Default

Since this discussion made me curious about oop vs procedural execution speed, I wrote a little test program in C++.
I don't have time to search the program for logical errors, so I won't release it yet.
But if it is all correct, it shows that the speed varies a lot depending on compiler. With VS 2005 I got remarkable results that speak for oop in this case.

I will upload the source code tomorrow when I find some time to check it for errors.

This, of course, does not cover the oop languages vs procedural languages dialog, but only tests the truth behind the general statement: "oop makes programs slower" in C++ case.
Eagg is offline                         Send a private message to Eagg
Reply With Quote
Old 22-08-2006, 09:09 AM   #78
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

It might only prove you're OO skills are not very high :|
I can write an OO program that is slow. Just instatiate a zillion objects; fill the heap with crap and voila. Slomo. Doesn't prove a thing.
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 22-08-2006, 01:47 PM   #79
Eagg
Forum hobbit

 
Join Date: May 2006
Location: ,
Posts: 29
Default

<div class='quotetop'>QUOTE(Reup @ Aug 22 2006, 09:09 AM) [snapback]250143[/snapback]</div>
Quote:
It might only prove you're OO skills are not very high :|
I can write an OO program that is slow. Just instatiate a zillion objects; fill the heap with crap and voila. Slomo. Doesn't prove a thing.
[/b]
The same way you could fill the heap with arrays (especially multidimensional, new programmers admire those) without using objects, that is not the point.

Saying that oop makes it slower means that the same "function/idea" programmed with objects would run slower than without.
Eagg is offline                         Send a private message to Eagg
Reply With Quote
Old 24-08-2006, 04:47 PM   #80
GrimFang4
Forum hobbit

 
Join Date: Jun 2006
Location: Strafford, United States
Posts: 31
Send a message via ICQ to GrimFang4
Default

<div class='quotetop'>QUOTE(Reup @ Aug 21 2006, 05:11 AM) [snapback]249863[/snapback]</div>
Quote:
<div class='quotetop'>QUOTE(GrimFang4 @ Aug 20 2006, 12:17 AM) [snapback]249673[/snapback]
Quote:
Object-oriented programming is deeply based on Pointers/References/Addresses.[/b]
That's not the case. OO is a paradigm. Not an implementation. It's a way of creating an abstract model of the problem at hand, and if used with a decent data-modelling language (such as UML) it can greatly simplify program design.
[/b][/quote]

OO is based on Pointers/References/Addresses when done correctly in C++/Java/Perl. You really have no choice but to use the implementation that your compiler uses. I didn't think it would be necessary, since we all know that functions and pointers take longer to work with than plain variables, but here's the code. I exaggerated the pointer to show that it is slower than procedural. C++ uses two forms of OO compared to Java. The first part of this test program is a variable that is an object. That isn't used too often when you're making a serious program, so I also have the pointer to an object (actually a triple pointer).

The point is that any full implementation of the OO paradigm is slower than a procedural implementation because you sacrifice speed for modularity and programming ease. That's a basic lesson in Comp Sci 2.

Word?

Code:

#include <iostream>
#include "time.h"

using namespace std;

class test
{
public:

****long setDatum(long i)
****{
********datum = i;
****}

****long datum;
};

int main()
{


****test OODatum;
****test*** OOPtr = new test**;
*****OOPtr = new test*;
******OOPtr = new test;

****long ProcDatum;

****clock_t startTime;
****clock_t endTime;



****for (int trials = 0; trials < 2; trials++)
****{
********float avg = 0;
********for (int j = 0; j < 10; j++)
********{
************startTime = clock();
************for (int i = 0; i < 100000000; i++)
****************OODatum.datum = i;
************endTime = clock();

************avg += endTime - startTime;
********}

********cout << endl << "OO Avg time taken: " << avg / 10 << endl;



********avg = 0;
********for (int j = 0; j < 10; j++)
********{
************startTime = clock();
************for (int i = 0; i < 100000000; i++)
****************OODatum.setDatum(i);
************endTime = clock();

************avg += endTime - startTime;
********}

********cout << endl << "OO w/Func Avg time taken: " << avg / 10 << endl;



********avg = 0;
********for (int j = 0; j < 10; j++)
********{
************startTime = clock();
************for (int i = 0; i < 100000000; i++)
****************(***OOPtr).datum = i;
************endTime = clock();

************avg += endTime - startTime;
********}

********cout << endl << "OO w/Ptr Avg time taken: " << avg / 10 << endl;



********avg = 0;
********for (int j = 0; j < 10; j++)
********{
************startTime = clock();
************for (int i = 0; i < 100000000; i++)
****************ProcDatum = i;
************endTime = clock();

************avg += endTime - startTime;
********}


********cout << endl << "Proc Avg time taken: " << avg / 10 << endl;

****}

****system("PAUSE");
****return 0;
}
__________________
GrimFang4 is offline                         Send a private message to GrimFang4
Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Translating Abandonia To Other Languages Kosta Old News 267 14-03-2010 01:23 AM
Different Languages = Different Versions? Vikingblood80 Old Suggestions 14 09-02-2006 01:08 PM
Languages Grinder Blah, blah, blah... 34 30-07-2005 12:03 PM
Languages #2 Grinder Blah, blah, blah... 3 29-07-2005 12:39 PM


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 05:34 AM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.