PHP 5 Released; PHP Compiler, Too
TheTomcat writes "After years of anticipation, PHP 5 was released today. This release represents a milestone in the evolution of PHP. It sports the new Zend Engine II, a completely re-worked object model, and many many new features. Check it and the changelog out."
In other PHP news, remote_bob writes "There have been many attempts, like
BinaryPHP
and PASM,
but finally there is a complete
compiler
for PHP. The Roadsend compiler produces standalone, native executables, and supports the entire PHP language (but not all extensions). It uses
Bigloo Scheme
to do its job, a variant of Lisp, the language that
Paul Graham writes about.
Benchmarks say that performance is pretty good. Is this another sign that dynamic languages are the future?"
Doing PHP development has been my main source of income for a couple of years, the new release will make my life much easier, especially the new OOP model, let's just hope that web hosts will upgrade soon.
Thanks again PHP team!
The IT section color scheme sucks.
One of our design goals for PHP 5, was to keep backwards compatibility as much as possible. Actually most PHP 4 sites run out of the box with PHP 5. If there are problems, there's a compatibility mode (configurable via php.ini) which makes the object-oriented model behave the same as in PHP 4.
Bottom-line: Very few people will have problems doing the upgrade. Of course you should thoroughly test your site before upgrading.
Yes the official interpreter is cross-platform, it is available for *nix and Windows.
Check out the downloads section at php.net for Windows binaries and *nix source, and here you can find more details on PHP under Mac OS X.
As for the compiler in the story, I haven't tried it before so I don't know.
The IT section color scheme sucks.
http://www.roadsend.com/home/index.php?pageID=faq
$400 for the license, which is only good for one year. After that, it won't compile until you renew.
Doesn't seem worth it for the casual hobbyist...
The compiler generates binary code that is executed directly by the CPU, avoiding the intermediate process of compiling to bytecode and running in a virtual machine
That's a true native compiler to me.
For those who are not new to php, but wan't a good primer for PHP 5 I would definatly recommend this book by George Schlossnagle. Advanced PHP Programming was recently reviewed here and it was upon reading that review that I decided to pick up a copy. It serves as an introduction to OOP to those who are unfamiliar and does a good job in covering the specific mechanics of how things operate in PHP. The book even includes some good info on some Zend Engine hacking.
Steal This Sig
Well that makes it pretty worthless.. on a plus side if they sell it there's likely support and other features which would make php more of a option in business.
And if they can do it, why can't we... how long till GCC compiles php code?
Any decent language has full PCRE support these days. Perls days as regular expression king are in the past. Sure it may have set the standard for how it's done, but now it's no longer a selling point. Plenty of other nicer languages exist.
TODO: Something witty here...
PHP itself including the zend engine is 100% opensource, You can download the source you can browse the cvs to your hearts content and see everything.
The products they produce to support the development of php the closed source.
You do not need to touch, use or otherwise dirty your poor soul with any "non-free" software to use php.
There is nothing wrong with this business model, get over it.
Personal Website
Speaking of PHP compilers, there's a good and very affordable solution from IonCube as well.
(no, I have no affiliation to them)
For a list of PHP 5 related tutorials and articles check out this faqt or simply look around the faqts PHP 5 section.
Very cross-platform...obviously some things like file paths might have to be changed to reflect the filesystem they run on top of (/usr/bin/whatever vs c:\program files\whatever) but with few exceptions, PHP code written on any OS will work on any other one.
If you'd like to see what's new in PHP 5, we got some of the leading PHP developers to write about new extensions they developed.
I also posted the first chapter of my PHP 5 book in that section which gives an overview of what's new in PHP 5. This book will be part of the Bruce Perens series of Prentice-Hall and will therefore be open-source and freely accessible to anyone.
LISP's parentheses turn everybody off, including me, but the data structures really are a win for tree-like applications.
A kind of slick way to test your existing code and applications is to do a little -fu in your apache.conf and set it up so you have two instances of Apache running on different ports but using the same DocumentRoot. One instance running the PHP4 module and one the PHP5 module. I've got this set up on my Gentoo dev server with PHP5 running over port 8080. Just add an :8080 to the URL and your page is running through PHP5, I've found it quite useful for playing around and testing. If anyone wants more details just e-mail me. And if you're not using Apache, you can probably set up a similar thing, but I can't really help you there.
------
Where are the slash-groupies? I distinctly remember being promised slash-groupies!
Sometimes, it also implies things like dynamically extensible type definitions at runtime, automatic memory management, and support for various functional-style features such as closures.
Compiling a dynamic language to machine code is usually a challenging problem.
In almost all cases PHP4 code will run fine under PHP5.
The only situations where you're likely to hit problems are in reassigning $this in OO code, for example if you had constructors which would go
$this = new My_Error_Class();
Which is no longer supported.
I would normally agree with you but the testing on PHP 5 has been so extensive and has gone on for so long (2 or 3 Betas and 3 RC's) that I am pretty confident in it. I have been using it since Beta 2 and I haven't had any problems with it. Premature releases are so ingrained into our mentality that we sometimes forget that there are quality developers out there who do do thorough testing.
I guess those of us who do not know how to make our own binaries just have to wait for Marc Liyanage to port this thing.
thanks Marc.
I cant wait to play with the final XML/DOM-3 libs.
...but Microsoft really did get there lightyears ahead of this, with a far more complete class library and a standardized language, as well as a scripting engine that supported true seperation of code, presentation and so forth.
Just to clarify this, consider the following:- ASP.net's been precompiled since the 2000 beta, and it's been production ready for years. The C# language is also fully documented and is a public standard ratified by the EMCA.
PHP5, however nice, is treading old water, and in terms of functionality is still lagging behind even Java/JSP. The whole reason I'm assuming people stuck with PHP4, rather than move to something more robust that provides this kind of capability, is that:-
1) They're apathetic about new technology.
2) If the old language does what they want, why upgrade. It's *Personal* Home Page, after all, not corporate homepage.
3) Why make things more complex, for very little benifit.
Performance wise, the compiled version advantages are fairly insubstantial, and 99.9% of the new stuff they've added could have been done in other ways using the existing language.
The whole thing seems pretty stagnant, and I'm guessing there's a small chance that the PHP guys are stuggling to find their own space between the land of true pre-compiled OO languages and the interperated world that lay behind it.
I've worked with PHP4 and ASP.net since both of them were betas, and if PHP wants to be a serious consideration for large scale development, it'd better decide which side of the OO fence its on, and stay there.
Have you looked at Ruby? Regular expressions are very well integrated, and it seems like a far more elegant language (to me).
Uttering logically derived and empirically supported truths to the disciples of the orthodox establishment.
Microsoft makes all its compilers available for free. You can find them all at http://msdn.microsoft.com
-- Cyrus (http://blogs.msdn.com/cyrusn)
zend is offering a package that includes the zend accelerator, studio, & encoder for $295 or $450 with upgrades/bells/whistles per year, as long as your company is pulling in less than 100k per year.
i dont work for zend; i bought the package (think its a good deal).
if you insist on free software, there are a number of free php code caching apps as well as development ides available...
In my experience, the memory management in PHP is not good. Coding should be very careful, or the memory will be usually exhausted.
Another problem is the speed. Well, it is inevitable that interpreter execution is slow. However, I think PHP can run at least twice than current version if the inner architecture of PHP could be carefully rewritten.
Additional, I hope PHP could be multithreaded. When develop a serious application, multithreading or multitask can help programmer lots. And also the efficiency of application could be higher.
I hope these problems could be solved in PHP 5 or later versions.
If you are interested in apia, check : http://clonefab.net/, but there is no English web site yet, sorry for this. It is developed in Chinese language initially. The English document will be ready ASAP. As for apia package itself already support english. You can download it in : http://clonefab.net/apiaDownload.php
Yes I can confirm. We, as in Zend, are working with Sun on the JSR 223. The result will be a Sun reference implementation of the standard (based on PHP) which defines what the interface between PHP (and other scripting languages) and Java will look like.
and also Creative Expression
Scrame: Sunglasses are for assholes.
A lot of folks have no problem migrating from f(a, b) to (f a b). In fact, a lot of people don't find the migration from 2+2 to (+ 2 2) all that hard. I use Scheme all the time and like it.
The problem isn't the core of PHP, but the dozens of PHP extensions and third-party libraries they use. Even if a library claims thread-safety, it is not always so. Therefore, we (as in the PHP development team) recommend to use PHP with the pre-fork MPM of Apache 2 or with Apache 1.3.
I eat hat now.
Yes I do use preg_match() quite often, but apparently I've never needed to match a backslash. I humbly apologize, and realize you are correct.
HOWEVER, other than that I can't think of anything too hard about the quoting style of PHP. You've got interpolated, non interpolated, and HEREDOC. *shrug*
why not just switch to Java? It's all that PHP5 has and more.
:)
Except for speed.
Uh... no. They also changed the object inheritance rules so that overloaded child methods have to have the exact same number of parameters as the original class. So, now you can't have multiple constructors *or* have child constructors that assume certain values and reduce the amount of paramters accordingly.
Yuck.
As a person who codes entire 20,000+ line application libraries in PHP and has been watching the development of PHP 5 very closely, there are a lot of decisions the PHP developers have made that make me very hesitant about going anywhere near the new PHP version.
As an aside, the PHP developers have decided to make SQLite, a light file-based database engine, the default session handler. Even with all file locking turned off, this is at least 4 times slower than the current system used by PHP 4. Of course you can change this setting back to flat session files, but the fact this is their default should say something about other decisions they've made. This setting itself makes especially no sense to me, as all session variables go into the $_SESSION superglobal as associative array keys - there is absolutely no benefit to using a database-enabled flat file for this, as opposed to a regular flat file. It's as if the PHP group were excited about sqlite and tried shoving it into everything.
Just read the changelog very carefully. If you're already using PHP, and have gone deeper than casual use, your applications *will* break - especially if you turn on PHP's strict mode which kills backwards compatibility with PHP 4.
Read: Rabbit Rue - Free serial nove
Here's a handy table:
Dynamic/weak: PHP
Dynamic/strong: LISP
Static/weak: C
Static/strong: Haskell
In a really simplified explanation:
Strongly typed - the identifier is typed
Dynamicly typed - the data (object) is typed
Weakly typed - the operations on the data are typed
Why not fork?
The basic summary is, PHP does not support Unicode or any other encodings properly. PHP strings are 8-bit-per-character and do not have any explicit encoding. Sure, there is a multibyte string extension available, but when you look at the big picture, it's worthless.
/maybe/ the popular graphical extensions like GDlib). Which means that for those developers, PHP does not do Unicode at all.
The reason is that PHP's biggest strength is that these days, you can get a PHP-enabled host for virtually no money. However, most of these installs run a standard PHP, some even a locked down one.
The consequence is that anyone who wants to develop PHP software for a large audience cannot use any non-standard stuff (except
I don't see why they won't do native Unicode, when Perl, Python, Java and all the other popular web languages support Unicode with all the bells and whistles.
I could be way off since it's been a while, but if I recall correcly, iterating over a collection (such as a hash table) in javascript was something like "for (item in collection) { stuff; }". (I last touched javascript for anything serious ~5 years ago writing a bugtracking system in jscript-based ASP for this startup I was working for at the time, because they Really Need NT *sigh* and were too cheap to buy a real bug tracking system *double sigh*. Yes, totally stupid, but welcome to '99...)
Yes, because it's exceedingly difficult to write a general tree or graph algorithm in a language that has arrays of arrays and references.
I can't believe you got a +4, Informative for a completely inaccurate comment. Congratulations.
The only thing I would add is that Mac OS X users should install Ruby themselvesbefore making any judgements on it. The version shipped with Panther is a bit dated, and if I recall correctly lacks some of the features you get from installing it yourself.
$ rpm -qlp roadsend-pcc-prereqs-beta2-1.i386.rpm | grep bigloob /bigloo/2.6c/ lib/bigloo/2.6c/bigloo.heap/ bigloo_config.hc .sog loofth_s-2.6c.so
/usr/lib/libbigloogc-2.6c.so
/usr/bin/bigloo
/usr/lib/bigloo
/usr/li
/usr/lib/bigloo/2.6c/bigloo.h
/usr
/usr/lib/bigloo/2.6c
<snip>
/usr/lib/libbigloo_s-2.6
/usr/lib/libbigloo_u-2.6c.so
/usr/lib/libbi
/usr/lib/libbigloofth_u-2.6c.so
/usr/lib/libbigloog c_fth-2.6c.so
...Dmitri who wrote Turck mmcache was offered a job at Zend and, shock horror, took it. However, as mmcache is GPL'd it lives on at sourceforge, with a new cvs commiter appointed (IIRC) and dev work continuing. To be honest though, it's pretty much feature complete so all they need to do is sure up support for PHP5 (still beta at the moment).
I am NaN
i'm not quite sure where you're getting this from.
/* outputs:
i've been using php5 since the first beta and afaik it has never required overloaded child methods to require the same number of arguments as the parent class.
<?
error_reporting(E_ALL|E_STRICT);
class SomeParent
{
function __construct($var1, $var2)
{
echo "Parent: $var1, $var2\n";
}
}
class SomeChild extends SomeParent
{
function __construct($var1,$var2,$var3)
{
echo "Child: $var1, $var2, $var3\n";
}
}
$x = new SomeParent(1,2);
$y = new SomeChild(3,4,5);
$z = new SomeParent(6,7,8);
Parent: 1, 2
Child: 3, 4, 5
Parent: 6, 7
*/
?>
as for sqlite as session handler, it is not the default, nor has it ever been the default.
there was a patch to ALLOW it to be used as a session handler, by setting session.save_handler = sqlite in php.ini
but if we look at the php.inis in the php5 distribution:
[solidox@server150 php-5.0.0]$ cat php.ini-*|grep "session.save_handler"
session.save_handler = files
session.save_handler = files
both dist and recommended use flat files as the default session handler.
No, perh has not had it, and still does not.
Those are not compilers, they just bundle the interpreter and needed libraries into package.