DEV Community

Discussion on: How a single JSON file could become your entire code base

Collapse
srmagura profile image
Sam Magura • Edited on

Yes, you can make a Turing-complete programming language whose syntax is a subset of JSON. Your if statement example demonstrates this nicely.

But what problem does that solve?

You can write any program as a JSON data structure, but you could write that same program in C# or JavaScript and it will be far more readable and succinct.

JSON can be used to represent just about any kind of data, including a computer program, but it's not optimized for this. Like JSON, C# and JavaScript can be viewed as formats for storing data — the difference being that C# and JavaScript were designed specifically to represent computer algorithms while JSON was not.

Collapse
zelcion profile image
Fábio M Jr Author

Hey Sam, thanks for coming up with this!

Well, I do agree with you. For simple tasks, such as the if statement in the article, it surely can take up more space than we would usually need with our own and beloved usual programming, and this is a good sign of the development of good languages for writing such rules in an easy manner.

I feel like data cannot simply replace our traditional programming, this is impossible given that the data needs to be eventually resolved in code. However, the great usability of this comes when we can abstract good chunks of repetitive logic in a simple API. If we combine that with a predictable API across multiple modules/libraries, we have come up with a way to greatly reduce programming effort.

Now, whether we want to represent our logic with data or not is up to the developer, and it also requires a good understanding of the problem (and its complexity) we are trying to solve. If we have enough flexibility within the data model, or the code is organized enough, this is likely influence our decision.

Collapse
mattthecuber profile image
MattTheCuber

Couldn't agree more