Cross Operating System ColdFusion Development Guide (First Draft)

This post is more than 2 years old.

Wow, that title is a heck of a lot more serious than I intended it to be. A few days ago I was working with some code Dan Swizter had written for BlogCFC. I ran into an issue when code he had written failed to run on my Mac. It turned out to be a simple enough mistake, but it occurred to me that it may make sense to create a simple list of development guidelines for ColdFusion programmers to ensure maximum portability of their web applications across Windows, Linux, and Mac platforms. I'm just starting this guide off with a few tips, and I hope my readers can help flesh it out. Once enough content is gathered, I'll create a proper document for it and link it up from the Guides pod to the right. So without further ado, here are some things to keep in mind when writing your code.

  1. When it comes to creating file paths, don't worry about \ versus /. Just use /. The / character will work on Windows, OSX, and Linux systems. Yes, you can write code to check for the proper file path separator, but if you are just reading or writing to a file, why worry about it?

  2. Don't let case sensitivity ruin your day. On more than one occasion I've worked with code that was fine on OSX and Windows, but failed on Linux because of case sensitivity issues. The simplest solution is to simple lowercase everything. Ie: klingon.cfc, ships.cfm, index.cfm, etc. Of course, the exception to this are the files ColdFusion use for application-specific functionality: Application.cfc, Application.cfm, and onRequestEnd.cfm. Everything else though should be lowercased.

  3. Minimize the use of operating system specific features called via cfexecute. This may be out of your control, but if you write CFML that makes use of cfexecute to run command line code, you want to ensure you are using a command line tool that runs on multiple operating systems, and runs with a similar API. You may not be able to though, so at minimum, this is a perfect example of something that should be carefully documented for your client so they are aware of the dependency.

Ok, what am I forgetting folks? Try to focus on things that should apply to most cases. Odd edge cases may not make sense in a general document like I the one I want to create. (But those tips could always be added to an Errata section).

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Mark Jones posted on 5/6/2009 at 5:37 AM

Don't forget that case-sensitivity applies to SQL, too: Table names (but not column names) are case-sensitive in MySQL on Linux, by default. Ran into this when a host's Windows CF plans used MySQL databases hosted on Linux servers.

Similar to / vs \, never hardcode paths: always use expandpath() and/or relative paths; that way you don't have to worry about C:\. That's just a general portability tip, though.

Keep a tight control on all external technologies needed, not just cfexecute calls. URL rewriting, for instance; for IIS, I use ISAPI_Rewrite v3 because it's compatible w/ apache-style .htaccess files. Assuming you're not going to be running Apache on Windows, anyway.

It's also another reason to avoid Access databases; Access DSNs are only available on Windows hosts.

Those aren't strictly CF-specific, but combined with what you've already got, they're everything I've run into thus far with my Windows-office, Linux-home, mixed-host experience.

Comment 2 by Elliott Sprehn posted on 5/6/2009 at 7:01 AM

Seems you've never seen the "Hi I'm Linux" adverts before!

Linux is a woman, not someone from Tron. :)

Comment 3 by Justin Lewis posted on 5/6/2009 at 9:21 AM

Since it runs on the JVM and it's supposed to be platform agnostic, I guess there's just file write operations like you mentioned.

- Get in the habit of using getDirectoryFromPath() and it's ilk for file operations?

I believe cfexecute on linux invokes fork() and that can be very bad - I don't know how windows handles it.

You could almost extend this into an Apache vs IIS discussion and there would be some more things that pop up.

I don't know what the limit on windows based machines but there is a ulimit max on UX machines that is like 2000 open files so if you are doing a bunch of file reads in high traffic it can hurt.

Comment 4 by Christoph Schmitz posted on 5/6/2009 at 3:35 PM

- If you have the chance, use a case sensitive file system for development. OS-X file systems can be case sensitive, too. ;-)
- Use VMs to test on various operating systems!


Comment 5 by Rob posted on 5/6/2009 at 3:40 PM

I ran into that with the QueryParam Scanner project on RIAforge. The last update was not reading directories on any Unix-based filesystem (I tested on both OS X and Unix). It turns out the problem was how he had written the code to recurse the directories, he had written it solely for a Windows system. I sent him a patch that I wrote to get it to work on all environments, but I'm not sure if he ever released it or not.

My work servers are all Unix, and my personal development is OS X. My Personal production is windows, so I set server specific application-level variables mapping out the directories and using the "proper" slash syntax for each. I did not know that forward slashes would work in Windows, thanks for that tip!

Comment 6 by Michael Brennan-White posted on 5/6/2009 at 4:13 PM

Will the Bolt IDE be restricted to Mac and Windows like the new versions of Flex Builder?

I certainly hope not

Comment 7 by Raymond Camden posted on 5/6/2009 at 5:09 PM

@Michael: Only Adobe is allowed to talk about Bolt. You know that. ;)

@Elliott: No one is better than Tron guy though.

@All: Thanks for the additions, keep em coming.

Comment 8 by Adrian J. Moreno posted on 5/6/2009 at 5:31 PM

Ray, I've got a post that covers a lot of this:

Plus as of 8.0.1, CF has become even more case-sensitive:


Comment 9 by Andy Sandefer posted on 5/6/2009 at 6:23 PM

I think that Flynn would have been a better representation of Linux because he's a true coder!

Comment 10 by Patrick posted on 5/8/2009 at 3:56 PM

I use <cfset application.fs = createObject("java", "java.lang.System").getProperty("file.separator")> to fight \ vs /

Comment 11 by Raymond Camden posted on 5/8/2009 at 5:02 PM

@Patrick: Of course, the point I had made was that many times, you don't NEED to know the 'real' separator. Just use /.

Comment 12 by Andy Sandefer posted on 5/8/2009 at 6:07 PM

If I can chime in here...
This was fresh in my mind yesterday when I was coding a multi-file uploader for a client and I used Ray's forward slash setup in a Windows environment and it worked like a charm. I've seen many postings arguing about this in the past and I'm really starting to believe that many CF developers are making more out of this than necessary. What are you gaining by throwing down the java? Everyone acts as if there is to be no time or thought spent when deploying an application in terms of what environment it will live in. If you have to store a bit of path data in a database table or your Application.cfc file and take a minute or two when deploying the app to set it up then so be it. I'd rather spend my time on feature development then geeking out over the file system.

Comment 13 by Raymond Camden posted on 5/26/2009 at 1:39 AM

Guys, I finally made time to 'formalize' this into a page on my blog:


Thoughts? I appreciate all the comments here, but I only specifically called out folks where I used their content in the guide. If that is bad, let me know!

Also, I realize the guide may not be perfect, but is it ok for a first real release? Will it be useful?