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

1

My personal C coding style as of late 2023

This has been a ground-breaking year for my C skills, and paradigm shifts in my technique has provoked me to reconsider my habits and coding style. It’s been my largest personal style change in years, so I’ve decided to take a snapshot of its current state and my reasoning. These changes have produced significant…

2

Minimalist C Libraries

In the past year I’ve written a number of minimalist C libraries, particularly header libraries. The distinction for “minimalist” is, of course, completely arbitrary and subjective. My definition in this context isn’t about the library’s functionality being stupidly trivial or even necessarily simple. I’m talking…

3

Go Slices Are Fat Pointers

One of the frequent challenges in C is that pointers are nothing but a memory address. A callee who is passed a pointer doesn’t truly know anything other than the type of object being pointed at, which says some things about alignment and how that pointer can be used… maybe. If it’s a pointer to void ( void * ) then…

5

Let's write a setjmp

Yesterday I wrote that setjmp is handy and that it would be nice to have without linking the C standard library. It’s conceptually simple, after all. Today let’s explore some differently-portable implementation possibilities with distinct trade-offs. At the very least it should illuminate why setjmp sometimes requires…

6

The CPython Bytecode Compiler Is Dumb

Due to sheer coincidence of several unrelated tasks converging on Python at work, I recently needed to brush up on my Python skills. So far for me, Python has been little more than a fancy extension language for BeautifulSoup , though I also used it to participate in the recent tradition of writing one’s own static…

8

My review of the C standard library in practice

In general, when working in C I avoid the standard library, libc, as much as possible. If possible I won’t even link it. For people not used to working and thinking this way, the typical response is confusion. Isn’t that like re-inventing the wheel? For me, libc is a wheel barely worth using — too many deficiencies in…

10

UTF-8 String Indexing Strategies

When designing or, in some cases, implementing a programming language with built-in support for Unicode strings, an important decision must be made about how to represent or encode those strings in memory. Not all representations are equal, and there are trade-offs between different choices.

12

strcpy: A niche function you don't need

The C strcpy function is a common sight in typical C programs. It’s also a source of buffer overflow defects, so linters and code reviewers commonly recommend alternatives such as strncpy (difficult to use correctly; mismatched semantics), strlcpy (non-standard, flawed ), or C11’s optional strcpy_s ( no correct or…

13

Render Multimedia in Pure C

In a previous article I demonstrated video filtering with C and a unix pipeline . Thanks to the ubiquitous support for the ridiculously simple Netpbm formats — specifically the “Portable PixMap” ( .ppm , P6 ) binary format — it’s trivial to parse and produce image data in any language without image libraries. Video…

14

Emacs Bytecode Internals (2014)

Byte-code compilation is an underdocumented — and in the case of the recent lexical binding updates, undocumented — part of Emacs. Most users know that Elisp is usually compiled into a byte-code saved to .elc files, and that byte-code loads and runs faster than uncompiled Elisp. That’s all users really need to know…

15

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…

16

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…

17

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…