Surface: a new programming language design view
This article is not going to introduce another programming language, but, a new view on designing a programming language. (Or addition feature we may need)
Below explains the reasons, examples, and something might be done for adding this feature.
So, what’s the problem?
When we are doing coding, whatever the language is, normally, we are based on the text editor (famous editors like vi/vim, or IDEs like vscode/jetbrains). We are coding like this (PHP for example):
It is 2D as we know, so it brings problems.
Problem 1: Comments
"Good programmers do comments.", "good programmers do fewer comments in the code"…
OK, we know, comments are part of coding. But when there’s a lot of comments, it is hard to get the full picture of the code itself. (What is your attention in the below code? I’m not saying the comments are useless, but it should be in another way on showing this.)
Problem 2: ORM, Json or other data serializer/deserializer methods
When we are dealing with the data storage and the model/class in the programming language, we normally map them together.
Example 1. Orm in java
Example 2. PHP Doctrine Annotations
Example 3. Golang Tags for serializing/deserialize json
As you can see, they mixed with normal codes there.
Problem 3: Context-based process
We also have other purposes of using annotations, ex. REST API entries.
Example 1. Swagger REST API in code:
Example 2. Python decorator
Obviously, they do special stuff.
Problem 4: Async codes
Though nowadays we are very familiar with async/await and make the code seems like we are doing synchronous steps, but it obviously is against our sense when writing the code.
I can't get you, so what's the problem exactly?
One picture explains everything. Why our programming language/IDE is not working like this in the below? (I called it "surface" for the solution.)
The "main code" is the coding you are writing normally. If you want to add comments/orm/json/async... just click the lineno or even highlight/select the words you want to comment/orm mapping/add json tag/add async code. It displays a block you can enter with tracing features. (See the lineno mapping)
And of course, to achieve this, the programming language should add tracking features and also it requires good IDE supporting...
At least, we are entering the 3D world from a coding view!
+ listener or subscriber (if event-driven supported)
You should know, maybe you are coding in a VR environment in the future. Links between different parts (`surfaces` here) is absolutely needed.