Live data from Hacker News

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

news.ycombinator.com

171–180 of 186 posts

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

#171
post #168

Earlier quoted context omitted.

From your repo: Respectfully, I disagree that checked exceptions are a misfeature. Java’s implementation definitely leaves a lot to be desired (inheritance doesn’t make sense for them), but otherwise checked exceptions are a better form of Result types.

Unchecked exceptions are the better version of Result type. The problem with checked exceptions is that methods throwing them force its callers to react to the even if they are irrelevant to them. In 99% of cases I don't have any JSON specific error handling, yet Jackson forces me to do a try-catch-rethrow ceremony in thpse 99% to declare I don't want to do anything specific.

That’s the not too comfortable part. But with a tiny bit of syntax sugar (say, a ! or ? that expands to a mini-try-catch block) it would be more than fine.

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

#172
post #34

Earlier quoted context omitted.

What's wrong with it?

It completely ignores the simple UI paradigm of tabs or a sidebar. You should be able to move between repos without blowing away whatever you're in the middle of. I'm forced to be in one at all times, and I can't manage multiple repos at once via a simple sidebar. It's like it takes all of the inherent arcane complexity of Git and creates a UI that is so barebones it almost mocks you for deigning to ask for a GUI.

Interesting to know, thanks!

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

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

I only looked over your code for a minute but found some stuff I would comment on in a code review.

Comment for a method says "null safe" - why not use an annotation?

A package called "util" is a code smell for me.

UrlUtils only provides two methods for URL encoding so why not name it appropriately?

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

#174
post #162
post #114

Earlier quoted context omitted.

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.

I think you just don’t realize when a given software is Java. I personally really like intellij, one might say it is “bloated” (though I hate that word), but that’s only because of indexing everything, not due to java itself. On the server front many cloud infrastructures themselves, apple servers, pretty much every top 500 company has some form of business critical infrastructure chugging along on top of the JVM hap…

Oh no, I realize what software I use is Java. Swing feels bad to use. On my workstation at least, JetBrains IDEs are slow, I haven’t used it in a long time, but Eclipse was slow, NetBeans was slow, there’s an enterprisey Java web start application I need to use at work and that’s slow. Like I said, Minecraft is the only piece of software written in Java that I enjoyed using.

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

#175
post #164

Earlier quoted context omitted.

I find it very weird that Xcode is faster than... anything, really

It may be faster than.. visual studio.

It IS faster than JetBrains, at least on my machine.

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

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

I find the Golang standard library code annoying to read and understand because of their use of single letter variables or very short abbreviations. I know some people like this but I don’t.

The single letter variable is only supposed to be used within a relatively short function or code block. They should be relatively obvious; I personally find this to work well, but I can understand where sometimes it wouldn't be clear what the author was referring to.

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

#177

Earlier quoted context omitted.

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…

I only looked over your code for a minute but found some stuff I would comment on in a code review. Comment for a method says "null safe" - why not use an annotation? A package called "util" is a code smell for me. UrlUtils only provides two methods for URL encoding so why not name it appropriately?

I’ve always heard about the “util” package code smell but usually in complex contexts that are hard to discuss.

How would you refactor this to avoid a util package or a UrlUtils class?

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

#178
post #154
post #114

Earlier quoted context omitted.

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.

Android apps are full of Java.

I was an Android user for years, iOS and most native iOS apps feel more performant and less laggy to me.

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

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

This was true for me as well until I used DBeaver (a universal database browser tool) I only realized it was java after I tried connecting to a really old server that needed me to change my ssl settings in the JRE. The user interface feels fairly snappy. DBeaver is a really fantastic tool and I don't see myself changing any time soon. It even supports making its own SSH tunnels to your database server using your local ssh agent.

I can attest that AWT and Swing were hot garbage 20 years ago, though. The cross-platform aspect worked great, but the algorithms weren't worth making cross-platform to begin with. It was basically a giant GUI ecosystem written by people with no understanding of how to implement graphics efficiently. My favorite was how they bragged about their "lightweight" visual components that don't require OS-level window objects. Except, OS window objects are part of an algorithm that tracks exposure regions and repaints it efficiently without needing to redraw the whole screen. Swing took the approach of repainting the entire application window in a back-buffer on every visual change and then copying that up to the entire application window area, even for things as small as tooltip pop-ups or menus.

I haven't checked which GUI framework DBeaver is using. I suppose it's possible that it is Swing and my workstation is just so fast these days that the inefficiency doesn't matter.

Post reply on HN