According to Wikipedia, Examples of concatenative languages are Cat, Enchilada, Factor, Onyx, Postscript, RPL, Staapl, Trith, XY, Kitten, Om, Min and Forth so none actually used by anyone today, and this in itself indicates that you should not waste too much time with this paradigm. Postscript is the best known (RPL has been used minimally in the past) and it is used for a very specific niche (printing) and in practice people do not program in it manually. Forth is interesting and has already been used a lot to make some video games when there was very little memory and processing capacity. It is simple as Assembly, but powerful and easier
One of the advantages of this type of syntax is code reduction, because you only write what you need to do with the data. The expression of the code is less imperative, as is the normal of the languages we know, it is more declarative, but with simplified syntax. It is usually based on a stack of data, as the computer usually is at a certain level, so the execution takes place on data that is on the stack of data, so you have an operation that stacks the data and operations that perform something on it. Although different looks like the execution based on registers, more typical of how the computer works at its base, but it is even simpler, because with registers it is necessary to say which are involved, with stack, are always the ones at the top of the stack, nor need I say what they are.
So you can just tell what to do without worrying about what you’re going to do, it’s always going to be the type of stack, give comes the name of the paradigm, you put one execution after the other concatenating the operations on top of the same data or the ones that derive from these initial data. For those who know functional programming, it’s like creating a pipe execution. In C# and language that copied LINQ is similar, you say what you want on top of the same data. LINQ alone is practically a concatenative language.
It gives a huge simplification about the state it’s manipulating, but it also complicates with constructions where it has many states, and where it has many strands of execution. It works well when it takes a few data and they are manipulated in sequence until it reaches the final result. So it’s much easier to write code for her, and it’s easier to find bugs, as long as you are using where it is appropriate.
In general these languages are homoiconic and use monoids. And it’s usually easy to write compilers for them, although this can be up to a negative point for the overall result.
Don’t you understand anything? No problem, it doesn’t help most programmers to know that. It helps, but you have to build all the knowledge to get there. This is a loose brick, they need others under it for this knowledge to form a solid wall.
Syntax of PS:
%!PS
/Courier % name the desired font
20 selectfont % choose the size in points and establish
% the font as the current one
72 500 moveto % position the current point at
% coordinates 72, 500 (the origin is at the
% lower-left corner of the page)
(Hello world!) show % stroke the text in parentheses
showpage % print all on the page
And RPL:
0 @ Start with zero on the stack
1 10 @ Loop from 1 to 10
FOR I @ "I" is the local variable
I + @ Add "I" to the running total
NEXT @ Repeat...
And Forth:
0 value ii 0 value jj
0 value KeyAddr 0 value KeyLen
create SArray 256 allot \ state array of 256 bytes
: KeyArray KeyLen mod KeyAddr ;
: get_byte + c@ ;
: set_byte + c! ;
: as_byte 255 and ;
: reset_ij 0 TO ii 0 TO jj ;
: i_update 1 + as_byte TO ii ;
: j_update ii SArray get_byte + as_byte TO jj ;
: swap_s_ij
jj SArray get_byte
ii SArray get_byte jj SArray set_byte
ii SArray set_byte
;
: rc4_init ( KeyAddr KeyLen -- )
256 min TO KeyLen TO KeyAddr
256 0 DO i i SArray set_byte LOOP
reset_ij
BEGIN
ii KeyArray get_byte jj + j_update
swap_s_ij
ii 255 < WHILE
ii i_update
REPEAT
reset_ij
;
: rc4_byte
ii i_update jj j_update
swap_s_ij
ii SArray get_byte jj SArray get_byte + as_byte SArray get_byte xor
;
I put in the Github for future reference.
Good to know that I don’t need to update myself with this. Just understanding the concept seems enough.
– Diego Souza
Maniero, when you come to Piracicaba to give a talk about Microsoft LUIS?
– Diego Souza
Never! I don’t go to Piracicaba... : D Lie, I always go there, I studied there. But the "never" is that I don’t touch with LUIS and I don’t intend to, so I’ll never talk about it in Piracicaba or anywhere else. But if you have organized some nice event that will go enough people I can bring someone who knows it well.
– Maniero
Gosh, the way you talk about it sounds like business still needs to mature a lot. I’m using Qna Maker for a FAQ chatbot. It’s good. There was Devpira these days. But I wasn’t.
– Diego Souza
Also need, I see no real good results, so there are people using as positive marketing that meet with humans.
– Maniero