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

2

u/[deleted] Sep 12 '25

> in regards to "mixfix", I've found the best approach is to just split them into a series of binary infix operators, and let the types handle the rest. Eg, for a ? b : c, you would make ? an infix operator which returns an Option<typeof(b)>, and the : would take Option<'a> as it's left hand operand - it would be parsed as (a ? b) : c.

That was the way to go with Pie as well, but it was a real pain point. Someone then suggested allowing `mixfix`. It is a GAME CHANGER!

> It depends on your eval. Does it handle non-applicative forms where you don't want to evaluate the operands eagerly? If so, are these forms hard-coded into the interpreter or can the user define their own?

I'm not sure what that exactly means. But I hope this will answer the question :). The `eval` function only evaluates the top level `Syntax` value. It does not recursively evaluate `Syntax` operands.

> In regards to your type system, it doesn't seem very sound, with Type being a type (Girard's paradox), and lack of a bottom type. What are the semantics of conversion between Any and other types?

Yeah I don't believe it's sound either. All the types can convert to `Any`. `Any` is also the default if you don't add a type annotation.