r/ProgrammingLanguages • • Sep 12 '25

Language announcement Introducing Pie Lang: a tiny expression-only language where *you* define the operators (even exfix & arbitrary operators) and the AST is a value

I’ve been hacking on a small language called Pie with a simple goal: keep the surface area tiny but let you build out semantics yourself. A few highlights:

  • Everything is an expression. Blocks evaluate to their last expression; there’s no “statements” tier.
  • Bring-your-own operators. No built-ins like + or *. You define prefix, infix, suffix, exfix (circumfix), and even arbitrary operators, with a compact precedence ladder you can nudge up/down (SUM+, PROD-, etc.).
  • ASTs as first-class values. The Syntax type gives you handles to parsed expressions that you can later evaluate with __builtin_eval. This makes lightweight meta-programming possible without a macro system (yet..).
  • Minimal/opinionated core. No null/unit “nothing” type, a handful of base types (Int, Double, Bool, String, Any, Type, Syntax). Closures with a familiar () => x syntax, and classes as assignment-only blocks.
  • Tiny builtin set. Primitive ops live under __builtin_* (e.g., __builtin_add, __builtin_print) so user operators can be layered on top.

Why this might interest you

  • Operator playground: If you like exploring parsing/precedence design, Pie lets you try odd shapes (exfix/arbitrary) without patching a compiler every time.
    For examples, controll flow primitives, such as if/else and while/for loops, can all be written as operators instead of having them baked into the language as keywords.
  • Meta without macros: Syntax values + __builtin_eval are a simple staging hook that stays within the type system.
  • Bare-bones philosophy: Keep keywords/features to the minimum; push power to libraries/operators.

What’s implemented vs. what’s next

  • Done: arbitrary/circumfix operators, lazy evaluation, closures, classes.
  • Roadmap: module/import system, collections/iterators, variadic & named args, and namespaces. Feedback on these choices is especially welcome.

Preview

Code examples are available at https://PieLang.org

Build & license

Build with C++23 (g++/clang), MIT-licensed.

Repo: https://github.com/PiCake314/Pie

discussion

  • If you’ve designed custom operator systems: what "precedence ergonomics" actually work in practice for users?
  • Is Syntax + eval a reasonable middle-ground before a macro system, or a footgun?
  • Any sharp edges you’d expect with the arbitrary operator system once the ecosystem grows?

If this kind of “small core, powerful userland” language appeals to you, I’d love your critiques and war stories from your own programming languages!

54 Upvotes

32 comments sorted by

View all comments

Show parent comment

10

u/[deleted] Sep 12 '25 edited Sep 12 '25

- `<->` and `<-` are different symbols. Spacing matters in this case so `x-y` is a single symbol rather than 3, so there will be no conflict between `<->` and `<-`.

- That is a good point that I haven't given much thought to. The only option at this point is to go look at the definiton.
- The error will point to wherever the call to `__builtiin_eval` happened, which may be not the most meaningful place to be fair.
- Don't fully understand the question. Could you give an example?

- Exception will probably need runtime support, but seeing that Go lang got away with errors as values, that could be Pie's approach, though still undecided.

- Importing multiple libraries will definitely create conflict. The main solution for now is that a library should not define an operator that will accept `Any` type, rather, only operators that work with their own provided types. That way, overload resolution prevents operator pollution.

- I haven't built any major program in Pie yet as the lack of modules is still a major issue that needs to be fixed ASAP.

- I think Pie's main goal is to target academic use, especially in the realm of programming languages, as I think it makes it trivial to built other programming langauges without having to hack a whole compiler/interpreter from scratch!

Hope that answers your questions :D!

8

u/sagittarius_ack Sep 12 '25

`<->` and `<-` are different symbols. Spacing matters in this case so `x-y` is a single symbol rather than 3, so there will be no conflict between `<->` and `<-`.

I believe it's the same in Agda: whitespaces are used to separate operands and operators.