Table of Contents

Phix

I’m lookin’ for a Phix!

Well, try lookin’ in the SVN repos

http://phix.pengus.net/svn

Mailing list can be found here: http://groups.google.co.uk/group/phix-dev/

About

Phix, or Personal Hyper Interpreting Xylometer for short is an attempt to inform the world about useless cat facts. (and perhaps one day be a replacement for PHP...)

Phix is being developed by Theo Zourzourvillys and Ian P. Christian

What

Phix is at attempt to offer a sensible, secure, heavily optimised replacement to PHP. although a replacement, it is not a clone.

In it’s current state, Phix runs most PHP code out of the box without any alteration in what we call compatibility mode. Compatibility mode provides an environment that most PHP scripts/applications that work with PHP 5.2 will function in without modification.

Once you are comfortable with using Phix, you can break free from PHP‘s “it’ll break backward compatibility” and “Keep it really simple”, and start to harness the power of Phix:

  • Namespaces
  • Optimization
  • Language normalization
  • OO’ification

In short, Phix is an attempt to create a more “professional” PHP, and although not our primary objective, we’ll try and cater for the less experienced developers too.

Note however that Phix is different from PHP in the way it works internally, as it is a compiler and virtual machine rather than an interpreter, and as such may not be a replacement under certain conditions:

  • Just-in-time parsing: Phix currently parses an entire compilation unit (ala PHP file) before it can run the code. (for a web server this means on the first hit/include when the cache is empty). One day we might offer an interpreter where we emulate PHP‘s lax behavious (but allows for massive speed improvement on first hit or when cache is disabled), but until then you have to put up with either taking a performance hit on the first HTTP request, or compiling the code.
  • Missing libraries: Phix doesn’t currently have the 1 million extensions PHP offers. One day someone might come up with a way of using PHP extensions directly (urgh!), but until then, you either need to use native PHP extensions (like anything in PEAR), or write the library extension yourself in C++. As so many of the PHP libraries are used by a very small minority of users, we’re going to focus on the more popular libraries (curl, libxml, xslt, date/time, mysql, postgres, pdo, json, imagemagik, gd, mcrypt, memcache)
  • No debugger: Well, not yet.

However obviously there are some major advantages to doing things the way we do:

  • Greatly improved parse time error detection due to extensive optimization engine.
  • Faster script execution (once compiled) (one day!)

Code Example

$ cat ./test.php
<?php
 
echo 1 + 2 + 3 * 4 / 2, "\n";
echo (1 + 2) + 3 * 4 / 2, "\n";
echo 1 + 2 + (3 * 4) / 2, "\n";
echo 1 + 2 + 3 * 4 * 2, "\n";
echo 1 + 2 + 3 * 4 + 2, "\n";
echo 1 + 2 + 3 * 4 % 2, "\n";
 
$ time php test.php
9
9
9
27
17
3
 
real    0m0.095s
user    0m0.036s
sys     0m0.060s
 
$ time ./phix test.php
9
9
9
27
17
3
 
real    0m0.029s
user    0m0.024s
sys     0m0.004s

Yes, it looks like PHP, because... well, it is. That’s the idea behind the project!

The Plan

  1. Write an initial PHP5 compatible language parser DONE
  2. Turn the parse tree into a CodeDom (ala System.CodeDom.*) DONE
  3. Byte compile the parse tree DONE
  4. Write basic (slow + crap) VM to prove it works DONE
  5. Add basic PHP functions str*, preg*, etc. DONE
  6. Create pass manager in compiler and simplify CodeDom accesses.
  7. Add optimizations framework to byte code compiler
  8. Write web server interfaces (FCGI + apache?)
  9. Write JIT
  10. Write real time feedback optimizer (ala Psyco)
  11. Add PHP language Phixes (Remove all the broken PHPness in non-compat mode)
  12. Make parser event based so we can do lazy parsing at runtime (integrate in with cache?)
  13. Debugger
 
start.txt · Last modified: 2008/01/07 15:49 by 87.127.89.138
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki