Live data from Hacker News

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

orel.li

91–100 of 202 posts

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

#91
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…

Erlang is intimidating? How? It's a braindead simple language.

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

#92
post #38

Earlier quoted context omitted.

The perception out there is that Haskell is an academic language, also that it is a "difficult" language. This is not fair on Haskell but that is what people think and that really is the issue that Haskell has to overcome.

Honestly, I find Go more difficult than Haskell

After you've learned both, maybe.

But that is beside the point. Haskell is more difficult to learn.

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

#93
post #27
post #24

Earlier quoted context omitted.

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…

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.

Hope the codebase runs well, because that's the bank I use in Singapore ;-)

Has you/anyone written something about how Haskell got picked for the task by that particular bank? Is the language used at other financial type businesses? I've heard some firms use Ocaml.

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

#94
post #56
post #14

Earlier quoted context omitted.

Not only that, but there's a multiprocess Queue class as well that is a drop in replacement for the threaded one. So if you are having problems with GIL contention (unlikely, but possible), you can still just as easily use multiple processes.

Exactly what I thought - "what about multiprocessing?" Doesn't that count as language-level concurrency support? You can fire off a background job to send email or whatever just as easily as in the Go example.

This confused me as well, it felt like the author was thinking about the problem space all wrong. As soon as I read

"As a Django developer, there wasn’t a straightforward and obvious way to just do things in the background on a page request"

I started thinking, "um, django produces http responses, you can only respond once...".

Clearly, from his gevents example, he's looking to do things that take time, and wants to do them as concurrently as possible, then send the whole response at once. But if he really doesn't want the user to wait, then this is not something you should be doing in a webserver anyways. You really should be building that into the front end javascript, and let it handle all the async data grabs from small, fast, cacheable web requests, then redraw the page as the data comes in.

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

#95

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.

Agreed. I think we, as a profession, have a tendency to focus on what's "easy" (syntax and constructs we're already familiar with) to the exclusion of other, potentially more important factors. I am and have been guilty of this myself, so I'm not claiming any sort of sainthood, just making an observation. Often people pick on the use of single-letter variable names as "unreadable." This is mostly a matter of keeping…

I think the issue with single-letter variables goes deeper than it just being unreadable (although its that too for someone that isn't "used to it").

For example there are issues with scope (what happens when I need a second or third "f" variable" and maintainability too (6 months from now I have to remember if "f" stands for "foo" or "file").

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

#96
post #65

Earlier quoted context omitted.

I recommend starting with http://tour.golang.org/#1 . Yes, the Go tool comes with package-management capabilities. "go get labix.org/v2/mgo" will download the very excellent MongoDB driver mgo, for example.

But then actually implementing something useful is cryptic and obscure. I tried figuring out how to connect to a postgresql server following the spaghetti documentation of https://github.com/bmizerany/pq and http://golang.org/pkg/database/sql/ and have yet to find anything useful. Hacking around only leaves me with frustration. Searching around only leads me to unhelpful descriptions of what the GO command does in MS…

Seriously? What is "cryptic" about db = sql.Open(...); db.Exec(); db.Query(); db.Close() etc.?

From https://github.com/bmizerany/pq/blob/master/conn_test.go:

  func TestExec(t *testing.T) {
	db := openTestConn(t)
	defer db.Close()

	_, err := db.Exec("CREATE TEMP TABLE temp (a int)")
	if err != nil {
		t.Fatal(err)
	}

	r, err := db.Exec("INSERT INTO temp VALUES (1)")
	if err != nil {
		t.Fatal(err)
	}
What is it exactly that you tried and failed? Because looking at conn_test.go the API is dead simple and pretty much like any other db API of this kind.

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

#97
post #70

Ah, code comparisons. I don't see much difference in the Go code vs Javascript, except for the extra comments and logging in the js. How about this? var cluster = require('cluster') , http = require('http') , os = require('os') if (cluster.isMaster) { os.cpus().forEach(cluster.fork) } else { http.createServer(function(req, res){ res.writeHead(200) res.end('Hello world') }).listen(8000) }

You should update the node.js docs if you consider the original JS snippet ugly, because that's where I pulled the original code sample from verbatim. In any case, it's still not an apples to apples comparison. The node.js example forks separate processes that share nothing, while in the Go example it all runs in one process so the HTTP handlers can communicate with each other via channels or other shared data struct…

The idea with node is that you dont normally need multiple threads or processes because you have nonblocking io.

    http = require 'http'
    server = http.createServer 'localhost', (req, res) ->
      res.writeHead 200
      res.end 'ok'
    app = server.listen 3000

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

#98
post #90

"... as a Python programmer, I was the member of an elite cabal of superhuman ultranerds, smarter than those childish Rails/JavaScript/PHP/whatever developers that couldn’t write a bubble sort or comprehend even basic algorithmic complexity, but more in touch with reality than the grey-bearded wizards of Lisp/Haskell/whatever that sat in their caves/towers/whatever solving contrived, nonexistent problems for people t…

"Everyone less nerdy than me is stupid and everyone more nerdy than my is a no-life". I think it's pathetic, not funny.

That was the joke.

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

#99
post #90

"... as a Python programmer, I was the member of an elite cabal of superhuman ultranerds, smarter than those childish Rails/JavaScript/PHP/whatever developers that couldn’t write a bubble sort or comprehend even basic algorithmic complexity, but more in touch with reality than the grey-bearded wizards of Lisp/Haskell/whatever that sat in their caves/towers/whatever solving contrived, nonexistent problems for people t…

"Everyone less nerdy than me is stupid and everyone more nerdy than my is a no-life". I think it's pathetic, not funny.

It's actually kind of bizarre that so many Pythonistas actually have the kind of attitude that the article mocks, since Python is a thoroughly mediocre language. I can only attribute their patronizing disposition to a lack of genuine awareness of the broader programming world.

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

#100
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…

Celery is one of the easiest things to set up. It really doesn't get much simpler. Your configuration is living in your django project as python source code, and `celeryd` is no-fuss.
Post reply on HN