jsonic proves that a DSL can be a simple & practical tool for solving a programming problem. We needed fewer than 50 lines of code for jsonic—making it even shorter than bf. Undoubtedly, writing a whole JSON-generation library in our favorite programming language would’ve been more work.
Of course, one reason jsonic can be small is that it relies heavily on Racket: as an implementation language, as the language for the embedded expressions, and for the json library, which handles the heavy lifting.
But that’s a good thing. All we need to do is design and implement the interface for our little language.
The other reason jsonic is small is that we’ve treated it as a tool for personal use. If we were sharing this DSL with others, we’d want to include tests, documentation, better error messages, and integration with DrRacket (about which, more shortly).
Mostly, this jsonic tutorial was meant to nail down the basic two-part framework of a Racket-implemented language that we saw in stacker and bf:
The next tutorials are going to assume that we’re completely cool with these ingredients. If any of these concepts are unclear, this is a good moment to review.
As a junior JSON engineer at MegaCorp, your invention of jsonic provided a huge boost to your productivity. Sure, it’s a toy language. But a very useful toy. In fact, by creating a JSON preprocessor, you discovered that you were able to complete your weekly JSON assignments in 1/3 the usual time.
What’s your next thought?
“Wow, I’d really like a promotion and a raise. I’m going to use jsonic to get three times as much work done as before. My boss will be so impressed.” Click here for your next tutorial.
“This is great—it’s going to free up so much time during the day for programming puzzles. I’ll be getting just as much work done, so my boss will never know.” Click here for your next tutorial.