why are some frameworks slow?
for example how comes that zend frameworks are slower than code开发者_如何学编程 igniter? if you don´t use a lot of classes, just chose the classes of your needs, then it shouldn't get slow?
are you forced to use a lot of classes with zend framework or are they preloading a lot of classes automatically?
It depends how much they have taken care of the speed when writing the code of the framework. CodeIgniter has been written amazingly always keeping the speed in mind. Also big frameworks autoload a lot of nuts and bolts making the framework slower. However, if you are experienced with any of these frameworks, you can speed up the framework to a good deal by filtering out the stuff that you think is not necessary for your current project.
Zend_Loader_Autoloader automatically loads classes when they are requested, so there are no "unneeded classes". There are some tutorials on how to speed up Zend framework powered applications, ie. commenting out "require_once's" and using the PluginLoader include file cache explained here (along with some other methods) http://framework.zend.com/manual/en/performance.html
There are some things you can't beat.
Any framework can be
- Simple
- Extensible
- Fast
- Understandable
- ...
But you can't have all at once. It can't be fast AND extensible. If it is extensible, it has to check if you want to use the internal class or your own. It has to define interfaces for everything. Therefore it has to load a lot of files (for classes and interfaces, abstracts, ...). Note the difference between loading class MySQLDB
class (one class for single purpose) and DbLayer_Interface
, DbLayer_Abstract
, DbLayer_MySQL
(complete infrastructure, where you can substitute any part of it).
Also with easy comes with some magic. The more the framework does for you, the more "magic" is going on under the hood. THe magic can be fast, as it's done for one purpose and doesn't have to check if you want to change anything.
That's why ZF is slower then CI and others. Any class can be replaced. For example we extended and injected custom Db_Select class, that handles multilingual column names automatically. You make select like SELECT table.name_en FROM table
and the underlaying logic transforms it to SELECT table.name_en, table.name_fr, table.name_de FROM table
on the fly... That's the power you receive in trade for speed ;)
精彩评论