Why Railo 3?
It's been nearly half a year since Railo 3 was released, and with 3.1 just around the corner it is a good time to write a post about some of the features that continue to make Railo such an excellent CFML engine!
This blog entry covers things new to Railo 3 - however, if you've not looked at Railo before, you should also look at my previous postings, as they are still valid:
1. cfdump - aborting and tooltip
Instead of having to do:
<cfdump eval=MyVar /><cfabort/>
You can do:
<cfdump abort eval=MyVar />
If no value is specified for abort, it is true (as with most attributes), or you can explicitly set it.
When abort=true, the variable is dumped before aborting the request.
When abort=false, the dump occurs and the request continues as normal.
When building multiple complex variables it can save a lot of time being able to do this, rather than having to continuously comment/uncomment aborts.
And there's another cool enhancement for anyone who does lots of dumping - simply hover the mouse over the dump output and a tooltip will tell you the filename and line number that generated it.
2. cfloop/array
Another relatively minor improvement which can help you write code faster, and make things much more readable.
Think how many times you've had to do this:
<cfloop index="i" from="1" to="#ArrayLen(Arguments.MyArray)#">
<cfset CurItem = Arguments.MyArray[i] />
...
</cfloop>
Well, with Railo 3 you can instead do this:
<cfloop index="CurItem" array="#Arguments.MyArray#">
...
</cfloop>
This is the exact same concept as cfloop/list but of course works on complex arrays rather than strings.
3. StructNew(type)
With Railo, the StructNew
function has an argument to define the type of structure it creates.
Type of structure? Well, by default a Struct is an unordered collection of key:value pairs, so whilst the value always matches a key, if you loop through the struct the order of the keys might change each time.
There are situations where it is useful to have an ordered collection, where the key order is the same every time.
The solution to this is StructNew('linked')
which will guarantee the order of your struct keys.
There is another type that might seem confusing at first - if you do StructNew('weak')
you create a structure which might have its items removed by the Java garbage collector to free up memory.
It might seem odd to want to do this, but this is ideal for using a struct as a caching mechanism which doesn't hold on to memory unnecessarily.
4. cfcontinue
This tag belongs in CFML Core - it is currently supported by OpenBD as well as Railo, and I can't understand why ColdFusion itself does not have it.
Quite simply, cfcontinue
will skip to next loop iteration, avoiding the need to have annoying nested conditionals.
For an example, perhaps you are reading a file and want to ignore certain lines...
<cfloop index="CurLine" file="myLogFile.log">
<cfif refind('^[##;]',CurLine)><cfcontinue/></cfif>
...
</cfloop>
As you can see - much tidier than having to have a negated if wrapped around the whole block.
5. cfimap
Another tag that could be considering to be missing from ColdFusion (again, this is also present in OpenBD).
Anyone who knows about email protocols will know that IMAP has many advantages of IMAP over POP3, and there is no reason not to have an appropriate tag built-in.
Railo's cfimap
implementation has identical attributes to cfpop, so it's nice and easy to use.
6. cfvideo and cfvideoplayer
Of course, no discussion of Railo 3 could be complete without covering these two multimedia tags.
cfvideo
performs actions on multimedia files. It can provide information, convert between different formats, extract images from the video, and combine multiple videos into one.
(Note: the video conversion functionality is an Enterprise-only feature.)
cfvideoplayer
is a Flash-based video player for streaming your video files. It supports grouping and playlisting videos, so you can play them all together or individually queued up.
Both of these tags have a whole host of options, giving you everything you need to add multimedia content to your site. You can read more details on these tags on the Railo blog.
7. Task Manager
A multi-purpose utility added to Railo Administrator, the Task Manager allows you to keep track of tasks spawned in a variety of ways.
For a developer, this is perhaps most likely to be via the cfthread
tag. If you have a process that you want to set running in the background, but if it fails you want it to wait a bit then try again.
<cfthread type="task" name="MyTask"
retryinterval="{ Interval:createTimeSpan(0,0,1,0) , Tries:5 }">
...
</cfthread>
The above code will create a new background task, which will appear in the Task Manager, and if it fails it will retry five times, with an interval of 1 minute between each try.
The retryinterval
attribute is very flexible and allows very complicated retry schedules.
Railo itself places tasks in the Task Manager, the main one of these being emails. If an email is failing to send you can check the error messages, and then re-send the email from the Task Manager.
8. Clustering and Synchronizing
With Railo 3 there is a whole new scope, the Cluster scope. This makes sharing data between multiple servers in a cluster nice and easy - just set a variable in the Cluster scope and it will be sent to all the other servers.
Another related functionality is synchronization of Administrator settings - if you have a cluster of servers you very likely want them to have the same configuration - instead of messing about doing this manually, Railo 3 allows you to setup remote servers and have the settings automatically sync.
Both of these use the Task Manager, so you can check this to make sure the transfers work or if there is a connection problem.
9. Growing Community
In the past year, the level of interest in Railo has increased immensely, and there are now quite a few people using Railo.
Anyone who might have been put-off using Railo because it was not mainstream enough should now be able to stop worrying and make the switch.
An example of how many people are using Railo can be seen with the vast array of installation guides which are popping up - whether you're using Windows, Linux or MacOS; Apache or IIS; JBoss, Tomcat, Resin or Jetty - odds are someone has either created an installation guide or can help you out on the Railo mailing list.
10. Soon to be Open Source
If you missed the big announcement last summer, Railo has teamed up with JBoss.org and will soon be released under the LGPL Free Software license.
So, what does this actually mean?
JBoss is a major part of RedHat, who produce the well-known Red Hat Enterprise Linux. Having such a big name accepting Railo can only be a good thing.
Railo will be a JBoss project, rather than a JBoss Product - the difference being that whilst JBoss will help support Railo, the current Railo team will continue to operate independently.
JBoss is of course a Java-focused community, and this means Railo will be presenting CFML to many new potential users, which has the potential to help grow the whole CFML community.
Railo will not require the JBoss AS server, and will continue to work with other non-JBoss servers, such as Resin, Jetty, and others. However there is the potential for additional JBoss-related features to be easily intergratable if you are using it.
The LGPL allows Railo to be distributed with any other software, and does not require you to release this other software under a compatible license (like the GPL does), but you can if you like.
(This can be seen as both a benefit and drawback, depending on your perspective, but purely from a practical stance, it does avoid potential complexities that using the regular GPL might bring.)
All in all, this proves that Railo is a serious CFML engine, and definitely worth looking at.
And that's it, a selection of ten reasons you should take a look at Railo 3 today.
There are many more benefits to Railo, and plenty of other improvements which Railo 3 brings, but why not download Railo now and discover these for yourself?