Concatenative languages warrant a mention of Factor, a modern, fairly mature, dynamically typed object-oriented concatenative language with a nice interactive environment—I encourage people to download it and play around, as well as read Andrea Ferretti’s Factor tutorial.
I’ve also been working on a statically typed concatenative language (Kitten) off and on for a while, which I hope to release this year (as well as update the tragically old website).
5 minutes? You probably did it wrong, in Factor, primes up-to 9 millions are computed at build time, and it usually takes less than 100ms on common hardware using a sieve of Eratosthenes (source: am the author of the math.primes
standard vocabulary in Factor).
I agree it would be better if the graphics were toned down a bit.
Factor's listener (repl) is a similar idea and has a nice and simple implementation. The listener evaluates the expression and then calls a generic function (which can be implemented on any type of object) to get a widget, which is then appended to listener.
I'm not the one getting triggered by this exchange. It's not that I like or dislike terms. You have clearly stated that you reject the field's standard definitions. I have simply pointed out that without the use of standardized language when interacting with other programmers how exactly do you expect them not to misunderstand if you're not using terms the same way?
You keep latching onto details and attempting to use them strengthen your position in your own eyes. Now you've resorted to insults. Your position is untenable and you are just doggedly refusing to accept reality. As for safe spaces you are the one demanding to be special by using your own personal vocabulary and insisting that people learn your terms rather than using standard terminology.
If you want a Forth like language that's higher level have you ever considered Factor? Forth is a low level language no matter what you personally think about it. It sits just on top of assembly.
Factor and its earlier cousin Joy are both homoiconic and allow functions to be manipulated as data structures at runtime, and I believe at compile time as well in Factor. Function values are called “quotations” in concatenative programming, and in these languages, they can be represented as an array containing a mix of “words” (named functions) and nested quotations. Concatenative languages have very simple structure, a bit like Lisp without all the parentheses. Of course you can also build more complex imperative-style notation on top of that basis; I’ve done some of that in Kitten to make it look more familiar to more programmers.
Well there is always factor, if you haven't tried it. Arguably had more momentum than oforth or 8th, but the creator hasn't been working on it the last few years. Still a very nice language.
Slava Pestov is a stack ninja, the disciple of Charles Moore, who is master.
Don't know of any other ninjas.
: start-jerk ?4realz if
Oh, I love me some Forth too. I am just waiting for one of these kids to build me a Forth powered browser though, so I can write AngularForth. I am also waiting for Rob Pike to learn about ColorForth so that we can jerk about how evil it must be to have syntatically significant syntax coloring.
then
Do you some time to talk about our lord and savior factor?
; start-jerk OK
Two exciting examples of minimalist syntax include:
the language Eve with the Search, Bind, Commit organization. It is a declarative only language which uses only one complex datatype which is sets of records.
the stack based Factor programming language. This is a point free language, there are no variables. This is perfect for an interpreter project because each language token is considered by itself. Syntax is just a series of words (well, they still use square brackets for a block of words) Each word either pushes itself on the stack (especially literals), or pulls values off the stack, processes it, and pushes new values onto the stack. This is the Forth language all grown up for the functional world.
Nice to see Factor on here—stack languages take a bit of getting used to, but once you understand the model it’s really addictive how expressive it is.
Factor’s interactive environment is awesome, too, better than any REPL you’re likely to have used. And it has a ton of libraries for such a young language (0.97 is coming out next month!). If you want a fun dynamically typed OO language with good performance, Factor is definitely worth a try. One persistent problem is the lack of tutorial-style documentation, though there’s a lot of reference-style docs, and the #concatenative channel on Freenode is very helpful.
As a matter of fact I do sell prints. You can get them off of my Redbubble. I haven't slapped this piece on there yet, but I'm happy to if you'd like a print of it specifically.
In terms of concatenation programming languages, I absolutely adore this variety. If you're ever interested in implementing something with them, take a look at Factor, it's easily the most modern full-featured one at the moment (Om is pretty nifty as well).
To others looking for a new language to try, check out Factor, an object-oriented concatenative language. It’s probably different enough from what you’ve used before to be an interesting challenge, but usable enough that you’ll be able to get something done. Although I’d recommend just reaching straight for the locals
vocab unless you’re very familiar with point-free programming already. :P
: upc ( str -- n ) 11 CHAR: 0 pad-head [ digit> ] { } map-as [ <evens> sum 3 * ] [ <odds> sum + ] bi 10 mod [ 0 ] [ 10 swap - ] if-zero ;
Note: I make every effort to programatically figure out if links originally posted to Reddit are still good, but it's difficult.
If the original URL doesn't work, or has been replaced with something else, please help out by searching the Wayback Machine for the URL and posting a contemporary link if you find one. There's also a Chrome Extension which makes this process easy.
It's a little more subtle than RPN. For example, there is a word that changes the mode of interpretation to quotation until a certain end word, sort of like bracketing. Until I get into that, if you have programming experience, I recommend looking into [Forth](/r/Forth) dialects, for example Factor.
I don't really think the mental load would be an issue, given how complex and varied sentence structure in natural languages can be, even within a single language (for example English; this is all one sentence (in a sense), and breaking down how the meaning emerges as you move through it is highly nontrivial).
Nice post.
/u/eatonphil, I have 2 questions for you:
Whenever I play with Forth (which is at least once a year, as I teach a Programming Languages class), I think that the language has some really nice ideas, but it's stuck in the 70s. We've learned a lot about PL design in the last forty years, and a stack-based PL that used some of the newer ideas might be very nice indeed. There is PostScript, of course, but it's hardly aimed at general-purpose programming. I've looked at Factor[1] a bit, and I've been impressed with what I've seen. Maybe some day I'll look more than just a bit. Anyway, the question: What do you think?
I played with your JSForth REPL a bit. Looks nice. It doesn't seem to support the { ... -- ... } syntax for named parameters. Or does it support some variation on that? And is there documentation?
EDIT. Never mind about question 2. I found the GitHub repository.
GraForth may not have been the best Forth implementation, but it certainly was better than ASM. Even today, there are stack-based languages like Factor (and even Postscript if you think about it, although probably nobody but Don Lancaster actually makes pictures by writing Postscript manually).
Just did this one rather late, but here it is in factor, I can't get it to post any output at ideone, but it does on my machine.
! Copyright (C) 2014 Sotolf. ! See http://factorcode.org/license.txt for BSD license. USING: io splitting math math.parser sequences kernel prettyprint ; IN: combinationLock
: parse-input ( str -- n seq[int] ) " " split [ string>number ] map dup 1 tail swap first ;
: get-input ( -- n seq[int] ) readln parse-input ;
: first-spin ( acc n seq -- acc+ n seq ) [ dup first ] 2dip [ swap ] dip + ;
: second-spin ( acc n seq -- acc+ n seq ) [ dup second ] 2dip 2dup swap rem [ -rot swap ] dip swap - swap dup [ rem + ] dip swap ;
: third-spin ( acc n seq -- acc+ n seq ) [ dup dup third swap second - ] 2dip rot [ 0 = ] [ drop over + ] [ + ] if ;
: main ( -- ) get-input dup 3 * first-spin second-spin third-spin [ 2drop ] dip number>string print ;
MAIN: main
Out of curiosity what do you think of Factor, [Joy](http://en.wikipedia.org/wiki/Joy_(programming_language) or Picolisp?
I favor pure, functional programming as a rule, and as such prefer Scheme flavored dialects of Lisp. However, if one spends time with concatenative languages it becomes clear that in the realm of functional programming there are multiple ways to skin a cat, no pun intended. Newlisp rarely defends itself elegantly, but picolisp's philosophical underpinnings and insight from concatenative languages with first class quotations, to which New and picolisp are quite close, reveal that one can program quite elegantly these kinds of languages.
I don't know if I would recommend Newlisp to programmers for new projects or real work, but I would definitely recommend that they really understand how one solves problems in such a language, at the very least to drive home the meaning of things like lambda
, eval
, closures and quote
ations. Even classic Lisp texts, like Lisp in Small Pieces, dwell at least for a short time on dynamically scoped Lisps. No one benefits from orthodoxy.
I'm not sure the discussion is entirely silly. Lisp and forth share much of the same spirit, and even if this particular foray into the discussion is somewhat poorly motivated, a full comparison of the languages is very instructive. And things get even more interesting when you include languages which are concatenative but otherwise are very much like Lisp, such as Factor.
I use Lisp much more often than I use cancatenative languages (this is mostly because there aren't many places in my life where I need to use a concatenative language, but I am always using emacs), and perhaps I ultimately prefer writing code in a language which has explicit parameter passing (it is very interesting, though, that even in languages like factor, where stack combinators simplify words that might otherwise require lots of stack shuffling, very simple words are often the hardest to implement, while complex words become almost uncannily clean looking), but spending some time really thinking about concatenative style was for me very educational and fun.
So even though this little piece is a bit glib and misinformed, I think it does start a nice discussion.