Hacker News new | ask | show | jobs
by gecko 5520 days ago
I've been enjoying using Go as a C replacement when I need more performance than Python, but don't actually need to use C. It's been fine for that purpose. I would note that they do keep changing the syntax on a fairly regular basis, the libraries are still young, and I do find the language oddly unexpressive in places compared to even C++ with boost. (E.g., no ternary operator, no list comprehensions, using the same word for all loop variants, and so on.) That said, if you're using it as a C replacement, rather than a Python replacement, I think those are fine trade-offs.
2 comments

Pretty interesting. What do you think of the quote from this article http://news.ycombinator.com/item?id=2518609 http://www.theregister.co.uk/2011/05/05/google_go/print.html

"Google has people who administer apps and services, and they need to, say, write tools that say scrape a few thousand machines statuses and aggregate the data," he says. "Previously, these operations people would write these in Python, but they're finding that Go is much faster in terms of performance and time to actually write the code."

Clever marketing or could Google's problems actually be handled better by Go than Python, in time to code?

I think this may be specific to Google's situation--at least for now. PyPI may not be as comprehensive as CPAN, but it's rare these days that I can't "pip install" my way into having half the solution done before I start writing code. The same simply isn't (yet) true for Go.

Google has many custom components, though. I personally don't write Go nearly as quickly as I write Python, but I have 4+ years of writing Python in everything from tiny scripts up to large applications, both for the desktop and for the web. I have maybe twenty to forty hours of experience writing Go code, absolute tops. It's not a fair comparison. If we assume that the Googlers who are claiming to be more productive in Go than Python have a couple orders of magnitude on me, and that they don't need many prefabricated libraries, and I find the claim plausible.

I don't believe it'd currently be true in the general case, though.

In addition to your custom components point, I wonder if licensing restrictions come into play at all. I am not familiar with Google's policy on use of external code based on license of said code. If there is, hypothetically, a policy to use code for internal projects of only certain licenses, then pypi (generally) may be slightly less useful to them.

If they were re-implementing a significant amount of code then go may indeed be more productive.

They do have a policy regarding external code. It's called "third-party". Google has one big shared code-repo. Generally, the only requirement is to plop the code into the directory called "third-party" and make sure its license is clearly visible. If it's good code, yet "external", Googler's won't have a problem finding a way to use it in there projects.
Have you looked into other Python performance solutions like Cython which lets you add type declarations to Python code, and compile it into a C/C++ module?

In my tests, it produces speedups on numerics that put it within spitting distance of hand-tuned C.

Oh, no question. That's part of why Mercurial is so close to Git in terms of speed, despite Git being hyper-optimized C and Mercurial being Python. But so far, this has always come up when I'm doing one-off, or nearly one-off, stuff. Getting CPython extensions whipped up is more effort, and less fun, than writing the solution in Go.
None of that is available on the GAE, though (you cannot use custom C extensions on GAE, which includes 3rd party tools like numpy).