RSS Amplifier

Blog

Re: Factor

Recent content on Re: Factor

re.factorcode.orgRSS feed ↗348 posts

Latest posts

Peace For All

I am perhaps susceptible to nerd-sniping and it often leads me down interesting rabbit holes . Today was one of those days. I bumped into a fun article about some obfuscated bash code on a T-shirt for sale: The obfuscated code in question is actually an easter egg, it’s being supplied via Uniqlo stores on an excellent t-shirt designed by Akamai in support of their Peace for All campaign . While…

Native ARM64

We have a contributor that has been working hard on support for native ARM64 compilation in Factor . Simultaneously, we are working on getting that into the C++ VM as well as the new Zig VM that might eventually replace it in a future version. I wanted to give a preview now that the native ARM64 version seems to work pretty well on macOS . Now that we are native , we expect significantly improved…

Getting Ziggy With It

It is possible that the next Factor release will be re-implemented in the Zig programming language and be faster in many cases compared to the current C++ VM. As a reminder, we have had several implementation eras, using: the Java programming language until at least version 0.60, the C programming language from at least version 0.66 to version 0.91 , the C++ programming language from version 0.92…

Standard Deviation

Standard deviation is “ a measure of the amount of variation of the values of a variable about its mean. ”. It’s a useful measure from statistics, and std in the math.statistics vocabulary included with Factor . I bumped into this – um, are they still called tweets? – today: Word with the lowest standard deviation of letter position in the alphabet, for each length…

PBRT

PBRT is an impressive photorealistic rendering system: From movies to video games, computer-rendered images are pervasive today. Physically Based Rendering introduces the concepts and theory of photorealistic rendering hand in hand with the source code for a sophisticated renderer. The fourth edition of their book is now available on Amazon as well as freely available online . I thought it would…

Migrating to GTK3

Factor has a native ui-backend that allows us to render our UI framework using OpenGL on top of platform-specific APIs for our primary targets of Linux, macOS, and Windows. On Linux, for a long time that has meant using the GTK2 library, which has also meant using X11 and an old library called libgtkglext which provides a way to use OpenGL within GTK windows. Well, Linux has moved on and is now…

DNS LOC Records

DNS is the Domain Name System and is the backbone of the internet: Most prominently, it translates readily memorized domain names to the numerical IP addresses needed for locating and identifying computer services and devices with the underlying network protocols . The Domain Name System has been an essential component of the functionality of the Internet since 1985. It is also an oft-cited reason…

Factor 0.101 now available

“Keep thy airspeed up, lest the earth come from below and smite thee.” - William Kershner I’m very pleased to announce the release of Factor 0.101! OS/CPU Windows Mac OS Linux x86 0.101 0.101 x86-64 0.101 0.101 0.101 Source code : 0.101 This release is brought to you with almost 700 commits by the following individuals: Aleksander Sabak, Andy Kluger, Cat Stevens, Dmitry Matveyev,…

zxcvbn

Years ago, Dropbox wrote about zxcvbn: realistic password strength estimation : zxcvbn is a password strength estimator inspired by password crackers. Through pattern matching and conservative estimation, it recognizes and weighs 30k common passwords, common names and surnames according to US census data, popular English words from Wikipedia and US television and movies, and other common patterns…

AsyncIO Performance

Factor has green threads and a long-standing feature request to be able to utilize native threads more efficiently for concurrent tasks. In the meantime, the cooperative threading model allows for asynchronous tasks which is particularly useful when waiting for I/O such as used by sockets over a computer network . And while it might be true that asynchrony is not concurrency , there are a lot of…

Cosine FizzBuzz

After revisiting FizzBuzz yesterday to discuss a Lazy FizzBuzz using infinite lazy lists, I thought I would not return to the subject for awhile. Apparently, I was wrong! Susam Pal just wrote a really fun article about Solving Fizz Buzz with Cosines : We define a set of four functions { s0 , s1 , s2 , s3 } for integers n by: s0(n) = n s1(n) = Fizz s2(n) = Buzz s3(n) = FizzBuzz And from that, they…

Lazy FizzBuzz

I wrote about FizzBuzz many years ago. It’s a silly programming task often cited and even included on RosettaCode . The task is described as: Write a program that prints the integers from 1 to 100 (inclusive). But: for multiples of three, print "Fizz" instead of the number; for multiples of five, print "Buzz" instead of the number; for multiples of both three and five, print "FizzBuzz"…

Lorem Ipsum

Lorem ipsum is a type of placeholder text that can be used in graphic design or web development. The most common form of it will often begin like this paragraph: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis…

Cardinal Direction

Cardinal direction describes points on a compass — North ( N ), East ( E ), South ( S ), and West ( W ). In addition to those, there are also 4 intercardinal directions (Northwest or NW , NE , SW , SE ), 8 secondary intercardinal directions (North-Northwest or NNW , WNW , NNE , ENE , WSW , SSW , ESE , SSE ), as well as 16 tertiary intercardinal directions (Northwest-by-North or NWbN , etc.).…

Flood Fill

Yesterday, Rodrigo Girão Serrão wrote an article about implementing the Floodfill algorithm in Python . He included a Javascript demonstration you can click on, as well as a step-by-step example at the end of his blog post to go over how flood fill works. We are going to implement this in Factor and then extend the images.viewer vocabulary : When working with bitmap pixel data , we typically store…

Parsing Chemistry

In Python , the chemparse project is available as a “ lightweight package for parsing chemical formula strings into python dictionaries ” mapping chemical elements to numeric counts. It supports parsing several variants of formula such as: simple formulas like "H2O" fractional stoichiometry like "C1.5O3" groups such as "(CH3)2" nested groups such as "((CH3)2)3" square brackets such as…

Split Lines

William Woodruff recently noticed that Python’s splitlines does a lot more than just newlines : I always assumed that Python’s str.splitlines() split strings by “ universal newlines ”, i.e., \n , \r , and \r\n . But it turns out it does a lot more than that. The recent Factor 0.100 release included a change to make the split-lines word split on unicode linebreaks which…

Extensible Data Notation

I wrote about the Data Formats support that comes included in Factor . As I mentioned in that post, there are many more that we could implement. One of those is Extensible Data Notation – also known as EDN – and comes from the Clojure community. We can see a nice example of the EDN format in Learn EDN in Y minutes : ; Comments start with a semicolon. ; Anything after the semicolon is…

Pseudo Encrypt

Pseudo Encrypt is a function drawn from the PostgreSQL project. pseudo_encrypt(int) can be used as a pseudo-random generator of unique values . It produces an integer output that is uniquely associated to its integer input (by a mathematical permutation), but looks random at the same time, with zero collision . This is useful to communicate numbers generated sequentially without revealing their…

std::flip

Morwenn posted a blog about implementing a std::flip operation in C++: This is basically walking up the tree from the child node as if it were a linked list. The reverse operation either implies walking through two children nodes, or simply flipping the order of parameters, which is where std::flip intervenes: auto is_descendant_of = std :: flip ( is_ancestor_of ); // This property should always…

Scream Cipher

Seth Larson wrote about a Scream Cipher : You’ve probably heard of stream ciphers , but what about a scream cipher 😱? Today I learned there are more “ Latin capital letter A ” Unicode characters than there are letters in the English alphabet. You know what that means, it’s time to scream: We can use bidirectional assocs to keep a single cipher data structure that efficiently maps into…

Environment Variables

Factor has an environment vocabulary for working with process environment variables on all the platforms we currently support: macOS, Windows, and Linux. Recently, I noticed that .NET 9 added support for empty environment variables . This was particulary relevant due to a test failure of the new Dotenv implementation on Windows. It turns out that we inherited the same issue that earlier .NET…

HiDPI

HiDPI is a name for high resolution displays, sometimes called retina displays. A long long time ago , I added support for Retina Displays on macOS using Factor . But, they have not been well supported on either Linux or Windows platforms. That ends today! Linux Some users have seen the “small window” problem on Linux, where on high resolution displays the Factor UI listener was…

Neovim

Neovim is a modern implementation of a vim-like editor. It started as a refactor, but “ not a rewrite but a continuation and extension of Vim ”. It does have some ability to load plugins built in Vimscript , but most new plugins seem to be written using the Lua programming language . Factor has many different editor integrations supporting various text editors as well as plugins for…

New Icon

Encouraged by a fun rant about MacOS Tahoe’s Dead-Canary Utility App Icons , the reality that Apple is moving into the wonderful squircle-filled future, and the particularly annoying fact that legacy icons look terrible on macOS Tahoe – we have a new icon for Factor ! The latest development version includes new icon files in both PNG and SVG formats. And these are being used across…

TA-Lib

The TA-Lib is a C project that supports adding “ technical analysis to your own financial market trading applications ”. It was originally created in 2001 and is well-tested, recently released, and popular: 200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc… See complete list… Candlestick patterns recognition Core written in C/C++ with API also…

String Length

I was reminded recently about a great article about unicode string lengths : It’s Not Wrong that "🤦🏼‍♂️".length == 7 But It’s Better that "🤦🏼‍♂️".len() == 17 and Rather Useless that len("🤦🏼‍♂️") == 5 This comes at a time of excessive emoji tsunami thanks to the proliferation of large language models and probably lots of Gen Z in the training data sets. Sometimes emojis are fun and useful…

Anubis

Tavis Ormany wrote a great blog post about the Anubis project asking a very valid sounding question: Hey… quick question, why are anime catgirls blocking my access to the Linux kernel? The answer seems to be that it “ weighs the soul of your connection using one or more challenges in order to protect upstream resources from scraper bots ”. In particular, this project is an…

Left to Right

An article about Left to Right Programming was posted a few days ago with a good discussions on Hacker News and on Lobsters . It’s a nice read with some syntax examples in different languages looking at some code blocks that are structured left-to-right or right-to-left. We can look at a few of the shared examples and think about how they might look like naturally in Factor , which inherits…

Pickle

Pretty much everything pickle is great: sweet, dill, bread and butter, full sour, half sour, gherkins, achar, even pickleball. In addition to being both yummy and fun and a great Tuesday night on the Playa , pickle is also the name for Python object serialization . There are currently 6 different protocols which can be used for pickling. The higher the protocol used, the more recent the version of…

Marp

Marp , also known as the Markdown Presentation Ecosystem , is a way to “ create beautiful slide decks using an intuitive Markdown experience ”. If you’ve seen a presentation about Factor before, you might notice that we have a slides vocabulary that allows us to build presentations in Factor and then present it using the Factor UI . Many of our previous talks are shared in the…

Data Formats

A data format is a standardized way of encoding, storing, and representing data, allowing different software applications to interpret and process it. I was reminded of this recently when a link was shared to From XML to JSON to CBOR which discusses three pivotal data formats and their evolution. Some data formats that Factor supports in its extensive standard library : Bencode or BitTorrent…

Tribonacci Numbers

Tribonacci numbers are a 3 argument version of the Fibonacci sequence . Specifically, they are defined by the first 3 numbers in the sequence and then a recursive formula: T(0) = 0 T(1) = 1 T(2) = 1 T(n) = T(n-1) + T(n-2) + T(n-3) Note: Some other tribonacci sequences have different starting values, and in general are defined by their first 3 values: a , b , and c — in this case: a=0 , b=1 ,…

Tak Function

The Tak function is a recursive function, named after Ikuo Takeuchi, used sometimes as a programming language benchmark. On the Concatenative Wiki , I noticed a page with concatenative implementations of the Tak function , and wanted to explore some different ways to build it in Factor . def tak ( x : int , y : int , z : int ) -> int : if y < x : return tak ( tak ( x - 1 , y , z ), tak ( y - 1 , z…

Ask OK?

To illustrate some varied aspects of programming with Factor , I wanted to show how you might write an example used in the Python documentation to demonstrate control flow and default values: def ask_ok ( prompt , retries = 4 , complaint = 'Yes or no, please!' ): while True : ok = input ( prompt ) if ok in ( 'y' , 'ye' , 'yes' ): return True if ok in ( 'n' , 'no' , 'nop' , 'nope' ): return False…

Asserting Implications

Asserting Implications is a short, but targeted, blog post by the Tigerbeetle team about writing some asserts differently &ndash; along with some interesting lobste.rs discussions . Their main conclusion was made using an example code change in Zig : // Before: assert ( header_b != null or replica . commit_min == replica . op_checkpoint ); // After: if ( header_b == null ) assert ( replica .…

World Emoji Day

Today, and every July 17th, is World Emoji Day . Kind of amazing that there have already been twelve annual global emoji celebrations! In any event, I was reminded of that by this post: Your fate is sealed in emoji! 🎲 Roll a d20 and face your destiny on World Emoji Day! pic.twitter.com/aIyzDJB4Bw &mdash; Dungeons & Dragons (@Wizards_DnD) July 17, 2025 We have had support in the calendar.holidays…

One Billion Loops

The Primeagen had a great video about Language Performance Comparisons Are Junk about six months ago talking about the 1 Billion nested loop iterations benchmark that Benjamin Dicken wrote. You can find a copy of the benchmark code on GitHub . The loops benchmark can be summarized by a version in Python : import sys import random u = int ( sys . argv [ 1 ]) # Get an input number from the command…

Command Arguments

A question was asked recently on the Factor mailing list about the Argument Parser that I had previously implemented in Factor : I have been trying to hack on command-line.parser to add the ability to call it with commands. The specific feature they want is similar to the ArgumentParser.add_subparsers function in Python&rsquo;s argparse module. I spent a little bit of time thinking about a quick…

Fibonacci Style

About 14 years ago, I wrote about Fibonacci Wars which described the relative performance of three different methods of calculating Fibonacci numbers . Today, I wanted to address a style question that someone in the Factor Discord server asked: How could I write this better? : fib ( n -- f(n) ) 0 1 rot 1 - [ tuck + ] times nip ; In a more concatenative style. I&rsquo;ve written before about…

Jaro-Winkler

Jaro-Winkler distance is a measure of string similarity and edit distance between two sequences: The higher the Jaro–Winkler distance for two strings is, the less similar the strings are. The score is normalized such that 0 means an exact match and 1 means there is no similarity. The original paper actually defined the metric in terms of similarity, so the distance is defined as the inversion of…

Best Shuffle

The &ldquo; Best shuffle &rdquo; is a Rosetta Code task that was not yet implemented in Factor : Task Shuffle the characters of a string in such a way that as many of the character values are in a different position as possible. A shuffle that produces a randomized result among the best choices is to be preferred. A deterministic approach that produces the same sequence every time is acceptable as…

Dotenv

Dotenv is an informal file specification, a collection of implementations in different languages, and an organization providing cloud-hosting services. They describe the .env file format and some extensions: The .env file format is central to good DSX and has been since it was introduced by Heroku in 2012 and popularized by the dotenv node module (and other libraries) in 2013. The .env file format…

Color Prettyprint

Factor has a neat feature in the prettyprint vocabulary that allows printing objects, typically as valid source literal expressions. There are small caveats to that regarding circularity, depth limits, and other prettyprint control variables , but it&rsquo;s roughly true that you can pprint most everything and have it be useful. At some point in the past few years, I noticed that Xcode and Swift…

Tracking Dict

Peter Bengtsson wrote about building a Python dict that can report which keys you did not use : This can come in handy if you&rsquo;re working with large Python objects and you want to be certain that you&rsquo;re either unit testing everything you retrieve or certain that all the data you draw from a database is actually used in a report. For example, you might have a SELECT fieldX, fieldY,…

bab=aaa, bbb=bb

Admittedly, I struggle sometimes when I read the word &ldquo; monoid &rdquo;. It seems to always remind me of that saying &ldquo;A Monad is just a Monoid in the Category of Endofunctors&rdquo; which is both a tongue-twister, requires repeated effort to understand, and is sometimes used in casual conversation when jealously describing the features and capabilities of the Haskell programming…

Bitcask

Phil Eaton issued a HYIBY? &ndash; have you implemented bitcask yet? &ndash; challenge yesterday. Of course, I immediately realized that I have not and also that it would be fun to build in Factor . Bitcask is described in the original Bitcask paper as a &ldquo; log-structured hash-table for fast key/value data &rdquo;, and was part of the software developed by Basho Technologies as part of the…

Game of Life

One of my first and most memorable graphical programs was implementing John Conway&rsquo;s Game of Life . At the time, that implementation was as a Java applet . I&rsquo;ve revisited it periodically in different programming languages including several years ago when I started to implement the Game of Life in Factor &ndash; something I&rsquo;ve always wanted to write about. The Game of Life is a…

Sorting IPv6

Recently, Chris Siebenmann was lamenting the lack of a good command line way to sort IPv6 addresses . This followed a post of his a few years ago about how sort -V can easily sort IPv4 addresses . Since I had some fun talking about sorting Roman numerals recently &ndash; and we have an extensive standard library &ndash; I thought I&rsquo;d talk about how you might solve this problem with Factor .…

Faster Leap Year?

Last week, Falk Hüffner wrote about making a leap year check in three instructions : With the following code, we can check whether a year 0 ≤ y ≤ 102499 is a leap year with only about 3 CPU instructions: bool is_leap_year_fast ( uint32_t y ) { return (( y * 1073750999 ) & 3221352463 ) <= 126976 ; } How does this work? The answer is surprisingly complex. This article explains it, mostly to have…