Now and again I wonder why PHP is never or rather, why it is rarely used for developing desktop applications. I may not be the only one who wonders the same thing so I decided to delve deeper into this so that I can settle my mind and here is what I have come up with.
The easy answer to why PHP is not suitable for developing desktop applications is because PHP is designed as a general-purpose scripting language that is especially suited for Web development and can be embedded into HTML or vice versa. Again by design PHP was developed and distributed as compiled C binaries as CGI. This would normally say it all bu again you have got to remember that PHP has traditionally been a procedural language and not an Object Oriented language.
Libraries
Object Oriented languages are better suited for developing GUI applications of which desktop applications form the bulk of. This does not go without saying that it sure is possible to develop GUI applications in PHP with available libraries like PHP-GTK which doesn’t seem to have had life for quite a while now. According to their website…
“PHP-GTK is an extension for the PHP programming language that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client-side cross-platform GUI applications.”
Another PHP GUI library is PHP-Qt as their website puts it…
“PHP-Qt is a language binding for Qt that allows you to write Qt application with the PHP language. Its goal is being a base and supplement for further bindings such as Akonadi, Plasma and other KDE related software as well as enabling PHP developers to write desktop applications.”
PHP-Qt team is also working on on support for the Roadsend Compiler which gives users the capability to compile their software into binaries which makes sense for desktop development. I am eager to see what they will do with this one.
Going into details though, I break it down further…
Tools
Another thing you need to realize about Software Developer trends is that they tend to lean towards areas where there is an abundance of quality development tools. Without development tools your framework is not bound to make it the front door of the lab.
PHP does not tend to have good or mature development tools; however, dealing with the ever growing switch to better Object Oriented programming support in PHP5 and especially PHP6 the whole ball game could change and we could start seeing better development tools for desktop applications being written for PHP. As it stands now, immature development tools and shady documentation.
Other Factors
PHP does not have true multi-threading support so going beyond the basic desktop applications would be tending to shoot one’s self in the foot. Well, that is if they have not already shot themselves attempting even the very basic app.
PHP also has terrible memory handling. Using it on desktop apps which have longer memory resident processes as opposed to web apps which drop everything upon end of page execution. It would be a disaster when all the memory leaks rear their ugly heads.
Finally
A whole lot of browser based applications can be developed to do what desktop applications could do. With a little bit of thought mixed in with PHP / HTML/CSS & JavaScript a lite web server running on localhost and a lite database like Sqlite which also supports encryption. You can get the same level of productivity without having to bend PHP to work on the desktop. The PHP code can be encrypted using ioncube and finally you may have to develop or use an existing tool to package an installation binary. The possibilities are endless.
PHP; believe it or not is a badly designed language. That does not go to say that it does not work, but it still sucks. Facebook may have heard first hand experience in this and I believe they are doing the right thing in converting the PHP code base to C/C++ using Hiphop-php. That is good news for C/C++. Knowing I am a C/C++ evangelist, that makes me really happy






I don’t know man…Have you coded any PHP? PHP has good development tools. Look at NetBeans IDE for starters. FREE and follows namespaces back to definitions, code hints, debugging, etc. PHP is a LOT more mature and advanced than you give it credit for. While it’s not the best for making desktop apps (obviously, no dispute there) … You might also say the same about JavaScript and HTML5. However, as time goes on you have things like Enyo.js and Intel’s encapsulator and Appcelerator and Adobe AIR and more.
It’s only obvious that you will eventually be able to make respectable desktop apps with PHP and other web languages for that matter. Why? Because that’s what dominates the world at the moment. You have many many more web developers than desktop application developers. Companies like saving money…So… Do the math.
Will you be able to make some super advanced game? No. Of course not. But I think the options you discussed above already prove that PHP is actually suitable for desktop applications. It’s just the TYPE of applications is what you need to clarify.
Oh and look into gc_collect_cycles() for PHP…. You can spawn child processes as well. I have several successful PHP daemons running on my server. I get to adjust how much memory that can take up as well. There’s actually a LOT of progress and growth with PHP. Again… Depending on “what” you want to do, you may actually be surprised.
I point you to my previous comments
Thanks Tom for your comments. In this I refer you to the heading with a stress in the word Suitable. This article does not go to say you cannot develop desktop applications with PHP it is all about how suitable it is. When you have an array of languages to choose from then PHP does not measure up to the others.
Again suitability is not encouraged when you have to pull so many hacks to get it to work. Users want something that just works and as a developer it is your duty to bring your app to point and more hacks you pull is inversely proportional to the suitability of your tools