DEV Community

Cover image for Flexibility of plang programming language
Ingi
Ingi

Posted on

Flexibility of plang programming language

This article explores Plang, an intent-based programming language designed to interpret natural language. For more information, visit plang.is

Consider a food diary app a friend uses; it allows you to add a meal to it.

When you eat that meal you can select that meal from a simple UI instead of typing everything in each time. You can even add bread to that meal, if you had a bit extra today. Nice feature.

Implementing this functionality requires a lot of work, at least a month or 2. Setting up a meal table, detailing the food, connecting it to calories, creating a UI, testing, and programming the logic for "had one more bread"

In contrast, the Plang app, FoodDiaryApp, offers this functionality for free to the developer and the reason is how plang solves the problem of receiving the user input.

FoodDiaryApp waits for user input, like any other app does.

You can simply send a message like "ham and cheese sandwich," and it will figure out the macronutrients (calories, carbs, fat, protein, etc.) 🥪

The app allows you to add knowledge to it, like, "I'm 65 year old male", "I'm diabetic"

Since knowledge is just knowledge, I can tell the app to create a shortcut, "es" for a meal. "es stands for 2 eggs and salad, with spinach, 2 tomatoes, cucumber." 🥗🍳

So, when I send “es,” the app knows exactly what that meal includes.

With just two letters, “es” you've logged your meal and received all necessary information—a great example of 'Job to be Done'. 🎯

How it works

In simple terms, it takes your input, "ham and cheese sandwich,", asks LLM to give macronutrients details about it, and then writes that information to database in a structured way, which the allows you to query the data later. All in about 90 lines of code.

To understand how the app does this, go to the repository and read the Start.goal file.

When you add knowledge to the app, it stores that knowledge in the database and submits it with each LLM request

Going advanced

What's interesting is that you can create variables in the your knowledge.

For instance, you could define the knowledge as "X es = x eggs and salad, with spinach, 2 tomatoes, cucumber, where X represents the number of eggs, the default is 2 eggs. Example: '3 es' = 3 eggs and salad.".

You can now send “4 es”, and the app would understand “4 eggs and salad”

What's cool here is that we're programming logic directly into the knowledge entry. Very powerful.

Conclusion

While the developers of the old fashion diary app had to create UI, complex logic & tests, simply because the way they receive input from users, using inputs and selects, the FoodDiaryApp with it’s natural input behavior, just makes it work without much or any work.

If you want to be ahead of the game, then less work is the key.

Top comments (0)