Hacker News new | ask | show | jobs
by jgalt212 3899 days ago
> no default parameter values

This would seriously bum me out as I find the easiest to extend the functionality of an existing Python function is to add a new parameter with a default value. This way, regardless of whether the existing code base the calls the new or old version of the function, it performs the same way as it always has.

2 comments

Since Go is statically-typed and compiled, it's much easier to refactor a function compared to Python. Change it and fix everywhere the compiler complains.
That's fine for internal functions, but a big problem when publishing any kind of interface. It's really nice to be able to extend an interface without breaking stuff or adding cruft.
true, forgot to think about that. But still potentially a lot of changes to fix, even if you are explicitly told what needs adjusting.
And this is where Go's tooling shines: https://golang.org/cmd/gofmt/

(Refactor automatically, not by hand.)

You can use variadic arguments with an interface type or a single struct parameter to get similar behavior.