12
\$\begingroup\$

In accordance with our meta agreement, since one candidate received more votes than the others, we have a new featured language! Throughout March 2021, our Language of the Month, nominated by myself (Bubbler) will be:

Factor

What's a Language of the Month?

See the meta post for nominations. In short, during March, those who wish to participate should learn (at least the basics of) Factor, and use it to solve challenges. Participation is completely optional, but is anticipated to be fun!

Information about Factor

The Factor programming language is a concatenative, stack-based programming language with high-level features including dynamic types, extensible syntax, macros, and garbage collection. On a practical side, Factor has a full-featured library, supports many different platforms, and has been extensively documented.

Factor is the modern stack-based practical language. If Forth (LotM of November 2020) was too hard to use because of its low-level-ness and nothing else, Factor is probably the right language for you.

Why Factor?

  • Factor is functional and object-oriented. Any object or function can be pushed on the data stack. The "object" includes containers (arrays, hashmaps, and the like).
  • Factor does not use syntax (if..then..else, for, while) for control flow. Instead, it extensively uses quotations (equivalent of anonymous lambda functions) and higher-order functions. For example, an equivalent of if-statement looks like boolean [ true-func ] [ false-func ] if.
  • The standard library includes lots of higher-order functions that act on the stack or arrays, which can give a feel of working in Haskell.
  • The functional idiom for reusing stack item(s) can give the feel of APL trains or Jelly links.
  • When the stack shuffling gets extra cumbersome, you can get away with local variables.
  • Factor implements whole numeric tower (bigints, rationals, floats, and complex numbers whose components can be in any of the three real number types).
  • Stack safety is enforced by checking the written stack effect against the actual one. It may be a hindrance to golf, but it makes Factor functions easier to debug. And you can ignore it by using a quotation for golfing purposes.
  • Despite the verbosity of syntax (space-separated words), Factor is often on par with other practical languages (JS, Python, R) byte-count-wise, thanks to the rich set of library functions.

Caveats

  • It is recommended to install the Factor binary locally to search for the library functions. (Factor binary is available for Windows/Mac/Linux.)
  • TIO seems to have a version different from the current stable (0.98), and some things that work locally may not work on TIO. e.g. tuck ( x y -- y x y ) is missing, and count does not load with auto-use.

Resources

Bounty

I (Bubbler) will award 50 × n rep for any user's n-th Factor answer posted this month, up to n = 10, maximum 2750 rep in total per user.

\$\endgroup\$
3
\$\begingroup\$

List of all Factor solutions posted in March 2021

(First time posters highlighted in bold)


List of all Factor tips posted in March 2021


List of Factor-related challenges posted in March 2021

  • add entries in the form:

      [<challenge title>](https://codegolf.stackexchange.com/q/<question-ID>) by [username](https://codegolf.stackexchange.com/users/<user-ID>)
    
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .