Inspiration

If Java is the most popular imperative language, then its opposite should be a tea! In all seriousness, EARLgrey stands for Easily Accessible Routine Language, and it was the logical progression from my 15-112 term project: KIMCHI. KIMCHI performed a similar task but focused more on the kid-friendly "drag and drop" component while EARLgrey focuses more on the functional programming element.

What it does

Opens a saveable shell that can be used to write in EARLgrey, a custom programming language. EARLgrey is a pure functional language where everything is based on function calls and assignment expressions (x := 3 creates an immutable variable and sets it equal to 3).

How I built it

I built the core animation out of the GUI for my 15-112 term project and ran everything on Python. The language itself is centered on five core types (built using the more unusual magic methods in Python OOP). The five types represent the most simplified version of datatypes that are necessary for basic programming: Number (i.e. Python float), Vocab (i.e. Python string), Logic (i.e. boolean), and Transform (i.e. functions). The last one is the strangest and most complicated since it is possible to create new Transforms as values using a special set of operators or use Transforms on Transforms to return new Transforms. An example is my MAP Transform: it takes in a 1-input Transform and returns a new Transform that takes in a Union and applies the original 1-input function to all elements of the Union (NON DESTRUCTIVELY).

Challenges I ran into

I am inexperienced with proper parser trees, so I had to make do with a VERY limited notion of what each function can do on its own (i.e. very few functions calls inside of function calls) rather than spend too much time focusing on making each line be able to perform compound tasks. Additionally, I was annoyed by the logistics of having a cursor that could move around and delete/add text where I wanted it to.

Accomplishments that I'm proud of

The sheer amount of work that went into debugging the transformations was staggering, since it involved using the eval() function with f strings to generate lambdas, and some of those components in the f strings were referencing my own data types and thus had to be converted back into the format Number(n).

What I learned

The parser tree was a far more important aspect of making the language complete than I anticipated. Due to my emphasis on function calls rather than operators, the existing algorithms I found on short notice would not work. I do wish that I had a greater degree of knowledge in that area.

What's next for EARLgrey

Build in a parser tree so that internal function calls & multi-dimensional Unions can be made, and potentially find a way to enforce type inference, since almost all of the functions are strongly typed. Also, formally type up the extensive documentation into the tutorial page, which I did not have time to write. Also, improve the interface to allow scrolling.

Built With

  • 15-112-graphics-library
  • python
  • tkinter
Share this project:

Updates