Blogs / Personal blogs

Chris Wellons

nullprogram.com

Buffered output typically comes in two flavors: fully buffered and line buffered. If output goes to a terminal then the implementation automatically selects line buffering, flushing its buffer when a line is completed so that it reaches the user immediately. Otherwise it fully buffers, holding output until the buffer…

Popular posts
74
Total points
14,949
HN comments
7,192
Rank
#45 personal

Visit nullprogram.com → RSS feedOn Hacker News Dec 2014 – Oct 2026

Software Engineering 64Systems & Performance 21Programming Languages 17Tools & Productivity 15Math & Algorithms 8Security & Privacy 7

62

When the Compiler Bites

So far this year I’ve been bitten three times by compiler edge cases in GCC and Clang, each time catching me totally by surprise. Two were caused by historical artifacts, where an ambiguous specification lead to diverging implementations. The third was a compiler optimization being far more clever than I expected…

63

A Basic Just-In-Time Compiler (2015)

Monday’s /r/dailyprogrammer challenge was to write a program to read a recurrence relation definition and, through interpretation, iterate it to some number of terms. It’s given an initial term ( u(0) ) and a sequence of operations, f , to apply to the previous term ( u(n + 1) = f(u(n)) ) to compute the next term…

64

The Value of Undefined Behavior

In several places, the C and C++ language specifications use a curious, and fairly controversial, phrase: undefined behavior . For certain program constructs, the specification prescribes no specific behavior, instead allowing anything to happen . Such constructs are considered erroneous, and so the result depends on…

66

Small, Freestanding Windows Executables

Recently I’ve been experimenting with freestanding C programs on Windows. Freestanding refers to programs that don’t link, either statically or dynamically, against a standard library (i.e. libc). This is typical for operating systems and similar, bare metal situations . Normally a C compiler can make assumptions…

67

Zero-allocation Trie Traversal

As part of a demonstration in an upcoming article , I wrote a simple trie implementation. A trie is a search tree where the keys are a sequence of symbols (i.e. strings). Strings with a common prefix share an initial path down the trie, and the keys themselves are stored implicitly by the structure of the trie. It’s…

68

A custom virtual machine for the Stars 4X game

Stars! is a 1995 4X game (explore, expand, exploit, exterminate) for 16-bit Windows 3.1 that I first played ~28 years ago. While Windows is famously backwards compatible, it’s notoriously difficult to play Stars! today. Windows x64 cannot run 16-bit applications, and playing requires either retro hardware or emulation…

69

Appending to a file from multiple processes

Suppose you have multiple processes appending output to the same file without explicit synchronization. These processes might be working in parallel on different parts of the same problem, or these might be threads blocked individually reading different external inputs. There are two concerns that come into play:

70

Emacs Lisp Readable Closures (2013)

I’ve stated before that one of the unique features of Emacs Lisp is that its closures are readable . Closures can be serialized by the printer and read back in with the reader. I am unaware of any other programming language that has this feature. In fact it’s essential for Elisp byte-code compilation because…

73

Closures as Win32 Window Procedures

Back in 2017 I wrote about a technique for creating closures in C using JIT-compiled wrapper. It’s neat, though rarely necessary in real programs, so I don’t think about it often. I applied it to qsort , which sadly accepts no context pointer. More practical would be working around insufficient custom allocator…

74

Keyringless GnuPG

My favorite music player is Audacious . It follows the Winamp Classic tradition of not trying to manage my music library. Instead it waits patiently for me to throw files and directories at it. These selections will be informally grouped into transient, disposable playlists of whatever I fancy that day.