r/ProgrammingLanguages • Transfem Programming Enthusiast • May 18 '26

Requesting criticism Flower Compiler (Bootstrapped Compiler)

Hey all!

For the past few months I've been working on a language called Flower. It was originally written in C (files can be found under /vendor/) but is now fully bootstrapped (with some caveats). The goal is to eventually move toward a fully self-hosted toolchain and custom backend, but for now it transcompiles to C.

Some current language features:

  • structs
  • pointers (@T)
  • arrays
  • function definitions/calls
  • manual memory management (new / prune)
  • operator precedence parsing
  • struct literals / array literals
  • casts
  • dereferencing / address-of
  • control flow (if, while, for, etc.)

Example:

struct Vec2 {
    x: float,
    y: float
}

float length(v: Vec2):
    return v.x * v.x + v.y * v.y
end

I thought I knew a decent amount of C and programming before hand, especially considering this isn't my first time making a language in C, but I've noticed how far my skills have come especially regarding just being able to problem solve and properly organize my project structure.

Recently I added parser error recovery in v1.1.0, and after a lot of trial and error I think I've finalized my parser to a recursive-descent style approach.

Let me know any criticism, opinions, or comments you have! I'd love to get some input :)

https://github.com/IvyMycelia/flower/blob/main/

25 Upvotes

19 comments sorted by

View all comments

Show parent comment

3

u/TrendyBananaYTdev Transfem Programming Enthusiast May 18 '26

The colon at the end of function definitions is mostly a pragmatic choice rather than a visual one. I'm planning on making the language newline-insensitive where possible, and the colon helps disambiguate function bodies cleanly. It also makes it immediately obvious whether a function is a definition or a forward declaration, though the forward keyword already partially solves that.

I’ve considered removing the colons from parameter declarations:

int foo(x int, y int)

and I may experiment with it more, but I’m slightly worried about ambiguity once generics or more complex type syntax are introduced.

I also intentionally avoid C-style declarations (int x) for variables. They're familiar to C programmers, but for everyone else they can be surprisingly unintuitive, especially once declarations become more complicated. Things like the “Most Vexing Parse” are a good example of how awkward declaration syntax can become when types lead the statement.

Pascal-style declarations:

x: int

feel much easier to parse visually, and honestly simpler to parse in the compiler too (at least in my opinion and experience with both).

The return type being before the function name is partially a compromise between the two styles, where return types stay prominent visually, variable declarations remain name-first, and parsing stays relatively straightforward.

3

u/TOMZ_EXTRA May 18 '26 edited May 18 '26

Lua uses the function foo(x,y) ... end syntax while being newline-insensitive, so it's definitely possible.

However, Lua also allows some quite unusual syntax due to it being newline-insensitive.

x = 1 y = 1
print(x)
-- This works fine.

1

u/TrendyBananaYTdev Transfem Programming Enthusiast May 18 '26

Definitely something for me to explore; whether or not RPAREN —> parse body at the end of functions.