Plurrrr

week 28, 2022

Integer math in JavaScript

You may know that all numbers in JavaScript are 64 bit double-precision floating point values. This is sometimes convenient and it works pretty well as a default for novice programmers, who are often confused by integer math, and rightfully so when 1 / 2 = 0. Unfortunately, it makes things slow. Doubles take a lot of memory and floating point math is slower than integer math on CPUs. It's also inconvenient if you want to port existing code to JavaScript, because existing code usually expects to use integer math.

Fortunately, there is a way to make JavaScript do integer math, and it works remarkably well!

Source: Integer math in JavaScript, an article by James Darpinian.

Your git log is not a changelog!

When you maintain a project, publishing new releases can quickly become a chore, so naturally one tries to automate it as much as possible.

One release step which is often automated is updating the changelog. We already have git commit messages, so let's gather all the messages since the last tag and "Voilà!" changelog entries for the new version!

There is however a problem with this idea:

Git commit messages and changelogs do not have the same target audience.

Source: Your git log is not a changelog!, an article by Aurélien Gâteau.

Chapterhouse: Dune

The desert planet Arrakis, called Dune, has been destroyed. The remnants of the Old Empire have been consumed by the violent matriarchal cult known as the Honored Matres. Only one faction remains a viable threat to their total conquest—the Bene Gesserit, heirs to Dune’s power.

Under the leadership of Mother Superior Darwi Odrade, the Bene Gesserit have colonized a green world on the planet Chapterhouse and are turning it into a desert, mile by scorched mile. And once they’ve mastered breeding sandworms, the Sisterhood will control the production of the greatest commodity in the known galaxy—the spice melange. But their true weapon remains a man who has lived countless lifetimes—a man who served under the God Emperor Paul Muad’Dib....

In the evening I started in the sixth Dune Novel by Frank Herbert: Chapterhouse: Dune.

A lifehack for your shell

I'm a fan of the unzip command line utility that ships with macOS. I give it a .zip file and it unzips it for me. No flags or arguments to remember (for my typical usages anyway). Most importantly, I've fully internalized the unzip command into muscle memory, probably because of its perfect mnemonic.

Source: A lifehack for your shell, an article by Álvaro Ramírez.

Do you really understand interfaces?

When I was learning Java in college, I did not understand the use for interfaces. You can't define functions inside an interface. You can only declare them. You have to have a class implement the interface to define it's functions and then use them. That's crazy! Pretty worthless piece of crap I would think. I can just write my classes and their functions normally. Why would I declare them in one place and define in another. I don't even need to declare them. Just write my functions normally in a class. It's totally redundant.

Source: Do you really understand interfaces?.

A Guide to the Go Garbage Collector

This guide is intended to aid advanced Go users in better understanding their application costs by providing insights into the Go garbage collector. It also provides guidance on how Go users may use these insights to improve their applications' resource utilization. It does not assume any knowledge of garbage collection, but does assume familiarity with the Go programming language.

Source: A Guide to the Go Garbage Collector.

Making Heatmaps

In this post, I'll walk you through building a heatmap using freely available CSV and geospatial data. This post will make use of Python, ClickHouse and QGIS, a toolchain that is both open source and free of charge.

Source: Making Heatmaps, an article by Mark Litwintschik.

A Spectre is Haunting Unicode

In 1978 Japan's Ministry of Economy, Trade and Industry established the encoding that would later be known as JIS X 0208, which still serves as an important reference for all Japanese encodings. However, after the JIS standard was released people noticed something strange - several of the added characters had no obvious sources, and nobody could tell what they meant or how they should be pronounced. Nobody was sure where they came from. These are what came to be known as the ghost characters (幽霊文 字 ).

Source: A Spectre is Haunting Unicode, an article by Paul O'Leary McCann.

The Top 10 Tips to Write Clean Code

A crucial feature of good software is clean code. Developers prefer to work on applications if the code is easy to understand and modify. Sometimes, the coding hastened to meet deadlines but eventually causes delay since more bugs need fixing. Studies have revealed that the time spent reading code compared to writing is higher than 10:1. Hence, the need for clean code arises.

Source: The Top 10 Tips to Write Clean Code, an article by Rebecca Daniel.

Choosing a PostgreSQL Number Format

It should be the easiest thing in the world: you are modeling your data and you need a column for some numbers, what type do you use?

PostgreSQL offers a lot of different number types, and they all have advantages and limitations. You want the number type that is going to:

  • Store your data using the smallest amount of space
  • Represent your data with the smallest amount of error
  • Manipulate your data using the correct logic

Source: Choosing a PostgreSQL Number Format, an article by Paul Ramsey.

Faster, more memory-efficient Python JSON parsing with msgspec

If you need to process a large JSON file in Python, you want:

  • Make sure you don’t use too much memory, so you don’t crash half-way through.
  • Parse it as quickly as possible.
  • Ideally, make sure the data is actually valid up-front, with the right structure, so you don’t blow up half-way through your analysis.

You can put together solutions with multiple libraries, of course. Or, you can use msgspec a new library that offers schemas, fast parsing, and some neat tricks to reduce memory usage, all in a single library.

Source: Faster, more memory-efficient Python JSON parsing with msgspec, an article by Itamar Turner-Trauring.

How MirageOS Powers Docker Desktop

Recently, I posted about how vpnkit, built with MirageOS libraries, powers Docker Desktop. Docker Desktop enables users to build, share and run isolated, containerised applications on either a Mac or Windows environment. With millions of users, it's the most popular developer tool on the planet. Hence, MirageOS networking libraries transparently handle the traffic of millions of containers, simplifying many developers' experience every day.

Source: How MirageOS Powers Docker Desktop, an article by Dave Scott.

Column order in PostgreSQL does matter

I’ve recently seen some really broad tables (hundreds of columns) in a somewhat inefficiently structured database. Our PostgreSQL support customer complained about strange runtime behavior which could not be easily explained. To help other PostgreSQL users in this same situation, I decided to reveal the secrets of a fairly common performance problem many people don’t understand: Column order and column access.

Source: Column order in PostgreSQL does matter, an article by Hans-Jürgen Schönig.

Postgres 15 improves UNIQUE and NULL

Postgres 15 beta 2 was released recently! I enjoy Beta season... reviewing and testing new features is a fun diversion from daily tasks. This post takes a look at an improvement to UNIQUE constraints on columns with NULL values. While the nuances of unique constraints are not as flashy as making sorts faster (that's exciting!), improving the database developer's control over data quality is always a good benefit.

Source: Postgres 15 improves UNIQUE and NULL, an article by Ryan Lambert.