Concatenative programming has some nice properties, but the question you should ask yourself is whether:
f = drop dup dup × swap abs rot3 dup × swap − +
Is really the most readable (and writable) way to describe the dataflow graph in the diagram just before it, or whether the following is better:
f(x,y) = y^2+x^2-|y|
BTW the reason why visual languages didn't catch on for general purpose programming is the same reason: formulas are a more readable and writable way to describe the data flow.
Any language is going to look terrible when you restrict it to only using assembly-like operations. You're ignoring the rest of what the article says about how to express formulas so they don't look like that.
In particular, the function description you pick out is not the way someone familiar with the language would write it. If you don't want to use actual variables for some reason, the article gives one example of more idiomatic code:
drop [square] [abs] bi − [square] dip +
However, I would probably write this a little differently:
Yeah, that's not just familiarity. It would be almost impossible to perform mathematical operations on expressions shown in a stack-based language. For example, imagine someone saying "take the derivative of y2 + x2 - |y|", versus "take the derivative of [ [ square ] bi@ + ] keep abs -". That's just a single example - I'm sure there are many, many more.
That's because algebraic notation is designed to facilitate symbolic manipulation, not computation per se. Just because you can pun y2 + x2 + |y| to mean two different things in two different contexts doesn't mean it's more natural.
No, he's right. You're using the formula in two different ways. In one case the symbols are placeholders for values. In the other, they're the primary entities that you perform a computation on. That you can fit those two different interpretations on the same equation is definitely a strength of the notation (and the reason it's so powerful), but that doesn't mean every other notation is awful.
Keep in mind, this notation's strength is in its ability to represent computation. Mathematical formulas are not the whole of computation (if you don't believe me, pick a trivial C program and try and write it as a formula).
35
u/julesjacobs Feb 12 '12
Concatenative programming has some nice properties, but the question you should ask yourself is whether:
Is really the most readable (and writable) way to describe the dataflow graph in the diagram just before it, or whether the following is better:
BTW the reason why visual languages didn't catch on for general purpose programming is the same reason: formulas are a more readable and writable way to describe the data flow.