Diomidis Spinellis
spinellis.gr · Personal blog · on HN since 2008
Diomidis Spinellis, a software engineering professor and author of Code Reading, writes on Unix history, C, and tooling.
What HN saysHN links it for the C preprocessing algorithm write-up, which a compiler writer says is needed, and for Unix history charts.
100HN people shared it
34linked it in comments
126stories submitted
3.1Kstory points
4 months agolast shared
2008people per year2026
Most-shared posts
- 1Codereading9 people · first shared 2008
- 2The Birth of Standard Error5 people · 116 points · first shared 2013 · 20 comments on HN
- 3Why I Choose Email over Chat Messaging5 people · 13 points · first shared 2025 · 1 comments on HN
- 4Scatter gather shell5 people · 8 points · first shared 2016 · discussion on HN
- 5Dave Proser's C Preprocessing Algorithm (2008) [pdf]5 people · 2 points · first shared 2019 · discussion on HN
- 6Dave Prosser's C Preprocessing Algorithm (2006)4 people · 124 points · first shared 2017 · 6 comments on HN
- 7How to Create a Self-Referential Tweet4 people · 58 points · first shared 2009 · 25 comments on HN
- 8Raspberry Pi Zero vs. Elliott 4053 people · 204 points · first shared 2015 · 98 comments on HN
- 9The Origins of Malloc3 people · 56 points · first shared 2017 · 7 comments on HN
- 10What can software developers learn from the Soviet Moon Landing Program?3 people · 7 points · first shared 2020 · discussion on HN
- 11How I fixed git-grep macOS UTF-8 support3 people · 6 points · first shared 2022 · 1 comments on HN
- 12How I slashed a SQL query's runtime with two Unix commands2 people · 253 points · first shared 2018 · 83 comments on HN
- 13How to monitor MySQL / MariaDB query progress2 people · 101 points · first shared 2019 · 15 comments on HN
- 14The Birth of Standard Error (2013)2 people · 81 points · first shared 2015 · 12 comments on HN
- 15Reviving the 1973 Unix text to voice translator2 people · 59 points · first shared 2021 · 19 comments on HN
What HN people wrote when they linked it
degurechaff · 2026-04-21
c-testsuite is amazing. i use it to test my compiler, but even after passing the test. my compiler still choke on some real world project. also the tests lack many of arcane preprocessor rules. so you still need to read https://www.spinellis.gr/blog/20060626/ in order to understand hideset and its macro expansion algorithm.
nerpderp82 · 2024-04-17
I'd love to see textual preprocessors kinda banned. Or at least done upstream and outside of the language. You can't both be <the language> and also have a textual preprocessor defined internally. It doesn't work.
I really like what Zig and C++ are doing with `const`.
https://ikrima.dev/dev-notes/zig/zig-metaprogramming/
Have you looked at Spinal?
https://github.com/SpinalHDL/SpinalHDL
https://spinalhdl.github.io/SpinalDoc-RTD/master/index.html
edit, I see in your post history that your first submission was on Prosser's macro expansion. https://www.spinellis.gr/blog/20060626/cpp.algo.pdf :)
fanf2 · 2023-10-22
I love this comparison of 60 years of progress
https://www.spinellis.gr/blog/20151129/
guiraldelli · 2022-10-26
What a great surprise (but not shocking) to see it's a work of the author of "Code Reading: The Open Source Perspective" [1].
[1]: https://www.spinellis.gr/codereading/
peter_d_sherman · 2021-06-27
The real gem of this article, the following chart:
https://www.spinellis.gr/blog/20210618/unix-architecture-timeline.png
chubot · 2021-01-28
Yes being able to store the FDs for pipes in variables is something that would make it more explicit and flexible. (It could also introduce deadlocks though)
Also, dgsh is along these lines: https://www.spinellis.gr/sw/dgsh/#compress-compare
It appears to use Unix domain sockets, not pipes.
I think I might want to use the Ruby-like blocks for syntax, something like
grep FOO *.py | wc -l | sort -n
pipeline {
pipe :p1 # variables that are pipes
pipe :p2
# this syntax isn't great but shows the idea
grep FOO *.py > &p1
< &p1 wc -l > &p2
< &p2 sort -n
}
-----
Although I think richer pipelines make sense, structured data will probably come first:
https://github.com/oilshell/oil/wiki/Structured-Data-in-Oil
neves · 2020-02-27
BTW, Spinellis MOOC about unix tools must be great: https://www.edx.org/course/unix-tools-data-software-and-production-eng…
I'm really a fan of Spinellis, his books are excellent: https://www.spinellis.gr/pubs/index.html#book
Effective Debugging book is a must read for any software developer. The Elements of Computing Style is useful for any knowledge worker. Code Reading is probably the only important book in the subject.
The only problem with his books is that they are rather expensive, specially for developers who doesn't earn in dollars :-(
wallflower · 2010-02-16
Great example. About a clever technique. And implementing it in the author's own code.
Check out Dr. Spinellis' Code Reading:
"Code reading requires its own set of skills, and the ability to determine which technique to use when is crucial. In this indispensable book, Diomidis Spinellis uses more than 600 real-world examples to show you how to identify good (and bad) code: how to read it, what to look for, and how to use this knowledge to improve your own code.
Fact: If you make a habit of reading good code, you will write better code yourself."
http://www.spinellis.gr/codereading/
SwellJoe · 2008-08-11
Yes, though I don't think you can say anything really objective about the "quality" based on the data available. I found some of the statistics in the case of Windows source indicative of lower readability and maintainability...defined global funcs and structs counts are higher than the Open Source systems (FreeBSD and Linux) and file length is significantly longer, even though Linux is a significantly larger codebase (the largest of all of the systems analyzed). But, of course, that's just numbers...roughly meaningless without context. And, obviously, Microsoft manages to keep shipping code that mostly works, and they hire some of the best developers in the world.
Here's the paper:
http://www.spinellis.gr/pubs/conf/2008-ICSE-4kernel/html/Spi08b.pdf
And some additional commentary:
http://www.spinellis.gr/sw/4kernel/
Anyway, while I've never seen the Windows source code, I have looked at FreeBSD, Linux and Solaris, and all are pretty good. I think FreeBSD may be the cleanest (partly because it tries to be fewer things to fewer people than Linux), but probably not technically the most interesting. And, of course, I've only taken a few quick trips through FreeBSD and Solaris, and I've actually written driver code for Linux. Doing real work in a codebase always makes the warts more apparent.
chirsz · 2025-11-06
The behavior of C macros is actually described by a piece of pseudocode from Dave Prosser and it is not in the standard:
* https://www.spinellis.gr/blog/20060626/
* https://www.spinellis.gr/pubs/jrnl/2006-DDJ-Finessing/html/Spi06j.htm
* https://gcc.gnu.org/legacy-ml/gcc-prs/2001-q1/msg00495.html
riffraff · 2025-08-24
I am not qualified enough to answer, but some ~15 years ago I enjoyed going through the book Code Reading[0], which is about this exact topic.
I think there was another one with a similar name but I can't think of it's name.
0: https://www.spinellis.gr/codereading/, check the TOC https://www.spinellis.gr/codereading/toc.html
cratermoon · 2025-04-10
See also https://www.spinellis.gr/blog/20250408/
"students must learn to avoid using unverified GenAI output. ... misuse of AI may also constitute academic fraud and violate their university’s code of conduct."
zvr · 2022-01-04
More than a decade ago, Diomidis Spinellis created an implementation running on the OLPC, written in Squeak:
https://www.spinellis.gr/sw/ameso/
greenyoda · 2021-06-12
I still remember using troff to create typeset output on a C/A/T phototypesetter hooked up to a PDP/11 running Version 7 Unix in the early 1980s. This article has a description of how that phototypesetter worked: https://www.spinellis.gr/blog/20131211/index.html
h0l0cube · 2021-01-13
There's nothing particularly wrong about it. Twitter does something like this with a bit of timing thrown in the mix, which is why some smart-asses have made self-referencing tweets:
https://www.spinellis.gr/blog/20090805/
I believe they also for a long time had a public API^.. and I'm pretty sure they soft-delete posts (bonus that they could revive the tweet down the track if it was a 'mistake'). I don't think the Twitter team are amateurs though.
Having monotonically increasing IDs for non-distributed systems removes the possibility of duplicate IDs. In distributed systems ID conflicts are unavoidable, and you might have less conflicts if you generate random IDs, as well as it becomes difficult for an attacker to guess IDs.
^ likely it would have been rate-limited, which isn't a problem if you've got a large pool of users you can authenticate with
MH15 · 2020-11-30
Congratulations! I tried a similar approach based on the original attempt at this challenge (https://www.spinellis.gr/blog/20090805/), but gave up after running it for a few hours.
Very cool that you were able to achieve this. I'd thought it was impossible while using the original method given how many more tweets there are now then in 2009.
DSpinellis · 2020-02-25
The proposed example problem that would be difficult to solve on the Unix command line can be written as a pipeline of just nine commands. See https://www.spinellis.gr/blog/20200225/
tpaschalis · 2019-10-11
I'm dropping a link [1] for the same post, but on the author's actual webpage; this mirror seems to have stopped updating circa 2016.
He's got some pretty neat stuff in there!
[1] https://www.spinellis.gr/blog/20131211/
userbinator · 2019-09-14
It has a preprocessor. You'll start to see it at around 20% of the way through cparser.py .
I don't know how standards-compliant it is, because I just quickly skimmed over the code, but fortunately the correct algorithm has been documented:
https://www.spinellis.gr/blog/20060626/cpp.algo.pdf
rui314 · 2019-09-06
https://www.spinellis.gr/blog/20060626/cpp.algo.pdf was actually very useful. With that doc, I could implement a preprocessor without thinking too much about how it should work in details. In that sense, even after I implemented a C preprocessor, I don't feel I fully understand how it works.
WalterBright · 2019-09-05
> I've almost finished implementing C preprocessor in just one day. It's actually a port from my previous attempt to write a compiler.
The preprocessor is fiendishly tricky to write. I wondered how he did it in such a short time :-) I had to scrap mine and reimplement it 3 times.
I wish I had had https://www.spinellis.gr/blog/20060626/cpp.algo.pdf to work from.
Carioca · 2019-07-30
Here's a comparison between a RPi Zero and a 1957 Elliott 405 (from the UK): https://www.spinellis.gr/blog/20151129/
On a simple clock comparison, it was about a million times slower than a Raspberry Pi Zero. Computing has come a LONG way
lepht · 2019-07-16
There's a decent write-up of how to do this here: https://www.spinellis.gr/blog/20090805/
As you said, it largely relies on reverse engineering and bruteforcing Twitter's ID generation.
hawski · 2017-09-17
It seems that it's not entirely the same semantics: https://www.spinellis.gr/blog/20170914/ ( https://news.ycombinator.com/item?id=15246690 )
unexistance · 2017-05-10
one of his software seems interesting, outwit[0]. Windows data manipulation via command line to be used with UnxUtils[1]
p/s: Yes I know there's PowerShell / WMIC
[0] https://www.spinellis.gr/sw/outwit/
[1] http://unxutils.sourceforge.net/
bch · 2017-02-12
For example, NetBSD, which also had a book[0] written about it.
[0] http://www.spinellis.gr/codereading/
read · 2014-11-30
Check out a talk on the mechanism if you want to know more.
https://www.usenix.org/conference/usenix-09/antikythera-mechanism-hack…
There's also a simulation (with videos) of the mechanism in Squeak EToys
http://spinellis.gr/sw/ameso/
ispolin · 2012-12-09
Using my complete lack of statistical knowledge, I multiplied the wrong output rate % by the total lines of code in the examples from original paper here http://www.spinellis.gr/pubs/conf/2012-PLATEAU-Fuzzer/pub/html/fuzzer.… to get a very bad approximation of fat fingering adjusted for program length. You'd expect more typos in a longer program; the original experiment always introduced 1 typo per run regardless of program length.
You guys enjoy while I prepare for the lynch mob of Statisticians :-)
Lang Err % LOC LOC adjusted Err %
Ruby 0.17 159 27.03
Python 0.15 161 24.15
Perl 0.22 156 34.32
PHP 0.36 224 80.64
JS 0.18 102 18.36
Java 0.1 331 33.1
Haskell 0.15 114 17.1
C# 0.095 389 36.955
C++ 0.08 461 36.88
C 0.1 458 45.8
mreid · 2012-09-17
Yes, that's more or less how it was done. The explanation is here: http://www.spinellis.gr/blog/20090805/index.html
bediger4000 · 2012-04-02
Windows is only a little higher-polling than "BSD". Why is that? If you look at Diomedis Spinellis' "Organizational Adoption of Open Source Software" (http://www.spinellis.gr/pubs/jrnl/2012-JSS-OSS-Industry-Use/html/SG11.… you'd expect to see Windows in the lead. as Hacker News seems like one of those places where "highly-productive employees and in rapidly growing and volatile organizations" are active.