Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript
Megnut

Web Topics
All Articles
Browsers
ColdFusion
CSS
Database
Flash
Graphics
HTML/XHTML/DHTML
Scripting Languages
Tools
Weblogs

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab






ColdFusion MX on Mac OS X, Part 1
Pages: 1, 2

ColdFusion MX

Since my introduction to version 3.0 (ages ago, in 1997-98), ColdFusion has gone through several major releases, each with its own set of new features that often setting the pace for others to follow.



The latest version of ColdFusion is part of the MX family and includes some exciting new features. For an overview, you might want to visit Macromedia's site.

Related Reading

Programming ColdFusion
By Rob Brooks-Bilson

For the purposes of this article, I want to focus on the most significant features of this release (in no particular order):

  • XML integration -- CFMX includes tools for manipulating XML data. Prior releases relied on the Web server or custom tags to process XML. New XML functions make it easier to create, manipulate, and exchange XML data from within a CFMX program.

  • Flash integration -- With CFMX it is easier to develop sites that provide "Rich Content" such as complex data, graphics, animation, and sound. By designing the new versions of Flash and ColdFusion to work together, Macromedia has streamlined the communication between client and server.

  • Web Services -- Earlier releases of CF had the capability to harvest information such as stock quotes, flight schedules, shipping rates, and so on, from other Web sites. But, the process was tedious and inefficient. The interface was problematical in that it would likely break if the target site changed its format or structure. A growing trend is to formalize the interface for inter-site communication as Web services. CFMX provides the ability to easily and efficiently publish and consume Web services.

  • Java Interface -- CFMX makes it possible for ColdFusion programs to coexist with, interact with, and share data with Java programs.

Speaking of the Java interface, this environment provides you with the best of both worlds:

  • The CF advantages of rapid development and deployment of prototypes or production applications.

  • The CF advantage of a short learning curve and quick-start development.

  • The broad acceptance and platform independence of Java programming.

  • The power and efficiency of the Java environment.

  • The ability to combine Java components from several sources (vendors) and interoperate among them in a single application.

You can develop parts of an application with ColdFusion, and other parts with Java. So, this environment can serve as a gentle introduction to Java programming. CFMX is a self-contained representation of the Web server environment (everything you need) that can be installed on a local machine with a free developer license.

ColdFusion MX and Mac OS X

"What about us who use a Macintosh for Development?"

I've always used a Macintosh to develop Web sites that use ColdFusion. But I couldn't install and run ColdFusion on my local machine. As an alternative, I could emulate Windows, and run ColdFusion under emulation. But this approach is slow and cumbersome -- not really a practical solution.

My other option was to write CF programs and upload them to a machine that runs ColdFusion, which isn't too bad. But, I still would look longingly at Windows and Linux developers who could install everything on a portable. They could prototype, develop, test, and demonstrate anywhere, anytime, with no need to connect to another machine.

Of course, this wasn't unique to ColdFusion. Other popular Web languages didn't run on the Mac either. With the release of Mac OS X, however, the situation is getting better for Web developers. Mac OS X ships with Perl, Java, PHP, and the Apache Web server. And, although not part of the official Mac OS X distribution, there are several open source (free) or commercial database systems you can download and install on your Mac, such as PostgreSQL.

So, now the Mac has a robust Web server, solid database options, and a variety of programming languages. That's everything you could ever ask for, right?

Well, except that Macromedia hasn't released a ColdFusion server that will run on Mac OS X, at least not directly. Fortunately, Mac OS X includes Java, which with a little work, enables ColdFusion MX to run directly on your Mac.

A Nickel Tour of CFMX and Java

We've talked quite a bit about ColdFusion MX and Java. To help you understand how these pieces work together under Mac OS X, let's take a little tour.

The Physical Machine environment

Diagram.

All programs eventually get reduced to a series of ones and zeros that are recognized as instructions by the computer's Central Processing Unit (CPU). Each make of CPU has its own set of instructions. This means a program written for an Intel CPU won't run on A Motorola CPU and vice versa. So a software company or a developer must write and maintain a separate set of programs for each CPU they want to support. This can be costly.

The Virtual Machine environment

Over the years there have been several attempts to eliminate the need to create a separate set of programs for every CPU manufacturer. One way to do this is to define an instruction set for a hypothetical machine (called a Virtual Machine) that's tied to no particular CPU. We then can write all our programs using the Virtual Machine's instruction set. However, to actually run our programs we must write one additional program (a Physical Machine Language program) -- one that translates the Virtual Machine's instructions to a given CPU's instructions.

We need write this translator only once, then every Virtual Program will run on (be translated to) that specific CPU. To support additional CPUs we need only write a translator for each one. There are lots of advantages here:

  • Your single set of Virtual programs will run on CPUs from multiple manufacturers.

  • You can upgrade your programs to a new CPU by simply writing a translator, instead of rewriting all your programs.

  • You don't really need to write the translators -- the hardware manufacturers will do this to enable them to sell their machines.

Diagram.

Java from Sun Microsystems is the predominant Virtual Machine -- there are translators for virtually every popular CPU -- this is what makes it possible to run CFMX on Mac OS X.

The Java Virtual Machine environment provides much more than a Virtual instruction set and a translator. Commonly-used functions and routines have been pre-written for us so we don't need to reinvent the wheel. Some examples are of built in functions are:

  • Draw a circle.

  • Search text for a phrase.

  • Calculate the square root of a number.

Java contains hundreds of these built-ins (called classes) and they greatly simplify our programming.

The Application Server environment

The computers of today are powerful and fast enough to run many programs concurrently. Several different programs may use a common set of business logic or services, for example:

  • Validate a customer's credit limit.

  • Log a transaction.

  • Update the database.

  • Send an email.

Rather than duplicate these functions in each program, we can package them as separate Java programs that perform them as services. Our program communicates with these services by sending messages to them and receiving results from them.

Diagram.

In our CFMX/Java world, all the services are written in Java, or are a Java program interface to an external program written in Java or some other language. The Application Server environment is provided by JRun, which is distributed with CFMX and also available as a separate product. JRun is written in Java. It consists of a kernel and a set of services.

We can write our own functions and business logic as Java programs and add them as new services, or write our application in Java and use the other services through the JRun kernel.

ColdFusion Web Application Server environment

We may choose to write our Web application programs in ColdFusion -- the advantages of doing so have already been discussed. We write the program in ColdFusion Markup Language (CFML), then save it with a special suffix (.cfm) in a place that is accessible to JRun.

When the Web Server service receives a request from a browser for a .cfm template, it passes the request through JRun to the CFMX service -- we'll call this the Web Application Server service.

Diagram.

The CFMX Web Application Server service reads the .cfm template, interprets the CF instructions, and passes the results back through JRun. Now, we can modularize our CFML code, too. We can have separate templates and functions that can be used by making requests through JRun.

We can also use the other services available to JRun by invoking them with a CF tag, for example, a cfquery tag will be interpreted to pass a request for db services through JRun. In this context, CFMX is just another specialized service available to JRun -- a service that interprets CFML.

This is the end of our nickel tour of CFMX and Java that provides just a glimpse of the highlights. I hope I've provided you with at least a big picture of what's there and how it all works together.

What's Next?

In Part 2 of this series we'll explore the various components of CFMX Web site development and how they interact with one another. Part 3 will take you through the steps necessary to get a CFMX Development system installed on Mac OS X.

Dick Applebaum has been doing Web development since 1997, primarily with ColdFusion -- including his latest challenge to port ColdFusion MX to Mac OS X.


Return to the Web Development DevCenter.