Language page — context, influences, and learning notes on the 100hellos site.
Source on GitHub (100hellos/factor)
docker run --rm --platform="linux/amd64" 100hellos/factor:latest
Read the repo README, or fork the project and customize it.
For an interactive shell:
docker run --rm --platform="linux/amd64" --entrypoint="" -it 100hellos/factor:latest zsh
Factor is a concatenative, stack-based programming language inspired by Forth and Lisp. It was designed by Slava Pestov and features powerful metaprogramming capabilities, a rich standard library, and an elegant object system.
Factor is a dynamic, stack-based language with powerful metaprogramming features. It combines the simplicity of stack-based programming with modern language features like:
In Factor, computation is performed by manipulating a data stack. Functions (called "words" in Factor) consume values from the stack and push results back onto it:
! Push numbers onto the stack
2 3 + ! Results in 5 on the stack
! String manipulation
"Hello" " " "World!" 3append ! Results in "Hello World!"
Our Factor program is remarkably simple:
USE: io
"Hello World!" print
USE: io - Imports the input/output vocabulary"Hello World!" - Pushes the string literal onto the stackprint - Pops the string from the stack and prints it to stdoutFactor's most distinctive feature is quotations - blocks of code that can be treated as data:
[ 2 * ] map ! Apply doubling function to each element
[ dup * ] keep ! Square a number while keeping the original
Higher-order functions that operate on quotations:
5 [ 1 + ] [ 2 * ] bi ! Apply both functions: results in 6 and 10
Factor organizes code into vocabularies (similar to modules):
USING: math sequences io ;
Factor was created by Slava Pestov in 2003, originally targeting the JVM. It has since evolved into a self-hosted language with its own virtual machine. The language is inspired by:
factorFactor represents a unique approach to programming that challenges conventional thinking about language design while remaining highly practical and expressive.
Content type
Image
Digest
sha256:b08ae881b…
Size
211.3 MB
Last updated
4 months ago
docker pull 100hellos/factor