PATH Should Be a System Call

2025-04-25

Emacs and bash, when starting up, inefficiently search for configuration files by iterating through each directory in the PATH environment variable, checking for the target file's existence one by one. This article explores this inefficient search mechanism, using the strace tool to trace the system calls of Emacs and bash, demonstrating numerous fstatat calls. The author argues that this search should be optimized by the operating system or file system, using a database-like query to directly return matching files instead of iterative attempts. Python's implementation, while relatively more efficient, is also shown to have shortcomings. The author proposes an improved solution: provide the OS with a list of all possible filenames and directories, reducing system calls and network roundtrips.

Read more
Development system call file search

The Comma Conundrum: Why JSON's Syntax Needs a Rethink

2025-04-06

This post questions the necessity of commas in JSON. The author argues that commas in JSON are not a clever design choice, but rather increase the likelihood of syntax errors and reduce readability. The author proposes removing commas, utilizing spaces and colons to distinguish key-value pairs, and uses JSON5 as an example of improvements, although JSON5 only partially addresses the issue. The post concludes by mentioning a curious side effect of using AI systems in text generation.

Read more
Development syntax