Daily Note - 2024-05-05
Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This note was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
I've been talking about why Caterpillar uses postfix operators. Yesterday, I introduced how those work for simple math operations, comparing them to infix. Today, I'd like to conclude the comparison to infix, by explaining why infix operators aren't an option as the only kind of operator in Caterpillar.
So, why is that? For a start, because they only work
with two operands. If you have fewer, you need prefix or
postfix anyway. If you have more, you need to repeat the
operator (1 + 2 + 3
). Postfix operators
have a similar problem (1 2 + 3 +
), but
also an easy way out. If you use arrays, you can write
something like [ 1 2 3 ] +
instead.
Infix operators have the advantage of being familiar. But in addition to not being generally applicable, they require parentheses and operator precedence (otherwise, their familiarity is subverted), each of which add complexity to the language. I think that makes avoiding them the right call for Caterpillar.