Programming Leftovers
-
Mark Dominus ☛ Puzzling historical artifact in “Programming Erlang”?
Can you guess the obscure bug? I don't think I'm unusually skilled at concurrent systems programming, and I'm certainly no Joe Armstrong, but I thought the problem was glaringly obvious: [...]
-
Geshan ☛ Jest mock implementation: A beginner’s guide to replacing function implementation for tests
Jest mockImplementation enables developers to replace the original implementation of a function with a mock function, allowing them to control the function's behavior and verify specific interactions. This technique proves particularly beneficial when testing code that interacts with external dependencies, such as APIs, databases, or filesystem operations.
-
Idiomdrottning ☛ Branching & Patching
One example of that for me is when I did the massive update of match-generics, which was one of the difficultest things I’ve ever written (ironic since the original version was just a one-hour hack wrapper for foof’s match-lambda). I kept the “rewrite” in its own branch until it was done, so I could still do maintenance fixes for the original. I knew the “rewrite” would take a while.
-
Nikhil Marathe ☛ A practical introduction to kill-safe, concurrent programming in Racket
I’ve written a long tutorial exploring the user of Racket’s Concurrent ML (CML) inspired concurrency paradigm to write an API wrapping git-cat-file. It is meant to serve as an introduction to kill-safety and CML concurrency, while assuming some existing knowledge of Racket or other Schemes. I found that there weren’t a lot of resources beyond the reference documentation that explained how to put these APIs together, and I hope this can fill that hole.
-
Daniel Lemire ☛ A simple WebSocket benchmark in JavaScript: Node.js versus Bun
Conventional web applications use the http protocol (or the https variant). The http protocol is essentially asymmetrical: a client application such as a browser issues requests and the server responds. It is not possible for the server to initiate communication with the client. Certain types of applications are therefore more difficult to design.
-
Python
-
Linux Links ☛ 20 Best Free and Open Source Python Visualization Packages
Python has a fantastic range of packages to produce mesmerizing visualizations. We recommend the best free and open source Python tools.
-
-
Shell/Bash/Zsh/Ksh
-
University of Toronto ☛ Unix shells and the current directory
Famously, Unix has the concept of a process's 'current directory', including for your shell processes. Recently, I saw an interesting Fediverse discussion on some aspects of the current directory which aren't necessarily obvious, partly because both Unix kernels and Unix shells have become more complicated over time.
The Unix kernel keeps track of your current directory not as text path but as a reference to a kernel object, normally the directory's inode. In the old days this was all the kernel actually knew about the current directory, but today Linux (and perhaps other Unixes) have developed kernel caches of the mappings between names and inodes; in Linux, these are dnodes (I believe for 'directory (entry) node'). Linux's dnodes mean that the kernel almost always knows the name of your current directory, if it has one.
-
University of Toronto ☛ A peculiarity of the GNU Coreutils version of 'test' and '['
Famously, '[' is a program, not a piece of shell syntax, and it's also known as 'test' (which was the original name for it). On many systems, this was and is implemented by '[' being a hardlink to 'test' (generally 'test' was the primary name for various reasons). However, today I found out that GNU Coreutils is an exception. Although the two names are built from the same source code (src/test.c), they're different binaries and the '[' binary is larger than the 'test' binary. What is ultimately going on here is a piece of 'test' behavior that I had forgotten about, that of the meaning of running 'test' with a single argument.
-