8 ms·
Concatenative Language
- compressedgas 4y agoThe minimal Joy: [A] a = A [A] b = [[A]] [A] [B] c = [A B] [A] d = [A] [A] [A] e = [A] [B] f = [B] [A]
- tromp 4y agoThat's 6 primitives (unquote,quote,cat,dup,drop,swap). For comparison, here's the minimal (non-concatenative) Combinatory Logic: S x y z = x z (y z) K x y = x The following by itself also suffices, but needs K in its definition: S' x y z = x z (y (K z))
- lupire 4y agoYou can do (approximately) the same in Joy, so I don't know what parent meant by "minimal". http://tunes.org/~iepos/joy.html#conssipk http://tunes.org/~iepos/joy.html#conssipk This should be expected, because concatenative is a syntax style alternative to applicative syntax for functions, and has no trouble with lambda calculus semantics. The main difference (why Joy uses (s',k) instead of (s,k)) is that Joy has quoting, but this just for convenience for large data, not essential.
- tromp 4y agoI use minimal in the sense of the smallest number of primitive proper combinators [1]. Thanks for pointing out that Joy is similarly minimal. Do you know of any concatenative language without quoting? I find combinary languages simpler than concatenative ones, since the former uses only application as a composition mechanism, whereas the latter uses both concatenation and grouping with []. [1] https://math.stackexchange.com/questions/839926/is-there-a-proof-of-nonexistence-of-a-proper-universal-combinator https://math.stackexchange.com/questions/839926/is-there-a-p...
- lupire 4y agoHonestly I don't really understand the deeper meaning of quoting/grouping, so I might be quite wrong about its use. How is concatenative grouping/quoting different from combinatory parentheses (or your binary equivalent). In pure lambda calculus you need parentheses to disambiguate, because everything is a function and there are no natural non-functional values. In a concatenative language you need something to solve that problem, maybe quoting does that? I'm over my head when I think about precisely how "small" these languages are, when trying to be explicit about how much is hidden in the virtual machine of evaluating a program (string of symbols).
- harperlee 4y agoWhat’s the computational efficiency though? (Is there a general way to study the relative gains of adding primitives to a computation base*? I suspect just defining the complex one in terms of the simpler one would risk losing the measure of some expressivity options further than just defining the complex one). * EDIT: Not merely expanding a base but e.g. comparing a 6-set with a /different/ 2-set, as above.
- tromp 4y agoThere are several possible ways to quantify expressiveness of a basis. For instance, you can count how many unique lambda normal forms you can generate with combinator expressions up to a certain size (modulo some terms that take too long to normalize). I once counted this for various choice of single-point combinator bases and up to size 16, and found that the above S' produced over 2 million normal forms whereas for instance the more well known \x.x S K produced only 244 normal forms. When you look only at how easy you can recover S and K, then the latter is much superior though (length 16/11 versus 3/3).
- stouset 4y agoAIUI, in theory, they're all the same given a sufficiently advanced optimizing compiler. They're all equivalently-powerful way to model computation, so can all in principle be translated back and forth. In practice extracting optimal efficiency is difficult.
- sfvisser 4y agoInteresting related paper by Jeroen Fokker: The Systematic Construction of a One-Combinator Basis (1989) https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.5163 https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19....
- l- 4y agoY'=SSK(S(K(SS(S(SSK))))K)=X(XX)X(XX)XX(X(XX)(XX(X(XX)X(XX)(X(XX)(X(XX)X(XX)XX))))XX) X(XX)X(XX)XX [ 0, 1 ] == {(, X}] Binary Combinatory Logic Truth: 1101111
- hoseja 4y agoThe title made me ponder a programming language with grammar different from the default english-inspired one, with it's immutable tokens and other ease-of-parsing limitations.
- JohnDeHope 4y agoIt's like a competition for which alternative programming paradigm is a hill most worth dying on: functional, concatenative, or object oriented. There seem like a few runner-ups: contract based, quantum, APL (not sure what paradigm to call it?), I'd like to think of some others. It's kind of a fun exercise. The majority of programmers seem to prefer procedural.
- cmrdporcupine 4y agoAPL & descendants are array/vector (or matrix) languages. Anyways, the majority of programmers like general purpose languages that are popular with other programmers, because that's how you get employed and make money. And what has happened in the last 20 years is that techniques from functional & vector languages have made their way into mainstream languages. Either in the syntax or in their libraries. That's a good thing after the previous decade+ of "object orientation will solve all our problems" dogma. Concatenative approaches remain relatively under-explored though.
- dTal 4y agoThey aren't mutually exclusive. If you use numpy, you're using array-oriented, procedural, and object oriented all at once; maybe functional too, depending on your programming style. They should be thought of less as all-consuming "paradigms" and more as useful tools, like regex. Sometimes a tool is so powerful you can do everything with it; that doesn't mean it's a good idea!
- agumonkey 4y agoPersonally I think the paradigm is not the right battle. OO is a child of modular programming, with other ingredients but to me the real pain point is aiming at low coupling subsystems to be able to iterate at low cost and navigate unknown problems or adapt to customer/market changes. There's also the middle layer trick (ala middle ground DSLs). But the goal is the same, ability to converge quickly on a proper solution. Something I rarely see talked about (but my radar has a short scope)
- infogulch 4y agoLogic languages
- toxik 4y agoVery interesting, though I have to wonder if this wouldn’t become incredibly hard to read. You sort of always put the horse before the cart. Especially the if is incredibly difficult to parse, as the condition is already on the stack, AND the two branches. This is quite the reverse of what imperative languages do, which mimics natural language: if x then y else z.
- lupire 4y agoStack/RPN languages are nice because they are easy to evaluate left to right, because you collect the arguments before you call the function. The stack is reduced as soon as possible, so max execution stack size is equal to the essential complexity of the calculus, for eager-evaluation languages. "Traditional" Verb-Object order is tricky because you have to save the whole stack of functions before you can start reducing anything. But it's nice if you have partial/lazy evaluation and might discard argument/function calls without evaluating them. For human UI, it's trivial to view/edit a program displayed in reverse, and add some redundant parentheses, for an applicative syntax, if you like.
- agumonkey 4y agoTo me stack language helped my brain forget about intermediate couplings, where in imperative language you have to imagine and manage data structures with operation around. When all you have is a stack, it's one variable less to worry about, you focus your energy on primitive ops.
- potiuper 4y agoVerb-Object order is not traditional as English is SVO, and Latin by "tradition" puts it at the end; nor does the whole stack of functions have to be saved before reduction can start see the sum or product operators or "verbs".
- lupire 4y agoEnglish instructions (programs) are Verb-Object with no Subject.
- artemonster 4y agoFORTH like I.
- lupire 4y ago* Forth I like
- jonsen 4y agoI Forth like or
- johnisgood 4y agome factor love-in-between? [ t ] [ f ] if
- account-5 4y agoExcuse my ignorance but could lisp be considered concatenative?
- cyberbanjo 4y agoI don't think so but Factor is a concatenation language with macros and extensible syntax.
- macintux 4y agoInteresting you ask: there are a fair number of similarities between Forth and Lisp. http://wiki.c2.com/?ForthVsLisp http://wiki.c2.com/?ForthVsLisp
- stonemetal12 4y agoNo, Lisp is applicative. The link splits languages in to applicative vs concatenative. This is straight up Church-Turing. Where Applicative is Church's a program is function application, and Concatenative is Turing's a program is a list of instructions concatenated on an infinite tape.
- t-3 4y agoNot traditionally, but if viewed as a style, like functional programming, most every language can be used concatenatively.
- cwmma 4y agoI read the title, thought it was about speaking languages and was confused because it's the non-concatanative one's that are interesting. https://en.wikipedia.org/wiki/Nonconcatenative_morphology https://en.wikipedia.org/wiki/Nonconcatenative_morphology
- carapace 4y agoAllow me to plug my own little entry in this space: a dialect of Joy written in Python, Prolog, and Nim (there's a Rust version in progress.) The project is messy at the moment (I am folding all the implementations into one repo from separate repos right now) but FWIW it's here: https://joypy.osdn.io/ https://joypy.osdn.io/ Some points: - Working with Joy has convinced me that syntax is a MacGuffin. You have to have some syntax to "move the story along" but it's not important in and of itself. (The Maltese Falcon.) All this work on languages and parsing is fun and useful, but now it seems to me like a bit of a sideshow. - It's relatively easy to manipulate Joy expressions in a kind of mathematical way. This is the "missing link" of Functional Programming: Do math to derive programs like Backus said. - Related to the above, Joy is sooooooooo simple. It is simpler and more elegant that Forth or even Lisp. - The Prolog interpreter is also a type inferencer! It can interpret over abstract stacks. IMO, it's one of those languages like Prolog or APL that you should learn even if you never use it, just to expand your mind.
- protomyth 4y agoPostScript struck me as a really nice concatenative language. It has some really nice extras. It's probably in the nature of the languages and their users, but they seem like a class of languages where a specialized IDE would really help.
- tromp 4y agoI agree; it's also nice for writing little obfuscated signatures, such as %!PS % -John Tromp http://tromp.github.io/ /t{dup 1 sub gsave dup 0 gt{[.4 .2 -.2 .4 .4 .2]concat t currentgray .8 mul .2 add setgray -1 1 scale t -1 2 translate t 1 -1 scale t[0 1 1 0 0 2]concat t pop}{0 moveto 1 0 lineto 0 2 lineto closepath clip fill}ifelse grestore}def 10 10 translate 600 600 scale 5 t showpage for producing a pinwheel tiling [1]. [1] https://tromp.github.io/img/pinwheel.pdf https://tromp.github.io/img/pinwheel.pdf
- spindle 4y ago(As you probably know), Factor comes with a really nice specialised IDE (written in Factor)
- protomyth 4y agoActually, I didn't. Thanks for telling me. I don't remember it from the time I looked into it. Is Factor a going concern?
- spindle 4y agoI don't think anybody's writing anything impressive in it any more, but yes it's a going concern in the sense that fine people are keeping it from bitrotting. :-)
- johnisgood 4y agoFactor (https://github.com/factor/factor https://github.com/factor/factor) is a pretty good language!
- a3w 4y agoRuns the linked wiki. Farkup for non-markdown rendered content sound like f*ckup, though. And: why another markup language?
- aidenn0 4y agoIf Om is concatenative, than so are lisp macros; they take the entire macro form as input and return a new form, which is then subject to macroexpansion.
- d0mine 4y agoShell has concatenative aspects: commands can be stacked while processing single data (command line) e.g.: $ timeout 1h notify <event> send-telegram <message> here's we send <message> if <event> occurs within an hour (3 commands: `timeout`, `notify`, `send-telegram`).
- Existenceblinks 4y agoHmm, am I correct that shell commands is kinda concatenative? So are languages that have "pipe", if they only permit to only use pipe?
- nuggets321 4y agowebsite is currently not responding.