matklad.github.io

订阅源链接共 18 篇文章

Consensus Board Game

Consensus Board Game Mar 19, 2026 I have an early adulthood trauma from struggling to understand consensus amidst a myriad of poor explanations. I am overcompensating for that by adding my own attempts to the fray. Today, I want to draw a series of pictures which could be helpful. You can see this post as a set of missing illustrations for Notes on Paxos , or, alternatively, you can view that post as a more formal narrative counter-part for the present one. The idea comes from my mathematics of ...

2026-03-19 00:00原文链接
未翻译

JJ LSP Follow Up

JJ LSP Follow Up Mar 5, 2026 In Majjit LSP , I described an idea of implementing Magit style UX for jj once and for all, leveraging LSP protocol. I’ve learned today that the upcoming 3.18 version of LSP has a feature to make this massively less hacky: Text Document Content Request LSP can now provide virtual documents, which aren’t actually materialized on disk. So this: can now be such a virtual document, where highlighting is provided by semantic tokens, things like “check out this commit” are...

2026-03-05 00:00原文链接
未翻译

Against Query Based Compilers

Against Query Based Compilers Feb 25, 2026 Query based compilers are all the rage these days, so it feels only appropriate to chart some treacherous shoals in those waters. A query-based compiler is a straightforward application of the idea of incremental computations to, you guessed it, compiling. A compiler is just a simple text transformation program, implemented as a lot of functions. You could visualize a run of a compiler on a particular input source code as a graph of function calls: Here...

2026-02-25 00:00原文链接
未翻译

Wrapping Code Comments

Wrapping Code Comments Feb 21, 2026 I was today years old when I realized that: Code and code comments ideally should be wrapped to a different column. For comments, the width should be relative to the start of the comment. It’s a good idea to limit line length to about 100 columns. This is a physical limit, the width at which you can still comfortably fit two editors side by side (see Size Matters ). Note an apparent contradiction: the optimal width for readable prose is usually taken to be nar...

2026-02-21 00:00原文链接
未翻译

Diagnostics Factory

Diagnostics Factory Feb 16, 2026 In Error Codes For Control Flow , I explained that Zig’s strongly-typed error codes solve the “handling” half of error management, leaving “reporting” to the users. Today, I want to describe my personal default approach to the reporting problem, that is, showing the user a useful error message. The approach is best described in the negative: avoid thinking about error payloads, and what the type of error should be. Instead, provide a set of functions for construc...

2026-02-16 00:00原文链接
未翻译

Justifying text-wrap: pretty

Justifying text-wrap: pretty Feb 14, 2026 p { text-wrap: pretty; } Something truly monumental happened in the world of software development in 2025. Safari shipped a reasonable implementation of text-wrap: pretty : https://webkit.org/blog/16547/better-typography-with-text-wrap-pretty/ . We are getting closer and closer to the cutting-edge XV-century technology. Beautiful paragraphs! We are not quite there yet, hence the present bug report. A naive way to break text into lines to form a paragraph...

2026-02-14 00:00原文链接
未翻译

Programming Aphorisms

Programming Aphorisms Feb 11, 2026 A meta programming post — looking at my thought process when coding and trying to pin down what is programming “knowledge”. Turns out, a significant fraction of that is just reducing new problems to a vocabulary of known tricks. This is a personal, descriptive post, not a prescriptive post for you. It starts with a question posted on Ziggit. The background here is that Zig is in the process of removing ambient IO capabilities. Currently, you can access program ...

2026-02-11 00:00原文链接
未翻译

CI In a Box

CI In a Box Feb 6, 2026 I wrote box , a thin wrapper around ssh for running commands on remote machines. I want a box-shaped interface for CI: const repository = "[email protected]/me/my-project" ; const commit_sha = Deno . env [ "COMMIT" ]; const runners = await Promise . all ( [ "windows-latest" , "mac-latest" , "linux-latest" ] . map ( ( os ) => $ `box create ${os} ` ) ); await Promise . all (runners. map ( async ($runner) => { await $ `box ...

2026-02-06 00:00原文链接
未翻译

make.ts

make.ts Jan 27, 2026 Up Enter Up Up Enter Up Up Up Enter Sounds familiar? This is how I historically have been running benchmarks and other experiments requiring a repeated sequence of commands — type them manually once, then rely on shell history (and maybe some terminal splits) for reproduction. These past few years I’ve arrived at a much better workflow pattern — make.ts . I was forced to adapt it once I started working with multiprocess applications, where manually entering commands is borde...

2026-01-27 00:00原文链接
未翻译

Considering Strictly Monotonic Time

Considering Strictly Monotonic Time Jan 23, 2026 Monotonic time is a frequently used, load bearing abstraction. Monotonicity is often enforced using the following code: fn now (clock: * Clock) Instant { const t_raw = os_time_monotonic(); const t = @max (t_raw, clock.guard); assert(t >= clock.guard); assert(t >= t_raw); clock.guard = t; return t; } That is, ask the OS about the current monotonic time, but don’t trust the result too much and clamp it using an in-process guard. Under normal s...

2026-01-23 00:00原文链接
未翻译

Vibecoding #2

Vibecoding #2 Jan 20, 2026 I feel like I got substantial value out of Claude today, and want to document it. I am at the tail end of AI adoption, so I don’t expect to say anything particularly useful or novel. However, I am constantly complaining about the lack of boring AI posts, so it’s only proper if I write one. Problem Statement At TigerBeetle, we are big on deterministic simulation testing . We even use it to track performance , to some degree. Still, it is crucial to verify performance nu...

2026-01-20 00:00原文链接
未翻译

Memory Safety Is ...

Memory Safety Is … Dec 30, 2025 Memory safety is one of those elusive concepts like intelligence, consciousness, or porn , that resist attempts to be put to words. Thus, I am not going to attempt to define it. Instead, I want to poke holes in definitions of others. Note that the present post is 90% sophistry in the style of Zeno — I don’t think you need a water-tight definition to have a reasonable discussion, and no definition can save an unreasonable one. But thinking about definitions focuses...

2025-12-30 00:00原文链接
未翻译

The Second Great Error Model Convergence

The Second Great Error Model Convergence Dec 29, 2025 I feel like this has been said before, more than once, but I want to take a moment to note that most modern languages converged to the error management approach described in Joe Duffy’s The Error Model , which is a generational shift from the previous consensus on exception handling. C++, JavaScript, Python, Java, C# all have roughly equivalent throw , catch , finally constructs with roughly similar runtime semantics and typing rules. Even fu...

2025-12-29 00:00原文链接
未翻译

Parsing Advances

Parsing Advances Dec 28, 2025 I find myself writing yet another toy parser, as one does during a Christmas break. It roughly follows Resilient LL Parsing Tutorial . Not because I need resilience, but mostly because I find producing a syntax tree and a collection of diagnostics a more natural fit for the problem than bailing out on the first error. One practical pitfall with the approach is infinite loops/recursion. Resilience sometimes means not consuming a token, and, if you do that in a loop o...

2025-12-28 00:00原文链接
未翻译

Static Allocation For Compilers

Static Allocation For Compilers Dec 23, 2025 TigerBeetle famously uses “static allocation” . Infamously, the use of the term is idiosyncratic: what is meant is not static arrays, as found in embedded development, but rather a weaker “no allocation after startup” form. The amount of memory TigerBeetle process uses is not hard-coded into the Elf binary. It depends on the runtime command line arguments. However, all allocation happens at startup, and there’s no deallocation. The long-lived event lo...

2025-12-23 00:00原文链接
未翻译

Newtype Index Pattern In Zig

Newtype Index Pattern In Zig Dec 23, 2025 In efficiency-minded code, it is idiomatic to use indexes rather than pointers. Indexes have several advantages: First , they save memory. Typically a 32-bit index is enough, a saving of four bytes per pointer on 64-bit architectures. I haven’t seen this measured, but my gut feeling is that this is much more impactful than it might initially seem. On modern architectures, saving memory saves time (and energy) as well, because the computing bottleneck is ...

2025-12-23 00:00原文链接
未翻译

Do Not Optimize Away

Do Not Optimize Away Dec 9, 2025 Compilers are sneaky beasts. If you time code like this: var total: u32 = 0 ; for ( 0 ..N) | i | total += i; print( "total={}" , .{total}); You will discover that LLVM is as smart as a little kid named Gauss, and replaces the summation with an equivalent formula N ( N + 1 ) 2 . What’s more, if you write something more complicated like total += i + 2*i*i - i*i*i , you’ll see that LLVM figures out a closed-form expression for that as well (a generalizatio...

2025-12-09 00:00原文链接
未翻译

Mechanical Habits

Mechanical Habits Dec 6, 2025 My schtick as a software engineer is establishing automated processes — mechanically enforced patterns of behavior. I have collected a Santa Claus bag of specific tricks I’ve learned from different people, and want to share them in turn. Caution: engineering processes can be tricky to apply in a useful way. A process is a logical cut — there’s some goal we actually want, and automation can be a shortcut to achieve it, but automation per se doesn’t explain what the o...

2025-12-06 00:00原文链接
未翻译