|
I am going to savage PHP. I know I am running Joomla now. I know I ran Word Press for years. Both run exceptionally well. I would say Facebook exemplifies what PHP can do and I would never dream of running a MYSQL server with PHPMyAdmin installed. So, I am not going to attack what can be done with PHP; I just can’t stand the idea of programming it any more. During my day job, I use .Net and the full line of Microsoft Tools. Problems, prolific swears and WTFs abound. My compiler crashes almost daily and I certainly do not view my bread and butter language as superior. However, it’s bad when you fire up either Eclipse or Zend studios and wish they performed half as well as .Net. There’s one simple reason – autocomplete and code look up. I never realized how much I depend on that little box of suggestions until I tried to create a data object model in PHP. I had a simple design. I extended the MYSQLI library to wrap a lot of the common functionality in a single class. I created a base case that invoked and instantiated the extended database class in the constructor. My data objects would then share the same base object and all of it would let me get to the good old fashion ORM without the need to muck with the underlying database object. To be fair, it worked as intended. PHP5’s object model allowed me to do everything I wanted. Unfortunately, when you are dealing with three levels of objects like I had designed, it’s very easy to get lost, especially when you need to relearn the syntax after a year or two of neglect. I wanted one thing. I wanted the code complete to tell me all of the methods and properties of the MYSQLI connection I had forgotten. The problem comes down with PHP’s lack of typing which creates a whole host of issues. In this case, it makes code complete impossible. If I declare the objects in a local scope, it works just fine because the IDE of your choice has enough intelligence to sniff out the object’s type. However, when you have a greater scope, like a class property, it would be impossible to predict the type. Since PHP rides loose with its typing, there’s simply no sane way to predict what the object will be. I could, at any time, assign a string or an integer to that database object. If I was trying to write an IDE with code complete, I could probably get close, but you eventually run aground on the lack of typing. That’s the one thing .Net gets right. You can type your variables. Of course, you could declare things as objects, set things to nothing and use all of those terrible practices visual basic allows. You could also program while wearing a metal strainer on your head and while soaking your feet in a bucket of cottage cheese. You can also turn on Option Strict, avoid data grid controls and use try catch blocks properly. However, the only way to get types in PHP is to enforce your own using instanceof and comparison operators. In short, fuck programming in PHP. It’s a powerful language. It can do amazing things. However, I consider its lack of enforced typing to be an incredible drawback. I, for one, am strongly for typed languages. |