ONLang: json based programming language
2 min read
·
8/15/2022

Recently, a person gave me the idea of ​​creating a programming language that runs on json. I really liked this idea. I thought it would be interesting to create such a language.

Idea

Everything starts with an idea. It was necessary to figure out how the command writing format would look like. The first ideas began to appear.

{ "print": ["Hello world!"] }

or

[
  { "let": ["var", "world!"] }, 
  { "print": ["Hello", { "var": "var" }] }
]

Of course, these concepts will be reworked later.

Start of development

The Rust programming language was taken as the basis. Speed ​​and security will help make the interpreter.

%[https://github.com/artegoser/ONLang]

First features

Initially, functions for output to the console were written.

[
  { "print": ["...arguments"] },
  { "println": ["...arguments"] }
]

In order not to always write println, the ability to output strings or arrays was added without writing {println:[]}

["Hello world!", ["Hello ", "world!"]]

To be able to add, subtract, compare values, the calc and comp functions was added.

[
  { "calc": [2, "*", 2]}, //return 4
  { "comp": [2, ">", 3]} //return false
]

Further features

Then loops, declaration of variables, getting the values ​​of variables, declaration of functions and conditions were added.

All functions that are now in ONLang are described here or in documentation

Factorial function test

Examples

[
  { "loop": [{ "println": ["Endless loop!"] }] },
  { "let": { "var_name": "value" } },
  ["var_name = ", { "var": "var_name" }]
]

YAML support has also been added.

What will be added

  1. Import other files.
  2. Methods for types (arrays, objects, strings).
  3. Type conversion.

complete list (it's updating)

What is this for?

For scripting fun.

If you can help improve the interpreter, then I will be grateful to you.