This content originally appeared on DEV Community and was authored by Fábio M Jr
The Problem
Well, it is no news for us that developing software is expensive, and takes A LOT of time and effort, after all, we're talking about code, good code.
It is that kind of code which solves a problem, and it does so while being elegant and readable... But doing that is hard, and here is where we touch the surface of a difficult problem.
Good code is really expensive, and inaccessible for most people and companies.
Not only bad/faulty code often fails to solve the problem it should, it also becomes the own problem. I bet you once had to understand the incredibly messy class system of a legacy code base, just because you were tasked to fix a "simple" bug.
My theory
I have a fun personal theory, that all ever created about code can be somewhat traced back to the code accessibility problem, with the sole purpose of making it bit by bit a little easier.
People started using C so they do not need to move bytes manually so often. On the web, the rise of JQuery led to more and more complex and capable websites, which was a thing only to dream about. Then came Java, C#, ReactJS, tools like Docker, and uncountable others goodies to make our life better.
However, the "writing good code" problem still persists, though adapted to the current scenarios.
Honestly, I don't think this problem has a definitive solution. As our society and technology gets more capable and complex, so does our problems; but I do think we can do better to make software more accessible.
Making code Accessible and Cheaper
Now, what if such "good code" could be written only once, and all of us could freely use that code for our own purposes? What if we can chain multiple good codes together, while not needing to write boilerplate code for that?
Perhaps, even better, we could be writing only the absolutely necessary code for our use case.
Here's where that JSON comes in.
Code as Data
Before we begin, for "code as data" to exist, tho following must be true:
If It is possible to represent any code as a piece of information, it is possible to organize it to compose features and functionality.
Luckily for us, data can represent anything.
Don't believe me? Try giving this a read:
{
"variables": [{ "name": "highestAllowedNumber", "value": 3 }],
"code": [
{
"procedureName": "if",
"boolean": {
"procedureName": "higherThan",
"input": "functionInput1",
"targetValue": "highestAllowedNumber"
},
"then": { "procedureName": "stdOut", "message": "too high!" },
"else": { "procedureName": "stdOut", "message": "you're fine." }
}
]
}
When the user input is higher than 3, we will get a message: "Too high!"
Now, perhaps you're asking yourself, what is the difference from this to regular code?
At first glance not too much, however, in practice they are fundamentally different. You cannot execute this data, but you can parse it into code (good code too!), then execute it.
Data as Code
If we think about it, a good part of programming is converting information of a business process into a language the computer can more readily work with.
Try making this simple exercise. Get that data from the last section and write it in JavaScript, then C#, then C++.
After completing it, I think you can somewhat visualize that we can tell a computer make this conversion for us.
Data and You Making Code Accessible
Oversimplifying for the sake of comprehension, let's say you've written the best, unrivaled, if statement
there is, and it could be represented by the same data structure we saw above.
If we manage to get data which correctly represents our intentions, it can become the best code we have, while not even thinking about its implementation at all. For best results, make it open source.
How a single JSON file could become your entire code base
Right now, I bet the title is not that far from reality, comparing what it initially seemed to be for you. Well, actually, such thing already exists, and here's a WIP example.
This was made possible by using Meta-System, an open source software in which I had the pleasure of working on. It makes software accessible, while also providing you a way to contribute to such accessibility.
Check the Repository, and join the discord, where we talk about making the world of software more welcoming and less challenging.
This content originally appeared on DEV Community and was authored by Fábio M Jr
Fábio M Jr | Sciencx (2021-11-01T18:03:56+00:00) How a single JSON file could become your entire code base. Retrieved from https://www.scien.cx/2021/11/01/how-a-single-json-file-could-become-your-entire-code-base/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.