Ask HN: What are the "best" codebases that you've encountered? - <AUTHOR> I am rather fond of the concepts described in "Clean Code" by Robert Martin but it seems that in real life, a really high-quality codebase is hard to come by.
While I am asking myself this question, the only one that popups to my mind would be Laravel: https://github.com/laravel/laravel (PHP)
One could think that a codebase as popular as React (https://github.com/facebook/react) would be a perfect example of "clean code" but with a glance, I personally don't find it very expressive.
This may all be very subjective but I would love to see examples of codebases that member of this community have enjoyed working with <comment><USER2> Perhaps I'm jaded, but I notice that all the examples given here are developer tools or otherwise things with well scoped functional inputs and outputs (e.g. ffmpeg).

Anyone have an example of a consumer application that has a good codebase? Chromium, GitLab, OpenOffice, etc? I feel like such applications inherently have more spaghetti because the human problems they're aiming to solve are less concretly scoped. Even something as simple as "Take the data from this form and send it to the project manager" ends up being insanely complex and nitpicky. In what format should the data be sent? How do we know who the project manager is? Via what format should the data be sent? How should we notify the project manager? When should we send the report? Some of these decisions are inherently inelegant, so I feel like you get inelegant code.

<comment><USER3> NetHack's source code is absolutely beautiful. It's probably the most well- kept, well-designed, well-structured and well-implemented K&R C program in history. Although they are switching to ANSI syntax soon. It's even more amazing because NetHack is (1) a video game, where generally speaking code quality is sacrificed for efficiency, and (2) it has been developed by a constantly changing team of volunteers over the course of over thirty years, and there still isn't any spaghetti.

<comment><USER4> Nethack suffers somewhat because the era in which it was birthed required a lot of portability, so there is a ton of #ifdef-ery which can be difficult to reason about.

#ifdefs are themselves spaghetti; windows.c [0a] and files.c [0b] have tons of platform-related ifdefs (but, mercifully, not too much nesting), hacklib.c [1] has some deep-ish ifdef nesting (though, again mercifully, well commented)

Ok on re-reading some of this, I guess it was worse in my mind than it actually is. Nethack was the first large codebase I ever made any changes to and tried to understand, so maybe the relative enormity at the time made a negative impression.

Check out the source for Brogue [2] for what I consider to be pretty readable game code.

[0a] [https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/wind...](https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/windows.c) [0b] [https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/file...](https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/files.c) [1] [https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/hack...](https://github.com/NetHack/NetHack/blob/NetHack-3.6/src/hacklib.c#L865-L895) [2] [https://sites.google.com/site/broguegame/](https://sites.google.com/site/broguegame/)

</comment></comment></comment><comment><USER5> For a C codebase, Postgres[1] wins for me hands down. It's clean and suuuuuuper well commente, such that with a little context you can dive into something very complex and still get a feel for what is going on.

[1]: [https://github.com/postgres/postgres](https://github.com/postgres/postgres)

<comment><USER6> Second this; Postgres codebase is what got me out of the "good code is self documenting" nonsense. For those of us in the database space it is an incredible resource - and overall a great example of good code.

sqlite is much less complex, but similarly approachable.

In more recent examples, I think you see a lot of this same reader-centric pragmatic ethos in many Go projects. The Kubernetes codebase comes to mind as a very large tome that remains approachable. And the Go stdlib, of course.

Java generally falls on the opposite side, but there are counterexamples. A lot of Martin Thompsons code eschews Java "best practices" in favor of good code. Seeing competent people in the Java space "break the rules" helps.. though of course Java is forever hampered by having internalized illegible patterns as best practices in the first place.

It's a shame because at least the OpenJDK implementation of the standard library in Java is generally quite good, especially around the concurrency parts. Clean, easy to follow, reasonable comments. But of course that's Java written by C developers, mostly.

<comment><USER7> > Postgres codebase is what got me out of the "good code is self documenting" > nonsense.

I'm a fervent believer in "good code is self-documenting", so I was curious to be proven wrong, clicked randomly until I found code and I saw this.

        /*
         * Round off to MAX_TIMESTAMP_PRECISION decimal places.
         * Note: this is also used for rounding off intervals.
         */
        #define TS_PREC_INV 1000000.0
        #define TSROUND(j) (rint(((double) (j)) * TS_PREC_INV) / TS_PREC_INV)

Usage of acronyms is one of the worst offenders in bad code. The context makes it clear that TS means timestamp, so that's not too bad (still bad though), but I'm still not sure what INV means, luckily I presume it's the only place it's used.

If it was named TIMESTAMP_ROUND, I wouldn't need to know "Round off to MAX_TIMESTAMP_PRECISION decimal places." Now that I've copy/paste that, it seems like the comment is wrong too, it's rounded off based on TS_PREC_INV, so if I was to believe the comment, I wouldn't get the right behaviour.

I'm not saying Postgres codebase isn't good code, just that "good code is self-documenting" is still true. That code was pretty much self-documenting except for the acronyms, but considering it was all used together, it's was fine and I was able to understand what they meant.

For me, comments should only be needed when something isn't clear. Defining what isn't clear is hard to determine for sure, but that's one thing for which code review helps quite a bit.

<comment><USER6> I mostly agree with this. Though as I wrote that sentence I realized Go has somewhat softened my position on abbreviations. I think the "note" portion is useful; ultimately a test would stop you breaking that secondary use, but the comment stops you spending time in that direction in the first place. But either way, overall I think you're right this would be fine without a comment.

I'm thinking more of examples like this: [https://github.com/postgres/postgres/blob/master/src/backend...](https://github.com/postgres/postgres/blob/master/src/backend/storage/page/bufpage.c#L105)

I just picked this at random from the storage subsystem, but I think it highlights what I mean. The comments are mostly about context. The comment for the routine is about when and who calls it, so that someone that reads the routine has that in mind. The specific line I'm linking to highlights in English prose that the correctness checking on the page headers is just a minimum guard and should not be fully trusted.

Back in the day I would have argued "oh, well, but you could break that into a function called "provisional_page_header_check(..)", or something. But.. there is nothing in the compiler that checks that function names stay in sync with their implementation any more than there is for comments. Writing it as a comment lets you use regular English sentences, breaking out a function takes that away and adds no compiler protection.

It's also.. friendly, somehow, to me. Working in this codebase is like participating in an ongoing and very slow conversation, which feels very pleasant.

<comment><USER7> That comment is exactly what I mean by when needed.

That does confirm that they are making pretty amazing code. I would have much prefered to get that file instead of the other one :P.

They do have a redundant comment at someplace but it's clearly a tiny minority and they aren't losing any one time.

<comment><USER6> Yep, I think we're in agreement :)

</comment></comment></comment></comment></comment></comment><comment><USER8> Anything by burntsushi, but especially xsv and ripgrep:

xsv: [https://github.com/BurntSushi/xsv](https://github.com/BurntSushi/xsv)

ripgrep: [https://github.com/BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep)

His code typically has extensive tests, helpful comments, and logical structure. It was fun trying to imitate his style when writing a PR for xsv.

The Quake 2 engine was also pretty interesting: It was almost totally undocumented, and it had plenty of weird things going on. But I could count on the weird things being there for a _reason_ , if only I thought about it long enough.

<comment><USER9> Note: this assumes you speak Rust...

<comment><USER10> Don't all the comments assume you speak the language the codebase is written in? I mean I can't tell if a given PHP/C/Perl/other language I don't know well codebase is good or not. I guess there could be people that can somehow do that...

<comment><USER9> Yes, but other comments actually mention the language, and the original post was using web languages as an example, so I thought I'd save someone the trouble of clicking expecting and realizing it's not what they expected.

</comment></comment></comment></comment><comment><USER11> NetBSD, hands down. Beautiful, simple to understand, consistent. The documentation is also top notch -- I wrote a trivial character-device kernel driver using _only the man pages_ as a reference. And you can too.

Also -- the source code to Doom. Read it, marvel at its clarity and efficiency -- and then laugh when you realize that the recent console ports were completely rewritten in _fucking Unity_. And the Switch version chugs, despite the original running well on 486-class hardware.

<comment><USER12> Unity sucks but as a hobbyist game developer it is a godsend. The only other way I can support all the platforms I want to (Android, web, PC) is through Web APIs directly, and nobody likes more Electron.

<comment><USER11> SDL be like "am I a joke to you?"

<comment><USER13> SDL is fine for cross platform development. Personally, I have used it for some commercial games in the past, but I think it's not comparable to Unity or unreal engine. SDL is not a game engine, it provides only lower level features (audio, opengl context initialization, joystick support, etc). Even for things like in-game menus and text rasterisation you are on your own.

</comment></comment></comment></comment><comment><USER14> For canonical C code, without a doubt I would say Redis and Postgres. Redis is written and annotated in a way that even someone with a cursory knowledge of C can understand what's going on.

For Python, I really like how SQLAlchemy is written and designed.

For Rust, ripgrep stands out as a sterling example of how to write a powerful low-level utility like that.

<comment><USER15> I just opened up server.c in Redis (not familiar with Redis and never seen it before) and at first glance it seems... alright, but I'm not sure what's particularly outstanding about it, and it could definitely be better. Some of the logic seems questionable (exit() in a signal handler? [9] also what about thread safety?), and more superficially (but annoyingly) I see: names like "sdscatprintf" [1] which are a little cryptic, lack of attention to spacing (too little [2] or too much [3] or inconsistent [4] [8]), lack of braces for single-line blocks (which at least I consider bad) [5], irritatingly inconsistent line breaks [6], etc.

Overall it's still definitely on the more readable side compared to other C code I've seen, I like the thorough comments, and it's generally decent, but I'm not particularly coming away from it in awe like everyone else seems to have.

[1] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4184)

[2] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4499)

[3] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4217)

[4] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4505)

[5] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4421)

[6] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L1839)

[7] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L1783)

[8] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4384)

[9] [https://github.com/antirez/redis/blob/unstable/src/server.c#...](https://github.com/antirez/redis/blob/unstable/src/server.c#L4535)

<comment><USER16> Redis code quality could be improved significantly, but you picked the wrong file to evaluate it: the first file created, and the one that for the nature of system software will be the less "overall designed", because it is the place where we call almost everything else sequentially. Still, if I had more time, I could improve it and other parts a lot. However to see how modern Redis was coded check the following:

* hyperloglog.c

* rax.c

* acl.c (unstable branch, the Github default)

* even cluster.c

Everything you'll pick will likely be a lot better than server.c

Other things you mentioned are a matter of taste. For instance things like:

        if (foo) bar();

Is my personal taste and I enforce it everywhere I can inside the Redis code, even modifying PRs received.

The line breaks are to stay under 80 cols. And so forth. A lot of the things you mentioned about the "style" are actually intentional. The weakness of server.c is in the overall design because it is the part of Redis that evolved by "summing" stuff into it in the course of 10 years, without ever getting a refactoring for some reason (it is one of the places where you usually don't have bugs or alike).

<comment><USER9> Ah I see. I didn't realize it was old, I just picked server.c since it just sounded like it'd have a decent mix of stuff. I think the only 'taste' things I mentioned is the lack of braces and possibly the function name, which I'm happy to ignore. But the rest were just inconsistencies, regardless of which way anyone's tastes lean -- the spaces after commas are entirely inconsistent (although I would argue if you took the stance that there shouldn't be a space at all, that's bordering on just being wrong, not merely a matter of taste!), and some lines are far longer than 80 columns [1] and some are broken at really inconvenient points just to fit them into 80 columns, which gets you the worst of both worlds.

Thankfully, like you said, the other files do seem better. :) However, they _do_ have the same problems I just pointed out above: spaces are inconsistent everywhere (after commas, after 'while', after casts, etc.) and lacking in awful places (honestly, how am I supposed to read a function call with eight identifiers and zero spaces? [2]) and some lines are broken and others longer than 80 [3][4].

A couple other immediate issues I have on syntactic things (semantic analysis would take me a long time so it's hard to give me feedback on that):

\- One comment I have that some others would vehemently disagree with me on is: I would cut down on the early returns. Personally, I really hate them, for multiple reasons -- the most practical one of which is that they prevent you from inserting a single breakpoint in a debugger (or printf(), or whatever you feel like doing) and being able to see what the function returns easily. Instead, you have to hunt through the entire function and place a dozen breakpoints to make sure you didn't miss any return path. And it becomes the most confusing thing in the world when you inevitably miss one. To me that's bad enough, but some people still insist on them. But if you're going to do that, I would at least make it easier for people to debug them. On my first reading, for example, I completely missed the return on line [5] -- because it's right _after_ the if condition and visually blends in. That also makes it hard if not impossible to put a breakpoint on it, which wouldn't be an issue if it were on a separate line. (Maybe you don't do that because you don't want to forget braces, but you know my opinion on that too. :P) That makes it even more painful to debug this function.

\- I'm not a fan of the liberal macro usage. I'm not saying you should _never_ use macros -- I know that sometimes it's outright impossible not to (especially in C), and sometimes they're _the perfect_ tool (code deduplication) -- but you shouldn't be using them to use them to define constants and perform normal function calls. [6] [7] Not only is it often possible to break them because of their textual nature, and not only do they lack type information that would be extremely useful, but they also make it harder to debug, since you can't just type them into a debugger at runtime and get their values. And you can't step through them like normal code either.

Hope some of this is helpful. All of it said though, they're pretty minor things overall, and the code does seem good quality, at least as far as I can tell in in this timespan. The fact that it's in C does always leave me with this nagging feeling that there's always going to be some resource leak somewhere (especially with early returns!), which I wouldn't have in most other languages, but that's not really an indictment of the code but of the language. And I love, love, love the comments. I don't leave comments nearly that good myself, and I will almost certainly refer back to them later.

[1] [https://github.com/antirez/redis/blob/583933e2d6b4c2721554ab...](https://github.com/antirez/redis/blob/583933e2d6b4c2721554ab77c33a9c0bc7672fa6/src/server.c#L1841)

[2] [https://github.com/antirez/redis/blob/unstable/src/rax.c#L10...](https://github.com/antirez/redis/blob/unstable/src/rax.c#L1002)

[3] [https://github.com/antirez/redis/blob/unstable/src/rax.c#L50...](https://github.com/antirez/redis/blob/unstable/src/rax.c#L507)

[4] [https://github.com/antirez/redis/blob/unstable/src/rax.c#L45...](https://github.com/antirez/redis/blob/unstable/src/rax.c#L457)

[5] [https://github.com/antirez/redis/blob/unstable/src/rax.c#L13...](https://github.com/antirez/redis/blob/unstable/src/rax.c#L1391)

[6] [https://github.com/antirez/redis/blob/unstable/src/hyperlogl...](https://github.com/antirez/redis/blob/unstable/src/hyperloglog.c#L191)

[7] [https://github.com/antirez/redis/blob/unstable/src/quicklist...](https://github.com/antirez/redis/blob/unstable/src/quicklist.c#L342)

</comment></comment></comment></comment><comment><USER17> The Windows operating system.

Windows is quite an engineering achievement. We didn't prioritize readability or "clean code". All the variables used hungarian notation, so you had horrible names like lpszFileName (lpsz = long pointer to a zero terminated string) or hwndSaveButton (window handle). You also had super long if(SUCCEEDED(hr)) chains that looked like your code was spilling down a staircase. Oh yeah, and pidls (pronounced "piddles" and short for "pointer to an id list") used for file operations.

What made the code base beautiful was the extreme lengths we went to to be fast and keep 3rd party software working. WndProcs seem clunky, but they are elegant in their own way and blazingly fast. All throughout the code base you would find stuff like "If application = Corel Draw, don't actually free the memory for this window handle because Corel uses it after sending a WM_DESTROY message."

The fact that thousands of people worked on the code base was mind boggling.

<comment><USER18> I'm mega curious about this

> ...like lpszFileName (lpsz = long pointer to a zero terminated string)

I remember those.

AIUI hungarian gives you some kind of typing. The typing is done by humans using the names. The humans have to get it right; they are the typecheckers.

The first thing I'd do is offload the typechecking onto an automatic framework - the idea of letting people do a computer's job is madness. It would not have been too hard to do (relatively very cheap for a large codebase like an OS), I think, and would have allowed the hungarian prefixes to be dropped because they'd become redundant, and strengthened and speeded up typechecking. So where is the flaw in my thinking?

(aside: one of my first contract jobs was working in pascal (delphi actually). The company I worked for had coding standards cos you need standards, don't you. It was to prefix every integer with i_, every float with f_, every int array with ai_, et cetera. As pascal was strongly typed this was totally pointless).

<comment><USER19> > So where is the flaw in my thinking

The codebase has 34 years worth of code written already, 100 million LOC or more if you count Office, VS etc. The cost of typechecking is trivial but the cost of rewriting this much code to be consistent with any new convention is in the hundreds of millions of dollars. This legacy cost then of course becomes higher every year...

<comment><USER18> Oh hell. Where did I say anything about it having to be rewritten? I did not. I said "allowed the hungarian prefixes to be dropped", not required. And all I meant was "in subsequent work", of course changing existing code would be idiotic.

And this absolutely misses the vital point that typechecking can be offloaded from the human to an automated typechecker, so why wasn't it?

"The cost of typechecking is trivial" \- not if it's done by humans.

</comment></comment></comment></comment><comment><USER20> I really liked the Go standard library (or at least from around 1.4-ish, it might have gotten more complicated now).

I liked that it was actually possible to read it and understand what was going on.

In a similar vein, P. J. Plauger's version of the _The Standard C Library_ is nice because even if it might not be especially optimized(?), you can actually read the code and understand the concepts that the standard library is based on.

 _Software Tools_ by Kernighan and Plauger would also be great except that you have to translate from the RatFor dialect of Fortran or Pascal to use the code examples.

Even so, I used its implementation of Ed, to create a partial clone in PowerShell that let me do remote file editing on Windows via Powershell when that was the only access that was available.

So even over 4 decades and various operating systems removed, there are still concepts in there that are useful.

 _Jonesforth_ is also a great and mind blowing code base although I'm not sure where the canonical repository is currently.

<comment><USER21> I supposed it's this one, but it's public domain and over the years has been forked many many times (far more than I ever expected).

[http://git.annexia.org/?p=jonesforth.git;a=summary](http://git.annexia.org/?p=jonesforth.git;a=summary)

</comment></comment><comment><USER22> _it seems that in real life, a really high-quality codebase is hard to come by_

I think a common misconception amongst mid-experienced programmers is that they confuse look with quality. Reading clean written code gives you a feeling of control and also the feeling that someone must have thought about that program. It's reassuring. You have in front of you a code that gives you trust.

When in fact, that code can be complete garbage.

The look of the code doesn't matter, what matters is the program. In the abstract meaning of the term. You don't judge a code by reading it, but by running it in your head. Granted you have to understand it in order to do that. Once you understand the code, you run it in your head and that's when quality enter the scene because running it in your head is what you do all day when you code. Some says that you spend most of your time reading code. That's simply not true, the effort is definitely not in reading but in running the code in your head. Basically what I'm describing is a 2 by 2 matrix where there is one column for look bad, one for look good, one row for runs badly in the head and one for run smoothly in the head. Granted, the best may be when both the code looks right and runs right, but don't be mistaken, the real important and difficult part is whether or not it runs well in the head.

A poor quality program may look good, but don't run well in the head. It's too complex or too confusing (in terms of logic, not in terms of presentation) or convoluted or simply wrong in terms of what it's supposed to do. On the other hand good quality code is code that surprises you by the way it runs. It's beautiful in terms of simplicity, it delivers a lot, it's small so that it fits well in the coder's head. And it may look like garbage which is not so important.

You may wonder how to know very quickly the quality of a code base. Run part of it in your head. Contemplate the machinery. Try not to think to much about the language and how it's constructed in this language, try instead to contemplate it in an abstract manner. Be critic, and _critic your critics_.

<comment><USER23> > by running it in your head.

I have encountered far too many people who don't even realize this is a thing. I figure they must be doing it in some limited form and just aren't recognizing it as a skill that can be trained up, otherwise I'm not sure how they can do any development, but...

<comment><USER24> Running non-trivial code in your head is far too tedious for daily use. I'd much rather add debug checks for invariants when I want to confirm that the code works the way I expect it to.

<comment><USER25> The human brain has, what, about 7 registers in medium term memory?

<comment><USER23> 5±3, if I remember right, but of indeterminate size. You can expand it to a couple dozen by moving up and down abstraction levels.

An exercise: I have 36 letters for you to memorize, in order and without mistakes: "The quick brown fox jumped over the lazy dog"

The sentence as a whole only uses 1 of those memory slots. As necessary, you can jump down one abstraction level to get 9 words, or again on a word-by-word basis to get the full 36 letters.

Code is the same. For example, use multiple slots to understand loop conditions, then file it away in a single slot as the whole conceptual loop. Use multiple slots to understand the loop body, in the context of one element; file it away as well. Combine them into a one-slot conceptual understanding of the whole loop. So on and so forth.

As you work with the conceptual models, you'll also end up with them in long- term memory and not have to do this reconstruction each time.

This pattern can continue indefinitely, with conceptual models of whole packages and systems. Most will do it unconsciously at that level as they become familiar with a codebase, but it works at every level, and is the basis of "running code in your head".

</comment></comment></comment></comment></comment><comment><USER26> I wish there was a way to read the codebase where there is a tag that tells you what the folder does.

In github, rather than see what has changed, it would be interesting if there was a comment that told you what the folder contained.

edit: Relevant here because the best codebase for me is one where I can understand the folder structure, but that is a sort of 0th order effect that should be equalized with some tool.

<comment><USER27> In Go, a folder is a package and as soon as you write a comment before the `package foo` declaration, it's package documentation. And thus GoDoc automatically generates a nice webpage out of it.

See for example this package comment: [https://github.com/golang/go/blob/master/src/net/http/doc.go...](https://github.com/golang/go/blob/master/src/net/http/doc.go#L6-L104)

Turns into this documentation (the beginning only): [https://godoc.org/net/http](https://godoc.org/net/http)

Out of the box.

<comment><USER28> What's the point of all these empty comments throughout the code?

        // ...

<comment><USER29> It's likely the Go libter requiring every public method / variable to be documented.

<comment><USER30> Yup. I saw a lot of codebases with things like:

// EnqueueEvent ...

func (q *Queue)EnqueueEvent(event Event)

</comment></comment></comment></comment></comment><comment><USER31> Unfortunately, I've found that almost all developers are incapable of objectively judging the quality of code until they actually have to start working with it and then after a few months they can start to appreciate or despise the code.

It takes a lot of investment from a developer before they can appreciate the beauty of the code... To make matters more confusing, a lot of developers tend to become extremely attached to even horrible code if they spend enough time working with it; it must be some kind of Stockholm syndrome.

I think the problem is partly caused by a lack of diversity in experience; if a developer hasn't worked on enough different kinds of companies and projects, their understanding of coding is limited to a very narrow spectrum. They cannot judge if code is good or bad because they don't have clear values or philosophy to draw from to make such judgements. If you can't even separate what is important from what is not important, then you are not qualified to judge code quality.

If you think that the quality of a project is determined mostly by the use of static vs dynamic types, the kind of programming paradigm (e.g. FP vs OOP), the amount of unit test coverage and code linting, then you are not qualified to judge code quality.

I think that the best metric for code/project quality is simply how much time and effort it takes for a newcomer to be able to start making quality contributions to the project. This metric also tends to correlate with robustness/reliability of the code and also test quality (e.g. the tests make sense and they help newcomers to quickly adapt to the project).

As developers, we are familiar with very few projects. If a developer says that they like React or VueJS or Angular, etc... they usually have such limited view of the whole ecosystem that their opinion is essentially worthless; and that's why no one ever seems to agree about anything. We are all constantly dumbing down everything to the lowest common denominator and regurgitating hype. Hype defies all reason.

It's the same with developers; most developers (especially junior and mid- level) are incapable of telling who is actually a good developer until they've worked with them for about 6 months to a year.

If you are not a good developer, you will not be able to accurately judge/rank someone who is better than you at coding until several months or years of working with them. Sometimes it can take several years after you've left the company to fully realize just how good they were.

<comment><USER30> > Unfortunately, I've found that almost all developers are incapable of > objectively judging the quality of code until they actually have to start > working with it and then after a few months they can start to appreciate or > despise the code.

While I agree when evaluating a codebase by the broad architecture (which I often judge by cohesion and coupling), I feel evaluating details first requires learning to read code as well as prose. Then "bad" or "ugly" code is code that reads arcanely like olde English.

</comment></comment><comment><USER32> Django! And django rest framework. To me, both codebases are so readable and so well put together that even if their documentation was bad (which it isn't), you could fully grasp their APIs and how to use their libraries by just reading through some of the code.

<comment><USER33> Also agree! I learned a lot about how Python works from digging through the inner guts of the Django ORM. I've been pleasantly surprised, getting back into Django after about 5 years, that the codebase is just as comprehensible as I remember it to be, and the documentation equally as comprehensive.

</comment></comment><comment><USER34> The Codemirror codebase [0] is simply written and richly commented, and using Codemirror itself in a project is a pleasure.

Tellingly, Marijn Haverbeke, Codemirror's creator, is also the author of the excellent 'Eloquent Javascript' [1].

[0] [https://github.com/codemirror/codemirror](https://github.com/codemirror/codemirror)

[1] [http://eloquentjavascript.net/](http://eloquentjavascript.net/)

<comment><USER35> It's unfortunate that the author doesn't appear to understand the value of a strict Content-Security-Policy.

<comment><USER35> For context, see this GitHub issue: [https://github.com/codemirror/CodeMirror/issues/4937](https://github.com/codemirror/CodeMirror/issues/4937)

Author is unwilling to change a handful lines of code to make the package compatible with a strict style-src.

Why does this matter? You can exfiltrate data such as CSRF tokens using inline styles from a HTML injection vulnerability: [https://medium.com/bugbountywriteup/exfiltration-via-css- inj...](https://medium.com/bugbountywriteup/exfiltration-via-css- injection-4e999f63097d)

</comment></comment></comment><comment><USER36> See also

[1] Interesting Codebases: [https://news.ycombinator.com/item?id=15371597](https://news.ycombinator.com/item?id=15371597)

[2] Show HN: Awesome-code-reading - A curated list of high-quality codebases to read [https://news.ycombinator.com/item?id=18293159](https://news.ycombinator.com/item?id=18293159)

<comment><AUTHOR> Thanks for the links!

</comment></comment><comment><USER37> I think the best codebases are the ones you immediately think "Oh, that's easy. I can reimplement that in a couple of hours.". When it's not. It's never easy.

</comment><comment><USER38> I've been enjoying reading Spectrum's codebase[0]. It's very simple, with little documentation you can understand pretty much what is going on and in the architecture level, is as simple as it needs. The first time I tried to open a PR, I was up and running my feature in a few minutes.

Small summary of the features I liked:

\- Simple documentation

\- Intuitive structure

\- Lots of JS best practices, but still simple

\- Event-driven architecture

\- A simple API gateway that will just fire events to workers

\- Properly divided workers (kind of microservices but with lots of shared code)

\- Monorepo

It recently been bought by GitHub(1) and was discussed here(2).

The author has talked in his blog about some decisions he took wrong. Super interesting post(2).

0\. [https://github.com/withspectrum/spectrum](https://github.com/withspectrum/spectrum)

1.[https://spectrum.chat/spectrum/general/spectrum-is- joining-g...](https://spectrum.chat/spectrum/general/spectrum-is-joining- github~1d3eb8ee-4c99-46c0-8daf-ca35a96be6ce)

2\. [https://news.ycombinator.com/item?id=18570598](https://news.ycombinator.com/item?id=18570598)

3\. [https://mxstbr.com/thoughts/tech-choice-regrets-at- spectrum/](https://mxstbr.com/thoughts/tech-choice-regrets-at-spectrum/)

</comment><comment><USER39> Anything by John Carmack. (DOOM's open source release, for example)

<comment><USER40> I'd second that. Some years ago I had a look at the quake 3 bots code, which I think were also written by John Carmack. The code was amazingly intuitive.

<comment><USER41> The Q3 bot AI was written by this man [https://doomwiki.org/wiki/J.M.P_van_Waveren_(MrElusive)](https://doomwiki.org/wiki/J.M.P_van_Waveren_\(MrElusive\))

Carmack said that he was "the best developer I ever worked with"

</comment></comment></comment><comment><USER42> Tornado, a python web framework. I doubt it is still popular today. But reading the source code is a pleasure. Its naming conveys clearly; its encapsulation allows extensibility; its documentation teaches me how to write an industry-level library.

[https://github.com/tornadoweb/tornado/blob/master/tornado/io...](https://github.com/tornadoweb/tornado/blob/master/tornado/ioloop.py)

<comment><USER43> I used Tornado to build the the WebSocket back end for this page: [https://www.slickdns.com/live/](https://www.slickdns.com/live/). It's less than 100 lines of code and very clean.

For most web apps my default choice is Django, but for special purpose web servers Tornado or Flask are still useful.

</comment></comment><comment><USER44> I've always been impressed by the quality of Three.js - [https://github.com/mrdoob/three.js/](https://github.com/mrdoob/three.js/)

</comment><comment><USER45> Peter Norvig's sudoku solver (Python) is excellent. Solves every possible variant of sudoku.

[https://norvig.com/sudoku.html](https://norvig.com/sudoku.html)

<comment><USER46> oh yeah, this one is so good. And his spell checker is really understandable, readable too [https://norvig.com/spell-correct.html](https://norvig.com/spell- correct.html)

</comment></comment><comment><USER47> For something a little different, the Clojure codebase – particularly `clojure.core` – is extraordinary in its elegance and simplicity.

</comment><comment><USER48> Whenever I have to dig into Spring sources, they always look awesome. This is the best Java project I've ever seen. Clean concise code, versatile architecture using proper design patterns, lots of documentation.

</comment><comment><USER49> Plan 9 codebase has been the best that I have encountered.

[http://9p.io/sources/plan9/sys/src/](http://9p.io/sources/plan9/sys/src/)

</comment><comment><USER50> Kubernetes for Golang. This has been brought up as an example of fine documentation: [https://github.com/kubernetes/kubernetes/blob/ec2e767e593953...](https://github.com/kubernetes/kubernetes/blob/ec2e767e59395376fa191d7c56a74f53936b7653/pkg/controller/volume/persistentvolume/pv_controller.go#L54)

Requests for Python [https://github.com/psf/requests](https://github.com/psf/requests)

<comment><USER51> K8S was transpiled from Java, and it shows. Much of the code isn't idiomatic Go at all. So I wouldn't cite K8S as a shining example.

Comments like the one cited are fantastic, but we're interested in examplars of good (i.e., elegant and readable) code, not ancillary matter.

<comment><USER36> Very interesting! I never knew that! Did a bit of googling to verify it. [1]

[1] [https://fosdem.org/2019/schedule/event/kubernetesclusterfuck...](https://fosdem.org/2019/schedule/event/kubernetesclusterfuck/)

</comment></comment></comment><comment><USER52> The Stockfish chess engine [1] is very nice, especially so since chess engines tend to be very kludgy.

[1] [https://github.com/official- stockfish/Stockfish](https://github.com/official-stockfish/Stockfish)

</comment><comment><USER53> Weirdly I find the v8 source and jQuery (at least several years ago) to be the best. They're examples of real-world, multi-distributed-collaborator, mature projects. Harder, I think, than writing "clean" code is maintaining a large code base's organization, distribution, etc and these are really good examples of that.

(d3 and three.js are also very interesting to read, but they're not quite in the same class as the former.)

</comment><comment><USER54> The compiler for the B language, by Arthur Withney [http://kparc.com/b/](http://kparc.com/b/)

<comment><USER55> I'd add to this family the J system, ver. 7 - [https://github.com/jsoftware/jsource](https://github.com/jsoftware/jsource) .

A good example of creating a DSL and then efficiently using that. "Never had a memory leak from day 1 (Roger Hui)" (written in C).

</comment></comment><comment><USER56> My personal favorite is Sequel. [https://github.com/jeremyevans/sequel](https://github.com/jeremyevans/sequel)

Beautiful codebase, rock solid, and way better option than ActiveRecord IMHO

<comment><USER57> Not only it is a high quality codebase, support from Jeremy is a top notch, there are no outstanding issues, everything gets fixed promptly. It's been a great joy using both sequel and roda all these years

</comment></comment><comment><USER58> In 2010, the nginx source was quite startling. It's very readable C, but also somewhat difficult in that it did not mechanize a lot of bookkeeping. If it wanted to construct a string of 8 components, there were 8 components in getting the length right, then 8 adds to the string. This was toil, and error- prone. But it was always done with such precision, and so consistent, that it was still quite beautiful.

</comment><comment><USER59> The Lua source code is very easy to read, especially for an interpreter. It's a hand written recursive descent parser and incredibly tiny. [http://www.lua.org](http://www.lua.org)

</comment><comment><USER60> It's a toy, but I remember being very impressed with the implementation of Turing Drawings: [http://maximecb.github.io/Turing- Drawings/](http://maximecb.github.io/Turing-Drawings/)

[https://github.com/maximecb/Turing- Drawings](https://github.com/maximecb/Turing-Drawings)

</comment><comment><USER61> What do you like about Laravel and dislike about React?

I like the Linux kernel codebase: [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/)

<comment><AUTHOR> At some point in Martins book, he mentioned a forgotten codebase from one of his friend that was solely composed of tiny functions but yet achieve a fairly complex effect. That's the kind of feeling I had working at Laravel (admittedly it's been a few years). React codebase, on the other hand, seem less human-friendly, it seems to require some prior knowledge of the code to be able to dive into.

</comment></comment><comment><USER62> Although it's not a "codebase" per se, Architecture of OpenSource Applications is a great way to see how lots of major applications are structured. [http://aosabook.org/en/index.html](http://aosabook.org/en/index.html)

</comment><comment><USER63> Octave is amazingly written, in my opinion. I remember delving into its source expecting a mess made by mathematicians and instead found a very well organised and clean code base. Kudos to that team!

</comment><comment><USER64> I think Faust looks like exemplary modern Python.

[https://github.com/robinhood/faust](https://github.com/robinhood/faust)

Also voted for Postgres, Redis, and NetBSD.

</comment><comment> c-smile I was impressed by code of Konstantin Knzhnik ( [http://www.garret.ru/](http://www.garret.ru/) ). All his database engines in particular.

</comment><comment><USER65> Well, Symfony's codebase is really great: It is very readable, It's behavior is logical, The documentation is great, It uses common patterns (solid), so you are never loss

</comment><comment><USER66> Suckless tools ([https://suckless.org/](https://suckless.org/)), clean, efficient, small (easy to know the whole codebase) and very hackable, hackable to the point where even configuration is in code: [https://git.suckless.org/dwm/file/config.def.h.html](https://git.suckless.org/dwm/file/config.def.h.html)

<comment><USER67> I would especially recommend reading through sbase and ubase:

[https://git.suckless.org/sbase/](https://git.suckless.org/sbase/)

[https://git.suckless.org/ubase/](https://git.suckless.org/ubase/)

</comment></comment><comment><USER68> Qt's codebase is very clean

<comment><USER69> I thought QT was a collection of libraries, even with different licenses. As such, it seems strange to apply a word like "clean" to the whole thing.

<comment><USER70> Qt core and most libraries are written by the same group of people in the same development process.

Splitting it up into libraries is good engineering practice as it ensures boundaries. (Whether it is packaged into their own dll/so/a/dynlib is a deployment question, you can compile all parts statically together)

The licensing is a political/business question independent from code being nice, good and clean. (Except one has to be careful during refactorings, as code might change license, but since afaik the Qt Company has CLAs ensuring copyright ownership they are able to do that)

</comment></comment></comment><comment><USER71> I would say the Mattermost ("open Source slack") codebase: Go server: [https://github.com/mattermost/mattermost- server](https://github.com/mattermost/mattermost-server)

React frontend app: [https://github.com/mattermost/mattermost- webapp](https://github.com/mattermost/mattermost-webapp)

</comment><comment><USER72> Not your question but I think the bash source code is the worst I've ever seen.

</comment><comment><USER73> Sedgewick and Wayne algorithm implementations. Although, those are literally textbook implementations :-) I'm not quite sure what it would take to turn them into a production ready standard library (generics?), but they look like a good foundation for that purpose.

[https://algs4.cs.princeton.edu/code/](https://algs4.cs.princeton.edu/code/)

</comment><comment><USER74> I enjoy reading Django's source code so much. I also love writing Django apps. Its elegance forces me to write a much cleaner code.

</comment><comment><USER75> [https://github.com/golang/go](https://github.com/golang/go)

</comment><comment><USER76> I think Brogue is quite nice to work with and well structured: [https://github.com/tsadok/brogue](https://github.com/tsadok/brogue)

Kudos also to Postgres, SQLite, Lean (theorem prover), and the containers library for Haskell.

</comment><comment><USER77> The Gatsby codebase is dreamy [https://github.com/gatsbyjs/gatsby/tree/master/packages/gats...](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby)

</comment><comment><USER78> ffmpeg [https://github.com/FFmpeg/FFmpeg](https://github.com/FFmpeg/FFmpeg)

<comment><USER79> The build system and assembly system (x86asm) are very underrated. Open source went from autotools, which are awful, to cmake, which also seems to be awful. ffmpeg's configure/make system has the same interface as autotools but is actually good.

libavformat is rather difficult to use and difficult to fix bugs in - you'll never find the bugs. Same with the ffmpeg frontend, which makes it easy to ask for something it's near impossible to get right, like copying an mkv file to an avi, it'll just corrupt your data silently.

Everything about the video decoders is great, but encoding never worked as well, which is why nobody uses ffmpeg2/4/etc and x264 is a separate project.

<comment><USER80> _libavformat is rather difficult to use and difficult to fix bugs in - you 'll never find the bugs._

Some examples?

 _encoding never worked as well, which is why nobody uses ffmpeg2 /4/etc and x264 is a separate project._

Most users use x264 _via_ ffmpeg since they may need to filter the video and/or filter/process/mux audio and other streams.

<comment><USER79> > Some examples?

Just try copying video between different containers (mkv, ts, avi for one) without reencoding.

> Most users use x264 _via_ ffmpeg since they may need to filter the video > and/or filter/process/mux audio and other streams.

They don't have to do that; you can handle each track separately and mux them back afterward.

I'm talking about ffmpeg's builtin MPEG2/4/MP3 encoders, which nobody used when they were competitive because it leaves all the options at "go fast" instead of providing tunings.

They're also unmaintained and the code is hard to figure out - that's why x264 was a separate project instead of just another part of libavcodec.

<comment><USER80> _Just try copying video between different containers (mkv, ts, avi for one) without reencoding._

I do, all the time. AVI is an old container and it has issues with B-frames and also VFR but those are container limitations, not a libavformat issue. All transmuxing between common modern containers with present-day common codecs work fine. There are always edge cases, but that's what they are, edge cases.

 _you can handle each track separately and mux them back afterward._

Why do that? What's the benefit?

 _I 'm talking about ffmpeg's builtin MPEG2/4/MP3 encoders_

You seem to be talking about the state more than a decade back. How's that relevant to 2019? BTW, there is no native MP3 encoder.

</comment></comment></comment></comment></comment><comment><USER81> prestodb is the best java codebase I've ever worked in, llvm is the best c++ codebase I've ever worked in.

</comment><comment><USER82> For Java, below are my favorites:

1\. Jersey - [https://github.com/eclipse- ee4j/jersey](https://github.com/eclipse-ee4j/jersey) 2\. Jetty - [https://github.com/eclipse/jetty.project](https://github.com/eclipse/jetty.project) 3\. Guava - [https://github.com/google/guava](https://github.com/google/guava)

Common theme is - Easy to follow, clean documentation & use of consistent patterns.

</comment><comment><USER83> I found the Akka source code to be very clean and readable: [https://github.com/akka/akka](https://github.com/akka/akka)

</comment><comment><USER84> I work at Citus (now Microsoft) so my opinion is biased but I think Citus [1] codebase is a really good example.

It borrows all the best practices from PostgreSQL the naming of variables and functions are more self-explaining in general.

I also believe that the practices around PRs and code reviews are also good examples.

[1] [https://github.com/citusdata/citus](https://github.com/citusdata/citus)

</comment><comment><USER85> arc.arc, core of the Arc language. Lots of lessons in there on how to write good Lisp code. I'd say the same thing about the core.clj of Clojure.

</comment><comment><USER86> many mature frameworks have good standards. For php you can look at any code base that adbides by PSR standards and get good code.

Not only that but laravel is in a mature space where the problems are already solved. Its basically reinventing the wheel.

Im not surprised that Laravel is written cleanly but I hate its API. It reminds me of the bloat of Zend but with an obnoxious artsy style added to it.

Im an engineer not an artisan.

<comment><USER87> > look at any code base that adbides by PSR standards and get good code.

No. PSR does not at all ensure good code, only standardized code style and some of the interfaces.

<comment><USER70> It does one thing: It indicates the author is willing to use "established patterns" instead of reinventing the wheel. (While sometimes it's good to reinvent the wheel - today's vehicles won't work with wodden wheels)

</comment></comment></comment><comment><USER88> Anything by Tobias Lütke ( [https://github.com/tobi](https://github.com/tobi) )

</comment><comment><USER89> Maybe I have a low-ish bar, but the Kodi Add-Ons in the official code base is a nice system of continuous integration with established acceptance and review procedures. I wrote a small add-on for a woodworking show and as soon as all the checks were passed and there was a final sign off, it was immediately available for installation on all platforms.

</comment><comment><USER90> [https://github.com/achael/eht-imaging](https://github.com/achael/eht-imaging)

This python code is responsible for the fairly recent imaging of the black- hole (i.e. imaging, analysis, and simulation software for radio interferometry).

It's extremely easy to digest despite the complexity involved.

</comment><comment><USER91> The cleanest real/nontrivial code I've seen is the plan9 implementation of the standard unix command line tools.

</comment><comment><USER92> With some healthy spoonfuls of caveats, Quake 3 ([https://github.com/id- Software/Quake-III-Arena](https://github.com/id-Software/Quake-III-Arena)). Skipped a lot of classes back in the day ripping that one apart and piecing it back together again.

</comment><comment><USER30> I liked some Objective-C codebases that adhered to the muffin-man principle:

\- (BOOL) doYouKnowTheMuffinMan:(TheMuffinMan *)theMuffinMan;

Also, lots of the Objective-C runtime code was clear enough to explain concepts like ARC hacks well enough that I could learn about and give a talk on the Objective-C runtime with a month's notice.

</comment><comment><USER93> Well there was a post few year back with title "Best-architected open-source business applications worth studying?" : [https://news.ycombinator.com/item?id=14836013](https://news.ycombinator.com/item?id=14836013)

</comment><comment><USER94> Unreal 4 is far from perfect but considering the size of the project I would say its pretty impressive.

</comment><comment><USER95> I'm only learning Swift and iOS dev but a fair amount of people recommended me to take a deeper look into Kickstarter for iOS app: [https://github.com/kickstarter/ios-oss](https://github.com/kickstarter/ios- oss)

<comment><USER96> Came here to post this.

It's got some interesting usage of custom Swift operators to create almost diagrammatic code, like here: [https://github.com/kickstarter/ios- oss/blob/master/Kickstart...](https://github.com/kickstarter/ios- oss/blob/master/Kickstarter- iOS/Views/Controllers/AddNewCardViewController.swift#L112-L115)

      _ = self.cardholderNameTextField
          |> formFieldStyle
          |> cardholderNameTextFieldStyle
          |> \.accessibilityLabel .~ self.cardholderNameLabel.text

And it's the first iOS codebase I've seen that puts test files right next to the files that define the things being tested. It's all there together.

Tons of other goodies to find.

<comment><USER97> 2 of the guys that worked on that app are doing video series about functional programming now where they talk a lot about the ideas in the app, [https://www.pointfree.co](https://www.pointfree.co)

<comment><USER96> Nice rec! They're the ones that wrote the tagged [0] repo I use, had no idea they were connected. Very cool.

[0]: [https://github.com/pointfreeco/swift- tagged](https://github.com/pointfreeco/swift-tagged)

</comment></comment></comment></comment><comment><USER98> ZeroMQ[1] for sure. It has a clean interface wrapped over low-level IO details and a well-designed unified polling mechanism. It's a piece of art.

[1] [https://github.com/zeromq/libzmq](https://github.com/zeromq/libzmq)

</comment><comment><USER99> MacPaint and QuickDraw Source Code [https://www.computerhistory.org/atchm/macpaint-and- quickdraw...](https://www.computerhistory.org/atchm/macpaint-and-quickdraw- source-code/)

</comment><comment><USER100> Here are a couple of codebases

[https://medium.com/@012parth/what-source-code-is-worth- study...](https://medium.com/@012parth/what-source-code-is-worth- studying-8755f88f8de5)

</comment><comment><USER101> sel4 microkernel is pretty cool.

"The world's first operating-system kernel with an end-to-end proof of implementation correctness and security enforcement is available as open source."

for instance, look at strnlen:

      word_t strnlen(const char *s, word_t maxlen)
      {
          word_t len;
          for (len = 0; len < maxlen && s[len]; len++);
          return len;
      }

[http://sel4.systems/](http://sel4.systems/)

[https://github.com/seL4/seL4](https://github.com/seL4/seL4)

</comment><comment><USER102> I've had the pleasure of working on this: [https://github.com/cloudify- cosmo](https://github.com/cloudify-cosmo) was the cleanest I've seen

</comment><comment><USER103> Someone mentioned joda-time. Does anyone know of other exemplary java repos?

</comment><comment><USER104> I think that the Twisted codebase has the best combination of sound and comprehensive metaphor, straightforward functionality, and fun.

I also enjoy diving into it when I hit a breakpoint that calls one of its methods.

</comment><comment><USER105> Whatever you do ... do not read the guts of PonyORM (python db orm). Also I would strongly urge anyone who has ever considered it to run, not walk, in the opposite direction.

</comment><comment><USER106> Any good to study Kotlin codebases? Or even Java (8+)?

</comment><comment><USER107> I really like AllenNLP.

[https://github.com/allenai/allennlp](https://github.com/allenai/allennlp)

</comment><comment><USER106> A side question. What is a good way to start understanding such code bases as mentioned on here, so that the learning is optimal and effective?

</comment><comment><USER108> minitest. The testimonials speak volumes.

[https://github.com/seattlerb/minitest](https://github.com/seattlerb/minitest)

Apparently, some people think my toy channel implementation called Normandy is somehow good:

[https://github.com/lloeki/normandy](https://github.com/lloeki/normandy)

</comment><comment><USER109> The easiest to read codebases I've found were all written in Common Lisp, like the clsql lib for example.

</comment><comment><USER110> Java: joda-time

C: redis

Python: scikit-learn

_______

Edit: formatting

</comment><comment><USER111> For C, I thought Tcl had code that was easy to read and understand.

</comment><comment><USER112> I know it's a cliche but the sqlite code is the easiest to read C I've encountered. Followed closely by the code for Redis.

<comment><USER20> I also like the C source for Tcl/Tk which I _think_ also follows similar engineering/style standards.

<comment><USER113> The author of Tcl/Tk wrote a fantastic book recently called "A Philosophy of Software Design" and it's brilliant, hands down my favourite programming book of the last decade.

</comment></comment></comment><comment><USER114> I'm really curious how you see laravel as a shining example of clean code?

That thing is the epitome of a framework for frameworks sake.

Pretty sure Most of Martin's talks begin by complaining about this sort of thing?

<comment><AUTHOR> A software's usefulness is not correlated to how well it was architected. What I like about Laravel is that its fairly complex code base that is mostly composed of tiny and expressive functions

<comment><USER114> I'm not sure I follow.

We're not talking usefulness here we are talking about clean code.

Architecture is not only correlated but causal in this situation.

It's over architecture is the problem. It's nano functions are a positive side effect but don't change the indirection problems you face.

</comment></comment></comment><comment><USER115> Because of ego, I'm going to plug my own (a Java parsing tool): [https://github.com/norswap/autumn4](https://github.com/norswap/autumn4)

And hopefully I can some constructive criticism :)

For something not from me but still in Java, the Proguard source code is very clean: [https://sourceforge.net/p/proguard/code/ci/default/tree/](https://sourceforge.net/p/proguard/code/ci/default/tree/)

<comment><USER116> it reads like C , not like regular java all idioms are C like</comment></comment>


Queue-flow: Chainable logic built on named (or not) queues in Javascript - <AUTHOR> http://dfellis.github.com/queue-flow/

<comment><USER2> Hi, I'm the author (finally figured out why I suddenly got so many new people starring the library).

I hope you guys find queue-flow useful. It's nice for organizing source code in Node.js, especially when you need to mix-and-match sync and async methods (the "flow" part of the name), but particularly shines when you have a large queue of data to process (the "queue" part of the name).

There are some other libraries I've written that are useful with it:

[sloppy-queue-flow](<https://github.com/dfellis/sloppy-queue-flow>) drops the "queue" part of queue-flow and leaves just the source code organization. Good for request-response type operations where any particular request has nothing to do with any other request.

[parallel-queue-flow](<https://github.com/dfellis/parallel-queue-flow>) keeps the queue in-tact, but allows each "step" to process more than one piece at a time -- but sends the results down the line in the order it received the input. (Blocking only enough to keep the order, not waiting for the entire queue to finish before continuing.)

[lambda-js](<https://github.com/dfellis/lambda-js>) is a simple library that creates true one-liner lambdas in javascript (not closures) with no perf penalty versus "regular" functions, and if it detects that you defined that same lambda elsewhere it re-uses that one rather than parse and re-define again.

[binders](<https://github.com/dfellis/binders>) was sort of a joke library that has some use. It creates a "binder full of bound functions." Give it an object and it will return another object where all of the methods are bound to the original object, perfect for passing around in functional-style libraries like queue-flow.

Finally, I'm working on what I call a "baby map-reduce", [queue-flow- server](<https://github.com/dfellis/queue-flow-server>). It's not ready, yet. I only got to start working on it a few days ago, though I'd been turning the concept around in my mind for a while. Feel free to make comments on the current design goals, and let me know if it seems like something you'd find useful.</comment>


A Covid project using SwiftUI and some basic Named Entity Recognition - <AUTHOR> https://apps.apple.com/us/app/ryden/id1510078309 <comment><AUTHOR> Took about 4 weeks - lots of rough edges but for a guy who hates UI stuff SwiftUI made the UX/UI part simpler than any framework I've used before.

Backend: AWS, Golang/Echo, & good old postgresql iOS: SwiftUI</comment>


Ask YC: wiki software for structured data - <AUTHOR>

does anyone know if there is wiki like software for structured data?  has to be open source.
ie- mediawiki is basically for a blank page of information.
im looking for something that is like wikipedia, but the data entered is a set group of fields.  ie- title, link url, description, phone number, address <comment><USER2> This answer is not super helpful, but anecdotally: this is how our product works; it's a Wiki engine running on top of Subversion that parses, stores, renders, and indexes valued "tags". We're using it right now to manage firewall rulesets; our customers document firewalls and rules in a Wiki, and to pull in relevant details from that documentation into their rulesets.

We wrote our own (in Ruby); it wasn't hard enough to do that we'd have considered outsourcing that part. So, one contribution: consider just writing it yourself.

Another contribution: this approach rocks a lot.

</comment><comment><USER3> I am not sure if this is what you need, but I have found <http://twiki.org/> to be useful. Drupal is another solution - can be made into a wiki with a few additions (which, however, can add up to quite a lot of extra time).

hopefully this helps, deyan

<comment><USER4> I was also going to suggest twiki but I don't have any first hand experience with it.

I have also looked at Roundup in the past. <http://roundup.sourceforge.net/>

WikidBASE is a fairly new but also in the same vein. <http://projects.nickblundell.org.uk/wikidbase>

If a hosted solution is acceptable you can look at Dabble DB or Coghead

<http://dabbledb.com/> <http://www.coghead.com/>

</comment></comment><comment><USER5> You can use MediaWiki and add Semantic MediaWiki extension to get something closer to what you want. We use this a lot and get all sorts of structured data (with RDFs, etc) when we need it, but freeform data around it.

</comment><comment><USER6> Not really what you want, but here is a nice showcase of what domain-specific wiki combining text and structured data can look like:

<http://wikinvest.com>

Edit: Again not a Wiki, but Google Spreadsheets could also work for you

</comment><comment><USER7> <http://flamenco.berkeley.edu/>

</comment><comment><USER8> Perhaps choose something like dekiwiki and mod it to suit your need?

<comment><USER9> I want to like dekiwiki, because it looks awesome. But, egads, it's slow! It's also kind confusing to use...which is surprising given all the work that's gone into the UI.

And, of course, it doesn't have any real support for structured data. It's just a really nice _looking_ wiki with the standard feature set (actually a rather anemic feature set, which is fine for many purposes, since most wikis are too damned complicated). Since structured data is the thing in this request, it seems like there are probably better alternatives. I only know of one wiki that deals with structured data (TWiki) but I'm betting there are others. I seem to recall seeing discussion of wiki+spreadsheet style tools, though I don't remember where or what.

</comment></comment><comment><USER10> Jotspot used to be like this until they were bought by Google...

</comment><comment><USER11> Infogami is precisely what you want.

www.infogami.org

</comment><comment><AUTHOR> wow, many thanks for the quggestions</comment>


Show HN: I updated the Smackbook script for OS X Yosemite - <AUTHOR> https://github.com/dabockster/Smackbook-Yosemite

<comment><AUTHOR> Hey guys!

Thanks for the comments on this small side project/homework procrastination of mine. When I originally saw this back in 2006, I thought it was one of the best tricks ever to do with a laptop computer. I was 13 at the time. Fast forward about 8-9 years, add some CS and Perl education, and bam, I finally know enough on how to update the script to save it from the black depths of the Internet.

Took me a while to find an implementation that referenced enough to OS X Spaces, but I'm glad I could revive the idea.

If I have the chance, I would love to write a clone of this and not have AMStracker as a dependency. Or if someone else wants to, that's cool too. I just don't know how long that AMStracker site will stay up.

</comment><comment><USER2> Please correct me if I'm wrong (I probably am), but using this for anything but a cool demo feels dangerous to me: You're relying on the input signal of an emergency motion detector to park the harddrive heads as a device to do UI interaction.

What I mean is: In order to switch spaces, you have to hit the machine hard enough for the "uh oh - shock emergency" sensor to actually trigger. That means that you have to hit the machine hard enough for it to think it has to do something in order to prevent hardware damage.

What was meant as an emergency measure for rare emergencies now becomes commonplace. Are you sure that a) the mechanism always works? and b) that the emergency head parking doesn't put too much stress on the disk to wear it down more quickly?

I'm basing this question on the fact that in the demo video there was one instance where they didn't hit the device hard enough for the switch of spaces to actually happen. That leads me to believe that the sensor isn't that accurate and really only measures dangerous levels of activity.

But yeah: As a demo performed once or twice it's really cool and fun to watch.

<comment><USER3> You can get acceleration data that's well within the non-emergency situation from Macs. This thing works on Chrome on my Mac (which is a little disconcerting, to be honest): [http://www.html5rocks.com/en/tutorials/device/orientation/de...](http://www.html5rocks.com/en/tutorials/device/orientation/deviceorientationsample.html)

<comment> Pirate-of-SV I got a MBA (Mid 2011) + Chrome but I can't get it to work.

A friend asked me WTF I was doing and it felt like a April fools joke.

<comment><USER4> Didn't work for me on my retina MBP either.

Wouldn't be surprised if our Mac notebooks, being SSD based, didn't have the SMS

 _Edit:_ Apple says all Intel Mac notebooks have the SMS, but then goes on to say that SSD notebooks don't use them [http://support.apple.com/en- us/HT1935](http://support.apple.com/en-us/HT1935)

</comment></comment></comment></comment><comment><USER5> I wouldn't use this, but this is cool. At first I thought it was using microphone to detect which side the smacking sound was coming from, but since others have pointed out, I didn't know harddrive heads have such sensors and can be accessed using programming language. It's probably suitable when you want to have an emergency button to destroy/encrypt/close all super- confidential information when someone's approaching and you don't have enough time to type/click anything, just smack!.

<comment><AUTHOR> The sensor is in the system itself, not the drive.

</comment></comment><comment><USER6> Oh, gotta love the SMS. There were several obscure apps that experimented with it:

\- [http://uri.cat/software/LiquidMac/](http://uri.cat/software/LiquidMac/)

\- [http://uri.cat/software/Tunnel/](http://uri.cat/software/Tunnel/)

\- [http://www.suitable.com/tools/seismac.html](http://www.suitable.com/tools/seismac.html)

\- [http://blog.isnoop.net/2006/05/20/macsaber-turn-your-mac- int...](http://blog.isnoop.net/2006/05/20/macsaber-turn-your-mac-into-a-jedi- weapon/)

Bonus video: MacSaber fighting! [https://www.youtube.com/watch?v=qK4AonfnFaM](https://www.youtube.com/watch?v=qK4AonfnFaM)

</comment><comment><USER7> Ha, neat! I remember using amstracker to jump forward in iTunes by bumping my laptop. Literally the first time I'd encountered physical UIs, it felt so natural. And now there's Wii and Kinect and Leap etc.

Ancient code: [http://interconnected.org/home/more/2005/03/bumptunes.py](http://interconnected.org/home/more/2005/03/bumptunes.py)

And ancient write-up: [http://interconnected.org/home/2005/03/04/apples_powerbook](http://interconnected.org/home/2005/03/04/apples_powerbook)

</comment><comment><USER3> YESSS I remember seeing this in high school and I'd completely forgotten about it. So glad to see it again.

Here's the original post courtesy of the Internet Archive: [http://web.archive.org/web/20121221154722/http://blog.medall...](http://web.archive.org/web/20121221154722/http://blog.medallia.com/2006/05/smacbook_pro.html)

<comment><USER8> Very cool, I wrote the ThinkPad version at the time. I had forgotten about it, there is a link to my post at the time in that page and I'm happy archive.org exists [http://web.archive.org/web/20070922232656/http://blog.micamp...](http://web.archive.org/web/20070922232656/http://blog.micampe.it/articles/2006/06/04/here- comes-the-smackpad)

I was definitely not in high school at the time.

</comment></comment><comment><USER9> So what does it do?

<comment><USER10> It uses the harddrive's motion sensor to figure out if the computer is being smacked on one side, and then switches to the next virtual screen in the opposite direction.

(that's what I gathered from the video at least)

<comment><USER9> This should be on the top of the readme, IMO.

<comment><AUTHOR> Agreed. I just updated the readme.

</comment></comment></comment></comment><comment><USER11> This is actually quite cool. Looks like all Macbooks around the 2012 era had SMS: [http://support.apple.com/en-us/HT1935](http://support.apple.com/en- us/HT1935)

</comment><comment><USER12> The one time I wish my Mac had a HDD instead of SSD

<comment><AUTHOR> All Macbooks claim to have the accelerometer, so it should work. If not, the sensitivity values are clearly marked in the script.

<comment><USER13> My Macbook pro retina does not have an accelerometer.

<comment><USER14> The acceleromenter was built into the MacBooks in order to protect the hard drives. I guess it makes sense that after moving to SSD the sensor has been taken out.

<comment><USER13> Yeah - it makes sense to me. I wasn't sure but I tried a few apps that are supposed to use it and looked for it in my system information and I didn't see it. (I'm really new to using a mac)</comment></comment></comment></comment></comment>


Uyghur musician tortured to death in China's concentration camp - abc-xyz https://www.bbc.com/news/world-asia-47187170 <comment><AUTHOR> Amazing how in 2019 no one can stop them. Or willing to suffer any consequences from stopping them.

 _> >"We hope the Turkish side will have a correct understanding of the efforts made by China to legally deploy measures..."_

Legally yeah, because China itself passed the law.

<comment><USER2> It sucks for the people being detained right now, but geopolitically there's not yet a pressing need to stop the Chinese government — the world knows China is without meaningful long-term allies and is weakening on top of that.

Xi only seems to know how to play a Xi-and-China-vs-the-world game, which isn't a game I'd want to play on the Chinese side.

Anyway, it will all take quite a long time to play out.

</comment></comment><comment><USER3> Later article from the BBC contradicting this one: [https://www.bbc.com/news/world-asia-47191952](https://www.bbc.com/news/world- asia-47191952)

<comment><USER4> The question though, is whether to believe the latest video.

</comment></comment><comment><USER5> It is depressing to think that there is nothing we can do to prevent the rise of dystopian regimes that consolide their power with thru censorship and authoritarianism. The worst is that most people in China support their current government and believes what has been done as for the greater good.

<comment><USER4> How will we know?

If you were Chinese would you take the risk of speaking out?

'freedom' is all well and good in the abstract, but would you risk yourself for it? Your wife and kids?

</comment></comment><comment><USER6> Contrast this grim development and international condemnation of China's treatment of its own people with the happy news from Chinese news organizations and government officials about "free vocational training" and "boarding schools." ([https://www.theguardian.com/world/2018/oct/16/internment- cam...](https://www.theguardian.com/world/2018/oct/16/internment-camps-make- uighurs-life-more-colourful-says-xinjiang-governor)) Hundreds of millions of Chinese people and many foreign people exposed to the English-language propaganda believe it, too.

</comment><comment><USER4> Here's another article on the camps in general

[https://www.bbc.co.uk/news/resources/idt- sh/China_hidden_cam...](https://www.bbc.co.uk/news/resources/idt- sh/China_hidden_camps#)

</comment><comment><USER7> The current HN headline is sensationalised and should be changed.</comment>


Ask HN: What are your goals for next year? - <AUTHOR> Been reflecting a lot myself and would be interested to hear others thoughts for the coming year?  Be as specific or vague as you like. <comment><USER2> Get my teeth fixed. Will have to get braces and wear them for 18 months. Terribly scared of that. But it has to be done.

Push my passive income to $10k/month. At that point I don't worry about money anymore.

Travel the world. Meet interesting tech, art and business people. And pretty girls.

Make some friends along the way.

</comment><comment><USER3> I'll add autoclave.js to the anythingbot after getting it into a working state...no one else is going to do it, that's for sure</comment>


Alex Berenson on Twitter: "Wow. nature published a paper claiming that lockdown - <AUTHOR> https://mobile.twitter.com/AlexBerenson/status/1270031726903951362 <comment><USER2> I checked the Tweeter's scientific skills and was not impressed. Interesting that he's anti-mask as well, if I read his tweet correctly.</comment>


Must-read on capital structure - <AUTHOR> http://www.nature.com/bioent/2010/100201/full/bioe.2010.2.html

<comment><AUTHOR> This piece is from Nature Biotechnology magazine that I received every month. Fortunately, it is available also online. I think the content is relevant to every aspiring company founder...</comment>


Mental Disorder - <AUTHOR> https://plato.stanford.edu/entries/mental-disorder/ <comment><USER2> One of the interesting problems with the medical model that emerged during our regular contact with it when our first kid was born is that medicine is intensely normative - that is, it assumes a median condition and looks for outliers that require correction. From a statistical and biological perspective this does not make sense. There is no underlying biological norm - variation is real (as in, our fundamental biology differs), and any normal behavior is merely the result of the central limit theorem, etc. Defining this real variation as disordered seems a fundamental problem. This becomes particularly problematic when those norms are measured using a non- representative sample (e.g. white Americans) and applied to everyone else.

<comment><USER3> > that is, it assumes a median condition and looks for outliers that require > correction

I think that's all evidence based medicine can really do. It's just a series of "well, people with high blood pressure tend to die early" and "people with high cholesterol have heart attacks". I don't know how they would approach it differently - if it was assumed that everyone was different with entirely different baselines, I don't know how it would be possible to make any sort of predictive assumptions. Really, the best solution would be to increase the granularity of the samples, but that's all they can do, develop more diverse pools of generalizations.

<comment><USER2> Increasing the pool of generalizations would certainly help. So would keeping this fundamental problem in front of mind.

My kid was an outlier because my genetics tend to being tall and thin. If he was being measured against a set of healthy people with similar genetics he would not be considered an outlier - but this calculus is not considered when he is measured and judged aberrant. Our doctor being Indian was able to see from her experience that he was "normal" \- for a kid with an Indian parent. Another doctor (like all the ones I grew up with) might not have the same insight and conclude there is a problem.

<comment><USER3> Could I ask what concerns they had with your child being tall and thin for his age? I was a 99%'er growing up but I don't remember there being health concerns.

</comment></comment></comment></comment><comment><USER4> I have lot of questions on the whole psychology seriousness, but I will skip on them and just ask a simple one:

In the case of, let's say, 60% of the population suffering of depression, is that a mental disorder or something that have to be ascribed to external conditions (maybe political, related to environment etc)?

<comment><USER5> _In the case of, let 's say, 60% of the population suffering of depression, is that a mental disorder or something that have to be ascribed to external conditions (maybe political, related to environment etc)?_

Possibly either, possibly both, possibly neither.

It might be the case that social or environmental factors are causing people to become depressed, in a way that could only be fixed by addressing those external factors. It might be the case that people are experiencing difficulty in coping with those external factors, but could learn to thrive with the right cognitive tools. It might be the case that we're over-diagnosing depression, or that the concept of depression itself has caused an iatrogenic epidemic. It might be something totally unexpected, like a hitherto- unrecognised prion disease or a strange reaction to an organic pollutant.

It's worth noting that, while rates of depression have been rising in recent decades, only 7.3% of the US population suffer from a depressive illness at any given moment; a larger proportion suffer from diabetes. Most people who are diagnosed with depression do get better with the right treatment. We're still a very long way from the point where we can reasonably argue "what does depression even mean if depression is the new norm?".

[https://www.sciencedaily.com/releases/2017/10/171030134631.h...](https://www.sciencedaily.com/releases/2017/10/171030134631.htm)

[http://www.diabetes.org/diabetes- basics/statistics/](http://www.diabetes.org/diabetes-basics/statistics/)

</comment></comment><comment><USER6> "Works of ancient philosophy are focused more on the psyche's health (or eudaimonia) than its illness. Nonetheless, there are hints that just as a unified soul is one that is healthy (as well as rational and virtuous), a soul lacking unity will be disturbed, or mad. Offering an account of the harmonious soul, whose rational and non-rational elements achieve a unified whole, Aristotle leaves us a picture of the warring and fractured state of an unhealthy soul, for example."

<comment><USER7> > Socrates used to say, 'What do you want? To have the souls of rational or > irrational beings?' 'Of rational beings.' And of what kind of rational > beings, those that are sound or depraved?' 'Those that are sound.' 'Then why > are you not seeking for them?' 'Because we have them.' 'Then why all this > fighting and quarrelling?'

\-- Marcus Aurelius, "Meditations"

On the other hand, I also _really_ like this, even though it's probably one of those fake internet quotes:

> If your heart is broken, don't try to fix it, they work better that way.

\-- Tibetan monk

<comment><USER8> If you keep spreading that last quote, eventually a Tibetan monk will read it and repeat it, and it'll no longer be fake.

</comment></comment></comment><comment><USER9> This looks interesting. Going to need to set time aside for something this extensive though.

<comment><USER7> Yes, this is the kind of thing that doesn't work well with this short window of time during which something is on the front page, I wish it was possible to subscribe to discussions to follow them over a few weeks, rather than hours or 1-2 days at most.

I know this is the opposite of helping, but just in case anyone isn't aware just _how_ extensive the whole site is: [https://plato.stanford.edu/contents.html](https://plato.stanford.edu/contents.html)

<comment><USER10> Exactly, only lurkers view them 9 months or years after. To the downside they cannot comment, but at least some provide useful links and resources was fascinated to read wikipedia views on: [https://en.m.wikipedia.org/wiki/Suicide](https://en.m.wikipedia.org/wiki/Suicide) [https://en.m.wikipedia.org/wiki/Depression](https://en.m.wikipedia.org/wiki/Depression) , and boredom seeing them as learned helplessness.</comment></comment></comment>