Akuli / oomph

Yet another attempt at making a usable programming language
MIT License
5 stars 1 forks source link

oomph

This is yet another attempt at making a usable programming language. Oomph is a high-level language, but it compiles to C and aims to be faster than Python.

sudo apt install libssl-dev
git clone https://github.com/Akuli/oomph
cd oomph
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
make oomph
./oomph tests/hello.oomph   # compile and run hello world file

Why Oomph?

Oomph aims to be a small and simple language, with little boilerplate and few "gotchas". I will compare Oomph to Python, because it's a programming language with somewhat similar goals.

Oomph code is short. For example, class Foo(Int number, Str message) is valid line of Oomph code that corresponds to 4 lines of Python code:

class Foo:
    def __init__(self, number, message):
        self.number = number
        self.message = message

With dataclasses, the Python code is still 4 lines:

@dataclass
class Foo:
    number: int
    message: str

I have helped lots of Python beginners, and seen lots of Python gotchas they struggle with. Linters and type checkers can help with some of them, but not all. These Python gotchas don't exist in Oomph:

Python gotchas that also exist in Oomph (but fixing is planned):

Learning Oomph

Example code:

Docs:

Two compilers

Currently there's two compilers:

The self-hosted compiler can compile itself:

./oomph -o oomph self_hosted/main.oomph

Currently make oomph uses pyoomph to compile the self-hosted compiler.

Editor support

Visual Studio Code

Copy the oomph-vscode directory into ~/.vscode/extensions (might be .vscode-server if using WSL)

Porcupine

Porcupine is an editor I made. With small modifications, these instructions should also work with any other editor that uses Pygments for syntax highlighting (although I haven't seen many such editors).

  1. Go to "Settings" in Porcupine's menubar then "Config Files", then filetypes.toml.
  2. Add this to the file:
    [Oomph]
    filename_patterns = ["*.oomph"]
    pygments_lexer = 'oomph_pygments_lexer.CustomLexer'
    comment_prefix = '#'
    autoindent_regexes = {dedent = 'return( .+)?|break|pass|continue', indent = '.*:'}
  3. Restart Porcupine so that it can import oomph_pygments_lexer. It comes with Oomph. Python imports from the current working directory when using the -m switch, so you can do this:
    cd path/to/oomph
    python3 -m porcupine

    Note that you should not have the Oomph virtual env activated when doing this, unless you installed Porcupine into it.

Other editors

If you can make something that works, please create a pull request.

TCC

I like to use tcc when developing oomph. It compiles much faster than gcc, even though it doesn't optimize as well.

./download-tcc
make clean

Now make, ./test etc will use the downloaded tinycc. Currently you need make clean because the Makefile isn't clever enough to realize that the C compiler changed and everything has to be recompiled.

Profiler

I use the ./profiler script for profiling Oomph programs:

$ sudo apt install valgrind
$ python3 -m pip install gprof2dot
$ make oomph && ./profiler ./oomph --verbose -o /tmp/a self_hosted/main.oomph

This creates perf.png in the current working directory.

Stuff I wrote before I used Github issues with this project

Known bugs:

Missing features:

Deprecated:

Design questions to (re)think:

Optimization ideas: