]> gitweb.factorcode.org Git - factor.git/blob - README.md
Created symlink to skov to mamke GitHub CI happy
[factor.git] / README.md
1 # Factor
2
3 ![Build](https://github.com/factor/factor/actions/workflows/build.yml/badge.svg)
4
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.
12
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
18 [deploy stand-alone
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
21 license.
22
23 ## Getting Started
24
25 ### Building Factor from source
26
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.
30
31 To check out Factor:
32
33 * `git clone git://github.com/factor/factor.git`
34 * `cd factor`
35
36 To build the latest complete Factor system from git, either use the
37 build script:
38
39 * Unix: `./build.sh update`
40 * Windows: `build.cmd`
41 * macOS: `./build.sh update`
42 * M1 macOS: `arch -x86_64 ./build.sh update`
43
44 or download the correct boot image for your system from
45 https://downloads.factorcode.org/images/master/, put it in the `factor`
46 directory and run:
47
48 * Unix: `make` and then `./factor -i=boot.unix-x86.64.image`
49 * Windows: `nmake /f Nmakefile x86-64` and then `factor.com -i=boot.windows-x86.64.image`
50
51 Now you should have a complete Factor system ready to run.
52
53 Factor does not yet work on arm64 cpus. There is an arm64 assembler
54 in `cpu.arm.assembler` and we are working on a port and also looking for
55 contributors.
56
57 ### Xcode
58 Checkout the `xcode` branch and open the **Xcode/Factor.xcodeproj** project to build and run the engine from Xcode debugger.
59
60 More information on [building factor](https://concatenative.org/wiki/view/Factor/Building%20Factor)
61 and [system requirements](https://concatenative.org/wiki/view/Factor/Requirements).
62
63 ### To run a Factor binary:
64
65 You can download a Factor binary from the grid on [https://factorcode.org](https://factorcode.org).
66 The nightly builds are usually a better experience than the point releases.
67
68 * Windows: Double-click `factor.exe`, or run `.\factor.com` in a command prompt
69 * Mac OS X: Double-click `Factor.app` or run `open Factor.app` in a Terminal
70 * Unix: Run `./factor` in a shell
71
72 ### Learning Factor
73
74 A tutorial is available that can be accessed from the Factor environment:
75
76 ```factor
77 "first-program" help
78 ```
79
80 Some other simple things you can try in the listener:
81
82 ```factor
83 "Hello, world" print
84
85 { 4 8 15 16 23 42 } [ 2 * ] map .
86
87 1000 [1..b] sum .
88
89 4 <iota> [
90     "Happy Birthday " write
91     2 = "dear NAME" "to You" ? print
92 ] each
93 ```
94
95 For more tips, see [Learning Factor](https://concatenative.org/wiki/view/Factor/Learning).
96
97 ## Documentation
98
99 The Factor environment includes extensive reference documentation and a
100 short "cookbook" to help you get started. The best way to read the
101 documentation is in the UI; press F1 in the UI listener to open the help
102 browser tool. You can also [browse the documentation
103 online](https://docs.factorcode.org).
104
105 ## Command Line Usage
106
107 Factor supports a number of command line switches:
108
109 ```
110 Usage: factor [Factor arguments] [script] [script arguments]
111
112 Common arguments:
113     -help            print this message and exit
114     -i=<image>       load Factor image file <image> (default factor.image)
115     -run=<vocab>     run the MAIN: entry point of <vocab>
116         -run=listener    run terminal listener
117         -run=ui.tools    run Factor development UI
118     -e=<code>        evaluate <code>
119     -ea=<code>       evaluate <code> with auto-use
120     -no-user-init    suppress loading of .factor-rc
121     -roots=<paths>   a list of path-delimited extra vocab roots
122
123 Enter
124     "command-line" help
125 from within Factor for more information.
126 ```
127
128 You can also write scripts that can be run from the terminal, by putting
129 ``#!/path/to/factor`` at the top of your scripts and making them executable.
130
131 ## Source Organization
132
133 The Factor source tree is organized as follows:
134
135 * `vm/` - Factor VM source code (not present in binary packages)
136 * `core/` - Factor core library
137 * `basis/` - Factor basis library, compiler, tools
138 * `extra/` - more libraries and applications
139 * `misc/` - editor modes, icons, etc
140 * `unmaintained/` - now at [factor-unmaintained](https://github.com/factor/factor-unmaintained)
141
142 ## Source History
143
144 During Factor's lifetime, sourcecode 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.
145
146 Use:
147 `git fetch origin 'refs/replace/*:refs/replace/*'`
148
149 or add the following line to your configuration file
150
151 ```
152 [remote "origin"]
153     url = ...
154     fetch = +refs/heads/*:refs/remotes/origin/*
155     ...
156     fetch = +refs/replace/*:refs/replace/*
157 ```
158
159 Then subsequent fetches will automatically update any replace objects.
160
161 ## Community
162
163 Factor developers used to meet in the `#concatenative` channel on
164 [irc.libera.chat](http://libera.chat). Drop by if you want to discuss
165 anything related to Factor or language design in general.
166
167 * [Factor homepage](https://factorcode.org)
168 * [Concatenative languages wiki](https://concatenative.org)
169 * [Join the mailing list](https://concatenative.org/wiki/view/Factor/Mailing%20list)
170 * [Join the Factor Discord](http://discord.gg/QxJYZx3QDf)
171 * Search for "factorcode" on [Gitter](https://gitter.im/)
172
173 Have fun!