Crosscut

Daily Thought - 2025-02-13

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

I showed you a clear-cut example that demonstrates a difference between prefix and postfix syntax. But of course, reality is more messy than that.

That difference is less clear-cut, if we consider bindings (also called variables). With those, yesterday's prefix code can be written like this:

let a = first_do_this();
let b = then_this(a);
finally_this(b)

Now the code reads naturally in order of execution, just like the postfix code. Depdending on the specifics, naming the intermediate values could even increase readability. Or it might not. In case it doesn't, many languages offer a pipe operator:

first_do_this |> then_this |> finally_this

With this, we can write postfix-like code in a prefix-by-default language, using a special operator. It's a little bit more noisy than an actual postfix language, but maybe that's fine.

And while we could argue that these techniques just offset a natural disadvantage of prefix syntax, there is also at least one aspect where prefix syntax is genuinely better. Let's talk about that tomorrow.

Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email every time I post a new one.