Results 51 to 71 of 71
Thread: OOP rant
-
08-28-2005, 07:16 PM #51WHT Addict
- Join Date
- Oct 2004
- Posts
- 100
Sure, I've written OOP code in C, simply by using OOP notation style and malloc/free cycle. It's not a very efficient use of programmer and maintainer time, but you can do it. Some kids with no perspective were claiming that Java is noticeably slower than C, but that's an extremely naive POV.
Of course you can create more efficient code in C than in Java, but generally you have a set amount of time to write your program, and with C, or PHP for that matter, you have to write an amazing amount of really basic code (think Collections in Java) yourself, and the results are often less than optimal because of the limited time available, and you have to debug all of that utility stuff yourself.
When writing serious software with an adult software development team, the most efficient use of the team's time is achieved by using a system which provides a constant, common and complete conceptual framework, which has a reasonably efficient default implementation and which you can optimize within that framework where optimization is required.
You'll understand when you grow up.
-
08-29-2005, 09:57 AM #52Web Hosting Guru
- Join Date
- Nov 2003
- Posts
- 297
-
08-29-2005, 10:38 AM #53Registered User
- Join Date
- Aug 2005
- Posts
- 70
Wow mikaelhg, you're just all sorts of wrong. Malloc/free cycle?? What does garbage collection have to do with OOP? And could you please explain to me what OOP notation is? Listen sweetheart, maybe some of the *kids* on this post are somewhat incorrect in their interpretation of what OOP actually is but you are just completely lost.
I don't dislike Java by any means and I believe it has it's uses, but it is slow, like little yellow bus slow, and has little advantage over it's natively compiled couterparts, e.g. C++, aside from it's 'write-once run-anywhere' ability. In fact, developing can be more time consuming in Java when you factor in the effort spent continually optimizing code to improve it's inherently slow performance. True, C++ has no gc but with a good debugger and decent coding practices memory leaks can be virtually non-existent, and if discovered can be isolated and repaired relatively easily.
BTW - I'm thinking 'collections in Java', and I guess I'm just not seeing it.
-
08-29-2005, 04:05 PM #54Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
I don't dislike Java by any means and I believe it has it's uses, but it is slow, like little yellow bus slow, and has little advantage over it's natively compiled couterparts, e.g. C++, aside from it's 'write-once run-anywhere' ability. In fact, developing can be more time consuming in Java when you factor in the effort spent continually optimizing code to improve it's inherently slow performance.
This is just absolute rubbish. These are mere rumors about Java that were only partial true years ago and haven't been true for many years. Java is not much slower than C++, here I"ll say it again Java is not much slower than C++. Java even will out perform C++ in some things. Although a large project writen in Java is going to be slower, but not much slower (at most 10% or so). And ugh....development in Java takes much less time than development in C++. Furthermore when it comes time to do optimizations in your project the optimizations if anything are going to be faster to do in Java (and please note you'll need to optimize C++ just as much as you will Java code). But no doubt you have more control in C++ and this makes it more suitable for some tasks.
Also your comments about memory leaks show you've never worked on a large project in C++ or C. Memory leaks are non-trivial to deal with, there are many examples of projects that have died due to memory leaks that could not be tracked down. Once the code base gets large memory leaks become extremely hard to track down.
So when developing a project in C++/C you need to do unit tests on each piece of code so you can catch memory leaks locally when possibly, but this adds a lot of developoment time to your project. Furthermore it doesn't mean you aren't going to have memory leaks when everything is working together.
-
08-29-2005, 05:08 PM #55Registered User
- Join Date
- Aug 2005
- Posts
- 70
This is just absolute rubbish. These are mere rumors about Java that were only partial true years ago and haven't been true for many years. Java is not much slower than C++, here I"ll say it again Java is not much slower than C++. Java even will out perform C++ in some things. Although a large project writen in Java is going to be slower, but not much slower (at most 10% or so). And ugh....development in Java takes much less time than development in C++. Furthermore when it comes time to do optimizations in your project the optimizations if anything are going to be faster to do in Java (and please note you'll need to optimize C++ just as much as you will Java code). But no doubt you have more control in C++ and this makes it more suitable for some tasks.
As for memory leaks, C is more prone to them but Java is not immune either, and properly trained developers, coding standards, and testing/debugging practices can eliminate them in either language. I will say that you can get away with sloppier code in Java, thus making the planning phase less critical, but that is just stupid and shouldn't be acceptable in any language, and certainly not in a team.
-
08-29-2005, 08:04 PM #56Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
More myths.
Java GUIs are not slow...Swing is not slow. GUIs in java are going to be a bit slower, but not much. And with GUIs it really doesn't matter, they are the sorts of things where speed is not the main issue.
Its just as easy to make a slow crappy GUI in C++ as it is in Java, in fact GUIs are easier to make in Java. The only issue with Java apps is treading, you need to have a decent understanding of it to write non-trival java GUIs.
Do you have a particular Java application in mind that is slow? Whenever I've seen a Java GUI app not respond fast it was a threading issue.
Java also has all sorts of IDEs for it that speed up development, that are just as good as the ones for C++. Java remains faster to develop in because you do not need to deal with memory issues. These issues in themselves take up a lot of planning and testing time. Debugging is also harder in C++ than it is in Java.
-
08-30-2005, 08:07 AM #57Web Hosting Guru
- Join Date
- May 2004
- Location
- Singapore
- Posts
- 263
hmm... but the question here isnt Java vs C++...
#include<cstdio>
char*s="#include<cstdio>%cchar*s=%c%s%c;%cint main(){std::printf(s,10,34,s,34,10);}";
int main(){std::printf(s,10,34,s,34,10);}
-
08-30-2005, 08:21 AM #58Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Wow, you're one of the outnumbered here who actually read the topic..
-
08-30-2005, 09:58 AM #59Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
Wow, threads change topics.
-
08-30-2005, 10:24 AM #60Web Hosting Guru
- Join Date
- Nov 2003
- Posts
- 297
an interesting discussion of OO in the field of UNIX programming which seems closer to where the topic started (PHP).
http://www.faqs.org/docs/artu/unix_and_oo.html
"Since the mid-1980s most new language designs have included native support for object-oriented programming (OO). Recall that in object-oriented programming, the functions that act on a particular data structure are encapsulated with the data in an object that can be treated as a unit. By contrast, modules in non-OO languages make the association between data and the functions that act on it rather accidental, and modules frequently leak data or bits of their internals into each other.
The OO design concept initially proved valuable in the design of graphics systems, graphical user interfaces, and certain kinds of simulation. To the surprise and gradual disillusionment of many, it has proven difficult to demonstrate significant benefits of OO outside those areas. It's worth trying to understand why............"
-
08-30-2005, 02:03 PM #61Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Originally posted by Froggy
Wow, threads change topics.
I don't want to make this into total flame war so I'm stopping here. Please, try not to reply to this Froggy. Thanks.
Back to the original topic - lots of people that actually took part on initial topic think that OO in php (version 4) is not just a lame feature but that it provides what it's meant to provide.
This also confirms my thoughts that you don't need the biggest gun to fire a bullet, you can do it with any gun that provides basic means (bullet beeing OO, gun the language we use).
Thanks to everyone who found the time to share the thoughts on the matter.
Of course, there are people that rather disagree with my conviction, but that's the way it is.
I'm just happy that I'm not alone in my thinking
-
08-30-2005, 04:35 PM #62Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
Yes you have a lot of people that don't understand OO or programming languages in general that are right with you in your thinking.
-
08-30-2005, 05:16 PM #63Aspiring Evangelist
- Join Date
- Jan 2004
- Posts
- 406
Originally posted by Froggy
I haven't looked into the history of OOP languages much but from what I know it was mainly created to deal with various issues in software development. That is OOP languages give you a better way of managing large projects.
I generally use OOP for most of my projects both on the web and else where. In fact even when I use a language like C structure things a bit as if it was an OO language.Originally posted by Froggy
But debating about whether you should use OO or procedural programming styles is pretty pointless, you should use whatever style you are most comfortable using.Affordable Business Web Site Hosting by Geo Redundant Hosting
-
08-31-2005, 03:57 AM #64Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Originally posted by Froggy
Yes you have a lot of people that don't understand OO or programming languages in general that are right with you in your thinking.
But anyways, I have my oppinions and you have yours. The only difference is that I won't try to "convert" people to my way of thinking.
I really dislike flaming, so I kindly ask you not to add oil to the fire anymore, if possible.
-
08-31-2005, 07:22 AM #65WHT Addict
- Join Date
- Oct 2004
- Posts
- 100
Tommar: what I meant by managing the malloc/free cycle in an object oriented manner in C was that I define structs for my objects, include all resource allocation references (object graphs) inside these structs, and then create constructor and destructor methods which handle creating and releasing of all of the resources which are contained on that level of the object graph and one level down.
That way, I can easily and separately test that each object can take care of allocating and releasing its resources, and be reasonably sure that those tests are valid on a systemwide level.
Is this clear?
-
08-31-2005, 02:25 PM #66Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
Having read that from a guy who tried to compare Java and C++ in terms of performace really means nothing..
And the point of my comment is that: ALl the peole that say they do OO in PHP4 are people that don't have any idea what OO really is..they are thinking of object based programming. Whether someone uses object based programming or prodecural programming in PHP4 is a matter of personal preference. And this is what I said in the beginning I don't see how that equates with trying to "convert" people.
-
08-31-2005, 03:31 PM #67Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
We are talking about two total different aspects Froggy. I just deleted what I was writing the last 15 minutes since it would lead to even more argues.
Just remember, OO IMO is a way of thinking first, and second - a language implementation. Even though PHP 4 lacks in implementation, I don't think that OO in PHP 4 should be ditched completely and that's what's it all about.
-
09-01-2005, 07:44 AM #68WHT Addict
- Join Date
- Oct 2004
- Posts
- 100
http://c2.com/cgi/wiki?DefinitionsForOo
There is no consensus on the definition of OO.
However, PHP4's implementation of OO is of less value than the utter lack of OO implementation in C, which at least didn't come in the way of the developer, slow the system down, and provide developer and library confusion.
-
09-01-2005, 11:03 AM #69Web Hosting Guru
- Join Date
- Nov 2003
- Posts
- 297
haha.. good call
-
09-01-2005, 04:02 PM #70Aspiring Evangelist
- Join Date
- Aug 2005
- Posts
- 438
However, PHP4's implementation of OO is of less value
-
09-03-2005, 11:00 AM #71Web Hosting Guru
- Join Date
- May 2004
- Location
- Singapore
- Posts
- 263
I don't believe the developers of PHP4 were trying to give an implementation of OO#include<cstdio>
char*s="#include<cstdio>%cchar*s=%c%s%c;%cint main(){std::printf(s,10,34,s,34,10);}";
int main(){std::printf(s,10,34,s,34,10);}