What Open Source License Should I Choose?

Do you have a project you're working on and want to share with the world, but just aren't sure about all of this "licensing legal mumbo jumbo"? Take a look at the latest post from the guys over at the For ColdFusion Foundation.

They have posted a document with great information about open source licensing.

It's a quick read with lots of valuable information!

Cheers, :) Jason

Serializing / Deserializing in ColdFusion 9

Today I was asked a question about serializing a CFC. Someone wanted to serialize the CFC for later use outside the current process.

Prior to ColdFusion 9, serializing a complex object in a way that could be deserialized back to a usable object within the runtime could be done by diving a bit down into the underlying java. This could only be done with CFCs as of CF8 as the serializable interface was added at that time. For those of you not on CF9, the code below can be used to serialize/deserialize objects in ColdFusion.

<cfscript>
function serialize(myObject) {
     // Create the underlying ByteArrayOutputStream
     byteOut = CreateObject("Java", "java.io.ByteArrayOutputStream");
     byteOut.init();
        
     // Create the ObjectOutputStream to which the object will be written
     objOut = CreateObject("Java", "java.io.ObjectOutputStream");
     objOut.init(byteOut);
    
     // Write the object to and close the stream
     objOut.writeObject(arguments.myObject);
     objOut.close();
    
     return toBase64(byteOut.toByteArray());
    }

    function deserialize(mySerializedObject) {
     // Create the underlying ByteArrayInputStream
     byteIn = CreateObject("Java", "java.io.ByteArrayInputStream");
     byteIn.init(binaryDecode(arguments.mySerializedObject,'base64'));
        
     // Create the ObjectInputStream to which the object will be read in from
     objIn = CreateObject("Java", "java.io.ObjectInputStream");
     objIn.init(byteIn);
    
     return objIn.readObject();
    }
</cfscript>

With ColdFusion 9, this is much simpler, but unless you've already looked at the other 200 new functions for CF9 you probably haven't seen this. With the new ObjectLoad() and ObjectSave() methods, now all you need is the following:

<cfscript>
    function serialize(myObject) {
     return toBase64(objectsave(myObject));
    }

    function deserialize(mySerializedObject) {
     return objectload(tobinary(mySerializedObject));
    }
</cfscript>

Heck, you don't really need the UDF's if you can remember to use two functions for this. :)

Now you can easily serialize an array, CFC, query, java object, structure... pretty much any object in ColdFusion.

Why would you want to do this? How about caching objects to your database to be retrieved later? Or maybe you want to store a CFC as a string in a form field... Those might be crazy, or you may have the need for something that crazy right now. You decide what cool things you want to do with this power. :)

Jason

What's going on with 4CFF?

Many of you may have heard of 4CFF (The For ColdFusion Foundation) when we announced it at CFUnited last year, but haven't heard much about it since. Why?

First, if you haven't heard of 4CFF. Check out our site at 4cff.org. The short description is that many of us believe there needs to be a neutral, non-profit, entity that can foster, sponsor, and "own" important projects to the ColdFusion Community, to ensure that those projects are always for the benefit of the CF Community. In a sense, we are shooting for an National Endowment for the Arts model... or in the software world, perhaps the Apache Software Foundation model.

Anyhow, back to the question, what is going on with 4CFF? Well, many things actually, but not enough. First, we have been spending time figuring out what we really want the foundation to do. We are all busy people, so just adding more work to the work we all already have was not very feasible. So, we have decided on how we can support projects in a way that is easy to manage. We have been talking about which projects to support, and we have a few that are interested in becoming part of 4CFF and we are interested in them becoming a 4CFF project... but then something seems to get in the way:

  • what is the true value of being a 4CFF project?
  • what do we do about copyright ownership?
  • or in one case How much money are you going to give me for my project to be owned by 4CFF?

These have been somewhat tough questions to answer, and in my opinion it comes down to one simple answer: money.

I don't mean that in a negative sense, the truth is that the world we live in operates on money. So, we have switched our focus temporarily to getting our 501(c)3 status. What is that? That is the thing that says the IRS agrees that what we are doing is for the benefit of a community of people and not just for our own benefit. By recognizing that, it allows donations to be tax deductible, which means your money is even more meaningfully applied. The Foundation gets more money, you get a tax break, it is a win-win.

Recently, we have been working with lawyers to apply for 501(c)3 status. My hope is that if we can get the organization to be officialy recognized as a tax exempt non-profit, then people and corporations are more likely to open up their checkbooks. Corporations and individuals that use these projects will have a vested interest in donating, to ensure that they will have even better software in the future. And once we have some money, we'll be able to make useful grants to projects, and once we have projects we will have more people interested in volunteering and something useful for them to volunteer to... then we keep repeating so that we have spectacular software that is for the CF community, and owned and supported by the community. It is a feedback loop and we just need to figure out how to get it started.

I want to be clear, everyone participating in 4CFF is doing it in a strictly volunteer basis. The ColdFusion world has already changed my life, I want to give back and I want to help make our community stronger. I know the other volunteers to 4CFF feel the same way. Those people are (in alphabetical order): Ray Camden, Sean Corfield, Sam Farmer, Rachel Lehman, Doug Morrison, Jared Rypka-Hauer, Chris Scott, Dan Wilson, and John Zhu. Thank you guys for volunteering your time.

So, what are we doing? Still trying to get through the early stages of starting a new venture. Should we be further along? Yep. Why aren't we further along? A good number of reasons, but lack of dedication isn't one of them.

Can we get to the next level? I hope so. Am I a dreamer? You tell me. :)

We'll keep pushing for the dream and hope it comes true,
Jason

ColdFISH 3.0 Alpha Released

You may not know what ColdFISH is, but if you are running BlogCFC then you are using it, and chances are at the minimum that you've read a blog that does use it. Well, I've been doing some work on ColdFish due to several requests. This latest version includes:

  • XML based configuration - no need to get into the code to change a color or add a keyword
  • Keyword formatting for CFML, CFSCRIPT, ActionScript, and SQL!!!
  • The ability to tell the parser you are just looking for just SQL, CFScript, or ActionScript (it can't guess script based languages... it does figure out tag-based on its own)
  • Caching of formatted code blocks (once it's been parsed it will stay in memory until it hits the cache limit, cache size is configurable)
  • A toolbar that allows for viewing the code as plain text, copying it straight to the clipboard, or even sending just the block straight to a printer
  • A cleaner default look and feel

If you're interested in testing the alpha out you can check it out of the subversion repository at http://svn.riaforge.org/coldfish/. Feedback is very welcome!

If you just want to learn more about ColdFish, check out the project at http://coldfish.riaforge.org/

Have a great New Years! Jason

10 Things ColdFusion 10 Really NEEDS

I was reading a ColdFusion 10 Wish List today (I am behind on my blog reading) and it is largely filled with minor tweaks that are a bit too myopic for me. I think Server-side Actionscript is interesting, particularly to Flex developers looking for a back-end, but almost everything else on the list struck me as missing a broader view.

From the general list there are things like incorporating Omniture (a web analytics tool), adding message queuing (I assume this is essentially incorporating JMS directly into the language. By the way, you can do this today with the JMS Gateway), calling a CFC from Java(CFCProxy already exists too), queryparam for LDAP, multiple datasources for ORM, and NTLM support.

Really??? This is what we want for ColdFusion 10!?!

Well I want more from Adobe than that. I know we are all still catching up to ColdFusion 9 (maybe even 8,) but there are 10 serious changes that ColdFusion NEEDS.

  1. Replace JRun
  2. I'm sorry, but if it's dead bury it. Get the engine to the 21st century. There are several viable options out there including replacing it with GlassFish, Geronimo, or a commercial application server.

  3. Overhaul Reporting
  4. ColdFusion ReportBuilder is a crusty outdated application built for windows only and very few people use it because of that. ColdFusion Builder deserves an Eclipse-based report building tool that understands CFML. Either update Jasper Reports or implement BIRT. If this is done right, Adobe sells more ColdFusion Builder and more ColdFusion... we get better report building tools out of the box.

  5. Overhaul CFDocument
  6. It's common knowledge that the underlying HTML renderer in ColdFusion is ICEBrowser. ICEBrowser did a decent job with earlier versions of the HTML spec, but found it commercially unreasonable to try to keep up with that. Its End-of-Service Life is next year. http://www.icesoft.com/products/icebrowser.html

    It's time to implement WebKit under the covers. WebKit is also the rendering engine used in Adobe AIR, so maybe there could be extra benefits to using this. If WebKit won't do the trick, hopefully Cobra can, or perhaps they go to just supporting XHTML with Flying Saucer. Whatever the answer is, it is probably not to stay on an unsupported OEM.

    A lot of people use this to generate PDF, it needs to be solid and it needs to work with later revs of the HTML and CSS specs.

  7. Fix Server Monitoring
  8. Server Monitoring was a terrific feature in ColdFusion 8 that just didn't make it all the way there. Either spend the time to get it there, or FusionReactor has their act together, partner with them to create an OEM'd version. They get an upsell opportunity for those in need of Enterprise Monitoring and the rest of us get a better Server Monitor.

  9. Re-think Flash Forms
  10. Flash Forms were a great idea when they came out with ColdFusion 7, they are an even better idea today. They probably need to be re-envisioned. But let the server-developers create code within their CFML that creates a rich UI! ColdFusion developers that don't want to go out and learn an entire new development language and paradigm should still be able to leverage the Flash Platform.

  11. Fix Application Deployment
  12. Sourceless deployment is simply not easy enough. CARs are not a bad idea, there just hasn't been enough time spent on making using them easy. Add a deployment wizard to ColdFusion Builder that then brings up my Server Manager so I can point > click > deploy.

  13. Make a Free Edition
  14. Yes, I said it. ColdFusion needs a Free Edition! This was tried once before and failed miserably and so those with corporate memory at Adobe sometimes bring that up (although really the only person left from that time is Ben Forta.) Here's the deal, like everyone else in the world one of these days I will get around to moving my blogs over to some free third party provider (blogger, posterous, tumblr, etc.) Why? Because I'm not going to pay $1299 to run a blog on CFML. All I really want is to stay with my warm and fuzzy CFML while staying with the platform I am familiar with. Give me an edition that just has the nuts and bolts:

    • CFML and CFSCRIPT
    • AJAX and Flash Forms
    • File Handling
    • XML Parsing
    • CFQuery (but I don't need the DataDirect drivers... all the databases provide their own)
    • CFMail
    • CFFTP
    • Deployment
    • BlazeDS (Hey it's free in supports the Flash Platform initiatives, so toss that in too)

    Keep the rest to yourselves. I just want to be able to run a blog and a wiki without paying for a commercial application server for my home computer, and without learning PHP. If you did that, maybe you'd win back some of the PHP market and even create a vendor market around ColdFusion again. Just give me something that has no more features than the free platforms. Worst case scenario, you make a better investment in expanding use of the Flash Platform.

  15. Add real support for Instant Messaging
  16. IM gateways were a cool idea, but supporting XMPP and Sametime is meaningless. Get the other gateways in there. While you're at it, make them part of the default language or easier to administrate. Maybe there is a way to make Gateways more approachable in general.

  17. Update the Web Services Engine
  18. The underlying web services engine is still good old Apache Axis 1. While that is great for backwards compatibility, Apache Axis2 is considerably faster (4-5 times faster) and supports many new features. Axis2 was first introduced in 2004... I would say it's mature at this point. Hot deployment and Asynchronous calls would be hot!

  19. Add a Workflow Engine
  20. Business Process Management is extraordinarily important these days. ColdFusion is often used to build custom business processes. Wouldn't it be awesome to drag-n-drop your way to a new application workflow?

    Take the work that has been put into LiveCycle Workflow or maybe jBPM. The Business Process engine should tail into ColdFusion Components nicely. Implement either LiveCycle Workflow Designer or jBPM Process Designer with some ColdFusion awareness into ColdFusion Builder and you have a winner.

While I appreciate that there are specific needs we all have for our projects, I think the 10 items I have outlined could dramatically change the direction of the product for the better. ColdFusion has recently seen a return to being respected and watched by analysts and media, a resurgence of customers upgrading after several years of waiting to see which way the wind would turn, and an increase in the number of developers using ColdFusion overall. Now is not the time to tweak. It is time to show that not only is ColdFusion surviving, but it is done with just getting back to its former strength on a new platform and instead is now ready to go back and re-invent itself while respecting its original vision, and take on the next set of challenges.

Push for greatness, go ColdFusion.

Jason

Complex Charting in ColdFusion with WebCharts

I did a session a couple of weeks back at RIAUnleashed in Boston and one of the topics I covered was about leveraging more of the WebCharts3D charting capabilities using Java. The point of it was to illustrate how easy it can be to reach down one level into the underlying technologies used in ColdFusion, all you need to know is where they are.

WebCharts3D is the underlying charting engine built into ColdFusion. The GreenPoint site has more information about the technology here.

You may not know this, but ColdFusion comes with a client application for designing WebCharts3d Projects. All you need to do is go to run C:\ColdFusion\charting\webcharts.bat (change as appropriate for your operating system). They have also made a WebCharts Eclipse Plug-in freely available if you are interested in that.

Running these will give you a chart type chooser that will look something like this:

Select your type and you will get a great utility to help you design your chart that will look a bit like this:

Once you have your chart designed, this utility has tabs for getting back the format of the XML needed "style" the chart, the XML needed to populate the chart, and even the java code needed to make it work for a jsp and even how to make it work in an applet, Swing, or SWT app. The jsp code needs a couple tweaks to make it work for CF.

The Style file that was generated for you will look like:

<?xml version="1.0" encoding="UTF-8"?>
<frameChart>
<yAxis scaleMin="0"/>
<legend isVisible="false"/>
<elements>
<series index="1" shape="Area">
<morph morph="Grow"/>
</series>
</elements>
<decoration style="FrameClock" foreColor="#0080FF"/>
<paint isVertical="true"/>
<insets left="5" top="10" right="10" bottom="5"/>
</frameChart>

The data file will look like:

<?xml version="1.0" encoding="UTF-8"?>
<XML type="default">
<COL>2009</COL>
<COL>2010</COL>
<COL>2011</COL>
<COL>2012</COL>
<COL>2013</COL>
<ROW col0="100.0" col1="200.0" col2="100.0" col3="180.0" col4="200.0"/>
<ROW col0="150.0" col1="300.0" col2="250.0" col3="230.0" col4="250.0"/>
</XML>

And then the code to execute this in ColdFusion will look like:

<!--- may need this for lazy initialization of charting engine--->
<cfchart chartwidth="1" chartheight="1"/>

<cfscript>
webCharts3DServer = createObject("java","com.gp.api.jsp.MxServerComponent").getDefaultInstance(GetPageContext().getServletContext());
myChart = webCharts3DServer.newImageSpec();
myChart.width = 320 ;
myChart.height= 300 ;
myChart.type = "PNG" ;
myChart.loadStyles(expandpath('./webchartStyle.xml'));
myChart.model= fileread(expandpath('./webchartModel.xml'));
writeoutput(webCharts3DServer.getImageTag(myChart,"/CFIDE/GraphData.cfm?graphCache=wc50&graphID="));
</cfscript>

Do that and you get a sexy new chart! Stock full of rollover states and all the polish you care to put on it. :)

This probably looks more complicated than it is. From a developer perspective, use a tool to design any chart type you want from the WebCharts charting set (and there are many!), and then figure out how to populate some XML. Add 7 lines of CF code (with only one of them actually creating a java object), and you're done!!!

Now you can create Bubble, Ring, Scatter, Gantt, Gauge, Radar, Polar, Star, Stock, Histogram, Regression, and Doughnut Charts, and you can create Maps and even Heatmaps. The charting world is your oyster!

Easy peasy.

Happy charting!

Jason

RIAUnleashed Slides Posted for CF - Java Relationship

I gave a talk today at RIAUnleashed on how to take advantage of the underlying JEE infrastructure in ColdFusion. The room was very packed, hopefully people found the topic interesting. :)

These slides are hosted on SlideSix.com, a very cool tool for posting presentations online.

I have given a session on this topic a few times now, but I decided to update this session to be a bit more applicable to the issues we run into when developing applications today.

Sorry for text size issues, CFXL, ColdFiSH, and JavaLoader which I refer to in the presentaion are posted on RIAForge.

I hope you find it interesting!

Jason

High Performance String Concatenation in ColdFusion

I was spending a bit of time last night preparing for the CF - Java Session I am giving at Bentley in a couple weeks and I decided to do an actual test on the difference between using a ColdFusion String and using a Java StringBuilder for concatenation. The results were even more striking than I had originally thought, so I decided to pass it on (sorry for the spoiler if you're going to attend my session at Bentley, I will have more than just this to talk about :).) If you want to learn more about leveraging Java with ColdFusion or a number of other topics, check out RIAUnleashed at Bentley College Waltham, MA November 13th.

So, back to my story, I took a string:

appendstring = "There's an old saying in Tennessee -- I know it's in Texas, probably in Tennessee -- that says, fool me once, shame on -- shame on you. Fool me -- you can't get fooled again";
God bless the wisdom of GWB.

And I appended it in a loop using ColdFusion Strings:

for (i=1;i<=iterations;i++) {
    string = string & appendstring;
}
And I also appended it in a loop using a Java StringBuilder:
stringbldr = createObject("java", "java.lang.StringBuilder").init();
for (i=1;i<=iterations;i++) {
    stringbldr.append(appendstring);
}

The results... With Strings I could append this sentence together 20,000 in 90 seconds... not bad right?

As it turns out String concatenation is actually exponential not linear (perhaps its cubic and not exponential... but it deteriorates quickly.) Take a look at the chart below:

Now a closer look at the same data, but extending to a scale meaningful to the StringBuilder:

With a StringBuilder, I could append the same string 1 MILLION times in 5 seconds!!! I actually had the system running out of memory in about 7 seconds (so be aware of that I suppose.) Trying to get to 1 Million iterations with Strings would take roughly "until the end of time"... okay, maybe not that long, but long enough that you would think a process hung on your server last Saturday.

Am I saying ColdFusion sucks at concatenation? No, not at all. The fact is you will have the same results concatenating strings in Java. In fact, a ColdFusion String IS A Java String. The difference is simple, ColdFusion does not have a keyword or object that does high performance string concatenation. There are hacks like appending an array and then using arraytolist(), but how awkward is that?

Next time you need to make a big string, just use a StringBuilder, its really no big deal. :) Remember, ColdFusion just makes your Java development faster, because the app you write using ColdFusion actually executes as Java.

Best of luck on whatever project you are working on today, :)

Jason

Update: 2:04PM October 23, 2009 With some of the interesting comments around other high performance concatenation methods I decided to give a couple a try under my test. The chart below includes String Concatenation, Appending a StringBuilder, Appending an Array and then Flattening it, and using CFSaveContent. Take a look at the chart below:

I think the results were a bit surprising at first, but after some discussion I think I actually get it. First, we know string concatenation is no good, easy. Next, we know StringBuilder's are linear, and they did what we previously expected.

Next up, an Array, you can see from the chart that an array is wicked fast and then the last iteration is costly because it converts to a string there. This made sense to me... the difference here is the array is only consumable as a string after everything is together. I moved the ArrayToList call inside my loop to make that part equivalent and while still on the same order of magnitude as a StringBuilder, it was several times slower. I guess if you have something that you can completely construct as an array and then just convert it when you need to consume it as a String, this is a viable option.

Lastly, CFSaveContent... this one perplexed me so I dropped a line to an old co-worker at Adobe. His insight was interesting, he said that CFSaveContent is essentially grabbing everything you are outputting to the ColdFusion output buffer which is already incredibly efficient and there waiting for strings (html output) to be thrown at it and then grabbing the content and sticking it in a variable. That does make me wonder what would happen if there were contention for the output buffer... but either way, in a single request environment this is incredibly efficient.

Well, very interesting stuff. I guess I would still prefer to use a StringBuilder, it just makes more sense to me to use something designed to manage strings. I can deal with an extra second and a half over 300,000 iterations. It's the hours it would take using a String that I take issue with. :)

That of course is a coding preference, and I encourage you to do whatever is appropriate for your situation.

Cheers again, :) Jason

ColdFusion Non-profit Announced at CFUnited

They just announced a ColdFusion Non-profit that is dedicated to the ColdFusion Community. I think this is awesome!

Ok, I'm cheating a bit as I am one of the co-founders and President of the 4 ColdFusion Foundation. Several of us have been spending our spare time trying to pull a real non-profit corporation together for the benefit of the ColdFusion Community. You should find out more information on the 4 ColdFusion Site at 4CFF.org.

Special thanks from me to the board members that have been working so diligently at this. They are:

  • Sam Farmer
  • John Zhu
  • Doug Morrison
  • Dan Wilson
  • Ray Camden
  • Sean Corfield
  • Jared Rypka-Hauer
  • Liz Frederick
  • Andy Allan
  • and many more
I'm looking forward to having a non-profit for the community and hope you are to. :)

Jason

ColdFish 2.0 Beta on RIAForge

I recently added ActionScript and MXML syntax highlighting support to ColdFish, as well as line number support. ColdFish is on RIAForge here. I have not had a chance to test it out that much as I do not spend a lot of time with AS3 or MXML so I am looking for some people to give me feedback. I did not update the ZIP since that is the stable release.

If you are interested in AS3 and MXML support for ColdFish, please checkout the SVN tree at http://svn.riaforge.org/coldfish/.

Please send me your comments or fill out the issue tracker on RIAForge!

Thanks! Jason

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner