Articles
MessagePack Support for ColdFusion / CFML
A pure ColdFusion port of msgpack-lite for encoding and decoding MessagePack binary format. Compatible with ColdFusion 2016+
MessagePack (or msgPack) is an "efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves."
I came across a clickbait headline on Medium entitled "How I Switched from JSON and Made My API 10× Faster" that claimed JSON was their "silent bottleneck". Their unit test compared JSON, MesagePack, Protobuf, Avro and CBOR. They went on to claim that using MessagePack was 7x faster than JSON when serializing & deserializing a 100 KB object. SEVEN TIMES FASTER... whoa! I'm missing out. MessagePack was also more flexible than other approaches because it didn't require a strict schema or .proto files (like Protobuf does).
NOTE: ColdFusion 2023 added support for Avro and Protobuf. ColdFusion 2025 didn't add any new serializers.
The author of the article was using Java (they never clearly stated which can be sometimes be difficult to determine) and they didn't mention which third-party MessagePack library they were using, but I visited the official MessagePack website to determine what was available. This format is used by redis, fluentd, Treasure Data and Pinterest for speed and compression reasons. The project webpage then lists 50+ programming language and environments that have support... and there's no representation by ColdFusion/CFML. :(
NOTE: I also have a CFC in the works that supports the msgpack-java library, but thought I'd see what a pure ColdFusion version could do since it was already ported to other languages so much... including JavaScript.
After starting work on the CFC, I realized that analyzing a specification and porting logic from one language to another is a perfect task for a pattern matching engine. I initially tried using the "grok-code-fast-1" model with the VSCode Cline extension, but the result wasn't functional, I had to keep training it and it kept repeating the same mistakes. The results when using Google Gemini (via web UI) was worse. I figured that I'd try the Claude AI web UI to see what it was capable of. I was surprised that it had something functional on the 3rd or 4th iteration... and then it generated unit tests. This approach made it easier for me to go back and forth to identity and report what was/wasn't working. I added my own unit tests and, upon completion, it auto-generated a full README.md file. I wasn't expecting any of this... not after my many fruitless experiments using Microsoft Copilot 365, Grok and Gemini AI.
After the serialize & deserialize functions were working successfully, I added extra helper functions to convert the values to HEX strings so I could test without having to generate a binary object.
Wait a minute... what about performance? What about the retention of typed data? Here's a screenshot of the progress so far. It also includes comparisons to using the java libary & dependencies (jackson-dataformat-msgpack, msgpack-core, jackson-databind, jackson-core, and jackson-annotations) and the built-in serializeJson & deserializeJson functions.
Project on Github
https://github.com/JamoCA/msgpack-cfml
