ColdFusion -vs- Modern Web Development
I’ve been a ColdFusion developer for many years, and I’m honestly a huge fan. It’s served me well, helped me build many side projects, enterprise applications, and even my Photo Scavenger Hunt business (FrogQuest.com). I’ve made a great living for myself programming in ColdFusion, especially as the pool of willing and qualified developers dwindles, making my skillset more niche. It saddens me to see ColdFusion make it’s slow death march toward the graveyard of forgotten languages. But unless the ever smaller community drags ColdFusion into the era of Modern Web Development, I’m afraid the future of ColdFusion may not be very bright.
There are a couple efforts I’m aware of bringing together the old (ColdFusion) with the new. Mark Drew has done some work with ColdFusion & GraphQL. Brad Wood built the CommandBox CLI for ColdFusion. And Adobe also created a CLI for ColdFusion 2016. I haven’t tried Adobe’s CLI and honestly don’t see a compelling reason to give it a go, but Brad’s CommandBox is A++! I’m sure there are many other efforts I’m not aware of marrying modern frameworks and libraries such as Angular and React to ColdFusion, but there aren’t enough and the few I’ve seen barely scratch the surface.
Lately, I’ve been diving deep into React, React Native, and GraphQL. I’d ultimately love to rewrite my entire FrogQuest site in React, but for now I thought I’d try to bridge the two worlds. Almost immediately, as I’m creating my next feature, I ran into my first hurdle.
Modern web apps commonly exchange data via JSON, and ColdFusion’s support for JSON is… errr… shall we say… lacking. But don’t take my word for it; let me show you.
My first objective is to take the results of a database query and convert it to JSON so that my React components can make use of the data. Sounds simple enough. ColdFusion has a method for that called SerializeJSON, so I’ll just query the database and serialize the results, right? Wrong! Here’s what that output looks like…
SerializeJSON(queryResult) =>
{
"COLUMNS": ["ID", "CODE", "NAME", "POINTS", "BONUS", "TOTAL"],
"DATA": [
[503, "D", "Village Foragers", 1361, 32, 1393],
[500, "A", "F Bombers", 1223, 24, 1247],
[502, "C", "Fleet Street Fanatics!", 1195, 26, 1221],
[501, "B", "Carls-baddies", 1053, 18, 1071],
[504, "E", "The Village Hunters", 741, 3, 744],
[505, "F", "John's Team", 574, 13, 587]
]
}While this is valid JSON, what I’d really hope for is this…
[{
"id": 503,
"code": "D",
"name": "Village Foragers",
"points": 1361,
"bonus": 32,
"total": 1393
},
{
"id": 500,
"code": "A",
"name": "F Bombers",
"points": 1223,
"bonus": 24,
"total": 1247
},
{
"id": 502,
"code": "C",
"name": "Fleet Street Fanatics!",
"points": 1195,
"bonus": 26,
"total": 1221
},
{
"id": 501,
"code": "B",
"name": "Carls-baddies",
"points": 1053,
"bonus": 18,
"total": 1071
},
{
"id": 504,
"code": "E",
"name": "The Village Hunters",
"points": 741,
"bonus": 3,
"total": 744
},
{
"id": 505,
"code": "F",
"name": "John Dewey's Team",
"points": 574,
"bonus": 13,
"total": 587
}
]There is an optional second attribute to SerializeJSON called serializeQueryByColumns that sounded like it might be helpful, especially since according to the documentation it takes a boolean, ‘row’, ‘column’, or ‘struct’ as it’s argument. But I receive errors when I try passing anything but the boolean into it, and passing true renders this equally unhelpful output.
SerializeJSON(queryResult, true) =>
{
"ROWCOUNT": 6,
"COLUMNS": ["TEAMID", "TEAMCODE", "TEAMNAME", "POINTS", "BONUS", "TOTAL"],
"DATA": {
"TEAMID": [561, 558, 560, 559, 562, 563],
"TEAMCODE": ["D", "A", "C", "B", "E", "F"],
"TEAMNAME": ["Village Foragers", "F Bombers", "Fleet Street Fanatics!", "Carls-baddies", "The Village Hunters", "John's Team"],
"POINTS": [1361, 1223, 1195, 1053, 741, 574],
"BONUS": [32, 24, 26, 18, 3, 13],
"TOTAL": [1393, 1247, 1221, 1071, 744, 587]
}
}This leaves me to write my own function to convert the SerializeJSON output into the format I’d naturally hoped for. /Sigh
I suspect the errors I received when passing strings as the serializeQueryByColumns argument may be caused by my not using the latest version of ColdFusion. I’m running ColdFusion 10, and the latest is ColdFusion 2016 as I write this. But there have been very few reasons to justify the risk and effort to upgrade IMHO.
Rather than focusing on API Managers and improving the PDF rendering engine, which seems to be the top priority of the Adobe ColdFusion Product Managers, I would argue that they should be focusing on reducing the friction between ColdFusion and Modern Web Development. In fact, I’d love to see them go many steps further and embrace modern web development as I suggested to them back in February 2016.
What do you think?
