How can I start learning Factor?

The best way to go about it is to figure out something you want to program and start trying to do it. Once you have a goal in mind, you can look at Factor's included documentation (available online at Factor's website), and ask questions on the mailing list or #concatenative at irc.freenode.net.

Are there any good books I can read about Factor?

Factor is a very young language, and so far, there are no books which use it yet. A good introduction to Forth, much of which applies in Factor, is Thinking Forth (PDF) by Leo Brodie. The best place to start to learn about the principles of modern concatenative languages is the Joy papers, by Manfred von Thun. Another good internet resource is Planet Factor, a blog aggregator for all things Factor-related. There won't be a Factor book written until after Factor 1.0 is released.

How can I keep track of the stack in my head?

At first, it may be useful to make diagrams on paper. But eventually stack shufflers should fade away in your mind and become part of the data flow. If your stack is hard to trace, it is likely that you are thinking about too many things on the stack at once. It is highly unusual for a Factor word to accept or return more than three arguments on the stack. If you ever need to keep track of the location of more than three or four items, you should probably reorganize the function by factoring it into smaller pieces.

How can I improve my Factor coding style?

  • Most word definitions should fit in three or fewer 64-column lines.
  • Any copy/pasted code should be factored out into new words.
  • Use combinators to abstract control flow patterns.
  • Use library words where possible.
  • More general words should go at the top of a file; more specific at the bottom.
  • Try to use collections instead of working with individual objects on the stack.
  • Don't use the datastack as a data structure.
  • Use meaningful word names. Avoid too many words named (foo) or foo*.
  • A word named (foo) should only exist to help implement the word foo.
  • Come to the IRC channel and we'll review your code. It's fun!

This revision created on Mon, 5 Jan 2009 18:24:28 by littledan