NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed. (sponsored)
In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.
Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.
Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
A while back, I wrote about the
Quercus engine from Caucho
(the makers of Resin), a version of the PHP libraries written in Java that compiles PHP code into Java bytecode. It seems that the project has really made some headway and is 100% open source and not so tied into Resin. The new project webpage describes the project as:
"Quercus is Caucho Technology's 100% Java implementation of PHP 5 released under the Open Source GPL license. Quercus comes with many PHP modules and extensions like PDF, PDO, MySQL, and JSON. Quercus allows for tight integration of Java services with PHP scripts, so using PHP with JMS or Grails is a quick and painless endeavor."
This week,
Ludovic Champenois spent some time trying to take Quercus and tie it into Glassfish
. He writes that while the Quercus Engine is still in alpha, it runs a lot of the most popular PHP applications such as MediaWiki, phpBB, Joomla, and others. From his entry, it looks like it didn't take that much work to make it work on an application server other than Resin. Is a project like this useful? In some ways, I can see how it would be useful to be able to run PHP applications right in the same server as your Java applications. It's even more interesting that you're able to have your Java and PHP code intermingle and communicate. This could make interoperability easier on some levels. What do you think? Chime in.
Thanks for the post, and your previous one. I made a javascript server with Jetty embedded as the internal web server. I'd like to explore the possibility of adding php using Quercus. It'd be weird to have access to the php apis and things like Smarty templates from java/javascript/other, and my java-side templating and data persistence techniques from php.
I'd also like to add Groovy and a few other languages as well. With javax.script (like bsf) it should be a breeze.
Which leads to the question: is there a javax.script binding for Quercus?
Here's where the power comes in in terms of a Java Developer.
Most folks have a reasonable chance of installing a PHP based application. You can typically do this with little actual PHP knowledge, assuming the documentation on the project is reasonable.
Some rote Apache, PHP, and MySQL HOWTO's will typically get the project installed.
But when you want to actually make changes or customize the PHP code, that's the rub. Now you're plunged in to the depths of PHP.
However, if instead of loading the PHP program on top of Apache you load it on top of an Java app container, someplace you may be well familiar with.
On the surface the application looks that same. But if you now want to modify the application, you no longer need to become so much a PHP programmer.
When someone says "Can you do XYZ", in Java, you may know the answer immediately. In Java, you could solve that problem quickly and efficiently. In PHP, however, you'd be neck deep in Google and learning the PHP world of documentation, libraries and community sites.
But now, if someone wants a change to a PHP program you installed, you can actually approach it with reasonable confidence. Now, you only need to be able to read enough PHP to know where you would like to put the new functionality, but instead of learning PHP to actually create it, you punt back down to Java and write some simple Java classes, or for example, making direct session bean calls to your app server from PHP. Nice.
As soon as you've crossed that boundary in to Java, a warm fuzzy feeling of familiarity washes over you. You now have more confidence in your solution, confidence in your tools, and you're not dredging the internet trying to fast track the solution to the problem. No longer does the solution become a research process, rather it's just a tried and true development project.
You can now potentially make better estimates because you're on more solid ground.
And, at the same time, you simply become more familiar with PHP, for good or ill. You'll more easily become more cross platform in your skill set, while still being productive.
I have avoided working with PHP projects in the past specifically for this reason. I never really wanted to have to learn a whole new environment, a whole new language, etc. Now, I don't necessarily have to. Now, I can more readily integrate all of the PHP work that is out there in to not just Java applications, but my Java knowledge and experience.
It will no doubt be no panacea, but I think this kind of integration can be a good thing and really opens the doors for folks like me that have enough time challenge keeping up with the Java space, much less going off to learn the PHP space as well.
Now there's no reason for many ISPs/providers to refuse the installation of a Java webapplication server on port 80 , since this won't disturb the PHP appliactions anymore .
Since Caucho published the sources, it would be nice if they would put them in some source repository(e.g. google code or sourceforge) to allow the the community to send patches easily.
This is a super cool technology. I would never have thought before that it would possible to have php and java within the same container. I have made a couple of little tests and it seems to work perfectly.
Nice idea. We should have come up with something like this ages ago.
I've come to believe that whenever you are able to translate a foreign programming language into java byte code, the performance will benefit directly from the massively cool technology which is HotSpot.
So I'd expect a much better performance than running PHP out of the box.
I didn't try it myself, but I guess it's implemented using lots of reflection, which is not very fast.
I think it will be able to run much faster if "invokedynamic" instruction is added to the JVM.
I don't know if it's 100% true, but the main advantage of PHP over Java is the class library size and it's heap usage.
Anyway, the quality of such integration depends most on compatibility with the native PHP. As a bad example, consider jython. It was a very promising project (I used it myself), but it probably was a very hard job for the developers keeping the pace with native python and today jython is pretty much dead.
"Quercus outperforms a straight mod_php implementation by about 4x (for Mediawiki and Drupal). Quercus roughly matches PHP performance with accelerators like APC."
> Now there's no reason for many ISPs/providers to
> refuse the installation of a Java webapplication
> server on port 80 , since this won't disturb the
> PHP appliactions anymore .
Probably not the reason why this was developed, but certainly a good reason to use it!
This is FAR more important than many can imagine, from a business point of view.
There are a ton of development shops that focused on rapid application development using PHP4 in the beginning, and now migrating to PHP5. Also, for each Java programmer, at least in Romania, there are three PHP programmers. PHP is easier to learn, easier to start with, and easier to deploy. The downside, until now at least, is that PHP is not enterprise. You could do some nice stuff in it, it can also be optimized & everything, but it is still just a in-page scripting language.
The leverage for a business doing most of its projects in PHP is huge: not only it can benefit from a wide range of application servers from the Java world, it can also augment the existing PHP applications with features that were not (easily/feasible) possible until now.
Your education begins where what is called your education is over.
Java and PHP Intermingling?
URL: Ludovic Champenois's Blog
At 8:05 AM on Mar 14, 2007, Matthew Schmidt wrote:
Fresh Jobs for Developers Post a job opportunity
"Quercus is Caucho Technology's 100% Java implementation of PHP 5 released under the Open Source GPL license. Quercus comes with many PHP modules and extensions like PDF, PDO, MySQL, and JSON. Quercus allows for tight integration of Java services with PHP scripts, so using PHP with JMS or Grails is a quick and painless endeavor."
This week, Ludovic Champenois spent some time trying to take Quercus and tie it into Glassfish . He writes that while the Quercus Engine is still in alpha, it runs a lot of the most popular PHP applications such as MediaWiki, phpBB, Joomla, and others. From his entry, it looks like it didn't take that much work to make it work on an application server other than Resin. Is a project like this useful? In some ways, I can see how it would be useful to be able to run PHP applications right in the same server as your Java applications. It's even more interesting that you're able to have your Java and PHP code intermingle and communicate. This could make interoperability easier on some levels. What do you think? Chime in.
13 replies so far (
Post your own)
Re: Java and PHP Intermingling?
Thanks for the post, and your previous one. I made a javascript server with Jetty embedded as the internal web server. I'd like to explore the possibility of adding php using Quercus. It'd be weird to have access to the php apis and things like Smarty templates from java/javascript/other, and my java-side templating and data persistence techniques from php.I'd also like to add Groovy and a few other languages as well. With javax.script (like bsf) it should be a breeze.
Which leads to the question: is there a javax.script binding for Quercus?
Re: Java and PHP Intermingling?
I think it's a pretty good idea.Here's where the power comes in in terms of a Java Developer.
Most folks have a reasonable chance of installing a PHP based application. You can typically do this with little actual PHP knowledge, assuming the documentation on the project is reasonable.
Some rote Apache, PHP, and MySQL HOWTO's will typically get the project installed.
But when you want to actually make changes or customize the PHP code, that's the rub. Now you're plunged in to the depths of PHP.
However, if instead of loading the PHP program on top of Apache you load it on top of an Java app container, someplace you may be well familiar with.
On the surface the application looks that same. But if you now want to modify the application, you no longer need to become so much a PHP programmer.
When someone says "Can you do XYZ", in Java, you may know the answer immediately. In Java, you could solve that problem quickly and efficiently. In PHP, however, you'd be neck deep in Google and learning the PHP world of documentation, libraries and community sites.
But now, if someone wants a change to a PHP program you installed, you can actually approach it with reasonable confidence. Now, you only need to be able to read enough PHP to know where you would like to put the new functionality, but instead of learning PHP to actually create it, you punt back down to Java and write some simple Java classes, or for example, making direct session bean calls to your app server from PHP. Nice.
As soon as you've crossed that boundary in to Java, a warm fuzzy feeling of familiarity washes over you. You now have more confidence in your solution, confidence in your tools, and you're not dredging the internet trying to fast track the solution to the problem. No longer does the solution become a research process, rather it's just a tried and true development project.
You can now potentially make better estimates because you're on more solid ground.
And, at the same time, you simply become more familiar with PHP, for good or ill. You'll more easily become more cross platform in your skill set, while still being productive.
I have avoided working with PHP projects in the past specifically for this reason. I never really wanted to have to learn a whole new environment, a whole new language, etc. Now, I don't necessarily have to. Now, I can more readily integrate all of the PHP work that is out there in to not just Java applications, but my Java knowledge and experience.
It will no doubt be no panacea, but I think this kind of integration can be a good thing and really opens the doors for folks like me that have enough time challenge keeping up with the Java space, much less going off to learn the PHP space as well.
Re: Java and PHP Intermingling?
Quercus is a great ideaNow there's no reason for many ISPs/providers to refuse the installation of a Java webapplication server on port 80
Since Caucho published the sources, it would be nice if they would put them in some source repository(e.g. google code or sourceforge) to allow the the community to send patches easily.
D.
Re: Java and PHP Intermingling?
This is a super cool technology. I would never have thought before that it would possible to have php and java within the same container. I have made a couple of little tests and it seems to work perfectly.Re: Java and PHP Intermingling?
If you get one of those $20 virtual dedicated Linux hosting accounts, you can do whatever you want, including running a java server.Re: Java and PHP Intermingling?
Thank you. This is really interesting;Re: Java and PHP Intermingling?
Yes, it is build in directly.I'm currently exploring the possibility to use it in a client application.
Re: Java and PHP Intermingling?
played with it more than a month, but some crusial code is not working. In my eyes, SOAP (which is a old technology nowadays) is necessary.It is however a great tool to use. It's fast and the normal stuff just works out of the box. And.... only the memory leaks that java provides
Performance compared to native?
Nice idea. We should have come up with something like this ages ago.I've come to believe that whenever you are able to translate a foreign programming language into java byte code, the performance will benefit directly from the massively cool technology which is HotSpot.
So I'd expect a much better performance than running PHP out of the box.
Can anyone confirm that?
Re: Performance compared to native?
I didn't try it myself, but I guess it's implemented using lots of reflection, which is not very fast.I think it will be able to run much faster if "invokedynamic" instruction is added to the JVM.
http://jcp.org/en/jsr/results?id=3659
I don't know if it's 100% true, but the main advantage of PHP over Java is the class library size and it's heap usage.
Anyway, the quality of such integration depends most on compatibility with the native PHP. As a bad example, consider jython. It was a very promising project (I used it myself), but it probably was a very hard job for the developers keeping the pace with native python and today jython is pretty much dead.
Get the RMI Plugin for Eclipse
Re: Performance compared to native?
http://www.caucho.com/resin-3.0/quercus/"Quercus outperforms a straight mod_php implementation by about 4x (for Mediawiki and Drupal). Quercus roughly matches PHP performance with accelerators like APC."
F'ing A !
Re: Java and PHP Intermingling?
> Now there's no reason for many ISPs/providers to> refuse the installation of a Java webapplication
> server on port 80
> PHP appliactions anymore
Probably not the reason why this was developed, but certainly a good reason to use it!
Re: Java and PHP Intermingling?
This is FAR more important than many can imagine, from a business point of view.There are a ton of development shops that focused on rapid application development using PHP4 in the beginning, and now migrating to PHP5. Also, for each Java programmer, at least in Romania, there are three PHP programmers. PHP is easier to learn, easier to start with, and easier to deploy. The downside, until now at least, is that PHP is not enterprise. You could do some nice stuff in it, it can also be optimized & everything, but it is still just a in-page scripting language.
The leverage for a business doing most of its projects in PHP is huge: not only it can benefit from a wide range of application servers from the Java world, it can also augment the existing PHP applications with features that were not (easily/feasible) possible until now.