views:

148

answers:

3

Yes i know Zend, Cake, Symfonie, Kohana and CodeIgniter.

But i would like to know if anyone has ever tried to get rid of the huge overload you get by writting core components in php and tried to factor as much stuff out into an extension. Precompiled router classes, caching (modules have a build in memcache), etc. could speed things up.

I also know about the current weaknesses that classes are impossible (?? still true ??) to implement in an extension. But who says it has to be OO?

I would like to hear your opinion and maybe links to experimental proof (or failure) of code. I know there is nothing prime time yet, but maybe somebody thought about this in the past.

EDIT: And even if there is nothing like this may question is why? Is it just because the number of people who have the skills to write PHP extensions are so limited (i would say it's ugly but not really difficult)?

A: 

There are none that I know of. I'm going to guess that the reason none exist is because of how hard it would be to make one vs doing it in php. In php, you change the script, press save, and test it. In C/C++, you'd have to recompile it and test it. Not to mention it's much harder to interface with PHP at that low of a level.

I know that Doctrine is or is planning to rewrite part of their code as a C++ extension.

ryeguy
A: 

Maybe you get interested in how Facebook is so fast even being a giant running in PHP.

Article: http://blog.facebook.com/blog.php?post=2356432130

Havenard
+3  A: 

I know no PHP Framework built as a C-extension, I have to admit.

The reasons I can see are :

  • Harder to develop :
    • less people in the community know C
    • Harder to test, too : you don't just alt-tab + F5 : you have to recompile, reload apache
    • If a PHP developper finds a bug, he most likely won't be able to fix it himself (no "quick and dirty" way if you don't know C well)
  • If there is a bug you don't only get a warning/error : you get a segfault, which crashes an instance of apache, which is not good
    • not quite good for the server
    • and worse than a fatal error for the user...
  • Less easy to install / update / deploy :
    • you must be admin of your server
      • which means it will not be used on shared hosting
    • often means you'll have to recompile the extension -- which not that many people know how to do ; especially on windows


OK, it might be great for performances... But the difficulties are too great, I think, for it to be really worth it...

... If you are running after performances, take a look at opcode cache, like APC ; those will already help quite a bit ;-)


Still, I've heard about some "mini-framework" or parts of an application stack that are developped as C-extensions :

  • blitz : a templating engine (a bit like smarty, but does less things)
  • it seems there will be a Doctrine extension (ORM framework)
Pascal MARTIN