Introduction
For some 60 years, we developers have been at version 2.x regarding programming. We are now entering version 3.0.
Version 1.x would be something like Assembly/Bytecode/IL, a low level programming with computer instructions. This is still used today, in fact the 2.x version of programming languages are often translated into this.
For some 60 years, we developers have been at version 2.x regarding programming. It is close to English, but difficult. It can be very complex. It's operational. We are required to type exactly what we want the computer to do. If we do something wrong, left becomes right, black becomes white.
We are now entering version 3.0. Computers are starting to understand abstract thinking.
Abstract thinking
We humans do abstract things all the time. “Get the milk”, this for us, is a simple thing, but let's break it down.
- You need know what milk is
- You need to realize that the milk is stored in the fridge
- You need walk to fridge
- You need to open fridge
- You need to pick up milk
- You need to walk back to table
- You need to put down milk
And each of those bullet items is an abstract action in itself. Like “You need to open the fridge”, you need to raise your hand, know where to grab, and pull, etc. To program this would be almost impossible.
Programming 3.0
Now let's talk about programming.
You may have seen demos of somebody who created an app without or with little programming knowledge. It goes something like this: “Create a task app for me”. ChatGPT will generate a ton of code and if you are lucky it will run, most times you need to do a bit of fixing.
The clickbait headline reads: Programmers are no longer needed.
But here comes the tricky part. What if I want to modify the app just a little bit, like add a due date to my tasks or oauth login? I would have to ask ChatGPT to generate the whole code again, for sure it will be different than what I had before, logically, it might not work the same.
The thing with programming, each program, each company, each country has their own version of that same program. So as a programmer, you must have a fine grained control over each action of the program.
This is why those apps created by ChatGPT are a cool demo, but nothing more.
The theory
This is my theory of programming 3.0. Best to show it with an example.
Let's create a user registration, most developers have done one before. Let's start by giving it a title and then list each action that will happen.
CreateUser
- Make sure name, email and password is not empty
- Hash password
- Write name, email, password to users table
- Create user in Brevo
- Create bearer token
- Write bearer token to response
That is it.
Here I describe step by step what should happen, if I need my custom action/property, it is easy for me to add, like the Brevo registration.
This looks easy to understand, most people would know what is happening except for the domain-related things, like Hashing, Brevo and what bearer token is. This is where you need domain knowledge.
This is also where you create context. You give an understanding to this function. It’s all in the details. “Create task app” gives no context.
All of this is handled by LLM, because it understands our abstract writing and translates it into computer code.
Introducing Plang
Plang is a programming language written in any natural language.
What it is not
plang will not generate a whole project for you by describing it in one or more paragraphs like, “Create task app….”. This is not what plang is for.
Plang described
plang (from pseudo language) allows you to define the business logic in natural language and have a runnable code. This is what developers would think of as a function or a method.
To understand what it means, lets give you an example:
Let's do the CreateUser function again, but something that would work in plang as we provide more detail
- Create file Start.goal in your root folder
Start
- Start web server
- Create file Setup.goal in your root folder
Setup
- Create table users, columns name(string, it cannot be empty),
password(string, not null),
email(string, not null), created(datetime, default now)
Now run Setup.goal (You must install plang).
$ plang exec Setup.goal
- Create folder api
- Create file CreateUser.goal
CreateUser
- Make sure %name%, %password% and %email% is not empty
- Hash %password%, write to %password%
- Insert into users, %name%, %password%, %email%
/ this is a comment. Next lines is a preparation for Brevo email service
- [code] Extract first name from %name%, write to %firstName%
- [code] Extract last name from %name%, write to %lastName%
- Post, create user in Brevo(former SendInBlue)
Bearer %Settings.BrevoApi%
parameters FNAME is %firstName%, LNAME is %lastName%,
%email%
- Create bearer token from %email%, write to %bearer%
- Write %bearer% to web response
That is it. You now have a working and deployable business logic.
Run this code by opening your console/terminal (You must install plang).
Browse to the directory where Start.goal is located
plang exec
In you REST client, you can do POST to http://localhost:8080/api/CreateUser
{
"name":"John Johnson",
"email":"test@example.org,
"password":"123"
}
Or even better, write this in plang
RestTest
- POST http://localhost:8080/api/CreateUser
{"name":"John Johnson", "email":"test@example.org, "password":"123"}
Write to %response%
- Write out %response%
Now
plang exec RestTest.goal
If you read the “code”, you should be able to understand what is happening.
If you open up .db/data.sqlite, you will be able to see the record you just created
It is important to note, that this is not how you handle creating users in plang, it is much simpler.
This example of a user registration is only for you to relate to something you have probably done before in other language.
Last thing
Just as a last thing, in the chapter "What it is not", I specifically say that plang is not "Create me a todo app" generator.
Here is the thing, you can build an app in plang that allows you to build other app, just by specifying this type of description. Check out this video where I show this how it is done. I take an idea in text and have fully functional app in 25 minutes (with long explanations).
The important stuff
If you find this interesting, the checkout our Github repository, and meet me on Discord where I can answer your questions.
This post was made from the content of the Plang paper I wrote while creating the language
Top comments (0)