CFUnited 2009: Adam Lehman - ColdFusion 9, What's New

First up was Server.cfc. However that is a bit of a misnomer. You can actually point the administrator to any CFC. That CFC simply needs to have an onServerStart() method. This should be quite a boon for getting sites that have an expensive (read "slow") first request all spun up and ready for traffic.

Next up was nested cftransaction. Not a lot to explain here. From what I saw, it should satisfy you if you ever said to yourself "I really wish I could nest transactions in CF".

Then we got introduced to cffinally/finally. I personally have never used this even in languages that I have access to it. Basically it gives you this syntax: "try { ... } catch (e) { ... } finally { ... }". If someone wants to explain an compelling use case for "finally", I would love to hear it...

And then there was cfcontinue and it was good. Seriously! I mean, I'm excited about this one and at the same time amazed it took them this long.

So, Adobe has "enhanced" its implementation of implicit structure and array syntax. In CF9 you can use them as expressions (as an argument to a function call, as an attribute of a tag, etc). Basically you can use them in other tags than <cfset />. I know, shocker!

You will also be able to use assignment chaining. Example: "a = b = c = 1;" Which would set a, b, and c all to 1. Personally, I see "some" limited uses for this. But, don't let Sean Corfield know your using it, or he'll fire you.

You will now have direct access to elements of arrays returned from functions. Example: "obj1 = getArrayOfObjects()[1]". I have tried this before, and never understood why it didn't work. So, I'll probably find this useful at some point.

And CF9 will now support a "real" ternary operator. Example: "a = (b < c)? b : c;". This is the equivalent of "if (b < c) {a = b} else {a = c}". Someone asked if you could uses this anywhere. And the answer was "yes". So, you should be able to use it like this: "foo = getSomeValue(arg1 = ((b < c)? b : c))". In this case arg1 will either be the value of "b" or "c" (whichever is less).

Next up was CFScript enhancements. You can now fully define functions and components (access, returntype, argument types/defaults/etc) in CFScript. This is done with JavaDoc style notations for documentation and metadata.

There are also quite a lot of CFC enhancements too. There is now a "local" scope in functions. For example, <cfset local.myVar = 1 /> is the same as <cfset var myVar = 1 />. And you can now use the "var" declarations anywhere in a function. I can't wait for this. I'm used to this from JavaScript and never understood why it was so rigid in CF. Also, CFCs can have automatic getters/setters based on <cfproperty />. CF9 will also introduce the "import" and "new" keywords. I think this will make more sense to developers when coming from other languages than "createObject("component",com.foo.bar).init('bla')". Check out how this will look below.

<cfscript>
      import com.demo.*;
      user = new User('Adam'); /* Runs the "init()" or "user()" function. */
      user.setLastName('Lehman');
      user.location = 'Las Vegas';
      user.persist();
   </cfscript>

They also showed us ColdFusion Builder. It's a CFML editor built in Eclipse. That's cool and all. But, it's not really part of the CF9 Server. So, I don't think I'll go into the details here. If you're curious, go check it out on labs.adobe.com.

CF9 will also have IMAP support. Not much to explain there. IMAP is what GMail uses. So, now you can do Google Apps email integration.

There will also be significant enhancements to what you can do with PDFs. CF9 will be able to generate "PDF Packages" (which are apparently like a zip file of PDF documents and other files). It will be able to add/remove headers and footers. There will be tools for optimizing PDFs. This will make them smaller in size by removing unused elements and down-sampling images. You'll also be able to extract text and images from existing PDFs. And you'll be able to generate higher quality thumbnails.

There are lots of MS Office Integration enhancements. You will be able to create, read and merge spreadsheets with <cfspreadsheet />. They will have support for Excel 97, 2000, 2003, 2007, and 2008 (oh! and Open Office). You will be able to generate PPT files from CFML/HTML content with <cfpresentation />. This will also be able to convert PPT files to HTML or Flash format. There will also be SharePoint Integration via <cfsharepoint />. There are like 50 different things this can do.

Adam told us about ORM (Object Relational Mapping) in CF. This has got to be one of the most important features if you ask me. I mean, they had <cfinsert /> and <cfupdate /> before. No one has recommended using those for years. One of the things that everyone always says about CFML is how easy it is to interact with databases. Well, now you will be able to save CFC data to a database without writing SQL. This will make it possible to build database independent applications. And it's bi-directional. So, you can configure CFCs that key off of existing databases. Or have databases created based off of CFC metadata. And it's all powered by Hybernate. Hybernate is THE industry leading ORM. Hybernate is very robust and mature (and some could say a little complicated).The CF9 ORM implementation simplifies the use of Hybernate (to the point of being nearly invisible). If you haven't already, I think that this would be the feature that should compel you to go download the CF9 beta from labs.adobe.com.

There will be advancements to Caching. CF9 will have an object cache (generic objects) in CF that is built on top of ehcache. I can vouch for how cool ehcache is. In fact there are already some projects on RIAForge that help you leverage ehcache in CFML. You can even have clustered caches that can keep cached data synced across CF instances. They will also have the ability to save fragments of pages to a cache. The way they described it sounded like <cf_accelerate />. If that's how it is, it should be a very cool way for people to help make their applications quicker and more scalable.

Adobe will be adding Solr on top of Apache Lucene as another option for full-text search. It sounds like it will replace Verity (and be better to boot).

CF9 brings something totally new to CF in CFaaS (ColdFusion as a Service). Basically there are a bunch of things like Pop, SMTP, Charting, Image Manipulation, PDF Manipulation, ... that the CF server will expose over both SOAP and AMF. To use the services on the server in AS3 and MXML projects, there will be a SWC that you add and then an easy to use syntax. And Flash Remoting is also supposed to be several times faster. Which is awesome, because it's wicked fast already.

And tangentially related to CF9, there will be support for an AS3 Data Persistence Library for Adobe AIR. This will support online/offline data synchronization and something that would be analogous to an ORM for SQLLight. I saw the few lines of code (maybe a couple of dozen) that this takes. And it replaces probably hundreds. This is going to be awesome.

There are some miscellaneous UI Enhancements including a multi-file upload widget, enhanced datagrid, Google maps support via the new <cfmap /> tag. That one is pretty sweet too. You can pass it in a query of addresses to plot on a map.

Last but not least is the Server Manager. This is an AIR desktop application for managing one->many servers. It does pretty much everything you could do in the /CFIDE/administrator. And can apply settings to multiple CF Instances at once. Plus it will be able to show a diff of settings between CF Instances.

This post seems kinda long. And I even skimmed over some stuff. So, um, you really should get CF9 when it comes out. Yeah. That's my unofficial recommendation anyway.

Comments
Adam Cameron's Gravatar The most common example of why one would use (cf)finally would be this sort of thing:

try {
   // open a file
   // do some file ops
} catch (any e) {
   // deal with any errors
} finally {
   // close the file
}

Basically, irrespective of whether the block being tried runs or fails, one still wants to close the file afterwards.

--
Adam
# Posted By Adam Cameron | 8/26/09 10:12 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.6.002.