Programming 3.0 - Theory
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 - 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 email and password is not empty
- Hash password
- Write email, password to users table
- Create user in MailChimp
- 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 MailChimp registration.
The code above for user registration would be 100+ lines to write in a language like C#, Typescript, etc. and doing it in clean code, involves fancy word such as dependency injection, interfaces, unit tests, patterns and dozens of files
Introducing Plang
Plang is a programming language written in any natural language.
plang (from pseudo language) allows you to define the business logic in natural language and have a runnable code.
To understand what it means, lets give you a real example.
Let's do the CreateUser function again but in plang.
CreateUser
- Make sure %request.password% and %request.email% is not empty
- Hash %request.password%, write to %hashedPassword%
- Insert into users, %hashedPassword%, %request.email%
- Post, create user in MailChimp
Bearer %Settings.MailChimpApi%
%request.email%
- Create bearer token from %request.email%, write to %bearer%
- Write %bearer% to web response
That is it. You now have a working and deployable business logic. You just went from hundreds of lines to 6 lines. 🤯
It's hard to argue against the increased productivity and as the rule says:
fewer lines = more security, fewer bugs & more stability
If you read the plang code, you should be able to understand what is happening.
Next steps
If you find this interesting, the checkout our Github repository, and meet me on Discord where I can answer your questions.
It is important to note, that this is not how you handle creating users in plang, it is much simpler.