Hot rod your PHP app with Caucho Quercus and start learning Java technologies
Caucho Quercus is a commercial solution for accelerating PHP applications that starts at around $700 for a single processor. They rewrote PHP to run on the Java Virtual Machine, which is a pretty amazing feat. Caucho was able to optimize PHP to be about 4 times faster or close to the same performance in some cases. More importantly, you can have direct access to memory when working with cached objects since it runs as a true server instead of the quick death design that most php apps have.
Regular php can't access shared memory like that without significant serialization overhead. This was one of the main reasons I decided not to use PHP.
Having better performance for cached data might make Quercus PHP on par with ColdFusion (CFML) performance and still a reasonable price compared to Adobe's product. This is interesting because I'm a CFML developer.
Railo is free, and better then Quercus PHP
However, since Railo (www.getrailo.org) is free and faster then PHP, I don't really care about Quercus for myself right now. If I was obsessed with doing PHP apps, I'd probably want to get my app to run on Quercus early on because of the huge performance gains you'd have with it. A lot of performance and design problems you have to deal with in PHP would be eliminated if there was virtually no overhead to load your entire library into memory. PHP apps spend a tremendous amount of time doing redudant work. My Jetendo CMS application built on CFML technology uses shared memory extensively and does almost no redundant work because of this. If you could get your PHP app to that point, it would be noticeably superior to other PHP software, which may be helpful if you plan on distributing it someday.
Quercus makes amazing compatibility claims for popular PHP apps
Caucho promises that they test Quercus's compatibility with Wordpress, Mediawiki, Joomla and many other existing notable PHP projects, which is very impressive to me. It must be pretty solid software for them to claim this (Note: I haven't actually tested Quercus myself yet). However, there are probably limitations in some fringe areas, and you may find yourself needing to learn or use Java or integrate another dynamic language with the Java server when you run into a problem that goes beyond what they've ported to Quercus.
Free version of Quercus is crippled, but still improve over original PHP
The free version of Quercus doesn't include the JIT Compiler that is in the commercial version, which makes it barely better then regular PHP unfortunately. Coldfusion and Railo use a JIT bytecode compiler as well. From what I understand, this is the best way to implement a language on top of Java virtual machine because it minimizes the amount of resources to execute the application.
The integration with Java is still useful in the free version if you are a Java company and you could also purchase the software later. They offer to help start-ups on waiving the license costs, but I don't know specifically what that requires without contacting them. I don't do enough PHP to feel like I need to bridge PHP and CFML right now. However, it would help a company that has significant investments in both technologies to merge them.
Quercus comes with Resin, but runs on other Java servers
Caucho is trying to sell their Java server, Resin which includes Quercus, but Quercus is able to work on other Java servers like Tomcat once you buy a license. I use Tomcat to run Railo, so that is important to me if I was using Quercus - I'd want that flexibility to choose the Java server if for some reason I had trouble with Railo on Resin. Tomcat is free, and (I think) the most commonly used Java server. It might be basic in some ways, but it's rock solid.
PHP today, Java tomorrow
When you are building stuff on the Java Virtual Machine, you can run all the other Java based languages side-by-side and share data more easily between them. Learning a variety of Java technologies seems to be a great direction for a web company to head towards. All the tools and servers you need are generally of great quality and free. The ones that cost money, typically are only charging for the highest levels of enterprise scaling requirements.
CFML is not the only dynamic language built on the JVM - Clojure is getting a lot of attention too
Sean Corfield talks a lot about CFML and has done a lot of notable things for the CFML community in the past, but he's been talking more about this other language lately which is called Clojure. It seems this one is gaining a lot of users now too. Clojure implements its own flavor of the LISP language on the Java virtual machine. LISP (and clojure) are designed in way that allows them to run in a massively parallel computing situation more easily. The language works entirely different and is written entirely differently compared to more OOP or procedural languages like C, Java, PHP and CFML. Clojure implements "Functional Programming" instead of Object Oriented Programming or other programming paradigms.
The design of the Clojure language forces you to do things in a way that allows it to scale to a massive amount of CPUs more easily. If you had an app optimized for Clojure in a few years when there are 64 cores in a single box, you would be able to utilize the available processing power more easily compared to traditional languages. Clojure is also fairly compact and seems to take less code to do advanced operations such as processing a collection with various different algorithms.
In php, multi-threading isn't even possible, which kind of makes it a dinosaur eventually. In CFML, I can make many slow things at least 4 times faster by spreading the work around the cpus with threads and its pretty easy. Later when there are 64 cores, this will be even more of a speed-up, but there are inefficiencies with how you handle threads in CFML unfortunately that Clojure does better despite both being dynamic languages.
I also realized that I try to write my CFML threading code similar to how Clojure does it. Now that Clojure explained to me what I was doing in better technical terms, I'm finding it easier to solve threading problems.
Immutable data = Work on copies, don't change the original
It appears that the best way to handle shared memory / multi-threading stuff is by working with immutable data which requires doing work on copies instead of the original. This allows you to avoid locking / synchronization overhead quite a bit. Clojure handles this in a more elegant way by reducing the cost of making copies quite a bit. It's definitely better to be moving towards multi-core friendly language. Java and C languages are able to do all this too, it's just more technical and verbose.
It's time to transition to a more exciting future
Your programming career is about more then choosing the most popular, easiest technology. Making PHP faster with Java technology, might be a cool short term fix, but really, the goal should be to transition to using Java or a more capable language built on Java in the future.
One can make lots of small business apps and do fine with any language, but if you want to minimize hardware costs after having built your business on slower technology, it could be quite difficult with PHP.
Facebook's mad scientist approach to fixing their PHP legacy has cost them a fortune in retrospect. I'm sure it helps them to get things done quickly and worry about scaling it later, but scaling PHP is quite inefficient compared to several other technologies - despite their efforts, they only got it to be around twice as fast with HipHop. That doesn't sound like much.
PHP is in decline, Apps are growing instead
If you take away all the free apps built on PHP, you'd find a much smaller community of developers. PHP as a language has actually been losing market share in recent years if you research it on Google Trends. Apps are more popular then languages now. Most people using PHP, don't even know the language. They are simply installing Wordpress, Joomla or another app and using a GUI. These people buy our themes, plugins and hosted service options, but they don't represent real competition as developers. Java and related technologies are the true leaders in web development once you get past the initial phase of "part-time hobbiest programming" - PHP.
The future is in the Java Virtual Machine (JVM) or the Common Language Runtime (CLR / .NET). I like the Java flavor better. I love Railo and I'm looking into Clojure and Java more in the future.
Bookmark & Share
Most Popular Articles
- Mass virtual hosting security tip when using a reverse proxy to connect to other servers
- Solution for MariaDB Field 'xxx' doesn't have a default value
- How to lock Windows immediately upon smart card removal
- Stop using sleep mode with Windows Bitlocker for better security. Learn how to use hibernate in Windows 8.
- Is Google Public DNS actually better then your ISP?
- Pros and Cons of CFML vs PHP and other languages
- Planning a system to visually create responsive data-driven web page layouts & widgets in the Jetendo CMS browser interface
- Run Windows Guest in CentOS 6 Linux Host using Virtualbox 4 via the command line