nullprogram.com Open in urlscan Pro
2606:50c0:8000::153  Public Scan

Submitted URL: http://nullprogram.com/
Effective URL: https://nullprogram.com/
Submission: On June 28 via manual from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

SOLVING "TWO SUM" IN C WITH A TINY HASH TABLE

June 26, 2023
nullprogram.com/blog/2023/06/26/

> I came across a question: How does one efficiently solve Two Sum in C? There’s
> a naive quadratic time solution, but also an amortized linear time solution
> using a hash table. Without a built-in or standard library hash table, the
> latter sounds onerous. However, a mask-step-index table, a hash table
> construction suitable for many problems, requires only a few lines of code.
> This approach is useful even when a standard hash table is available, because
> by exploiting the known problem constraints, it beats typical generic hash
> table performance by 1–2 orders of magnitude (demo).

[…]
 * c
 * optimization


MY RANKING OF EVERY SHAKESPEARE PLAY

June 22, 2023
nullprogram.com/blog/2023/06/22/

> This article was discussed on Hacker News.
> 
> A few years ago I set out on a personal journey to study and watch a
> performance of each of Shakespeare’s 37 plays. I’ve reached my goal and,
> though it’s not a usual topic around here, I wanted to get my thoughts down
> while fresh. I absolutely loved some of these plays and performances, and so
> I’d like to highlight them, especially because my favorites are, with one
> exception, not “popular” plays. Per tradition, I begin with my least enjoyed
> plays and work my way up. All performances were either a recording of a live
> stage or an adaptation, so they’re also available to you if you’re interested,
> though in most cases not for free. I’ll mention notable performances when
> applicable. The availability of a great performance certainly influenced my
> play rankings.

[…]
 * rant
 * meatspace


HAND-WRITTEN WINDOWS API PROTOTYPES: FAST, FLEXIBLE, AND TEDIOUS

May 31, 2023
nullprogram.com/blog/2023/05/31/

> I love fast builds, and for years I’ve been bothered by the build penalty for
> translation units including windows.h. This header has an enormous number of
> definitions and declarations and so, for C programs, it tends to dominate the
> build time of those translation units. Most programs, especially systems
> software, only needs a tiny portion of it. For example, when compiling
> u-config with GCC, two thirds of the debug build was spent processing
> windows.h just for 4 types, 16 definitions, and 16 prototypes.

[…]
 * win32
 * c
 * cpp


MY FAVORITE C COMPILER FLAGS DURING DEVELOPMENT

April 29, 2023
nullprogram.com/blog/2023/04/29/

> This article was discussed on Hacker News and on reddit.
> 
> The major compilers have an enormous number of knobs. Most are highly
> specialized, but others are generally useful even if uncommon. For warnings,
> the venerable -Wall -Wextra is a good start, but circumstances improve by
> tweaking this warning set. This article covers high-hitting development-time
> options in GCC, Clang, and MSVC that ought to get more consideration.

[…]
 * c
 * cpp


PRACTICAL LIBC-FREE THREADING ON LINUX

March 23, 2023
nullprogram.com/blog/2023/03/23/

> Suppose you’re not using a C runtime on Linux, and instead you’re programming
> against its system call API. It’s long-term and stable after all. Memory
> management and buffered I/O are easily solved, but a lot of software benefits
> from concurrency. It would be nice to also have thread spawning capability.
> This article will demonstrate a simple, practical, and robust approach to
> spawning and managing threads using only raw system calls. It only takes about
> a dozen lines of C, including a few inline assembly instructions.

[…]
 * c
 * optimization
 * linux
 * x86


CRT-FREE IN 2023: TIPS AND TRICKS

February 15, 2023
nullprogram.com/blog/2023/02/15/

> Seven years ago I wrote about “freestanding” Windows executables. After an
> additional seven years of practical experience both writing and distributing
> such programs, half using a custom-built toolchain, it’s time to revisit these
> cabalistic incantations and otherwise scant details. I’ve tweaked my older
> article over the years as I’ve learned, but this is a full replacement and
> does not assumes you’ve read it. The “why” has been covered and the focus will
> be on the “how”. Both the GNU and MSVC toolchains will be considered.

[…]
 * c
 * win32


LET'S IMPLEMENT BUFFERED, FORMATTED OUTPUT

February 13, 2023
nullprogram.com/blog/2023/02/13/

> This article was discussed on reddit.
> 
> When not using the C standard library, how does one deal with formatted
> output? Re-implementing the entirety of printf from scratch seems like a lot
> of work, and indeed it would be. Fortunately it’s rarely necessary. With the
> right mindset, and considering your program’s actual formatting needs, it’s
> not as difficult as it might appear. Since it goes hand-in-hand with
> buffering, I’ll cover both topics at once, including sprintf-like
> capabilities, which is where we’ll start.

[…]
 * c


LET'S WRITE A SETJMP

February 12, 2023
nullprogram.com/blog/2023/02/12/

> This article was discussed on Hacker News.
> 
> 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 the use of volatile.

[…]
 * c


MY REVIEW OF THE C STANDARD LIBRARY IN PRACTICE

February 11, 2023
nullprogram.com/blog/2023/02/11/

> This article was discussed on Hacker News and critiqued on Wandering Thoughts.
> 
> 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 both interface and implementation. Fortunately, it’s easy to
> build a better, simpler wheel when you know the terrain ahead of time. In this
> article I’ll review the functions and function-like macros of the C standard
> library and discuss practical issues I’ve faced with them.

[…]
 * c


U-CONFIG: A NEW, LEAN PKG-CONFIG CLONE

January 18, 2023
nullprogram.com/blog/2023/01/18/

> This article was discussed on Hacker News.
> 
> In my common SDL2 mistakes listing, the first was about winging it instead of
> using the sdl2-config script. It’s just one of three official options for
> portably configuring SDL2, but I had dismissed the others from consideration.
> One is the pkg-config facility common to unix-like systems. However, the SDL
> maintainers recently announced SDL3, which will not have a sdl3-config. The
> concept has been deprecated in favor of the existing pkg-config option. I’d
> like to support this on w64devkit, except that it lacks pkg-config — not the
> first time this has come up. So last weekend I wrote a new pkg-config from
> scratch with first-class Windows support: u-config (“micro-config”). It will
> serve as pkg-config in w64devkit starting in the next release.

[…]


NULL PROGRAM


CHRIS WELLONS

wellons@nullprogram.com (PGP)
~skeeto/public-inbox@lists.sr.ht (view)
 * Index
 * Tags
 * Feed
 * About
 * Tools
 * Toys
 * GitHub

All information on this blog, unless otherwise noted, is hereby released into
the public domain, with no rights reserved.