Concatenative languages (10)

1 Name: #!usr/bin/anon 2006-01-02 00:06 ID:eGiwJnGc

Anyone played with any concatenative languages, such as Joy and Factor?

http://www.latrobe.edu.au/philosophy/phimvt/joy.html
http://factorcode.org/

Joy is more conducive to playing with. I like it a lot. Factor is a "practical" type of language according to those who practice it.

Forth is also considered a concatenative programming language.

2 Name: !WAHa.06x36 2006-01-02 00:39 ID:Heaven

Sounds like more "let's do things different BECAUSE WE CAN!" functional-language wankery. I don't see it doing anything any better than any other language, just different for the sake of being different.

3 Name: #!usr/bin/anon 2006-01-02 19:12 ID:Heaven

Don't be such a curmudgeon. I'm trying to get some discussion going here.

4 Name: #!usr/bin/anon 2006-01-03 18:14 ID:eGiwJnGc

>>2 posted much too soon after >>1 to have seriously evaluated an unfamiliar programming paradigm. This reaction to new ways of thinking is a little disturbing.

Anyway, concatenative languages are sort of like reverse Polish notation (RPN). You write 2+5 as '2 5 +', where each number pushes itself and the + operator pops two operands and pushes its result on the stack. But concatenative languages are not the same as RPN. You can square whatever number happens to be on top of the stack by doing 'dup *', where dup is the operator that duplicates the object on top of the stack. This is not possible with RPN calculators. In Forth, the word (Forth calls subroutines "words") to square the number on top of the stack is defined by:

: square ( n -- n ) dup * ;

"( n -- n )" is a comment indicating that the word consumes one value from the stack and leaves one new value.

Forth dates back to the 1970s, but the author of Joy was first to use the term "concatenative", probably in the late 90s or early 00s. Joy is a more functional language, with quoted programs (basically functions) that can be pushed on the stack and used by various combinators. Factor on the other hand is intended for practical programming and as an evolution of Forth. Although it borrows quoted programs from Joy, it doesn't have the recursion combinators.

5 Name: !WAHa.06x36 2006-01-04 03:23 ID:Heaven

No, I didn't spend much time doing that, because the presentations of the language made no attempt to convince me there was any value in doing so. There was no suggestion as to why making this fairly significant effort would be of any benefit to me. It just seemed like the same old functional-programming academic thought experiments that I've seen a thousand times already. They're like obfuscated programming languages with less humor and more delusions of importance.

Now, I only looked at Joy, so I don't know about Factor. If it's designed for "practical programming", that's obviously better, but for the life of me I can't see why you'd ever design for anything else.

6 Name: #!usr/bin/anon 2006-01-05 17:42 ID:Heaven

"Practical programming" languages take new ideas from academic-type languages and put them to real-world use, e.g. Factor contains concepts borrowed from Joy. Without the more theoretical programming languages, we'd all be using a very nicely polished COBOL.

Academic languages are also good for thinking about computation: the Scheme REPL and so on. If that's "wankery", well, what field of mathematics isn't?

7 Name: #!/usr/bin/anon 2006-02-04 17:55 ID:+Vqa0je4

I'm backing WAHa up on this one: for the last week, I've been attempting to understand the whole concatenative language paradigm. None of the Forth tutorials I've read can offer up a good reason why stack-based mental gymnastics are better than letting the compiler do all that work. I've made inquiries at concatenative language lists, and the only answers I've gotten have been:

a) Expand your mind! (with nothing to back that statement up), or
b) Forth allows you to micromanage the stack for effiency (which is funny, because the "blazing fast" GForth compiler is usually about an order of magnitude slower than C over at the Great Computer Language Shootout).

The final straw came when, whil reading "Thinking Forth", the definitive Forth book, the author proceeds to demonstrate something that "could only be done in Forth!" that could have just as easily been done in C with pointers fifteen years ago.

Fleh.

8 Name: #!/usr/bin/anon 2006-02-05 20:25 ID:eGiwJnGc

>>7
The main reason I've heard (at least for Forth and Factor; Joy is closer to Lisp) is that these languages allow you to factor your code into really short words. Supposedly, this allows you to manage complexity and write less code. I've no comment on this personally as I've barely tried either language, but I'm surprised you didn't hear that justification. It's one of the major selling points of Factor and is mentioned on Chuck Moore's colorForth website (Chuck Moore is Forth's inventor).

9 Name: #!/usr/bin/anonymous : 2006-05-02 14:41 ID:Heaven

Yeah, "smallness" by eliminating redundant code is the main FORTH advantage I've heard about.

The interpreter is small, the code you write is small, and Chuck Moore is such an extremist at eliminating redundancy he produces completely functional systems (OS, API, GUI, apps) in a few megabytes.

I rejected that as pointless for a long time. Now I'm thinking this militant anti-redundancy approach might be a solution to code complexity and bloat. How many times have you read programmers' complaints about maintaining huge, undocumented, poorly written apps? If they were SMALL, NON-REDUNDANT poorly written apps, it wouldn't be as difficult.

Next step: check if FORTH really does guide a lazy programmer to avoid redundant code.

10 Name: #!/usr/bin/anonymous : 2006-05-02 14:43 ID:Rb2nnVFz

bump.

#9 was saged, but I want to see if anyone has any real experience with FORTH.

This thread has been closed. You cannot post in this thread any longer.