Hacker News new | ask | show | jobs
by crop_rotation 1073 days ago
The stdlib is the killer feature of go. Several times I wrote high enough performance small services/servers that people not familiar with go were astounded with (mostly the speed of writing the code and memory usage). I made many go converts this way. And I always only had to use the stdlib (many benefits when writing within a company).
1 comments

I consider the stdlib to be Go's best feature too. As a somewhat contrived example, can you name any language that lets you write a HTTP/2 TLS endpoint that computes the HMAC of a PNG file's pixels without any dependencies? And if something is still missing, it's probably in golang.org/x (which is basically stdlib)!

After that, I probably consider readability at 3am [1], defer statements, explicit error handling and fast compile time to be the most important.

[1] Readability of not just your code: being able to go-to-definition into stdlib and immediately understanding it without having to grok a million unrelated decorators/FactoryFactoryFactory/std::_Vector_iterator<std::_Vector_val<std::_Simple_types<<block>>> is incredible

Just cos I was curious and Java has a pretty good comprehensive library.

- PNG: https://docs.oracle.com/en/java/javase/14/docs/api/java.desk...

- HMAC - https://docs.oracle.com/en/java/javase/14/docs/api/java.xml....

You need Jetty for HTTP/2.

Java also has a comprehensive stdlib but the golang stdlib is designed so much better, and has a small number of simple and orthogonal concepts. (e.g io.Reader and io.Writer go a long way, compared to the 20 io interfaces in java).
Dang, If you didn't have the 2 requirement java could do it with this

https://docs.oracle.com/en/java/javase/20/docs/api/jdk.https...

I'll betcha 2 for the server comes soon.

We are now with Java 21 around the corner, and any Java EE server (nowadays Jakarta EE) framework supports HTTP/2, which is basically the Java standard library for servers.