SE Radio 570: Stanisław Barzowski on the jsonnet Language
Stanisław Barzowski of XTX Markets and a committer on the jsonnet project joins SE Radio's Robert Blumen for a conversation about the jsonnet programming language. A superset of JSON, jsonnet adds programming language capabilities, particularly to address the need to handle large but mostly repetitive JSON configurations. They discuss the project's history, use cases for Grafana and Kubernetes config, and interoperability with YAML. They examine jsonnet details, including the command line, constrained capabilities of the language, and objects and inheritance, and then consider the toolchain: compiler, formatter, and linter, as well as test frameworks and testing, package management, and the language's performance. Barzowski describes four implementations -- go, C++, Rust, and Scala -- as well as popular libraries and the standard library.
Stanisław Barzowski of XTX Markets and a committer on the jsonnet project joins SE Radio’s Robert Blumen for a conversation about the jsonnet programming language. A superset of JSON, jsonnet adds programming language capabilities, particularly to address the need to handle large but mostly repetitive JSON configurations. They discuss the project’s history, use cases for Grafana and Kubernetes config, and interoperability with YAML. They examine jsonnet details, including the command line, constrained capabilities of the language, and objects and inheritance, and then consider the toolchain: compiler, formatter, and linter, as well as test frameworks and testing, package management, and the language’s performance. Barzowski describes four implementations — go, C++, Rust, and Scala — as well as popular libraries and the standard library.
Show Notes
Transcript
Transcript brought to you by IEEE Software magazine.
This transcript was automatically generated. To suggest improvements in the text, please contact [email protected] and include the episode number and URL.
Robert Blumen 00:00:16 For Software Engineering Radio, this is Robert Blumen. Today I have with me Stanislaw Barzowski. Stan is a graduate of the University of Warsaw. He’s a Developer at XTX Markets in London and formerly was a software engineer at Google. He is a committer to the Jsonnet open-source project, and that is what we will be talking about today. Stan, welcome to Software Engineering Radio.
Stanislaw Barzowski 00:00:42 Hello, Robert.
Robert Blumen 00:00:44 I’m very interested to talk about Jsonnet with you. Jsonnet is closely related to JSON. I’m guessing most of our listeners have been exposed of that, but could you give us a quick summary of JSON and then we’ll move on to Jsonnet?
Stanislaw Barzowski 00:01:00 So JSON is a very simple, I would say mostly a data interchange format — just a tiny subset of Java script. But actually like the Javascript part isn’t that important. It’s only the historical part. It’s just how everyone saves data these days. So yeah, and Jsonnet is much, much more. Jsonnet is a programming language. It’s a language for building configuration. So you write your program in Jsonnet to generate your JSON, but it happens that if you have valid JSON, it’s also programming Jsonnet, which generates with JSON, which is quite convenient, hence the name.
Robert Blumen 00:01:38 What does Jsonnet add that is not there in the original JSON?
Stanislaw Barzowski 00:01:43 So it adds a natural programming language features that you might want in your configuration file. So starting with variables, then functions for templating first, a form of object orientation, which is somewhat non-standard — I believe we’ll talk about this in a bit more detail later — and ability to input other files so you don’t have to have your big fig all together. And you can also reuse pieces in different configuration files.
Robert Blumen 00:02:12 I’m going to put two questions together and you can answer them at the same time or one after the other. But why was Jsonnet created, and what do you get from having these additional features that are not there in JSON?
Stanislaw Barzowski 00:02:28 Okay, so the original motivation was to create an open-source solution to something similar to what was used internally at Google. So you have this need when you have a lot of microservices or, in fact, any sort of situation. You have like hundreds of configuration files of, we’re using some logic, some parts between them so we don’t have to repeat the same file name over and over again, for example. Or to make sure things are consistent between your configuration files. And Google has an internal language for this purpose, but around the time when Kubernetes became popular, they’ve had an idea to create an open-source language sort of like that with some lessons learned. So I would say better structured, in some ways, though actually quite a bit different in implementation and yeah, so in 2014, JSON had started as a 20% project at Google.
Robert Blumen 00:03:24 So, I often find with JSON I have some very long files, and one of the things you mentioned is you have a lot of files which are quite similar but only slightly different, or within the same file I have big chunks of code that are very much repetitive but they’re not exactly the same. And if I could just say I want this block here that’s 90% the same and I want to just change these three things, there isn’t really a natural way to do that with JSON, but a programming language should enable me to do things like that where I could have a chunk of code and then I reuse that code. Is that some of the motivation for this project?
Stanislaw Barzowski 00:04:04 Yes, exactly that. So you sort of have the cycle when like you introduce some configuration to your program. At first, you start with configuration inside your program just like as part of your source. Then you start extracting it. You first have like a simple configuration file with just a few parameters, but then as it grows it turns out that you need variables, you need to reuse parts of this. And then like you want to have some templates because things are not always exactly the same. Then you want to add inputs to share things between files, and then you sort of reinvented the whole programming language just specifically for the purpose of your program — usually in a quite ad hoc basis so the outcome of this process usually isn’t of very high quality. So what Jsonnet does is sort of gives you a generic solution to that problem.
Stanislaw Barzowski 00:04:54 It gives you like something that you can use to have this complex configuration and manage complex configuration for your software. And the two ways to approach that: one is from the offer of a program perspective, which is oh, I don’t want to invent my new programming language just to specify my complex config in a convenient way. So I can just use JSON and suggest that someone can use Jsonnet or one of the comparable solutions instead. And actually, I don’t even need to care which one the user actually chooses in the end. And the second perspective is sort of from the user’s point of view. So let’s say I have a lot of microservices, or just a lot of configuration modernization, and I can have a centralized mechanism to generate all of this configuration and share some parts between them.
Robert Blumen 00:05:50 Just now you said something I hadn’t thought of. The way I would have seen this being used, and the way I’m using it in my job right now, is we have a tool chain that runs into Jsonnet programs and generates JSON and pushes those out to where the configuration can be consumed. You mentioned that you could teach your program to use Jsonnet as the configuration language. So, the program instead of reading JSON would incorporate Jsonnet. In that situation, would you embed the Jsonnet language into your program and have it process your config files?
[...]