Live data from Hacker News

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

news.ycombinator.com

41–50 of 186 posts

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

#41
post #18

[dead]

This is pretty good! I'd be happy to work with you :-)

There are undoubtedly some pointless comments, but there are some good ones too, and the code is understandable. I think the sibling comments are being overly harsh and are zeroing in on single examples and missing the forest for the trees.

I suspect recommending your own code as an example of the most elegant codebase is triggering to others, so there's probably a negative initial reaction and probably a lot of people clicking your link so they can point out why you're wrong

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

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

You might really like Ruby! It's part descended from Perl and maintains a lot of the nice things about perl such as json, and the amazing string functions.

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

#45
fs2 (reactive streaming, https://github.com/typelevel/fs2) written in Scala. It shows how nicely things can compose in a typesafe way if the language supports it.

And then, the opposite is Monix (https://monix.io/) also written in Scala. It's also about reactive streaming and the API is great, but the internal code is ugly because it sacrifices readability/composability for performance.

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

#46
mentioned in this thread:

C

* Lua https://www.lua.org/source/

* Redis https://github.com/redis/redis (mentioned twice)

* Ruby https://github.com/ruby/ruby

* SQLite https://sqlite.org/src/dir?ci=trunk

C++

* Botan https://github.com/randombit/botan

* ClickHouse https://github.com/ClickHouse/ClickHouse

Go

* Go's standard library https://cs.opensource.google/go/go

* HashiCorp repos, particular those by Mitchell https://github.com/hashicorp

F#

* jet.com repos https://github.com/jet?language=f%23

Haskell

* Elm compiler https://github.com/elm/compiler

Lisp

* CL-PPCRE https://github.com/edicl/cl-ppcre/

* Mezzano USB driver https://github.com/froggey/Mezzano/blob/master/drivers/usb/m...

PHP

* Carbon https://github.com/briannesbitt/Carbon

* Laravel https://github.com/laravel/laravel

Python

* pytudes (notebooks) https://github.com/norvig/pytudes

R

* sf (ex of functional OOP) https://github.com/r-spatial/sf

Ruby

* Sequel https://github.com/jeremyevans/sequel/

* Sidekiq https://github.com/sidekiq/sidekiq

Rust

* ripgrep https://github.com/BurntSushi/ripgrep

Scala

* fs2 (ex of good type safety) https://github.com/typelevel/fs2

* monix (ex of ugly code with great performance) https://github.com/monix/monix

TypeScript

* GitHub Desktop (ex of SPA) https://github.com/desktop/desktop

---

thanks to: cejast, bb86754, wewxjfq, antonyt, bit, diego_moita, agjmills, freedomben, Contortion, valenterry, DethNinja, mberning, seneca

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

#47
post #15
post #9

Earlier quoted context omitted.

To me, "anti-pattern" has the same bogus meaning as "clean code"

Although at a high level many of things things are subjective, this take is almost entirely wrong in every dimension. Anti-patterns are things like using a wrong data structure, using the wrong levels of abstractions, tightly coupling components so they are not composable, leaky interfaces, god objects doing too much The strict definitions of many of these can be subjective at the edges, but they all objectively exis…

This is a solid argument, thanks for taking the time to write this out!

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

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

> universal API for all databases

Go has this too, very handy:

https://godocs.io/database/sql

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

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

> Compare to Python, where you need to import a different module and use a different API for every different kind of database.

You... don't. Python has a unified DB api (DBAPI 2.0) which drivers usually support. They often also provide a lower-level API specific to the DB.

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

#50
C++

An old one, but the FTGL library (renders truetype fonts in old-school OpenGL in half a dozen different ways: texture-per-letter, texture-per-word, 2D polygons, 3D polygons, etc) is the best example of C++ inheritance I've ever run across. The code formatting isn't my favorite, and comments are sparse, but the hierarchy of objects subclassed for all the different rendering modes is just about perfect. https://sourceforge.net/p/ftgl/code/HEAD/tree/trunk/

Perl

The Mojolicious / Mojo toolkit. Great minimalist API and great documentation and clean code all around. https://metacpan.org/release/SRI/Mojolicious-9.33/view/lib/M...

Post reply on HN