Live data from Hacker News

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

news.ycombinator.com

31–40 of 186 posts

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

#32
post #18

[dead]

A great example of how NOT to write Java. You say absolutely nothing with a whole lot of extra words.

For example: //============================================================== // Ajqvue Constructor //==============================================================

   public Ajqvue()
The constructor definition is already clear, I don’t need a big header telling me what a constructor is.

Instead, use comments generously where needed - for example, if you have a piece of business logic, a comment explaining the intent behind it can help the maintainer (likely you) a year down the road. What I mean by this, is that what your code DOES should be self evident - but documenting the business decision behind the implementation has done wonders for me.

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

#33
post #18

[dead]

The getWebsite method comment says it returns the version. That's an example of how not to comment - totally pointless and misleading if it diverges from the code. The code is nice and clear without the comments.

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

#34
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

Now if only GitHub desktops actual UI/UX wasn't a poorly thought out mess of anti-patterns and anti-design.

What's wrong with it?

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

#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 across something new. It's very frustrating to use.

Perl's DBI provides a universal API for all databases, with implementation-specific details in an underlying DBD module (which both provides glue between the DBI abstraction and programmer access to features specific to different database systems).

Compare to Python, where you need to import a different module and use a different API for every different kind of database. As I increasingly use Python for a living, I frequently wish they'd follow Perl's example with this.

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

#36
post #12
post #9

Earlier quoted context omitted.

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

That's an interesting take! I'm still early in my career and I ask with genuine curiosity, but why do you think "clean code" has a bogus meaning?

I suggest you read malux85's comment: https://news.ycombinator.com/item?id=36371733

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

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

Ruby, being a Perl-inspired language, has `.to_json` built in. You can do

```rb

   # hashes
   { foo: 'bar' }.to_json
   
   # numbers
   28.to_json

   # anything really
   ['hello', 42, { lorem: "ipsum" }].to_json
```

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

#40
post #29
post #12

Earlier quoted context omitted.

That's an interesting take! I'm still early in my career and I ask with genuine curiosity, but why do you think "clean code" has a bogus meaning?

Not the OP, but clean code misses the point. Its is very subjective and depends on one person's previous experience and patterns they've been exposed to. "Reasonably readable" is what I strive for nowadays, and a key aspect is that I no longer think there is an objective measure for it. It depends on the team/company you're in, and its important to keep in mind that the goal is to effectively communicate the program…

[deleted]
Post reply on HN