Programming Leftovers
-
Loris Cro ☛ Dead Simple Snapshot Testing In Zig
When your tests are expressed as Zig test {} definitions, you can use a library to update the snapshot by directly modifying the Zig source code that contains your tests. This is what TigerBeetle presented in “Snapshot Testing For The Masses” (see also Oh Snap!).
In my case, Zine is a static site generator and, as such, it has files as the natural unit of input/output, meaning that my tests look more like integration tests orchestrated by the build system, rather than unit tests written in Zig files. To be clear, I do have unit tests for my parsers, but for the static site generator as a whole, integration tests are the way to go.
-
Jussi Pakkanen ☛ C++ compiler daemon testing tool
In an earlier blog post I wrote about a potential way of speeding up C++ compilations (or any language that has a big up-front cost). The basic idea is to have a process that reads in all stdlib header code that is suspended. Compilations are done by sending the actual source file + flags to this process, which then forks and resumes compilation. Basically this is a way to persist the state of the compiler without writing (or executing) a single line of serialization code.
The obvious follow up question is what is the speedup of this scheme. That is difficult to say without actually implementing the system. There are way too many variables and uncertainties to make any sort of reasonable estimate.
So I implemented it.
-
Andy Wingo: baffled by generational garbage collection
Usually in this space I like to share interesting things that I find out; you might call it a research-epistle-publish loop. Today, though, I come not with answers, but with questions, or rather one question, but with fractal surface area: what is the value proposition of generational garbage collection?
hypothesis
The conventional wisdom is encapsulated in a 2004 Blackburn, Cheng, and McKinley paper, “Myths and Realities: The Performance Impact of Garbage Collection”, which compares whole-heap mark-sweep and copying collectors to their generational counterparts, using the Jikes RVM as a test harness. (It also examines a generational reference-counting collector, which is an interesting predecessor to the 2022 LXR work by Zhao, Blackburn, and McKinley.)
The paper finds that generational collectors spend less time than their whole-heap counterparts for a given task. This is mainly due to less time spent collecting, because generational collectors avoid tracing/copying work for older objects that mostly stay in the same place in the live object graph.
The paper also notes an improvement for mutator time under generational GC, but only for the generational mark-sweep collector, which it attributes to the locality and allocation speed benefit of bump-pointer allocation in the nursery. However for copying collectors, generational GC tends to slow down the mutator, probably because of the write barrier, but in the end lower collector times still led to lower total times.
So, I expected generational collectors to always exhibit lower wall-clock times than whole-heap collectors.
test workbench
In whippet, I have a garbage collector with an abstract API that specializes at compile-time to the mutator’s object and root-set representation and to the collector’s allocator, write barrier, and other interfaces. I embed it in whiffle, a simple Scheme-to-C compiler that can run some small multi-threaded benchmarks, for example the classic Gabriel benchmarks. We can then test those benchmarks against different collectors, mutator (thread) counts, and heap sizes.
-
Hackaday ☛ C++ Is 45 Years Old. [Stroustrup] Says You Still Don’t Get It!
We were surprised when we read a post from C++ creator [Bjarne Stroustrup] that reminded us that C++ is 45 years old. His premise is that C++ is robust and flexible and by following some key precepts, you can avoid problems.
-
Amazon Inc ☛ Port .NET Framework workloads to Linux with Amazon Q Developer, Part 1: Class libraries [Ed: Better to help people rewrite in non-.NET]
-
Perl / Raku
-
Arne Sommer ☛ Find the Check with Raku - Arne Sommer
You are given an array of integers, @ints.
Write a script to re-arrange the given array in an increasing order and return the indices where it differs from the original array.
-
-
Python
-
HowTo Geek ☛ How to Get Started Creating Interactive Notebooks in Jupyter
You may think of programming as typing code into an interpreter, text editor, or IDE. Enter Jupyter, a radically different way of programming that freely mixes text, code, and graphics into interactive documents. It's powerful but also easy to use.
What Is Jupyter?
Jupyter is a "notebook interface" that lets you create "literate programs," programs that mix code with explanatory text. Jupyter is an offshoot of the IPython project, which aims to create a better interactive mode for Python. While Jupyter incorporates IPython, it's still available as a standalone program. Despite the name, Jupyter doesn't support Python only. Python is one of the many language "kernels" you can use with it.
-