Idea for a (toy) programming language
11 Jul 2019
Project Page (WIP)
With the advent of V (which I only took a cursory look at. Alas, what I saw I liked very much. It looks and feels like Go on steroids)
I’ve recently become interested in writing my own (toy) language. Partly to serve as a learning/teaching aid in language theory
(My niece. My mother. The trainees at my day job. I’ll be damned if I don’t turn everybody I meet into a programming nerd 😹). Partly to have a modern,
easy to use language for writing small applications and games.
The initial implementation is unlikely to be “high fidelity”. Just straightforward BNF for the grammar,
Go for the compiler/generator, and a few bits and bobs in C++.
PSA that I’m not even remotely a language theorist, nor a compiler designer.
Initial Ideas
- File extension: .tby
- No unsightly semicolons.
- int as a shortcut for int32
- int should ALWAYS be 32 bits wide. Even on 64 bit systems.
Contrary to Go but similar to C#.
- Arithmetic overflow checks.
- Subtracting a larger numerical from a smaller one
should, for starters, either
return 0 or throw a runtime/compiler error.
- Immutable by default.
- Prepend a variable/structure with ~ to signify its mutability.
- Pure functions by default.
- Support for conditional imports (?).
- Go, Rust, C++ or V as “IR” (intermediate representation).
- go-compiler uses C++, but that could
be altered quite easily.
- For Go I would have to test the code extensively, with GC disabled.
- Standard library that includes some form of graphics support. Potentially, Cairo/SDL2/OpenGL.
- Support for 32Blit and other embedded gaming devices.
- Microsoft UWP support (requires OpenGL ES or DirectX bindings).