Roguelikedev Does The Complete Roguelike Tutorial 2019 - Starting June 18th

I could write a book about this. For me, it was love at first sight when I first saw Factor code several years ago. At its core, it's a series of words that manipulate a stack of dynamically-typed values.

If I want to do a bunch of transformations on an object, I could write x = g(f(e(d(c(b(a(y))))))) in an applicative language. In a concatenative language like Factor, that's just a b c d e f g. Function composition, not function application, is the inherent form of data flow. (And being able to read your code from left to right is nice as well!)

It turns out that when you build a language around this concept, you can use it to write clear programs from top to bottom. I find it remarkable. Due to this implicit handling of arguments and values in general, once you get good at using data flow combinators, you don't have to do a bunch of stack-shuffling or name a whole bunch of stuff. I'm not good at naming things, so it's a godsend for me.

More generally, I like it because to me, it is simplicity itself. Factor has no privileged syntax, no statements, no finicky order of operations, no scoping (unless you want it!). Everything simply executes left to right, first at parse time, then at run time. Flow control is handled by higher order functions (and tail-call recursion if you want).

Like in Forth, the parser is exposed to your programs, so you can add whatever syntax you want. Like in Lisp, functions are just lists of code. Unlike Lisp however, you get all these benefits with with much 'flatter' code.

There's a lot of subtle nifty things you get in a concatenative language that you have to work for in an applicative language. One example is true multiple return values that you don't have to tuple (like in Lisp) or assign to values at the call site (like in Go).

Almost every single language concept in Factor is just a library. Lisp-style macros? Just a library. Continuations? Exceptions? Co-routines? Libraries. Haskell-style monads? Objects? Multiple dispatch? You guessed it.

Factor has a huge standard library that has just about anything you could want. Even static typing for example. It's compiled to machine code, even in the REPL, and because it doesn't use traditional stack frames for function calls, there's almost no overhead for writing a million tiny functions (words), which is encouraged. Its performance is comparable to the SBCL implementation of Common Lisp, which I find to be quite impressive for a dynamically-typed garbage-collected language.

Oh, and it has its own cross-platform UI written in OpenGL, with a fairly clean design, which I will leverage for my roguelike. It uses this UI to great effect in its self-contained help/documentation system, and did I mention that the language is incredibly well-documented? Everything is right there, from language tutorials to philosophy to word documentation.

It also has a code walker which allows you to step forwards and backwards through your code while you observe how it changes the data stack, which given the left-to-right nature of Factor code makes it very easy to follow, unlike in say C++ where every statement can be a minefield of implicit function calls.

Alright, I think that's enough gushing for now. You really hit my berserk button with that question, haha.

/r/roguelikedev Thread Parent