Hacker News new | ask | show | jobs
by Queue29 1390 days ago
If your goal is to minimize lines of code, sure, Python takes the cake here.

But here's a different way of looking at it: using only Python example, can you identify every way that launching that container might fail?

Now do the same with the Go example. See the difference? Folks who value looking at a piece of code and knowing what might happen - not just in the happy path but also in the error path - I think will likely appreciate the Go sample.

3 comments

The best example of Go code of "knowing what might happen" is `pv_controller.go` in kubernetes, which is commented "space shuttle style", ie: "PLEASE DO NOT ATTEMPT TO SIMPLIFY THIS CODE. KEEP THE SPACE SHUTTLE FLYING." https://github.com/kubernetes/kubernetes/blob/master/pkg/con...
In this specific example, I can't imagine how all of this exposed plumbing and error handling adds much value for the person reading or writing the code. In fairness, however, the Go code could easily be moved into function that does all of the dirty work and presents a minimal interface...which is what the Python example is doing:

https://github.com/docker/docker-py/blob/923e067dddc3d4b86e4...

Sure, but why not adding the "easy way of doing things" as well in the Go SDK? It certainly would help a lot when writing prototypes and trying things out. Later on, sure you can rely on the most robust approach (which yes, I agree, Go does seem more robust in the particular examples in the SDK page)