Convenience vs Performance in PHP

PHP, while known for it's simplicity and scalability, is an overall slow and memory consuming language. I my 5 years of programming, I've managed to build myself a fully custom and highly optimized set of libraries which I use in a lot of my projects. These libraries range from Geo Location and Authentication, to Sessions Handling and Web Crawling. While these libraries are highly optimized, they still don't have the performance I am hoping for from my applications. PHP consumes high amounts of memory, and isn't the fastest language by any means. I've spent the last few months trying out new ways of upgrading my applications to be more powerful and faster, even learning new languages and techniques along the way.

My first idea was to learn Java. Java, which is cross platform like PHP, is a compiled language, which means it naturally runs faster due to the fact it doesn't read through the raw code each time a program is run. To my disappointment though, Java isn't as straightforward to develop for as PHP. This is mainly due to my habits, as I use raw text editing for my projects, rather than an IDE. I am sure if I spent the time to learn Java as well as I know PHP, then this would be a different story, but unfortunately I don't have the time. So ultimately, Java is not the option I chose for building the back end to my web apps. On a side note, I also tried installing Apache tomcat to run .jsp files from my server. Since this failed, this was the main reason I decided not to put more time into learning Java, maybe in the future.

Secondly, I decided to go for Python. Python isn't compiled language, but due to it's simplicity, is used for many real-time applications and web apps. Personally, I don't like the syntax and find it a bit dry to work with. Also I couldn't get mod_python working on my server, which meant I couldn't run web apps via Apache. This is another project for a later date.

I then came to realise, I know PHP extremely well. I could write any application straight off without any guidance, documentation or code suggestion. Why should I learn a new language? My answer is simple. I won't! I recently came across a project called HotSpot which is used by Facebook internally to make PHP work for their billions of monthly page views. Their initial answer was to code PHP extensions using C++, which runs as native code, speeding up many aspects of their applications. They then went on to build a project to convert PHP to C++, so that PHP can essentially become a compiled language. People had done this before on a small scale, but never converted a site the size of Facebook.

So my conclusion is this. I will learn small snippets of new Applications for various parts of projects, rather than coding my entire project from scratch in a new language. For example. I will use Java or Python for real-time aspects of the applications. I will use C++ and build extensions for features I use all of the time for things like caching and reading large sets of data. The more you learn, the better you become in every area of programming. Since I learned AS3 I have realized many different ways to optimize my heavy JavaScript applications and vice versa. I will post more information on how to actually put these above tips into practice in the next week. Contact me if you have any questions