Live data from Hacker News

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

news.ycombinator.com

61–70 of 186 posts

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

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

Speaking for myself, the language itself is simple. There aren't a lot of features, which means you do have to write more and it's more verbose, but learning the entirety of the language's features is very easy to do.

Even with the relative magic of things like init functions that execute on import, there's so much less magic that you have to consider.

IMO it's the easiest to jump into for this reason. Yes, the code itself might be excessive, but reading Go is as simple as can be.

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

#62
post #10

At the beginning of the year I was rewriting a SPA and looking for ideas on how to structure a web app. One project I looked at was Github Desktop and I think it has very clean code for an app. https://github.com/desktop/desktop

Thanks for recommending this, I just browsed some files online and it's looking indeed amazing.

P.S. It's now easy to check a repo file by replace .com with .dev: https://github.dev/desktop/desktop

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

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

I love Go. I think it depends on what trajectory you followed to reach to Go or any other language. For me it was

BASIC -> VB -> Java -> Python for some time -> Go

How you feel about Go is how I feel about JavaScript

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

#64

Anyone have any good clojure examples?

I try not to toot my own horn, but I wrote this little quadtree library that tickles that elegance part of my brain. I try very hard to write elegant code. I have other Clojure repos, but they suck. :P

https://github.com/janetacarr/quadtree-cljc

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

#66
post #10

At the beginning of the year I was rewriting a SPA and looking for ideas on how to structure a web app. One project I looked at was Github Desktop and I think it has very clean code for an app. https://github.com/desktop/desktop

Thanks for recommending this, I just browsed some files online and it's looking indeed amazing. P.S. It's now easy to check a repo file by replace .com with .dev: https://github.dev/desktop/desktop

You can also just click the . (period) key when viewing any repo.

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

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

It’s the complete lack of magic. What you see in front of you is pretty much exactly what happens. You don’t have to keep a cathedral of language semantic subtleties in your head when reading someone else’s code.

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

#68
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.

I tried very hard to like Ruby. "On paper" it looks great, but I had a lot of trouble getting used to the syntax.

I ended up going deep on the D programming language for my "new language". As a statically typed language it's not as expressive as the Python/Ruby/Perl contingent, but it's a lot more expressive than most static languages, and its C-like syntax "clicked" with me in a way Ruby never did.

It also can approach C-like run-time performance and memory footprint at times, which I appreciate. As much as I like developing in Python and Perl, I frequently wish they had better run-time performance and a smaller memory footprint. D gives me that, at the cost of a little expressiveness.

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

#69
post #67

Earlier quoted context omitted.

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…

It’s the complete lack of magic. What you see in front of you is pretty much exactly what happens. You don’t have to keep a cathedral of language semantic subtleties in your head when reading someone else’s code.

Then why don’t we go back to assembly? There is even less magic there, every line is trivial to understand, isn’t it?
Post reply on HN