For our series of interviews “Strumenta Talks”, we host Adolfo Ochagavìa.

Adolfo Ochagavìa is a freelance software developer with an interest in Domain Specific Language. He will explain his project and share with us his experience of building DSLs for the chemical industry.

[…] There are also some tools to report this as a Word document. And for that, I built a templating system on top of Microsoft Word, which automatically inserts the tables in the right places. And also updates the table of contents and all kinds of stuff. […]

[…] Well, they’re not technical, so we need to communicate in a non-technical way. And I think having a DSL has enabled this to happen. […]

Interview transcripts

Federico Tomassetti:

Good morning, Adolfo, and thank you for joining us. How are you today?

Adolfo Ochagavìa:

I feel very good. Thank you for having me. I’m doing well, thanks and you?

Federico Tomassetti:

I’m doing well myself. And I think the first thing we should ask you is to tell us a bit about yourself.

Adolfo Ochagavìa:

So well, just to keep things short, right? I’ve been living for 10 years in the Netherlands. I studied here computer science at the University of Utrecht, which has a very nice, functional programming department. We learned Haskell and learned to make programming languages there. After that, I started working on you could say a boutique consultancy. We made web applications for other companies. After a few years, I decided to start as a freelancer on my own. Since then, well, I’m doing all kinds of stuff actually. So right now, for instance, my main project is helping a team develop an Elixir application.

And I’m part of the team sharing responsibilities and all that. But what I’m going to show you today, the DSL we were talking about before, is an independent project I’m doing fully on my own with a business. They’re much less technical than working with a team of programmers. So I like both worlds. I like being really deep into programming, at the same time, talking to business people, trying to open the door to the technology for things they normally don’t get their hands on. And the project I wanted to show you today started last year. I can start talking about that if you want, otherwise-

Federico Tomassetti:

Yes. We will ask you for some references for your services. So we will add them to the article. But I think right now would be very interesting to talk about this project involving any specific language.

Adolfo Ochagavìa:

So yeah, this project is for a chemical laboratory. They offer a service in which they analyze construction materials to certify they are safe. So a typical example is a paint. If you paint your room, there’re all kinds of things going to come out of the paint and get into the air of your room. So you want to be able to say that it’s not unhealthy to go and live there, right? So what these people do is they measure the emissions that come from construction materials. They analyze them to identify the chemical components, and then they check that against legislation to ensure that the limits are satisfied, that there must be no more than so many micrograms of some carcinogenic substance, for instance.

And afterwards, they report on it. So, I’ve been helping them with the latter two. So checking that the legislation is satisfied and reporting. And for that, well, since there’s quite a bunch of different legislations, I thought I would make a DSL for myself to describe the different things we need to check. So maybe this is the point when I start sharing my screen for a little while. Afterwards, we can get into the code. So just let me prepare everything. Yeah, we’re ready for that.

Federico Tomassetti:

While you prepare it, I will just comment that I think it’s interesting that you’re using a DSL to cover the availability in different countries. Because we have seen a sample of DSLs used by the way, by a company based in the Netherlands to describe the different regulations. For example, for the green path, we have to ensure that someone could enter a certain building. And there was a DSL to describe the different regulations in the different countries. Or we have seen DSLs used to help in the different ways that taxes or social contributions like calculating needs that countries. So when you have a problem with different constraints in different countries, maybe it’s a good fit for a Domain Specific Language.

Adolfo Ochagavìa:

Definitely. And in fact, you will see… Well, I’m going to start sharing my screen now. Hopefully, everything is visible.

Federico Tomassetti:

Yes, yes it is.

I can see this application.

Adolfo Ochagavìa:

This is the application I built for my clients so they can do the reporting and the checking themselves. So what you see here is the table reporting the results of one of the measurements, according to French legislation. And on the left side, you see the different compounds that need to be reported. And here you see the classification for each of the compounds according to the criteria defined here, right? So what you see here is that, well, the measurement itself is not being reported in the table because it’s not necessary. You can look at it in a different place, but in any case, you can see the limits of 10, 60, or 120. And depending on the limit on the measured value, you will get A plus, or A, or B, or C.

So if you look here below to the right, you can see the evaluation of the whole table, A+. And so what I build is a DSL to describe these tables, including their limits. And you could say it includes a compiler to extract the measurements and the limits and compare them to calculate the classification. So just to give you an example, I have here the definition of the table, which is a plain C# class. Just for my own ease of use, I put the limits as separate properties of the class and below, well, are the different things.

So you see the evaluation strategy, which goes from worst to best. And as you can see in the table, first comes the worst evaluation. And then at the end, the best. Of course, you also need to define for each evaluation the text associated with it. And then you start just building a table. For each limit, you insert a row and include the measurement, including the limits, and you can customize it. There’s lots of customization possible around the limits.

So, for instance, you can choose to show the operator or to hide it, because depending on the legislation table, it’s a little different. And sometimes you need to show the units of measurement. We support different units of measurement. Sometimes it’s micrograms, sometimes it’s milligrams. Maybe just to show you that everything really works, we could have a quick look at the results we are reporting here, which are from day 28 if I remember correctly. So let’s say there’s this data here with a concentration of three micrograms per cubic meter. We say here that the limit must be 10 for A+. So let’s change this to one and apply them to the code. We have hot code reloading nowadays in C#, though it doesn’t seem to work. So I’ll need to restart this thing anyway. Maybe…

Federico Tomassetti:

Was this table or was that-

Adolfo Ochagavìa:

Yeah, it was this table. It was the French compliance. And otherwise, well, let’s have a quick look just to be sure. Yeah. So now you can see that the limit has changed. It’s now less than one and the classification has changed also. And below, to the right, you can see that the evaluation has become just A. So as a programmer, I don’t want to be the whole day dealing with tables. So when I noticed that my client, that they really needed a lot of them, I thought I would make my own life as easy as possible, which I did.

There’s a bit more than just this. There are also some tools to report this as a Word document. And for that, I built a templating system on top of Microsoft Word, which automatically inserts the tables in the right places. And also updates the table of contents and all kinds of stuff. So I think it’s better not to show that because it might be… Well, it’s kind of more of a proprietary report, I assume, just to be sure. So I don’t know, maybe you have questions about all this?

Federico Tomassetti:

Yes, yes. I understand that something we discussed, you created these internal DSL to simplify your work. Even if you were writing lots of these tables with many similarities, but also many small differences, like for example, showing the operator or not, that are really important for your users. And I understand that at this time, you are using the DSL yourself so that you can be more productive. But one thing that you are considering, if I’m not mistaken, is having domain experts, people that understand this regulation defining these tables themselves, am I right?

Adolfo Ochagavìa:

Yeah. So I was thinking about that. Mainly so in this kind of projects, depending on the budget, you can do more or less. In this case, I’m really trying to limit all changes to what’s absolutely necessary just to avoid making more hours than is good for my client. And one of their desires is to be able to modify the tables. And we have a recent conversation in which I asked them to more precisely tell me what they exactly want to be able to modify. Because if they want to modify everything, of course, then I will need a full-blown DSL that they can control. And it’ll be lots of work, but it turns out they mostly want to modify only the limits. So what I’m probably going to end up doing is to extract the structure of the limits into their own class, and then populate it from JSON or create a special editor for it.

And that way, I can avoid the whole complexity of, well, creating a language that is actually usable for people. I also had some crazy ideas to allow them to write their own tables in C#. Because if the DSL is clear enough, well, someone can modify some things without too much difficulty. So actually, the current version of the software makes it possible to load and compile C# code on the fly with your own tables. But I’m not sure. That was more of an experiment just to know if that was a possible direction in case they really wanted to go for the full-blown editing experience.

I did play a bit with JetBrains MPS and it was interesting to see. As a language enthusiast, being able to build your language with such speed was nice. But on the usability side, it didn’t really convince… I mean, I didn’t imagine my users using MPS, which was a pity. Maybe someone should make a web version of it with a more customizable user experience.

Federico Tomassetti:

Yeah, that is a good point. I think that MPS is amazing quickly to build languages. Then there is the problem of the learning curve that is definitely not easy to get started. And regarding the editors, one thing I think is emerging in the community is that maybe the editor of the language itself at the part where the user edits the code is relatively simple. But what is appearing as very complex is whatever is around the editor. So all the panels, all the menus, give you the idea that you are using an ID intended for developers, and this is a bit overwhelming.

Adolfo Ochagavìa:

Yeah.

Federico Tomassetti:

And so, one direction of having MPS moving to the web where one, you don’t need to install it on the machine, on the different users, with all the limitations, the difficulty of distributing updates, but also you can create an editor without the shell around. And maybe having also this editor integrated into other applications in the system. And so, yes, there are definitely attempts to go in this direction. We also experiment with this, but as far as of now, there is not one mature solution that has emerged that is winning. But I agree that there is interest in this direction.

[For more information, you can have a look at these resources: MPSServer: enabling integration with MPS, webeditkit and Saving JetBrains MPS models in a database using Modelix Ed.]

Adolfo Ochagavìa:

Yeah.

Federico Tomassetti:

Good. And then, can you also tell us a bit more about these users? What kind of background do they have If they are… I guess they’re not developers?

Adolfo Ochagavìa:

Oh, no. So this laboratory was actually… It came a few years ago from a research phase. So they developed a methodology to do all this testing and we are in a fairly… Well, they are starting up. So before this, they were doing… They have chemists working there and there’s one or two who really understand the whole thing, like how you should do all these calculations. I mean, I glossed over the complexity around measuring all these things and identifying the chemical components. There’s lots of work going on there, but they discovered that they were losing lots of time on the reporting side of things, which was very repetitive and error-prone because it was all manual.

So in our first conversations, they showed interest in, well, improving things in general. And I actually had to have more of a product-owner role, trying to distinguish what were the pain points and identifying all this one, the reporting, that’s really the most important one. So yeah, they’re not technical at all. I mean, they don’t program. So that’s also why, for me, really giving them access to a full-blown language, they would end up coming back to me anyway. So if I’m going to program the thing, I’d rather program in a real programming language than in my own DSL.

Federico Tomassetti:

And I think there are a few things that I would like to underline what you’re saying because I think they’re interesting and general in the sense that you were saying they were doing a lot of repetitive work that was error-prone. And so the DSL in part solved this problem. Another thing that you say that I found very interesting because I saw this common problem in explaining DSLs is this: you say, of course, you didn’t go into many details about the complexity. This is I found it’s always a challenge in presenting DSLs because maybe to understand why in each case a DSL is useful, one should present all the complexity of the domain. But on the other hand, if you try to explain all the complexity of this domain related to chemical measurements, probably no one in the audience will be able to understand. So that is always a challenge in presenting DSLs.

Adolfo Ochagavìa:

Maybe there’s one additional thing: by using a DSL, I’ve been able to show the code to them when we are talking. So I’m no chemist, so there are many things I don’t understand. And usually, I need to check with them, is this the right thing to do. And in some occasions, I’ve shown them the code while we were having a call. And because it’s so intuitive, they can follow along. And also because it encapsulates every table in such an elegant way, we can talk about, well, it’s what you, in domain-driven design, you call having a shared ubiquitous language, right? We are talking… I’ve been able to model what they have in their head to some extent, in my code. And that makes it very useful, well, in a situation in which the other… Well, they’re not technical, so we need to communicate in a non-technical way. And I think having a DSL has enabled this to happen.

Federico Tomassetti:

So that’s a good point. Having a DSL, I think the most advanced situation is the one in which the user can use it themselves and write their own thing without no support. But there are a lot of advantages already when is still the developer who uses the DSL, but this code can be shown to domain experts that can validate it, and one can have a meaningful discussion. Maybe you can also try and do some tweaks on the fly, starting applications and showing the changes. So it probably makes moving on much, much faster.

Adolfo Ochagavìa:

Mm-hmm, yeah.

Federico Tomassetti:

I think I’m taking more of your time than we agreed to, but I’d like to ask you just one final question about your future plans. So I think you said a few words before, but can you tell us what do you think to plan next?

Adolfo Ochagavìa:

So I don’t know for sure. I’m currently on a contract for the coming months and I’m enjoying it very much, I’m learning a lot. It’s not necessarily related to languages actually. And after that, well, the thing is I usually, try to have a contract to fill most of my time. And then on the side, do a few other things. So this project I just showed you is one of those more the side project. And I like the combination. Yeah, I’m actually very open to almost whatever comes. So I just try to keep in touch with lots of people. And when the time comes, I’m sure someone will have mentioned, “Hey, when you are free again, maybe you could come to help us with whatever.”

So for instance, I’ve worked in the past in the Rust compiler and also in the Language Server. Yeah, I like programming languages. So I had the chance recently to join a team, building a Rust application, and I didn’t go for it, but maybe next time I will. Because well, this time I think it didn’t make much sense, but I’m just… Yeah, I don’t know. I’m looking around and see what I find.

Federico Tomassetti:

So I think it’s time to thank you for your time. And again, we will insert it in the articles’ references so that people can learn more about your work. [Here is Adolfo Ochagavia’s website: https://ochagavia.nl/ Ed.] And for now, I would like to thank you for your time and say goodbye.

Adolfo Ochagavìa:

Yeah, thank you too. Bye.