News for hackers. Stuff that matters.
Re:Ask HN: Codebases with great, easy to read code? by jedisct1 on Monday March 21, 2022 @12:33PM (#30756126)
Anything written in Zig or Go.

Both languages are extremely readable, even when looking at unfamiliar code.

The Zig standard library is small, yet covers a lot of common tools and structures. Every file contains implementations of one particular thing, so you can casually browse random files and understand what's going on without having to understand the entire context.

Re:Ask HN: Codebases with great, easy to read code? by Nullabillity on Monday March 21, 2022 @12:39PM (#30756223)
Couldn't disagree more in the Go case. Folder-level namespaces (rather than file-level) makes Go exceptionally annoying to navigate, and interfaces heavily obscure the.. interface between abstractions and implementations.
Re:Ask HN: Codebases with great, easy to read code? by rubiquity on Monday March 21, 2022 @01:06PM (#30756682)
I'll +1 Zig code, but I came here to say this about Go as well. Once Go codebases creep past medium sized (25-50k LOC perhaps) into large I find them to be inscrutable. I've noticed this even in projects that people in the community point to as the gold standard such as the various HashiCorp tools.

I don't write much Go anymore but my hunch is that it's a combination of the package layout and auto method delegation for embedded structs. Even Java does a much better job of helping the developer at obviating the interfaces between different subsystems.

Re:Ask HN: Codebases with great, easy to read code? by KptMarchewa on Monday March 21, 2022 @05:56PM (#30760240)
Java basically does the same thing and I've never heard anyone complaining about that.

Python does the file level thing and it's source of constant annoyances with cyclical imports. Ugh, wasted so much hours on fixing it.

Re:Ask HN: Codebases with great, easy to read code? by Nullabillity on Monday March 21, 2022 @06:43PM (#30760719)
> Java basically does the same thing and I've never heard anyone complaining about that.

I don't love dealing with Java, but it has none of these particular issues. It's easy to find the definition of a class, because it enforces that the file path must match the fully qualified class name for all public classes (and this tends to be followed for privates as well in practice). Finding the implementation isn't quite trivial, but if you know a class in the tree then you can easily find the whole parent tree by following the "extends Foo" clauses, or find subclasses by grepping for it instead.

Re:Ask HN: Codebases with great, easy to read code? by psanford on Monday March 21, 2022 @05:36PM (#30760024)
It seems like gopls solves your problems. It will do the correct thing for navigating to definitions and listing implementations of interfaces.
Re:Ask HN: Codebases with great, easy to read code? by Nullabillity on Monday March 21, 2022 @06:39PM (#30760675)
In my experience gopls hasn't been useful for much more than crashing.

But that aside, Go's incessant insistence on structural typing makes it impossible for any tool to generate a list that is both complete and free from false positives.

Re:Ask HN: Codebases with great, easy to read code? by pxeger1 on Monday March 21, 2022 @01:29PM (#30757101)
This is a massive generalisation. It is very easy to write bad code in any language.

Well, bad on a large scale. Go in particular has some nice tools to ensure code at a small scale is always good (enforcing syntax style), but no language can stop you from having a bad project architecture.

Re:Ask HN: Codebases with great, easy to read code? by opportune on Monday March 21, 2022 @04:13PM (#30759123)
Go basically codifies a lot of best practices for writing C++ at Google, but I wouldn’t say it always teaches good code. Good Go would definitely help you learn how to write good systems code in any systems programming language though, and to be explicit/clear instead of terse.

But you can easily code yourself into a corner with Go too. If someone doesn’t know how to use concurrency well they can do bad things like overcreating goroutines or making a mess with channels. And some of the common patterns (particularly excessively overriding things) can be considered an anti pattern in terms of understanding (IMO)

Re:Ask HN: Codebases with great, easy to read code? by oxplot on Monday March 21, 2022 @01:23PM (#30757001)
Absolutely this. Especially Go's standard library is a pleasure to read. Lots of idioms and good practices to be learnt.