Grumpy: Go running Python! by Google

248 comments · 92% upvoted · source · other discussions

comments

semi_colon

As someone who doesn't use Go or Python: what is the use for this?

vplatt

To run Python code as a Go compiled executable. This allows them to avoid the Python Global Interpreter Lock (which severely limits Python's scalability within a single process) and run the Python code using Go modules as if they were Python modules.

Really, unless you're Google or another Python shop interesting in moving to Go, you probably don't have a use for this.

VodkaHaze

Getting around the GIL is a huge step. Python's chief weakness is lack of parallel scalability, IMO. Most solutions around this (joblib, dask, etc.) don't feel like complete solutions. Not when, for example, in C++ or Julia you can slap a macro above a loop to make it instantly parallel.

[deleted]

It doesn't need GIL, because it offers subset of functionality that python has. It is not even capable of compiling all python standard library.

This code is for Google to move away from python. They can include python libraries in their go code and then one by one rewrite it in go.

weberc2

The only design decision that prevents it from compiling the standard library is the lack of C support. The solution is to reimplement those modules in Go or Python. Anything else that doesn't compile is due to bugs in this alpha implementation (as far as I can tell, anyway).

[deleted]

PyPy also doesn't natively support C extension and also needs GIL. C support is one of reason of GIL's existence but not the only one.

weberc2

Right, this comment was about compiling the standard library, not building a GIL-less Python.

EDIT: From what I understand, supporting C extensions and threadsafe garbage collection are the two biggest challenges to removing the GIL. This project uses Go's threadsafe garbage collector, so the latter shouldn't be a problem.

EDIT2: This page has some good information: https://wiki.python.org/moin/GlobalInterpreterLock

sultry_somnambulist

This code is for Google to move away from python. They can include python libraries in their go code and then one by one rewrite it in go.

Speaking of this, what's the general trajectory of go? Is it worth dabbling into at this point? People seem to be very divided over the language.

[deleted]

People seem to be divided, because while the language is not bad, it's nothing special (seems like the only significant thing it brings to the table is the go routines, but other languages are adding similar functionality), there's a bit of hype going on because it's backed by Google.

It also initially was trying to be marketed as a C replacement, but it is nowhere close to fit the niche that C fits. Rust seems like a language that has potential to replace C, but it is too early to say.

Go is more on level of Python, Java etc, although a bit lower level than them. Some people compared it to D, but I never used it, so can't comment. The goal of this language is to be a very simple and opinionated language, some people like that some don't.

If you are asking the question you can try and see if you like it, it has low learning curve, so it's not hard to learn it, and then you will have your opinion about it.

TankorSmash

I've heard it's got a bit of boilerplate and written to be as easy to write as possible to help with the incredible amount of new talent Google gets out of schools.

Only a rumour though.

the_birds_and_bees

Id say it's more about making it easy to read and maintain. The google code base is 2 billion+ LOC, so designing a language that eases the burden of maintaining a code base of that size seems like a sensible goal.

derraidor

There is a talk by one of the creators (Russ Cox?) stating this

[deleted]

If you like it, then do it. No reason not to.

The community is sizable and there's a ton of tooling so it's not really like you're taking a risk.

weberc2

I think so. If you have prior programming experience and a free afternoon, you should be able to start writing real (i.e., non-toy) programs. Check out http://tour.golang.org.

Go has a lot of quirks--most notably, no generics--which turn off a lot of folks. But if you want to build performant, scalable software quickly, Go is worth a look.

th3_pund1t

I think so. If you have prior programming experience and a free afternoon, you should be able to start writing real (i.e., non-toy) programs. Check out http://tour.golang.org.

Not entirely true. You should be familiar with pointer based languages like C. If you come from a python/ruby/Java experience you will spend a whole lot longer to get used to pointers.

Source: work had a hackathon. I decided to code in go. Spent a lot of time correcting my code related to pointers before it would work.

recycled_ideas

I don't know about python and ruby, but you can actually run into a lot of really weird bugs in Java if you don't have at least a cursory understanding of how pointers and references work.

The big problem that companies like Google and Facebook and the like are constantly trying to solve is that folks who know dynamic languages like Python or PHP or Ruby are a dime a dozen, but these languages really don't scale well to even ordinary enterprise scales let alone the kind of volume these companies see.

That's why we see so many transpilers and why Twitter is written in PHP even though the general industry consensus is that it's probably one of the worst non joke languages in existence.

weberc2

Python/Ruby/Java are all pointer based languages. C, C++, and Go simply have value types in addition to pointers. But yes it is important to understand the difference between pass by value and pass by copy. Fair point.

pjmlp

Regardless of what we think of Go, the language has found its killer domain.

It is the main language used to develop GNU/Linux based containers (Docker and Kubernetes) and Microsoft is a big supporter of it in VSCode, so anyone that cares about having skills in this domain should learn Go.

kalifornia_love

I'd say go ahead and start dabbling ;)

Sorry. I had to and I'm also interested in seeing people's responses to this.

[deleted]

that is a very strange thing to say