
Factor: An impressive stack-based language environment - yumaikas
https://www.junglecoder.com/blog/factorlang-review
======
undecidabot
For those who want a taste of Factor, check: [http://re-
factor.blogspot.com/](http://re-factor.blogspot.com/) (You might want to
scroll down past the release notes.)

~~~
pome
And if anyone is interested in knowing more about Factor, this tutorial is
pretty good, from basics to the web development using Furnace (Factor Web
Framework) - [https://andreaferretti.github.io/factor-
tutorial/](https://andreaferretti.github.io/factor-tutorial/) :-)

------
3rdAccount
I didn't think Slava was involved anymore.

It certainly seems like a neat language, but I could never find enough
beginner material to make any headway (not sure if anything has changed in the
past few years).

There is a Google tech talk where Slava talks about Factor @ Google.

~~~
dom96
Slava is working on Swift at Apple now AFAIK

~~~
3rdAccount
Thanks Dom. I recalled he was working at either Apple or Google, but couldn't
remember which.

------
doublec
I have a PDF of some of my Factor related blog posts here if interested:
[https://bluishcoder.co.nz/2008/04/04/collection-of-factor-
ar...](https://bluishcoder.co.nz/2008/04/04/collection-of-factor-articles-in-
pdf.html)

It gives an overview of using some Factor libraries and features. Some have
bitrot by now but many still work.

------
foldr
Factor is definitely very cool. Apart from being stack-based, it's also
impressive for compiling to native code on Windows, Linux and OS X without
going via LLVM or anything similar. It can even produce self-contained
executables.

IIRC, named local variables have been available as a library feature for a
long time now, so you don't have to write in a concatenative style when it's
cumbersome to do so.

~~~
pome
How Factor compiler is different from something like SBCL? It's interesting
because Factor have plans to support ARM/Android/iOS, how hard to achieve
these goals? It's interesting because Common Lisp's (SBCL, CCL), Scheme (Chez
Scheme), Smalltalk (Pharo, Squeak) also have native compiler's, but no one
have iOS/Android support, SBCL also have self-contained executables and ARM
port. What are the biggest problems to these projects from having iOS/Android
support.

~~~
lispm
LispWorks has a native compiler and supports Android and iOS:
[http://www.lispworks.com/products/lw4mr.html](http://www.lispworks.com/products/lw4mr.html)

The iOS situation is difficult, because Apple does not allow runtime
compiled/loaded code in general. LispWorks pre-compiles Lisp code and one
creates an App with the help of Apple's Xcode. LispWorks has still an
Interpreter at runtime. Generally it is a very complete implementation of
Common Lisp (minus the runtime compilation), but without a Lisp-based GUI
library. They also had to write a special Garbage Collector for the 64bit ARM
iOS. Seems like it was not possible to have their usually more advanced GC,
which for example is available with their 64bit ARM Linux port of LispWorks.

~~~
ppseafield
That's not exactly Apple's policy - there are React Native apps in the iOS
store, and that runs on nodejs. Apple specifically forbids applications that
download and run code or allow for other code outside of the application's
code to be run. I.e. any and all code that your application will execute has
to be submitted with your app.

[https://developer.apple.com/app-
store/review/guidelines/](https://developer.apple.com/app-
store/review/guidelines/) specifically 2.5.2

~~~
lispm
[https://code.janeasystems.com/nodejs-
mobile](https://code.janeasystems.com/nodejs-mobile)

> On iOS, V8 cannot run because the operating system forbids just-in-time
> compilation; so instead of V8, we use our own port of the ChakraCore engine,
> on top of the integration with Node that Microsoft created in Node.js on
> ChakraCore. ChakraCore has a well-optimized, pure interpreter mode which
> complies with iOS’ restrictions.

[http://www.janeasystems.com/blog/node-js-meets-
ios/](http://www.janeasystems.com/blog/node-js-meets-ios/)

> Apple does not allow Just-In-Time compilation on iOS (except for its own
> JavaScriptCore engine).

So the claim is that Apple will not allow a third-party Javascript engine
which provides a JIT - even though interpreted code engines are allowed and
this is what their node.js version did.

My impression is also that this is a technical restriction.

Has that changed?

~~~
ppseafield
Ah, you're right. I should have read your comment more carefully.

> ChakraCore has a well-optimized, pure interpreter mode which complies with
> iOS’ restrictions.

(Which does not include runtime-compilation.)

------
eggy
I'll have to check out the new 0.98 release. I always enjoy playing with
Factor, and I even wrote a program to munge data from a sensor many years ago
for work. It's one of those languages that if it took off, I'd be happy to use
it for work all the time. It is a lot of fun though!

------
platz
What is the value prop of a stack-based language?

~~~
cultus
Everything is based on composition, which makes it easy to build computations
up like building blocks. Stacks are also efficient. The JVM bytecode is
actually a stack language, for example.

There's a newer one called Kitten that is statically typed and uses term
rewriting to allow for more normal syntax when you want. It's pretty cool. Too
bad none of these languages will ever take off.

~~~
bgongfu
And since composition is seamless, and they're relatively trivial to
implement; they make great glue/DSL/process description languages. Take off as
in replace C++ or Java, probably not. I see them more as a complement to
existing languages, a more convenient way to glue the pieces together. Even
wrote my own [0] to see how far it's possible to push that idea in C.

[0] [https://github.com/basic-gongfu/cixl](https://github.com/basic-
gongfu/cixl)

~~~
rurban
Interesting. But does cixl really do refcounting on stack values? It should
only be done on aggregates or objects reaching out into the heap, not on int
or float primitives on the stack.

~~~
bgongfu
Primitive types such as booleans, int, floats, times etc. are passed by value.

Reference counting is only used for heap allocated values and types that
themselves reference values, like pairs and tables.

[https://github.com/basic-
gongfu/cixl/blob/master/src/cixl/bo...](https://github.com/basic-
gongfu/cixl/blob/master/src/cixl/box.h)

