- Factor (programming language)
Infobox programming language
name = Factor
paradigm = stack-based
year = 2003
developer =Slava Pestov
latest_release_version = Continuous Builds [http://factorcode.org/binaries.fhtml]
typing = strong, dynamic
influenced_by = Joy, Forth, Lisp, Self
influenced = Cat
operating_system = Windows,Mac OS ,Linux , others
license =BSD license
website = [http://factorcode.org/ factorcode.org]Factor is a dynamically typed concatenative
programming language whose design and implementation is led bySlava Pestov . Factor's main influences are Joy, Forth, Lisp and Self. Current versions of Factor exist as Continuous Builds for supported platforms while version 1.0 is under development [http://factorcode.org/binaries.fhtml] . A 1.0 release is planned in 2008.Like other concatenative languages, Factor has a postfix syntax, meaning that you write the arguments of a function before its name. As an example,
Hello world in Factor is "Hello world" printFactor 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 usingtuple s and other mechanisms. Factor supports inheritance. Additionally, there are other ways to make classes other than types or tuples; Factor supportspredicate class es and union classes. Factor's built-in compound datatypes include fixed and variable length vectors and hashtables. The language also supportsfloating point , and arbitrary precision integers.Linked list s,complex number s andfraction s are implemented in the standard library.Factor was originally only
interpreted , but is now fullycompiled (the non-optimizing compiler basically unrolls the interpreter loop [ [http://factor-language.blogspot.com/2007/09/two-tier-compilation-comes-to-factor.html Factor: a practical stack language: Two-tier compilation comes to Factor ] ] [ [http://factor-language.blogspot.com/2008/01/compiler-overhaul.html Factor: a practical stack language: Compiler overhaul ] ] ). The optimizing machine code compiler is written entirely in Factor. It does not output standalone executables, but rather generatesmachine code which is saved in the image. This image can then be deployed with the deploy-tool which produces a minimal tree shaken image along with the VM.When using the stack system does not suffice, lexical and
dynamic scoping are supported alternatives. Factor has a growing library which supports vocabularies,continuation s, an HTTP server and accompanyingweb framework , anOpenGL binding, aGUI library, anXML 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).Lisp Like Features
Factor shares a lot of features with Lisp, including a homoiconic syntax, garbage collection, HOFs, compile-time evaluation, REPL, treeshaker, etc.
Unlike Lisp, function composition proceeds left to right rather than [ [http://reddit.com/r/programming/info/657vx/comments/c02vk21 Slava Pestov, reddit comment] ] : (loop (print (eval (read)))) [ Read-eval-print loop, Implementation] you would write instead [ read eval print ] loop [ [http://www.reddit.com/info/6pq50/comments/c04jxfx pjdelport, reddit comment] ] This is an inherent feature in concatenative languages.
Concurrency Support
Factor's concurrency support was insipired by Erlang, Termite, Scheme48 and Java's java.util.concurrent library including basic Lightweight co-operative threads, to advanced libraries supporting Promises/Futures, Mailboxes and Message-passing concurrency.
Implementations
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 [ [http://lambda-the-ultimate.org/node/900#comment-8675 Concatenative Language Kont | Lambda the Ultimate ] ] :
M: compound (compile) compiling dataflow optimize linearize simplify generate ;
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.
External links
* [http://factorcode.org/ Factor website]
* [http://factorcode.org/binaries.fhtml Get Factor]
* [http://fun-factor.blogspot.com/2007/10/getting-started-with-factor-easy-ffi.html Getting started with Factor - Easy FFI]
* [http://tech.groups.yahoo.com/group/concatenative/message/1756 The birth of Factor]
* [https://lists.sourceforge.net/lists/listinfo/factor-talk Factor mailing list]
* [http://tunes.org/~nef/logs/concatenative Logs of #concatenative] onfreenode , anIRC channel which mainly discusses Factor
* [http://docs.factorcode.org/ Factor documentation]
* [http://planet.factorcode.org/ planet-factor] (a feed aggregator)
* [http://factorcode.org/responder/cgi/gitweb.cgi?p=factor.git;a=summary Git development repository]References
Wikimedia Foundation. 2010.