| [<--Prev] [Next-->] | ||
| [Printable Version] [Search: ] [Daryl's TCP/IP Primer] [Daryl's ColdFusion Blog] |
![]() |
ColdFusion is a programming language. Like Java, in the sense that it is nothing by itself; it requires a programmer with vision and skill to make anything useful out of it. Like Visual Basic, in the sense that the language is tailored for a specific purpose, but general enough to accomplish most any task easily within that scope. (Visual Basic is designed to make applications for the Windows environment; ColdFusion is designed to make applications for the Web server environment.)
ColdFusion was originally designed for allowing database contents to be easily displayed in Web pages for any browser, without plugins, by manipulating the HTML output of a Web browser. Since the browser is fed nothing other than standard HTML, no plugins are needed.
ColdFusion also makes gathering, manipulating, and
presenting data from other data sources easy, including other Web servers, FTP
servers, ASCII data files, POP mail servers--not even COM and CORBA objects are
safe
Most programmers are used to working with procedural or object-oriented (oop) languages like Pascal, C++, and Java. The "run-time" environments for these languages are similar: you start an application, the application runs, and then the user quits the application. A continuous "state" is created at startup, maintained throughout the operation of the program, and destroyed (or saved) at program shutdown.
A ColdFusion template (think "program" or "program module") is processed when a request is made to the Web server. Once the template has completely finished processing, the Web server sends the HTML generated by the template. (Not even one byte of output is sent to the browser until the template has completely finished.) During a template's execution span, it may prepare and send several SQL statements to be processed by ODBC database systems, or prepare and send HTTP requests to other Web servers, or do whatever else is necessary to acquire and format data for the end user.
ColdFusion's primary strength is its ability to actively "glue" systems together. Sometimes dynamically writing SQL statements, sometimes gathering related data from other systems, and sometimes altering or outright writing JavaScript statements to be sent to the client browser, ColdFusion acts as middleman and traffic cop. Because you can be working with four or more programming languages in the same template (I'm counting SQL and HTML as "programming languages" here, though that's being generous,) it's extremely important to remember which language you're working with at any given time, especially since you'll often find ColdFusion expressions or tags embedded in any of them.
ColdFusion is designed to be embedded in other languages--most notably HTML. It is designed like HTML; most of its major capabilities are accessed through tags. Just as <TABLE> and </TABLE> mark the beginning and end of an HTML table, <CFQUERY> and </CFQUERY> mark the beginning and end of an SQL query in ColdFusion.
SQL is designed to easily and conversationally retrieve and manipulate data stored in any form of relational database (or manipulate the databases themselves, but I'm not going into that in this Primer.) SQL statements are executed outside of ColdFusion; once the </CFQUERY> tag is reached, the SQL generated within the <CFQUERY> tag is sent to the SQL database engine (Access, Oracle, NonStop SQL, or whatever.) The ColdFusion server waits for all of the results to be returned, then resumes processing of the template.
Someone once asked me which is faster, a ColdFusion database or an Oracle database. The question was nonsensical. (What coffee tastes better: Maxwell House or Mr. Coffee?) I was reminded of the Dilbert comic where Dilbert's boss asked him to build a database. Dilbert was fairly sure his boss didn't understand what he was talking about, so he asked his boss what color he wanted that database. 'I think Mauve has the most RAM...'
| * |
At the risk of being redundant, ColdFusion is not a database system. ColdFusion is an applications development language tailored toward presenting data retrieved from SQL data sources in HTML format. |
JavaScript is designed to make a browser a complete programming environment; unfortunately, due to severe compatibility problems from browser to browser, its practical use seems (in my humble opinion) limited to basic forms automation. Since some people turn JavaScript off in their browsers, or run browsers that don't support JavaScript at all, I try to restrict my JavaScript to non-critical features. On internal systems with a predictable browser set (such as company intranets) I will use more JavaScript.
About the only things JavaScript and Java have in common are the name, and some basic syntactic elements. I generally try to avoid Java applets in Internet systems; they often take way to long to load, their window size is static, and most of the features you'd use an applet for can be implemented in a simple, standard, HTML-based manner. When graphing is required, however, you will often find me using ColdFusion to write parameters for the KavaChart applets, available at http://www.ve.com/.
It's also critically important to keep in mind when and where these languages are executing:
| * | It is very easy to forget which language you're coding in from one line to the next. One of the biggest hurdles novice ColdFusion programmers have to overcome is remembering where, and when, code from various languages is run. For example, you cannot change the processing of the ColdFusion portion of a given page using JavaScript, because the JavaScript is not processed until after all of the ColdFusion code has been processed, and the Web server has sent the resulting HTML to the browser. |