Concatenative topics
Concatenative meta
Other languages
Meta
Does Factor have a concurrency model?
Yes, Factor supports explicit, cooperative coroutines. A new thread can be spawned with the word in-thread
, and control is passed between threads with the yield
word. The core thread
vocabulary contains the most basic thread operations, and derived coroutine operations are in the coroutines
vocabulary.
Does Factor support multiple OS threads?
Currently, no. Factor's threading model works somewhat similarly to Erlang's, with the important difference that there is only one heap, and the runtime (virtual machine) always runs in a single OS thread. The VM isn't currently thread-safe, though it will be made so in the future. Certain language features, such as word properties, currently pose challenges for making Factor thread-safe. Because everything is run in a single OS thread and there is no direct efficiency gain, Factor threads are most useful for things like executing parallel I/O operations that involve waiting.
What's some cool feature of Factor that other languages don't support?
One small feature that comes in handy is the make
word, which assists in building sequences. Another cool feature is Factor's unique object system, related to CLOS. A third feature is the sequence and assoc protocols, allowing numbered sequences and associative mappings to be treated generically. This isn't something that's uniquely possible in Factor, but Factor's library just happens to be very well-designed here. A very interesting library is the units
library, which, due to postfix notation, looks very natural. (The calendar
library also works well with postfix.) It works very well in conjunction with a library called inverse
, which takes advantage of the properties of concatenativity to invert some of computation. Slava described some of these cool properties in a reddit comment.
What kind of foreign function interface does Factor have?
Factor's FFI library is called alien. It works by linking do a dynamically linked library (.dll, .so or .dylib) at runtime, allowing the user to be free of writing, generating or otherwise messing with C code. Currently, alien only supports interfacing with C. Elie Chaftari wrote a good introduction to Factor's FFI.
Why isn't my code using alien working?
First, you have to makes sure the appropriate dynamically linked library is being loaded using the word add-library
. Once that is loaded, run the word recompile-all
to compile all words that haven't been compiled. This will link words using the FFI up with the DLL.
What kinds of GUI libraries does Factor support?
Currently, Factor uses a cross-platform UI library written in Factor itself, using OpenGL and a small amount of native code on each platform. The listener uses this library. There is a Cocoa binding, which is used for the window frame and menu for Mac applications, though it could be used for other things. Similarly, for Unix, there is an X binding, and it has been used in a Factor window manager, Factory. On Windows, there is a binding to some parts of the Windows API through C, but not parts that create widgets. There aren't any bindings to wxWidgets or Gtk yet. Gtk bindings would be doable but somewhat challenging due to their heavy use of macros and complicated structs, and a SWIG binding could be helpful in implementing them. wxWidgets bindings would be impossible right now, as alien does not support C++'s name mangling.
Why isn't Factor in the Computer Language Shootout?
We want to make Factor faster before compiling a submission. Most things are already far faster than scripting languages, but certain things, such as I/O, still need some work. The shootout benchmarks are heavy in I/O. But don't let any of this hold you back from making your own Factor submission!
How do you put a Factor program into a package so it can be run easily?
A tool for this is in development which currently makes Mac OS X .app
packages and Windows executables, bundled with an image and some .dll
s. There will soon be a Unix version. To deploy a vocabulary (a package which will run the vocabulary's main word), use the code
USE: ui.tools.deploy "vocab-name" vocab deploy-tool
Does Factor support Unicode?
There is no one meaning to the phrase "Unicode support", but there are a few things that a modern programming language is expected to support in its library: UTF-8/UTF-16 input and output, Unicode collation, Unicode-appropriate casing operations, normalization, and UI support for Unicode input and output. Of these, Factor supports all but collation and UI support, both of which are in the works and should be finished before 1.0 comes out. All Factor strings can hold any Unicode code point, and it's planned that strings will be consistently held in Normalization Form D.
Can a vocabulary have sub-vocabularies?
Yes, but the the module structure tends to be fairly flat in practice.
Can I have two words with the same name in different vocabs?
You probably don't want to design a set of vocabularies to have overlapping word names, but sometimes it comes up that you want to use two libraries that use the same word names. In this case, ther eare two resolution strategies. The simplest, if you only need one of the words which overlaps, is to put the one you want second in the order of the USING:
declaration. If you need both, or in more complicated overlap situations, you can use a qualified library import. In this case, you should include the qualified
vocabulary to enable qualified naming, and load a vocab called foo
as
QUALIFIED: foo
To access the word bar
in vocab foo
, use the name foo:bar
. When the same name is used in two vocabs, one vocab is usually put in the USING:
declaration and the other loaded with QUALIFIED:
.
This revision created on Mon, 5 Jan 2009 18:14:41 by littledan