Dictu - A simple programming language
Tags: programming, computerscience, opensource, showdev
Published: 2021-10-05 19:04:28

## Dictu
[Dictu](https://github.com/dictu-lang/Dictu) is a high-level dynamically typed, multi-paradigm, interpreted programming language. Dictu draws inspiration from the family of languages surrounding it, such as Python, JavaScript and Lua. It's a language that I have been working on for a few years now with contributions gratefully coming in from developers from all parts of the globe.

Dictu doesn't deviate massively from the family of languages surrounding it, and it doesn't intend to replace them either - that would be incredibly difficult with the eco-system surrounding them; instead Dictu actually started off as a learning project building on the very good [craftinginterpreters](https://craftinginterpreters.com/) book. Since then however, it has grown into an actually usable language with my first "production" (public facing) application written in Dictu: https://paste.dictu-lang.com/

## Examples
I always find examples useful when first exploring a language, so I'll jot a few down here.

### Simple Guessing Game

```js
const guess = 10;

while {
    const userInput = input("Input your guess: ").toNumber().unwrap();
    if (userInput == guess) {
        print("Well done!");
        break;
    } else if (userInput < guess) {
        print("Too low!");
    } else {
        print("Too high!");
    }

    System.sleep(1);
}
```

### HTTP Request

```js
import HTTP;
import JSON;

HTTP.get("https://api.coindesk.com/v1/bpi/currentprice.json").match(
    def (response) => {
        const data = JSON.parse(response["content"]).unwrap();
        print("${} per BTC".format(data["bpi"]["USD"]["rate"])); // $50,417.1200 per BTC
    },
    def (error) => print(error)
);
```

It's worth noting that Dictu handles with errors differently to languages such as Python that have exceptions, instead Dictu has a Result value. A Result is a value that is either in a `Success` state or an `Error` state that can be unwrapped. For more detail, see the [documentation here.](https://dictu-lang.com/docs/error-handling/)
## Features
For a full overview it's better to consult the documentation, but for the sake of this post i'll list some of the standout features.

1. Result type error handling (explained briefly in the previous section).
2. Multi-paradigm, Dictu doesn't force a certain paradigm upon you and allows you to write how you want.
3. Functions are first class citizens.
4. Range of datatypes and methods relating to these datatypes built-in to the language (heavily inspired by Python).
5. Classes and inheritance along with access levels.
6. Garbage collection.
7. Modules.

## Future
Dictu is definitely in a state where it is usable to create projects with, but it still has a long way to go, and a lot of testing to be done. It is also missing some external tools that are almost a necessity if "mainstream" adoption of the language was to ever take place, such as a package manager, but it's slowly getting there.

Priorities in its current iteration is to extend the standard library that Dictu offers with a lot of that potentially being written in Dictu itself, which will be nice to see and a whole lot of testing for any issues.

If the language has perked your interest at all the following links may be of interest:
- https://github.com/dictu-lang/Dictu
- https://dictu-lang.com/