Monday, February 8, 2010

Let the battle continue | ColdFusion vs PHP

I’ve read many many………..blogs from developers doing their comparisons between ColdFusion and PHP and while some do have really good points I personally think they all tend to attack basically the same subject almost every time. The subject in mind should be obvious if you’re a developer that must have working knowledge of multiple server-side languages under your belt, as I sure do. One day I could be developing in ColdFusion, the next PHP or even some classic ASP on rare occasions.

Before I go into it I must state that I could care less what language I will be programming in any day, any time. Give me a language I haven’t seen before and I will figure it out as because lets face it, they’re pretty much the same here and there but mostly there.

First off, the obvious, database stuff:
Every ColdFusion developer knows that making a connection to a database server and querying database records is as easy as cracking open that first beer. As for PHP it can be done also with ease. Only difference I see is that you keep your database connection settings somewhere on the server or in the site directory. The annoyance for PHP is querying some records. If you’re a noob to PHP, you might find it difficult but if you’ve done it a couple thousand times, it should be second nature but ColdFusion is of coarse better at doing database stuff.

Now for syntax stuff:
As for ColdFusion’s syntax, it’s similar to HTML and is suppose to be easier for developers to understand and sure sure, it is in fact easier to look at but that’s about it really. PHP syntax should be very familiar to any developer that has played with languages that contain the norm of curly brackets, concatenation, escape characters and echoing out your variable values and such. One thing that I think PHP might have up on ColdFusion in the syntax stuff is that a developer who is familiar with Java, JavaScript, C++ and even C# can easily have an understanding of the mark up. Not a huge thing mainly because ColdFusion has the cfscript tags that you can use if you prefer to code in the norm.

Storing an include into a variable:
I might get whined at for this one but PHP is definitely better at this. For PHP, all you do define your variable and put the path to your include into a string via the include() function and that’s it. As for ColdFusion, you use the cfsavecontent tag which is a bit much to be honest. Yea, I know, if your programming via custom functions you can include the file that way and call your method but that’s not the point I’m making here. Know matter what, PHP got this one.

Opening and closing tag stuff:
ColdFusion and PHP are the same here BUT their not. For ColdFusion, you can put all your code into the page without having to worry about opening or closing sections of code when you need to put in some CSS or HTML. Not the case here for PHP and it’s definitely annoying to look at a page and all you see are opening and closing PHP tags all over the place. ColdFusion got this one, no doubt.

Function argument stuff:
Sorry Cfer’s but I think PHP wins this one also. To include an argument into your functions via PHP, just toss them into your functions ($parentheses) and delimit them by a comma as norm. For ColdFusion, you use cfargument to include any arguments to the functions. One thing that ColdFusion’s cfargument tag does have is the ability to set the type of the argument as well as if the argument is required. You know what, think I’ll call this one a tie because they both have their goods and bads.

File upload stuff:
ColdFusion is a beast when it comes to file uploads for sure. Use the cffile tag and toss in some common logic and you’re golden. But for PHP you gotta write the file as temporary file, do common logic, then use the move_uploaded_file() function to do more logic. ColdFusion got this one without even thinking twice.

Image manipulation stuff:
This one might be a toss up but we’ll see. ColdFusion has a boat load of image functions already available without installing anything special. Just open the image via ColdFusion and start messing around with it. That’s about it really. PHP is kind of the same but with some things that may or may not create some headaches. To do some playing around with images via PHP you must have the GD library installed and in some cases I’ve seen this installed by default but it all depends on the server really. Once you have the GD library installed you can pretty much do the same thing you can do with ColdFusion, such as resize, flip, crop, draw and tons more. But for the sake of having less headaches, I’m gonna give this one to ColdFusion only because image manipulation is there already and there’s no need to install any junk.

Community stuff:
Whoooooaaaaa buddy does ColdFusion have this one in the bag, in fact two bags……….maybe three. The ColdFusion community is just badass to say the least. Ask a question about ColdFusion on Twitter and you’re flooded with responses. BUT ask a question about PHP and nada, nothing, not even a peep will come from it.

Other general stuff:
ColdFusion and PHP both have the normal functions that every language has such as creating and manipulating an array structure, zipping files up, executing .exe or unix binaries, error and exception handing, support for basically any database, a form of creating application wide variables and security functions for SQL Injection.

Let’s face it, every language has their annoyances even Microsoft’s beloved .NET, but all that matters is how you handle those annoyances, which is one of the main reasons why I love programming as much as I do. You get a job, you start that job, run into walls while working on the job, you figure out how to break the wall down and you get to raise you arms up in the air like you won a battle.

In my opinion and that’s all it is. Is that the community for any language should be willing to give each other a hand or even some solid knowledge about how to accomplish certain things especially to the newcomers and this is where ColdFusion definitely wins the battle.

- Pete

No comments: