Live data from Hacker News

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

news.ycombinator.com

181–186 of 186 posts

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

#181
post #136

Earlier quoted context omitted.

Try JetBrains Rider, and be sure you are using a recent flavor of dotnet. When I migrated past 4.x to 6 of the .Net ecosystem, it dramatically improved my ability to work and deploy in C# with their rather delightful build system. For example, in the Monogame game library, you can build a self contained binary for Windows, Linux or MacOSX nearly effortlessly with just a single command line.

But these executables are quite huge, are they not?

Could it be any worse than an Electron application?

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

#182
post #171

Earlier quoted context omitted.

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.

Yes, I would be fine with a shorthand syntax like that. But it's not available which makes checked exceptions more trouble than worth.

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

#183
post #137

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…

As much of a fan as I am of Java, I have to agree. There are some real bombshells in the library that can either make your coding life or debugging a prod service miserable (sometimes both). Other additions are great, but have hurt readability a bit (i.e. Java lambdas). Checked exceptions get a bad rep, but I've frequently found taking advantage of their hierarchical nature can be beneficial to at least making them l…

As much as "not" a big fan of java, I need to give credit where it is due.. as my (almost) first language almost 25 years ago I learnt heaps by going through the source code. Sure there were bad and (what are now) outdated conventions etc. But as a junior eng learning how layouts worked, how data structures were implemented, how network code was written and tons more, the Java src folder was a huge treasure mine. Did I mention swing?

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

#186

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…

That’s because it is easy to use. Maybe you use too much python or Java but go was designed to specifically allow people to memorize the entire syntax, truly. Want to make a function or variable or field public? Just capitalize it. That’s it. Error handling? Check if the error isn’t nil and handle it, otherwise move on. No need for silly things like try except. And there are no magic functions because everything is e…

Try except isn't silly it shortens the code a lot. An exception can simply break out of a function, checking for error requires an explicit check at every line of the function and an added return statement to get out of the function.
Post reply on HN