Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Factor: A Practical Stack Languge (factorcode.org)
89 points by otoburb on Jan 16, 2020 | hide | past | favorite | 21 comments


As someone who built Forth compilers back in the day, I really like this language. There's a nice overview of Factor as a paper here: https://factorcode.org/slava/dls.pdf and a Google tech talk video of Slava Pestov (Factor's creator) showing off the language here: https://www.youtube.com/watch?v=f_0QlhYlS8g


Unrelated to the main topic, but I watched this video when I was in college and it was one of the factors that inspired me to pursue programming seriously.


I have had Factor installed and ready to go on each of my last three personal machines, and never got to the point of having a solid project to attempt.

I absolutely love the idea of concatenative languages, I just haven't gotten my toes in the door, so to speak.

Maybe this year, as I'm back in a coding job.


I recommend a 4-function calculator, if you don't mind trying GUI code.


GUI handling is actually my biggest gray area, that's a great suggestion.


Is there a concise document somewhere that gives reasons why someone who uses an Algol style block structured imperative language (C, C++, C#, Pascal, etc.), or indeed any non-concatenative language, would benefit from switching to Factor?

The older I get the less willing I am to learn languages just because they are interesting.


> [why would I] benefit from switching to Factor?

Here's how it usually goes:

It works like this: You try Factor. You stick with its weirdness through one or two small projects. Somewhere in there your brain starts to accept the new way of doing things. Shortly after, you discover there are things you like and things you don't. You refine your opinion as you use the language more.

After a week or so, you will want to use an abstraction from Factor in a project for your day job. Maybe you implement it. You have confidence it will work because you've already seen it in Factor. But maybe you don't implement it for whatever reason. Even then, you have an advantage over your coworkers because you already have mental tools in place to help you reason about the problem.


The Sapir-Whorf hypothesis sure seems to hold with programming languages. Some ideas are easier to have in some programming languages than in others, although once you have the idea you can often 'explain' it in a programming language where it's less obvious.


https://factorcode.org/slava/dls.pdf

That said, effectively no one would benefit from switching. I like Factor, and stack languages in general, but from a difficulty perspective, they are MUCH more difficult than languages from the Algol family to use.


There is no reason. We identify things in terms of words, not positions on the stack. We think "multiply first vector's y coord by second vector's z coord", not "multiply item 15 on the stack by item 12 on the stack". Thus, stack-based languages lose out in usability and are really just a curiosity without much practical applications.


Reasons? Hmm maybe not but if you work through a few examples here

https://andreaferretti.github.io/factor-tutorial/

I found it somewhat enlightening.

If you’ve ever coded Haskell in “point-free” style you might also get the gist of how “words compose”.


> it has powerful metaprogramming capabilities, exceeding even those of LISPs;

The part where it says it even exceeds that of Lisps, is it because it has access to change all prior tokens and later tokens? Basically factor parser words are like full program reader macros?


I don't know if it's Baader-Meinhof or what, but I'm seeing concatenative languages all over the place now. Which is great, because now I'm planning to write my own! My gut says that a concatenative language could be ideal for competitive programming, where you want to quickly apply various transformations to your input and immediately see the result.

Here's a talk I watched recently describing some of the neat mathematical properties of concatenative languages: https://www.youtube.com/watch?v=_IgqJr8jG8M


I implement small Forth-likes quite a lot, for instance [0].

I really like having something to explore 70-80s machines (other than Basic), hardware and systems that have no/bad Repls (like Xamarin). This kind of thing is ideal for that as it takes a really short time to implement, gives full and flexible access and it is fast enough to prototype things with.

[0] https://gist.github.com/tluyben/16ee2645c4c8aed813005d51488d...


What would this language do better than current languages?


It's small and easy to port. It might be useful in some embedded projects. Per Wikipedia the original use case was video game scripting.

A newer concatenative language with a better website: https://8th-dev.com/


Factor is definitely not that small (there's a full optimizing compiler and a giant standard library…) and doesn't run on any embedded platforms. It's more like C# than like Forth in terms of usage scenarios.


Looks fun! It's a shame that it's not open source, but I'm not in the owner's shoes, so there's that.



They were talking about 8th.


Ah whoops!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: