🍑PEACH🍑 programming language
PEACH - Prototypical language with knack for extensibility and meta programming
PEACH is a modern programming language, handwritten in both Python and itself, completely written from scratch over the past 20 days. Included is the core language, a standard library, and some examples(including TicTacToe!)
In PEACH, all types are objects, and vice versa. Everything is an object, and that includes functions. Objects descend from a parent object and inherit functions and variables from the parent. For example, to create a type, we extend from a parent
Object (in this case
Type), and define any methods needed within the type.
The core library in PEACH is written in itself, even allowing for methods to be attached with the
Object.patch() method at runtime. Types in PEACH are built of
Objects and have overloadable functions for operations such as addition, subtraction, multiplication, division, modulus, and compare.
All builtin types such as String, Int, Float, Array, Bool, etc. are all defined completely in PEACH, including all operations that can be done on them. An example of this supercharged extensibility being the call operator can be overloaded, with an example being that when a Number is called, like
5(10), the values are multiplied together, allowing for a more classical math-like syntax in programming.
Types are objects and all objects are patchable, meaning you can swap out or add methods dynamically.
Later we plan to rewrite PEACH in C/C++ for better speed, efficiency. Both of us have more experience in C/C++. We plan to keep PEACH code and the standard library similar to how it is today.
vars - How to declare and use variables
functions - Writing and calling functions
strings - Strings operations and interpolation
operators - Available operators + Operator overloading
types - Custom types
embedding - Embedding in Python
proto - Extending types using prototypical inheritance
macros - Macros
arrays - Array operations
iterators - Building custom iterator objects
random - Random number generation
modules - Modules
console - Console input and output
files - File reading and writing
Be sure play the TicTacToe example for yourself!
Start the REPL by running
main.py and call
tictactoe(); to try it out!
using our macro syntax (check the doc for more info), we have been able to prototype more of the extensibility features we’d envisioned originally. This includes building custom control structures such as a custom match or switch-like block.
With the macro feature:
To start the PEACH repl:
What's cool about PEACH is that much of the language is built in itself, such as boolean types and even the 'Null' object! You can peer into the code by looking at the files in
std/types/. Here's what null looks like, hopefully this gives an idea of how parts of the language are implemented internally.