Factor/FAQ/What's Factor like?

Where can I see some example programs?

Check out the Examples page on the wiki.

Why is there a distinction between words and quotations?

Words and quotations are used in different places. Factor programs are built out of words, which are just compositions of other words. Words are invoked simply by naming them. Words contain metadata about their module, source location, and other things in addition to the code. If a word is on the stack, it is called with execute. Quotations, on the other hand, are the code-data used in most combinators and are not associated with the same metadata that words are. They are invoked with call.

Is Factor purely functional, like Haskell?

No, it allows arbitrary side effects and the standard library includes several mutable data structures and imperative I/O.

Why not?

It makes things much simpler. Effects don't need to be sequenced explicitly, as in Haskell. (No one has yet implemented anything like monads or uniqueness types in Factor, but we would welcome that development.) A broader range of algorithms can be used when mutability is included. It is certainly possible to write Factor code in a purely functional way, and there are a lot of interesting possibilities to explore here. It may be possible, but no one has yet designed a metaprogramming system in a purely functional language with the degree of flexibility that Factor allows.

Why is Factor dynamically, rather than statically, typed?

For basically the same reason: it makes things more simple and flexible, allowing a high degree of metaprogramming. Additionally, a flexible enough type system for concatenative languages has not yet been designed. However, Factor 2.0 may include optional static typing, if a suitable type system can be found.

Does Factor have variables?

Yes. There are statically scoped ones in the locals vocabulary and dynamically scoped variables in the namespaces vocabulary. The former are local to a word, while the latter are used for communication between words.

But aren't dynamically scoped variables bad?

They are, if they're used for everything by default. Usually, data is passed around using the stack or with locals. Dynamically scoped variables are used for a number of wider things where it would be awkward and repetitive to pass data lexically, such as the current input and output streams.

Why are the stack shufflers given names like dup, swap and drop? Why not just x-xx, xy-yx and x- or something like that?

The use of mnemonics is much more clear in almost all cases, as they can mentally represent the abstract data flow going on. If you need to do an impossible shuffle like xyz-xzyxxy, then rewrite your code to use different abstractions instead; for example, dataflow combinators or locals.

What license is Factor under?

Factor is free software under a BSD-style license with no advertising clause. This means that you can do whatever you want with Factor, as long as you distribute the license and the copyright notice with Factor source or binaries. You are completely free to fork Factor or any code included with its distribution for a closed-source or GNU GPL-licensed project (unless otherwise noted). To signify this, at the beginning of each code file distributed with Factor, there should be lines of the form

! Copyright (C) 2007 Manuel Lopez Garcia.
! See http://factorcode.org/license.txt for BSD license.

A BSD license was chosen rather than the GPL or LGPL because it allows for the most flexible reuse. However, as a result, we can accept no GPL or LGPL code for the Factor distribution itself.

This revision created on Fri, 17 Jul 2009 23:08:32 by slava