0

From what I've read about PHP HipHop – it serves the purpose of converting PHP code into C++. The bit I did not understand is how the actual code is later on executed and whether only some elements of code can be HipHop'ed.

I have files helpers.inc.php (contains a lot of functions), database.class.inc.php (contains PDO extension) and similar that don't change often. I'd like to convert them into C++ PHP module that I could include to other project files or simply make them available across the system.

Is that possible using PHP HipHop?

Gajus
  • 69,002
  • 70
  • 275
  • 438
  • 2
    Is your application the size of facebook? If not, there are many optimizations you should address before even considering something like that: namely minimizing disk I/O and database overhead. And even if you get to such a point, the benefits of HipHop over a caching mechanism like [APC](http://php.net/manual/en/book.apc.php) or [XCache](http://xcache.lighttpd.net/) are likely insufficient to justify its use in your project. This sounds like a case of premature optimization :) –  Jan 22 '12 at 15:35
  • "Premature optimisation is the root of all evil." - Donald Knuth – Bojangles Jan 22 '12 at 16:00
  • Well, it is certainly not as big as Facebook. : ) It is avg. 50k requests every 5 minutes throughout the day. I am not experiencing any issues with slow response either or lack of server resource. I am only curious to investigate technology around me. That said, things like minimizing I/O (server is using SSDs anyway), APC, memcached are taken care of/in use. – Gajus Jan 22 '12 at 18:21

1 Answers1

1

You've been misled and should read the Running HipHop wiki page:

You can run HipHop in 5 different modes.

Mode 1: Compiling HipHop and running it directly.

Mode 2: Compiling HipHop in a temporary directory and running the compiled program from the command line.

Mode 3: Compiling HipHop in a temporary directory and running the compiled program as a web server.

Mode 4: Interpreting HipHop directly.

Mode 5: Starting a Web server or daemon and interpreting HipHop on the fly.

If you want to create extensions, you should dive into the documentation: http://www.php.net/manual/en/internals2.php

But mostly, YAGNI.

greut
  • 4,305
  • 1
  • 30
  • 49
  • Thanks for introducing me with YAGNI. Though, see the comment I made on the original post. I am interested in learning things & I am doing that in my spare time. – Gajus Jan 22 '12 at 18:30
  • We are also answering you in our spare time mate. The wiki page says that you have to run everything through HipHop, not just modules or libraries. If you want a specific piece of code to be optimized, you'll have to create a PHP extension (PECL) and write it yourself in C++. HipHop has alternatives too: http://www.php-compiler.net/benchmarks – greut Jan 22 '12 at 18:55