Factor (programming language)
![]() | |
Paradigm | stack-based |
---|---|
Developer | Slava Pestov |
First appeared | 2003 |
Stable release | |
Typing discipline | strong, dynamic |
OS | Windows, Mac OS, Linux, others |
License | BSD license |
Website | factorcode.org |
Influenced by | |
Joy, Forth, Lisp, Self | |
Influenced | |
Cat |
Factor is a dynamically typed concatenative programming language whose design and implementation is led by Slava Pestov. Factor's main influences are Joy, Forth, Lisp and Self.
Like other concatenative languages, Factor has a postfix syntax, meaning that you write the arguments of a function before the function name. As an example, Hello world in Factor is
"Hello world" print
Factor is dynamically typed, and a unique object system accompanies it. In Factor, there is a small group of base types, and users and the standard library can make their own classes using tuples and other mechanisms. There is no inheritance, but there is delegation as in Self. Additionally, there are other ways to make classes other than types or tuples; Factor supports predicate classes and union classes. Factor's built-in compound datatypes include fixed and variable length vectors and hashtables. The language also supports floating point, and arbitrary precision integers. Linked lists, complex numbers and fractions are implemented in the standard library.
Factor was originally only interpreted, but it can now also be compiled. The optimizing machine code compiler is written entirely in Factor. It does not output standalone executables, but rather generates machine code which is saved in the image.
When using the stack system does not suffice, dynamic scoping is a supported alternative. Factor has a growing library which supports continuations, an HTTP server and accompanying web framework, an OpenGL binding, a GUI library, an XML parser, and several other utilities.
One of Factor's main goals is to be useful for interactive and test-driven development, which is why Factor is, at its core, a safe version of Forth. Factor is dynamically typed, but the compiler assesses the stack depth of words (functions).
So far, both Java and C implementations have been constructed. The Java implementation is deprecated and no longer maintained. The native runtime of the C version is continually shrinking as an increasing proportion of Factor is self-hosted. However, there will likely always be a portion of Factor written in C.
Though Factor does not adhere to an external standard the way C does, the language is heavily documented.
As of May 2007, the current version of Factor is .89. A 1.0 release is planned within two years.
External links
- Factor website
- Factor mailing list
- Logs of #concatenative on freenode, an IRC channel which mainly discusses Factor
- Factor documentation
See also
Joy programming language Forth programming language Self programming language