Dimitri89 Posted February 12, 2009 Share Posted February 12, 2009 Hey all. Well, I have a concern - I want to make myself a framework so when I develop web applications, I won't have to re-write intense amounts of code. Now, my only problem concern is - how slow is OO vs Procedural? I want the most optimization but also a steady and firm frame-work. I am talking about speed without using a bytecode compiler or such. Cheers and thank you. Though also, another question on mind - What is a good bytecode compiler/reader for php to use? Preferably one that doesn't take too much work to set up on remote hosts Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/ Share on other sites More sharing options...
corbin Posted February 13, 2009 Share Posted February 13, 2009 OOP definitely has an overhead (in any language, not just PHP, just for the record). Most of the overhead, however, when compared to procedural programming, is instantiating classes. Not sure exactly how it works in PHP, but in lower level programming, function calls execute code at a certain block of memory. Method calls are essentially the same idea, except each instance of a class has it's own memory block. So, in essence, most of the overhead comes in actually creating the object. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760929 Share on other sites More sharing options...
Dimitri89 Posted February 13, 2009 Author Share Posted February 13, 2009 Cheers thank you, I also heard that it is faster to call static members within an Object instead of making them instantise normally with it (Resembles Prototype in javascript in a way?) I just need to find a careful balance. I could always stick with procedural but use strict naming conventions. I just need to plan this very carefully and smartly. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760930 Share on other sites More sharing options...
corbin Posted February 13, 2009 Share Posted February 13, 2009 There are distinct advantages to OOP. Encapsulation, the whole "objects" thing, so on.... And in the wild, the overhead of instantiating a class is very, very minimal. Static members within an object? Well, in lower level languages, that would only be faster because an object wouldn't have to be created, and also, the memory location for a specific instance woudn't be involved (as in finding). I would imagine it's the same in PHP. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760934 Share on other sites More sharing options...
Dimitri89 Posted February 13, 2009 Author Share Posted February 13, 2009 Hmm I suppose it will make life easier. Ultimately I'll make most parts cache except for the constant changing pages. Yeah.. I guess its time to start working on a framework. After working on such an intense project for 3 weeks I realised how important it is to use a framework. I'm making last minute dead lines here! Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760936 Share on other sites More sharing options...
corbin Posted February 13, 2009 Share Posted February 13, 2009 Just of curiosity, are you writing your own for a learning experience or what? Why not use one of the 1928290 out there already? Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760938 Share on other sites More sharing options...
Dimitri89 Posted February 13, 2009 Author Share Posted February 13, 2009 Well, yes learning experience is one of it. I have been only programming in php since late december as a company just randomly asked me to work in it so I said why not. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760941 Share on other sites More sharing options...
corbin Posted February 13, 2009 Share Posted February 13, 2009 Frameworks are a very large task.... If you're worried about speed, you might want to stick with a well known one. No offense intended, of course. Also, the design of well known, public frameworks is usually quite good. But yeah, making a framework could be a really good learning experience ;p. And, I guess I'm assuming you're going to make a full out framework..... Guess a small one would be a different beast. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760945 Share on other sites More sharing options...
Dimitri89 Posted February 13, 2009 Author Share Posted February 13, 2009 Haha I've had a sudden change of heart. I think I'd rather enjoy life then waste time writing a framework - I've decided I'm going to try use http://www.yiiframework.com/ Yeah, your right - why make one when theres a gazzilion otheres out there. My main idea of a framework was to help me build CMS's and other content driven websites much more faster and seemingly more custom. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-760950 Share on other sites More sharing options...
corbin Posted February 13, 2009 Share Posted February 13, 2009 Didn't mean to dissuade you from your learning, but what ever works ;p. Link to comment https://forums.phpfreaks.com/topic/145011-php-oo-speed/#findComment-761053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.