Live data from Hacker News

Ask HN: What are some of the most elegant codebases in your favorite language?

news.ycombinator.com

111–120 of 186 posts

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#111
post #5

Go and it’s standard library. ‘Elegant’ is pretty subjective, but it’s a treasure trove of learning how things work under the hood. I’ve learned loads about networking, compression, encryption and more by browsing through it, because the code is super easy to read and understand.

What makes it easy to read and understand though? I am seriously having a hard time figuring this out. People tout Go for this all the time, but I don't know of a single codebase in it that I think fits that description. When I look through them they look convoluted and just sort of messed up. Things like awkward error handling, dealing with null, capitalization for public/private, magic functions, and imports, and m…

> People tout Go for this all the time

What gets me about go is 2 things.

Its touted as being so easy that a junior dev can pick it up easily; it's targeted towards average developers. Fine, this is a virtue; when Java said the same thing, it's a horrifying blight.

The other is that people seem to mistake motion for action. "The code flies from my fingers" is one way I've heard it said. And, sure, you have the same error catching boilerplate (which again, in go is a virtue but other languages seems to be considered a sin) 1000x, as if the clicky-clicky of the keyboard is some measure of productivity.

It's got a big "blub paradox" thing going, to my eyes. I don't find it elegant at all, or maybe I mean not very expressive.

Taken ad absurdum, I have a language that only adds 1 to a variable. I can understand that language in milliseconds. But I can't do much with it. Maybe go hits a good balance, I dunno, but I found it quite tedious.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#112
arthur whitney's famous first J interpreter.

https://www.jsoftware.com/ioj/iojATW.htm

The first version of KDB the timeseries database was written by arthur in C to bootstrap the K interpreter that was used to write KDB. It was 26 files, named a.c to z.c, none larger than a single page of C written with notepad.exe.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#113
post #84

Earlier quoted context omitted.

That’s simply not true. This method is monkeypatched by json gem

JSON was added to Ruby stdlib in ruby-2.0.0 (2013), and has been a default gem since ruby-2.3.0 (2015). This is pretty close to "built in", I think.

You're both right, I think.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#114
post #78

I'd nominate Java itself. In the decades Java sources have been available, any of the kazillion junior programmers could debug-step into java.* and see exactly what's happening -- progressive disclosure at its finest for building expertise. Most other languages have a hard boundary, so the roots of language are a matter of conceptual documentation and experience. Java also offers that fly-over knowledge, but when pro…

After a decade of programming 50+ hours a week in many languages (typescript, javascript, python, scala, java, lua, bash, c++, etc), I have come to the conclusion that Java is simply the best. The tooling, libraries, stability, verbose rigidity. It forces a style of programming that simply scales to more engineers better

As an end user though, I honestly can’t think of any Java software I actually enjoy using. Minecraft? That’s literally the only thing that comes to mind.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#115
[C#] Bitwarden server repository is probably one of the cleanest (non-novel) solution architectures I have seen so far. I always point people to it as learning material for structuring the code. It is not the most minimalistic but I feel like it strikes very good balance and does not follow blindly all the """fancy""" OOP patterns people should never use anyway.

https://github.com/bitwarden/server

Otherwise, I can see why people are burned, average Java/C# codebases look abysmal and written without understanding of (not) using heaps of mediator/factory/adapter/provider classes.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#116
post #105

Earlier quoted context omitted.

Have you tried C#? It looks a lot nicer to work with than Java.

The ecosystem is nowhere near as mature though. I don’t work with either anymore but back in 2017 I made the switch from C# to Java and it felt like a breath of fresh air when it came to the maturity and capability of JVM tooling compared to what’s available for .NET.

I'm curious, what kind of tooling are we talking about?

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#117
post #35

Working with Perl, two things spoiled me for other languages: JSON and DBI/DBD. In Perl, everything serializes to JSON without fuss. It can be "lossy"; objects without an explicit JSON serialization method and coderefs can't be deserialized, but serializations at least have placeholders for them. Compare to Python's json module, which doesn't try very hard to serialize things and throws exceptions every time it runs…

The only thing about the JSON package though, when things go wrong, it is very unhelpful about where it goes wrong.

I usually end up always wrapping the json_decode in an eval to catch the error and handle it in an easier to understand fashion.

But I agree though, its nice how json and perl data objects pretty much map to each other. It's great.

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#118
post #114

Earlier quoted context omitted.

After a decade of programming 50+ hours a week in many languages (typescript, javascript, python, scala, java, lua, bash, c++, etc), I have come to the conclusion that Java is simply the best. The tooling, libraries, stability, verbose rigidity. It forces a style of programming that simply scales to more engineers better

As an end user though, I honestly can’t think of any Java software I actually enjoy using. Minecraft? That’s literally the only thing that comes to mind.

Have you tried Jetbrains stuff?

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#119
post #78

I'd nominate Java itself. In the decades Java sources have been available, any of the kazillion junior programmers could debug-step into java.* and see exactly what's happening -- progressive disclosure at its finest for building expertise. Most other languages have a hard boundary, so the roots of language are a matter of conceptual documentation and experience. Java also offers that fly-over knowledge, but when pro…

While I think there's a lot to love about Java, the standard library itself is not an especially great role model. Most of it was written a long time ago and has a fairly antiquated style - lots of mutable state, nullability, and checked exceptions. Not that the library isn't an incredible asset - it's luxuriously rich compared to working in Node.js - but if it were written from scratch today, I suspect it would look fairly different. Eg, the collection classes would use Optional and have separate read/write interfaces.

For an example of "modern Java" I would point at something like this (which I wrote, sorry about the hubris):

https://github.com/stickfigure/hattery

Re: Ask HN: What are some of the most elegant codebases in your favorite language?

#120
Shewchuk’s Triangle code for Delaunay mesh generation is some of the most elegant C-code I’ve ever seen [1]. It even won the SIAM Wilkinson Prize for numerical software at the time it was written. It’s written in a literate style, and builds up from the most fundamental arithmetic operations and data structures, all the way to one of the most efficient mesh generators of its kind. He has a few other codebases written in a similar style [2, 3]. It’s very different from what you see in the wild, but it’s been great for understanding what’s happening under the hood for complex algorithms like mesh generation.

1. https://www.cs.cmu.edu/~quake/triangle.html

2. https://github.com/ctlee/Stellar

3. https://www.cs.cmu.edu/~quake/robust.html

Post reply on HN