Live data from Hacker News

Why I went from Python to Go (and not node.js)

orel.li

41–50 of 202 posts

Re: Why I went from Python to Go (and not node.js)

#41
post #20

Another gonatic? I'm immediately reminded of the days when everyone who liked D proclaimed it would overtake C++ and rule the world with terrible, contrived examples: "let me show you why my language is better than yours by completely misunderstanding how to solve a problem, then implementing that broken/overengineered solution in your language, then compare it to something my language's API can do for me, just so we…

>The insight to async I/O is that this server, for this I/O bound task, will perform as well as your GOMAXPROCS example: Will it? Luvit, which is implemented on Node's libuv outperforms Node in the trivial case because of higher lua performance (and lua->c interop performance).

I'd be interested in a more in-depth look at why this might be the case, because in JS written such that V8 will optimize properly, it's generally faster.

Re: Why I went from Python to Go (and not node.js)

#42
It would help a bit if the article included at least roughly equivalent Go code next to the Python code. The Go code is wordier, but maybe it takes less time to write because it doesn't require as many decisions (libraries etc.) as with Python.

        package main;

        import (
                "fmt"
                "net"
        )

        func main() {
                hosts := []string { "www.google.com", "www.example.com", "www.python.org" }
                c := make(chan string)
                for _, h := range(hosts) {
                        go get_ip(h, c)
                }
                for i := 0; i "
                        return
                }
                c 

Re: Why I went from Python to Go (and not node.js)

#43
post #24
post #21

Dimissing Erlang and Haskell with a wave of the hand, while seriously considering node.js? Carry on, nothing to see here.

ah, so, I don't think I wrote that section particularly well. I hold Erlang and Haskell in very high regard; I was really trying to mock my own superiority complex, which I think is fairly common in the Python community. I guess what I was really trying to get at is that Go is verymuch an industry language. Haskell I would argue against being an industry language not because it can't be used in industry; that's not a…

Actually, I loved that section. I'm one of those "grey-bearded wizards of Lisp/Haskell/whatever" but I like the idea of becoming one of the "insane Erlang programmers who are content writing sumerian cuneiform all day long." Guess I'll have to learn me some Erlang.

Re: Why I went from Python to Go (and not node.js)

#44
post #27

Earlier quoted context omitted.

You're digging in. > Haskell I would argue against being an industry language FYI, the problems the Haskell community has been working on are things like scalability, performance and safety because they're critical to industrial problems . Toy approaches don't work at the scale we operate at -- you need real computer science. You want 1,000,000 Haskell threads in your app? You've got it. Want to write numerical model…

> /me wanders back to a multi-million line Haskell codebase running systems in 25 countries, processing billions a year in financial transactions. Curious... Can't be a bank, too conservative. Hedge fund? I know Jane Street love their OCaml so functional does have a place in that world. But 25 countries? You'd have to be huge.

According to his profile, he works with/for Standard Charter Bank.

There is REAL WORK being done in Haskell! Now I just gotta find out how to get my foot in the door :)

Re: Why I went from Python to Go (and not node.js)

#45
post #17

Earlier quoted context omitted.

"For me, Go's major shortcoming is its community's lack of focus on readability as compared to Python." Can you be a bit more concrete here? Because whether you like the code styles enforced by gofmt and the compiler itself or not, Go is the most consistently readable language I've ever used (once you adapt yourself to the language). IMO, this seems like an especially odd problem for someone to have with Go.

Idiomatic Go: http://golang.org/doc/effective_go.html Idiomatic Python: http://python.net/~goodger/projects/pycon/2007/idiomatic/han... (doesn't cover a number of important things) When comparing the two, I'm not impressed with Go.

The first link, Effective Go doesn't talk about the philosophy behind idiomatic Go, like _Code like a Pythonista_ does. There is however snippets of Go code on that page, and it's fairly reminiscent of C/C++. I don't really see that as a drawback, for I believe C code is fairly readable for what it offers (speed.) Go likeness to C doesn't offend me one bit, considering the power and speed it offers versus C.

Re: Why I went from Python to Go (and not node.js)

#46
post #27

Earlier quoted context omitted.

You're digging in. > Haskell I would argue against being an industry language FYI, the problems the Haskell community has been working on are things like scalability, performance and safety because they're critical to industrial problems . Toy approaches don't work at the scale we operate at -- you need real computer science. You want 1,000,000 Haskell threads in your app? You've got it. Want to write numerical model…

> /me wanders back to a multi-million line Haskell codebase running systems in 25 countries, processing billions a year in financial transactions. Curious... Can't be a bank, too conservative. Hedge fund? I know Jane Street love their OCaml so functional does have a place in that world. But 25 countries? You'd have to be huge.

Can't be a bank, too conservative

I know two large international banks that have significant Haskell codebases. I don't know where you get the idea that banks are too conservative.

Re: Why I went from Python to Go (and not node.js)

#47
post #15

"As a Django developer, there wasn’t a straightforward and obvious way to just do things in the background on a page request. People suggested I try Celery, but I didn’t like that option at all. A distributed task queue? What? I just want to do something in the background without making the user wait; I don’t need some super comprehensive ultimate computing machine. The whole notion that I would need to set up and co…

I just want to do something in the background without making the user wait

What's more, the strategy of just spawning a thread to do with async processing doesn't scale. Once you hit the limit of requests that a machine can process, you'll need a distributed work queue anyway. Or do Go coroutines run through some sort of managed execution queue?

Re: Why I went from Python to Go (and not node.js)

#48
post #35
post #20

Another gonatic? I'm immediately reminded of the days when everyone who liked D proclaimed it would overtake C++ and rule the world with terrible, contrived examples: "let me show you why my language is better than yours by completely misunderstanding how to solve a problem, then implementing that broken/overengineered solution in your language, then compare it to something my language's API can do for me, just so we…

People please .. stop the four line code comparisons. Write something serious instead and then see how it compares. Like for example show me how to suspend the HTTP request and wake it up later when you receive a message back from some long running process. Or simpler: show me how to start a long running async task from a request handler.

I do believe that's what I said. The comparisons the OP gave aren't useful because the trivial example does not require parallelism, so it amounts to little more than complaining about the lack of features in Node. I'd like to see some nontrivial case studies as well.

Re: Why I went from Python to Go (and not node.js)

#49
post #41

Earlier quoted context omitted.

>The insight to async I/O is that this server, for this I/O bound task, will perform as well as your GOMAXPROCS example: Will it? Luvit, which is implemented on Node's libuv outperforms Node in the trivial case because of higher lua performance (and lua->c interop performance).

I'd be interested in a more in-depth look at why this might be the case, because in JS written such that V8 will optimize properly, it's generally faster.

IIRC, you can't tell v8 to keep memory in the same place (it can and does move things around as part of its gc).. this complicates sending strings to the socket, so you have to make a copy from the v8 world to some other world before initiating the async write.. i believe (suspect?) that lua does not have this limitation, so the extra work involved is not necessary.. this is based on old, vague notions so I may be off my rocker, but it is the best of my understanding. I would love a detailed look.

Re: Why I went from Python to Go (and not node.js)

#50
post #36
post #15

"As a Django developer, there wasn’t a straightforward and obvious way to just do things in the background on a page request. People suggested I try Celery, but I didn’t like that option at all. A distributed task queue? What? I just want to do something in the background without making the user wait; I don’t need some super comprehensive ultimate computing machine. The whole notion that I would need to set up and co…

well, the complaint isn't entirely that it's hard, per se, but that there are many different ways to do things concurrently in Python, and that it presents too many choices to be made for the novice programmer. In Go, you just say `go myfunction()` and you're done. There's a lot of value in that.

Note that Celery isn't just about what you describe here. A distributed task queue is beneficial in Go (or node.js) too. Async is one thing, distribution is another. Also web servers are often volatile environments (e.g. for tasks that must complete).
Post reply on HN