3 ![Build](https://github.com/factor/factor/actions/workflows/build.yml/badge.svg)
5 Factor is a [concatenative](https://www.concatenative.org), stack-based
6 programming language with [high-level
7 features](https://concatenative.org/wiki/view/Factor/Features/The%20language)
8 including dynamic types, extensible syntax, macros, and garbage collection.
9 On a practical side, Factor has a [full-featured
10 library](https://docs.factorcode.org/content/article-vocab-index.html),
11 supports many different platforms, and has been extensively documented.
13 The implementation is [fully
14 compiled](https://concatenative.org/wiki/view/Factor/Optimizing%20compiler)
15 for performance, while still supporting [interactive
16 development](https://concatenative.org/wiki/view/Factor/Interactive%20development).
17 Factor applications are portable between all common platforms. Factor can
19 applications](https://concatenative.org/wiki/view/Factor/Deployment) on all
20 platforms. Full source code for the Factor project is available under a BSD
25 ### Building Factor from source
27 If you have a build environment set up, then you can build Factor from git.
28 These scripts will attempt to compile the Factor binary and bootstrap from
29 a boot image stored on factorcode.org.
33 * git clone https://github.com/factor/factor.git
36 To build the latest complete Factor system from git, either use the
39 * Unix: `./build.sh update`
40 * Windows: `build.cmd`
41 * M1 macOS: `arch -x86_64 ./build.sh update`
43 or download the correct boot image for your system from
44 https://downloads.factorcode.org/images/master/, put it in the `factor`
47 * Unix: `make` and then `./factor -i=boot.unix-x86.64.image`
48 * Windows: `nmake /f Nmakefile x86-64` and then `factor.com -i=boot.windows-x86.64.image`
50 Now you should have a complete Factor system ready to run.
52 Factor does not yet work on arm64 cpus. There is an arm64 assembler
53 in `cpu.arm.64.assembler` and we are working on a port and also looking for
56 More information on [building factor](https://concatenative.org/wiki/view/Factor/Building%20Factor)
57 and [system requirements](https://concatenative.org/wiki/view/Factor/Requirements).
59 ### To run a Factor binary:
61 You can download a Factor binary from the grid on [https://factorcode.org](https://factorcode.org).
62 The nightly builds are usually a better experience than the point releases.
64 * Windows: Double-click `factor.exe`, or run `.\factor.com` in a command prompt
65 * Mac OS X: Double-click `Factor.app` or run `open Factor.app` in a Terminal
66 * Unix: Run `./factor` in a shell
70 A [tutorial](https://docs.factorcode.org/content/article-first-program.html)
71 is available that can be accessed from the Factor environment:
77 Take a look at a [guided
78 tour](https://docs.factorcode.org/content/article-tour.html) of Factor:
84 Some demos that are included in the distribution to show off various features:
90 Some other simple things you can try in the listener:
95 { 4 8 15 16 23 42 } [ 2 * ] map .
100 "Happy Birthday " write
101 2 = "dear NAME" "to You" ? print
105 For more tips, see [Learning Factor](https://concatenative.org/wiki/view/Factor/Learning).
109 The Factor environment includes extensive reference documentation and a
110 short "cookbook" to help you get started. The best way to read the
111 documentation is in the UI; press F1 in the UI listener to open the help
112 browser tool. You can also [browse the documentation
113 online](https://docs.factorcode.org).
115 ## Command Line Usage
117 Factor supports a number of command line switches:
120 Usage: factor [Factor arguments] [script] [script arguments]
123 -help print this message and exit
124 -i=<image> load Factor image file <image> (default factor.image)
125 -run=<vocab> run the MAIN: entry point of <vocab>
126 -run=listener run terminal listener
127 -run=ui.tools run Factor development UI
128 -e=<code> evaluate <code>
129 -no-user-init suppress loading of .factor-rc
130 -roots=<paths> a list of path-delimited extra vocab roots
134 from within Factor for more information.
137 You can also write scripts that can be run from the terminal, by putting
138 ``#!/path/to/factor`` at the top of your scripts and making them executable.
140 ## Source Organization
142 The Factor source tree is organized as follows:
144 * `vm/` - Factor VM source code (not present in binary packages)
145 * `core/` - Factor core library
146 * `basis/` - Factor basis library, compiler, tools
147 * `extra/` - more libraries and applications
148 * `misc/` - editor modes, icons, etc
149 * `unmaintained/` - now at [factor-unmaintained](https://github.com/factor/factor-unmaintained)
153 During Factor's lifetime, source code has lived in many repositories. Unfortunately, the first import in Git did not keep history. History has been partially recreated from what could be salvaged. Due to the nature of Git, it's only possible to add history without disturbing upstream work, by using replace objects. These need to be manually fetched, or need to be explicitly added to your git remote configuration.
156 `git fetch origin 'refs/replace/*:refs/replace/*'`
158 or add the following line to your configuration file
163 fetch = +refs/heads/*:refs/remotes/origin/*
165 fetch = +refs/replace/*:refs/replace/*
168 Then subsequent fetches will automatically update any replace objects.
172 Factor developers are quite active in [the Factor Discord server](https://discord.gg/QxJYZx3QDf).
173 Drop by if you want to discuss anything related to Factor or language design in general.
175 * [Factor homepage](https://factorcode.org)
176 * [Concatenative languages wiki](https://concatenative.org)
177 * [Join the mailing list](https://concatenative.org/wiki/view/Factor/Mailing%20list)
178 * Search for "factorcode" on [Gitter](https://gitter.im/)