Live data from Hacker News

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

news.ycombinator.com

51–60 of 186 posts

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

#51
post #17
post #6

So many, I like reading how other people write code. R - sf package is a clean example of functional OOP Python - pytudes (Peter Norvig’s notebooks) Haskell - Elm compiler. I could mostly understand what’s going on even though I barely know any Haskell. Ruby - Sequel is really nice. Rust - Ripgrep Pretty much any F# codebase is super readable too.

Do you have any F# favorites? People often mention jet.com repos, but I’m interested to hear about others.

Jet.com has a lot of good ones yeah. One I was looking through the other day is a GitHub repo under /ScottArbeit/Grace and it’s an interesting take on version control. It was a pretty cool repo to look through. To make it easier though, remember that F# source code files are all “in order” so you read them from top down, which Github doesn’t currently have functionality for.

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

#52
post #18

[dead]

Good structure overall and appreciate the summary at the top. For the inline comments more "why" and less "what" would give higher signal-to-noise as a large percentage of that content is adding nothing that basic Java syntax and variable names don't already tell you.

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

#53
post #37
post #18

[dead]

Anyone suggesting their -own- code as an example of the "most elegant codebase" is dubious. Practice some humility.

I’d be a little forgiving if it was almost an art piece. Like, they spent a year making the most elegant JSON serializer possible.

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

#57
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 much, much more all add up and make me abhor the language. I don't think it's good or easy to use at all, but people rave about it.

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

#58
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…

Omg the python stdlib json / simplejson both refuse to support custom serializers for keys only, as an explicit design decision. It is justified as "JSON keys must be strings", but JSON values can only be string/float/book/null so it seems a bit arbitrary. Leads to annoying gymnastics if you want to enforce "strong typing" of keys with Enum/pydantic/etc.

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

#59
C++ this file covers all the math for working with NURBS curves and surfaces:

https://github.com/solvespace/solvespace/blob/master/src/srf...

There is a lot more in other files - triangulation, booleans, creation - but the core math functions are there in very readable form.

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

#60
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…

Funny enough, but I've come across some really nice Perl code in the wild at work. I was used to the vendor providing some 40 class Java monstrosity to do something that should take like a page of code, so I was pleasantly pleased to find a contractor who provides an extremely well commented page of code to do something simple, yet critical to operations. The way Perl calls the OS to do something and glue everything together was pretty elegant.
Post reply on HN