Factor/FAQ/Why?

  • What is Factor's specialty? Where is it best used?

Factor can be used for anything. It is not a scripting language but it is suitable for rapid development. Factor has been used for everything from web applications to game development to XML parser implementation. Factor isn't meant for extremely low-level things, like boot loaders or microcontroller programming, though.

  • What is Factor's purpose?

Factor is an experiment to build a modern, useful concatenative language with strong abstraction capabilities. Though there are some pitfalls, many problems can be more cleanly expressed in a concatenative language.

  • Is Factor suitable for implementing my next program?

Probably. There are only a couple places where it might not work. For example, you'll never be able to program your TI-83 calculator in Factor, because it has a footprint at least as big as the image, which means at least 500 Kb for most programs, even with a minimal image. Also, Factor won't (yet) work for situations where things need to run extremely fast (though it is already faster than most scripting languages for most tasks, and it's possible to write some parts of a Factor program in C). It would be difficult to write, say, a bootloader with it. One disadvantage of Factor is that there is currently no way to use a C++ library. But for everything else, it should be usable.

  • Is Factor cross-platform?

Though Factor images can only run on one specific platform, the same Factor source code can easily be run on any platform that Factor is ported to. Portability issues only occur when interfacing with native libraries, or if there is a bug.

  • How is Factor different from Forth?

Forth is untyped, not garbage collected, and close to the machine. For flow control, Forth code tends to use immediate words. Variables and arrays tend to be global, and programs aren't usually written in a functional manner. Factor is very different from this. It is dynamically typed, offering a high degree of reflection. Unreferenced objects are garbage collected with a generational garbage collector. Factor code is a little bit more distant from the machine, though the C FFI allows using words like malloc and mmap. For flow control, Factor generally uses quotations, allowing flexible higher order functions; parsing words are used mostly for definitions and data literals. Variables are dynamically or statically scoped (see below), and arrays are just objects which don't need to be treated specially. There is no need to think about pointers, although in Forth, this can usually be factored out to just a few words. Factor is generally a functional programming language.

  • If Factor programs are just compositions of existing words, how is Factor as powerful as other programming languages?

Factor is a Turing-complete programming language whose programs are capable of doing whatever any other programming language can do. In fact, it isn't all that complicated to translate between a stack-based language and an applicative one, as long as it's known how many arguments the words in the stack-based language take.

  • Why do we need a new stack-based language?

Because the other ones aren't suitable for high-level development. Forth is great for low-level things, but its lack of type system and garbage collection make it difficult to debug programs, and it doesn't mesh well with functional programming. Joy made a very important theoretical contribution, but it is difficult to compile efficiently, its syntax is inextensible and it has an insufficient module system. Additionally, it is almost purely functional, making many things difficult. Factor combines the best aspects of these two systems, together many other borrowings from various places.

This revision created on Mon, 5 Jan 2009 04:59:53 by littledan