News for hackers. Stuff that matters.
Re:Four years of Go by shazow on Monday November 11, 2013 @05:22AM (#6710895)
One scenario I ran into is building a generic function call caching solution. Coming from Python, there tons of great libraries for memoizing and caching [0][1][2]. Even the Python 3 standard library has a simple one built in [3]. But building something similar in Golang proved to be near impossible.

I got a half-working solution [4] with a lot of interface{} and some reflection, but upon speaking with some of the Golang devs, the consensus was "this is not something you do in Go." From what I understand, you're expected to build a custom memoizing function for each set of datatypes you're expecting to use it for (which admittedly is not a ton of code), and generic helpers are not advised.

I can't say authoritatively whether "Go needs generics!" or not, but life has been much easier after porting my code back to Python—though a large part of it was because it was a fairly dynamic webapp which is still a pain point for Go. I hope to give Go another try soon, probably for a different project.

[0] https://pypi.python.org/pypi/dogpile.cache

[1] https://pypi.python.org/pypi?%3Aaction=search&term=cache&sub...

[2] https://pypi.python.org/pypi?%3Aaction=search&term=memoize&s...

[3] http://docs.python.org/dev/library/functools.html#functools....

[4] https://github.com/shazow/memoizer

There are no comments on this comment yet.