RSSAmplifier

Blog

Re: Factor

Factor: the language, the theory, and the practice.

re-factor.blogspot.comRSS feed ↗25 posts

Latest posts

Migrating...

I am migrating this blog to a new site available on the domain re.factorcode.org . While I do joke a lot about all of the Killed by Google apps, products, and features... it seems inevitable that at some point Google will kill the Blogger product and I wanted more control of this website. For anyone curious, the new Re: Factor is built currently on Hugo the "world’s fastest framework for building…

OpenAI

It’s been pretty hard to avoid all of the incredible stories about artificial intelligence over the past few months. There seem to be incredible applications to the area of generative AI occurring on a daily basis. Image generation with Midjourney is pretty next-level. Code generation using GitHub Copilot seems pretty amazing. Interacting with large language models like GPT-4 or Bard or Bing…

ASCII Table PDF

Vasudev Ram has a blog with many different posts about various programming topics including Python, Linux, SQL, and PDFs. On the topic of PDF generation, they have a blog post about making an ASCII Table to PDF with xtopdf . Recently, I had the need for an ASCII table lookup, which I searched for and found, thanks to the folks here: www.ascii-code.com That gave me the idea of writing a simple…

Short UUID

The shortuuid project is a “ simple python library that generates concise, unambiguous, URL-safe UUIDs ”. I thought it would be a fun exercise to implement this in Factor . What is a “short UUID”? You can read the original announcement , but basically it is a string representation of a number using a reduced alphabet that can be used in places like URLs where conciseness is…

Geo Timezones

Brad Fitzpatrick wrote a Go package called latlong which efficiently maps a latitude/longitude to a timezone. The original post describing it was on Google+ and is likely lost forever — unless it made it into the Google+ archive before Google+ joined the Google Graveyard . It tries to have a small binary size (~360 KB), low memory footprint (~1 MB), and incredibly fast lookups (~0.5 microseconds).…

Reference Server

Phil Eaton made a repository of Barebones UNIX socket servers with this description: I find myself writing this server in some language every few months. Each time I have to scour the web for a good reference. Use this as a reference to write your own bare server in C or other languages with a UNIX API (Python, OCaml, etc). Many developers learning network programming will encounter Beej's Guide…

Weighted Random

Some time ago, I implemented a way to generate weighted random values from a discrete distribution in Factor . It ended up being a pretty satisfyingly simple word that builds a cumulative probability table, generates a random probability, then searches the table to find which value to return: : weighted-random ( histogram -- obj ) unzip cum-sum [ last >float random ] keep bisect-left swap nth ; Is…

DuckDuckGo

The conversation around the current quality of web search engines, the doomsday prediction about various incumbents, and the equal parts inspiring and challenging rollout of large language models to improve search has been fascinating to watch. There are many challengers in the search engine space including companies like Kagi and Neeva among many search engine startups . One privacy-focused…

Magic

Ever wonder what the type of a particular binary file is? Or wonder how a program knows that a particular binary file is in a compatible file format ? One way is to look at the magic number used by the file format in question. You can see some examples in a list of file signatures . The libmagic library commonly supports the file command on Unix systems, other than Apple macOS which has its own…

Hipku

Once upon a time, there was a Javascript project called Hipku . The original post that described it was lost somewhere in the series of tubes , but thankfully the "full documentation and a working demo" was saved by the Wayback Machine . It is also still available on npm for installation. Hipku is a small javascript library to encode IP addresses as haiku. It can express any IPv4 or IPv6 address…

Proquint

A few days ago, Ciprian Dorin Craciun wrote a binary to text encoding blog post about the "state of the art and missed opportunities" in various encoding schemes. In that post, I was introduced to the Proquint encoding which stands for " PRO-nouncable QUINT-uplets ". In the Factor programming language , we have enjoyed implementing many encoding/decoding methods including: base16 , base24 , base32…

Semantic Versioning

Semantic Versioning (or "semver" for short) is a specification for handling version numbers, and providing a way to sort and specify compatibility using a MAJOR.MINOR.PATCH structure with optional "pre-release" and "build" information. Some examples of semantic version numbers: 1.0.0-alpha 1.0.0-beta+win32 1.0.0-rc.1 1.0.0 For a long time, I thought it might be funny to follow the upcoming release…

Five Questions

Many years ago, there was a blog post containing five programming problems every software engineer should be able to solve in less than 1 hour . I had bookmarked it at the time and didn't notice the controversy it created on Reddit . The original link seems to be down — you can view a copy of it on the Wayback Machine — but there are various solutions posted online, including a solution in Python…

GetPercentageRounds

There was a funny post on Twitter a couple of days ago about a recent event where the "Dutch government was forced to release the source code of their DigiD digital authentication iOS app" with this piece of C# code: Some very funny discussions continued, with comments about how good or bad this code is, and how one might rewrite it in various ways. I thought it would be a fun opportunity to show…

Project Gemini

Project Gemini is a neat modern take on the Gopher protocol . You can read the Gemini FAQ or the Gemini specification to learn more details, but the home page has a nice summary: Gemini is a new internet protocol which Is heavier than gopher Is lighter than the web Will not replace either Strives for maximum power to weight ratio Takes user privacy very seriously There are some nice Gemini clients…

Guided Tour of Factor

Many years ago, Andrea Ferretti created a Factor tutorial which I had written about at the time . One of our new core developers, Raghu Ranganathan , got permission to include the tutorial in the main Factor repository, and has reformatted it and updated it for the not-yet-released version 0.99 as the Guided tour of Factor . You can access it in a recent nightly build by doing: IN: scratchpad…

Speedrun Feedback

Recently, Tomasz Wegrzanowski chose Factor for his 100 Languages Speedrun: Episode 71: Factor and it encouraged us to make some improvements that I wanted to describe. Many of our users use the Factor environment through the UI developer tools or on the command-line with the listener . Another important use case is being able to eval and run scripts -- and this is where much of Tomasz' criticism…

Factor 0.98 now available

“Even though you're growing up, you should never stop having fun.” - Nina Dobrev I'm very pleased to announce the release of Factor 0.98! OS/CPU Windows Mac OS X Linux x86 0.98 0.98 0.98 x86-64 0.98 0.98 0.98 Source code : 0.98 This release is brought to you with almost 4,300 commits by the following individuals: Alexander Ilin, Arkady Rost, Benjamin Pollack, Björn Lindqvist, Cat Stevens, Chris…

Minesweeper

Minesweeper is a fun game that was probably made most popular by its inclusion in various Microsoft Windows versions since the early 1990's. I thought it would be fun to build a simple Minesweeper clone using Factor . You can run this by updating to the latest code and running: IN: scratchpad "minesweeper" run Game Engine We are going to represent our game grid as a two-dimensional array of…

$7.11

Today, someone blogged about a fun problem: “A mathematician purchased four items in a grocery store. He noticed that when he added the prices of the four items, the sum came to $7.11, and when he multiplied the prices of the four items, the product came to $7.11.” In some ways, this is similar to the SEND + MORE = MONEY problem that I blogged about awhile ago. You can always approach this problem…

Dirty Money: Code Challenge

There's a fun coding challenge to follow the dirty money that I discovered recently. A shady Internet business has been discovered. The website has been made public by a whistle blower. We have enough evidence about the dirty deals they did. But to charge them we need to get hands on precise numbers about the transactions that happened on their platform. Unfortunately no record of the transactions…

The Twelve Days of Christmas

Programming Praxis posted a task to write a program to print the words to The Twelve Days of Christmas song. We are going to solve it in Factor . We start off by defining all the gifts received on each day: CONSTANT: gifts { { "first" "a partridge in a pear tree" } { "second" "two turtle doves and " } { "third" "three French hens, " } { "fourth" "four calling birds, " } { "fifth" "five golden…

AnyBar

AnyBar is a macOS status indicator that displays a "colored dot" in the menu bar that can be changed programatically. What it means and when it changes is entirely up to the user. You can easily install it with Homebrew-cask : $ brew cask install anybar The README lists a number of alternative clients in different programming languages. I thought it would be fun to show how to use it from Factor .…

Reverse Factorial

A few years ago, I wrote about implementing various factorials using Factor . Recently, I came across a programming challenge to implement a "reverse factorial" function to determine what factorial produces a number, or none if it is not a factorial. To do this, we examine each factorial in order, checking against the number being tested: : reverse-factorial ( m -- n ) 1 1 [ 2over > ] [ 1 + [ * ]…

Gopher Server

A few days ago, I noticed a post about building a Gopher Server in Perl 6 . I had already implemented a Gopher Client in Factor , and thought it might be fun to show a simple Gopher Server in Factor in around 50 lines of code. Using the io.servers vocabulary, we will define a new multi-threaded server that has a directory to serve content from and hostname that it can be accessed at: TUPLE:…