|MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA|
ColdFusion MX on Mac OS X, Part 1by Dick Applebaum
Editor's note--In this series of articles, Dick Applebaum discusses the evolution of ColdFusion MX, one of the hottest new Web development products, and how to get ColdFusion MX running on Mac OS X.
What is ColdFusion?
ColdFusion is a system for rapidly developing and deploying Web sites, particularly those that involve interaction with databases and the presentation of dynamic results.
In a few short years, ColdFusion has become one of the major players in the highly competitive environment of hosting and delivery (serving) of Web applications. There are many reasons for the popularity of ColdFusion, but I'd like to focus on those that I think are most important from a Web developer's point of view.
A Little Personal Background
I've been developing Web sites since 1997. I use programming to give the sites capability beyond serving static HTML pages. Like many others, I began with Perl CGI programming and even wrote a few Perl shopping carts, for my own amusement. Sometimes, a client needed some modifications to existing programs, so I also wrote some ASP and hybrid applications.
Drill-Down and Dynamic Data
At the server, I would design my programs so they would efficiently deliver pages in smaller, more digestible chunks.
For example, one site displayed news articles. We could have designed it to retrieve hundreds of long articles then download them for display on the browser. This would probably take several minutes and the user would likely get bored and move to a friendlier, more responsive site.
Instead, we retrieved and downloaded the title, author, and a short abstract of the top ten news articles. This only took a few seconds! The user could click on a specific article to retrieve and display the complete text in a pop-up window (another few seconds). Alternately, the user could browse through the next (or previous) ten articles or jump to the first, last, or intermediate groups of ten. Each browse action initiated another request to the server for another group of ten article abstracts.
A third option was to search the articles for such things as keywords, authors, source, and so on, to display a list of articles and abstracts that matched the search criteria. As above, the user could navigate through the matched articles in groups of ten.
With this approach, called drill-down, the user can quickly and easily browse large amounts of data and focus on the specific information desired. The user experience is an interactive "Click and Go" rather than "Click and Wait".
You might say: "I've seen lots of sites that work this way". That's the point. It's a pretty good way to design a Web site. It doesn't overload the server, the communication lines, the browser, or the user with volumes of unnecessary information. But, as we'll see, this requires extra design and programming effort.
To support this interactive user experience, some work needs to be done in the programs that run server-side. We must:
Most of the early Web programming languages do little or nothing to assist the developer with these requirements. Many languages do not even support databases without first installing add-on components. So you end up having to do all the work yourself in each and every program that uses drill-down or dynamic data.
From its inception, ColdFusion (CF) was designed to integrate database with Web presentation. CF hides a lot of the messy details of interfacing a database. You don't need to devote your valuable developer time to understanding and programming these details. CF does that for you. Instead you focus your attention on the needs of the application. Here are a few ColdFusion benefits for our drill-down example:
All these things are built into ColdFusion and designed to work together. They make it easy to accomplish drill-down presentation of dynamic data. So, from a developer's point of view, it's much easier to write complex programs with ColdFusion than with other programming languages.
Application Program Maintenance
The Web changes rapidly, and the sites that don't keep up with the changes will likely languish. An often-ignored part of Web development is the cost of maintaining a Web application over time -- usually by several different people.
ColdFusion programming uses English-language tags such as
Prototyping and Rapid Development
When a developer interacts with a potential client, the client may have only a general idea of what he or she wants from the Web site. The power and compactness of the CF language make it ideal for quickly prototyping the "look and feel" of the site to show to the client. Using CF, the developer can easily:
It's a simple matter to put together such a prototype, deploy it, then demonstrate it in the client's office, or even over the phone. So, from a developer's point of view, CF helps to determine the clients' needs and demonstrate a prototype solution without investing a lot of time and dollars. And you, as the potential developer, get to "Strut your stuff".
The Macro Power of ColdFusion
ColdFusion has a full complement of powerful tags and built-in functions that make it easy to tackle almost any Web-programming task. By this, I don't mean that you can write macros with CF; rather, that the ColdFusion tags and functions themselves are powerful macros. To illustrate the significance of this, here's an example:
When I first became aware of ColdFusion, I wanted to test its capability by writing a "Real Application". I had recently completed a Perl shopping cart program that was about 100K of liberally commented code.
I copied this into a blank ColdFusion template (program file). Then, I went through the program routine by routine, analyzing the Perl statements and converting them to CF statements that give the same results. As I'd convert a group of statements, I'd comment out the Perl and include the CF tags intermingled with the comments.
After several hours of this, and some testing, I had an operational CF program with hundreds of lines of "Perl comments." I zapped the "Perl comments" and I had a CF program that was smaller, ran faster, and was easier to understand than the Perl original. I was amazed how easy it was to replace lines of Perl statements with fewer, more powerful, CF tags.
Consider a little routine to calculate a cookie expiration date, seven days after today's date. It's not as simple as it sounds. You must take into consideration month-end, year-end, leap year, and so on. This took about 30 lines of somewhat cryptic Perl code. In CF the replacement one-liner reads:
All in all, I was able to throw away 75 percent of the Perl code.
In this case, macro programming means replacing one for many. This is truly a power feature that sets CF apart from other Web programming languages. With CF, developers can be more productive, competitive, and profitable!