Explain concatenative languages to me like I'm an 8-year-old

后端 未结 7 2002
粉色の甜心
粉色の甜心 2021-01-30 22:53

I\'ve read the Wikipedia article on concatenative languages, and I am now more confused than I was when I started. :-)

What is a concatenative language in stupid people

7条回答
  •  失恋的感觉
    2021-01-30 23:23

    I reckon the main idea is 1. We can create new programs simply by joining other programs together.

    Also, 2. Any random chunk of the program is a valid function (or sub-program).

    Good old pure RPN Forth has those properties, excluding any random non-RPN syntax.

    In the program 1 2 + 3 *, the sub-program + 3 * takes 2 args, and gives 1 result. The sub-program 2 takes 0 args and returns 1 result. Any chunk is a function, and that is nice!

    You can create new functions by lumping two or more others together, optionally with a little glue. It will work best if the types match!

    These ideas are really good, we value simplicity.

    It is not limited to RPN Forth-style serial language, nor imperative or functional programming. The two ideas also work for a graphical language, where program units might be for example functions, procedures, relations, or processes.

    In a network of communicating processes, every sub-network can act like a process.

    In a graph of mathematical relations, every sub-graph is a valid relation.

    These structures are 'concatenative', we can break them apart in any way (draw circles), and join them together in many ways (draw lines).

    Well, that's how I see it. I'm sure I've missed many other good ideas from the concatenative camp. While I'm keen on graphical programming, I'm new to this focus on concatenation.

提交回复
热议问题