News for hackers. Stuff that matters.
Re:Why I went from Python to Go (and not node.js) by ak217 on Friday September 14, 2012 @04:24PM (#4523766)
Lots of sentiment, not much substance.

Concurrency support is possible in Python, without gevent-style monkey patching (or callback madness). Have a look at concurrent.futures and http://www.dabeaz.com/coroutines/index.html. It really needs a lot more work before it's part of the language's DNA, though. Also, pypy needs much wider adoption as quickly as possible, to address the speed problems (and its STM branch holds huge potential).

For me, Go's major shortcoming is its community's lack of focus on readability as compared to Python.

Re:Why I went from Python to Go (and not node.js) by georgemcbay on Friday September 14, 2012 @04:38PM (#4523827)
"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.

Re:Why I went from Python to Go (and not node.js) by wonderzombie on Friday September 14, 2012 @05:33PM (#4524093)
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 the code light on the page, as they put it. If you're dealing with a package centered around Foo, especially methods on same, it's customary to just abbreviate it to f. That clashes with a lot of people's instincts even though, once you get used to it, it works well.

"Once you get used to it" is key -- this is true of any language with substantially new or different syntax/semantics from what a programmer is used to. All else being equal, familiarity ought to be orthogonal to merit; the mere presence of a learning curve ought not be a deal-breaker.

Anyway, Go is one of the most readable languages I've ever seen, given that it is not a scripting language. Among other things, type inference and literals make the code very clean, to the point where you can in short order read the standard library code and expect to understand it.

Re:Why I went from Python to Go (and not node.js) by dantotheman on Friday September 14, 2012 @08:16PM (#4524637)
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) by lambda on Saturday September 15, 2012 @12:00AM (#4525248)
Generally, I try not to use single letter variable names in any scope that doesn't fit into a single screen in my editor. That way, I don't need to remember what "f" means, it's right there in front of me. And I shouldn't have too many variables in that scope, so conflicts aren't all that important; if I really do, I just start using multi-letter names again.
Re:Why I went from Python to Go (and not node.js) by viscanti on Saturday September 15, 2012 @01:37PM (#4526685)
This is a good heuristic. For me, single letter variables are almost always iterators in places where space is at a premium (i.e. one line list comprehensions in python). If I'm breaking a loop out over multiple lines (which is almost always the case), I prefer a longer, more informative variable name.
Re:Why I went from Python to Go (and not node.js) by shasta on Friday September 14, 2012 @11:57PM (#4525241)
Speaking of scope issues, you're missing a paren.
Re:Why I went from Python to Go (and not node.js) by Evbn on Friday September 14, 2012 @10:18PM (#4525000)
You can look at the method signature that accepts or returns f. At worst case, you need an IDE with hover popups, or to open the functions doc page or source code.
Re:Why I went from Python to Go (and not node.js) by syaramak on Saturday September 15, 2012 @12:53AM (#4525362)
The biggest gripe I have with single-letter variable names is that they invariably require mental translation to their full names before anyone can understand how they're being used. Even for those who wrote the code in question.
Re:Why I went from Python to Go (and not node.js) by epidemian on Friday September 14, 2012 @05:05PM (#4523956)
I can't speak for @ak217, but for me Go hits a bad spot on "expressibility". Some of the nuances of static typing are mitigated a bit with features, yes, like the type inference on local variables, or the automatic interface detection (i.e. no explicit "type X implements Y"). But overall, i think the chosen type system is lacking on expressibility. Having no parametric polymorphism in a static language is a deal breaker for me at least. No way of doing type-safe parametric container types for example.
Re:Why I went from Python to Go (and not node.js) by strmpnk on Friday September 14, 2012 @05:38PM (#4524120)
It's a fair complaint. Duplicating code just for the sake of type specialization is annoying and interface{} has it's costs as well as dangers.

However, the built-in arrays, slices, and maps (which are parametrically polymorphic) seem to have covered all the cases where I need parametric types so far. Maybe I'm just lucky or haven't written enough lines of Go but it seems like an 80/20 sort of feature in the presence of the built-in maps.

Re:Why I went from Python to Go (and not node.js) by Evbn on Friday September 14, 2012 @10:19PM (#4525004)
You can use reflection to get parametricity. Python doesn't have type safe anything, so Go bests Python on that front.
Re:Why I went from Python to Go (and not node.js) by rryan on Saturday September 15, 2012 @01:43AM (#4525444)
If I'm going to be burdened by a static type system, then I expect it to do certain things for me in return. One of those things that I take as a given is that a static type system can check that my basic use of types in my program are safe.

Not being able to type-check something as simple as a container lookup is a show-stopper for me because using containers is a huge part of day-to-day programming. Static typing without parametric polymorphism is extremely retrograde -- like Java in the 90's.

I've read rsc's essays on adding parametric polymorphism to Go -- I'm not saying it's a "duh -- just add parametric polymorphism". I'm well aware of the issues -- I'm just saying that Go looks great except for this glaring exception.

Re:Why I went from Python to Go (and not node.js) by ak217 on Friday September 14, 2012 @04:54PM (#4523903)
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.

Re:Why I went from Python to Go (and not node.js) by winter_blue on Friday September 14, 2012 @05:25PM (#4524053)
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) by lambda on Saturday September 15, 2012 @12:12AM (#4525271)
What makes you unimpressed? Why do you think that Python clearly wins? Do you think that the additional type safety, namespace safety, and ease of concurrency in Go are worth nothing? Or do you just think that Python has more that outweigh that?

I know that I frequently kick myself in Python when I typo a name somewhere, and everything dies far beyond where I made the mistake because it goes along happily storing something into that typoed variable, and then when I read it later it has the wrong value, and it takes me a while to trace back and find where I made the typo.

Re:Why I went from Python to Go (and not node.js) by paul-woolcock on Saturday September 15, 2012 @11:05AM (#4526220)
This is what linting tools like pyflakes are for. Running it as a prerequisite to running the test suite means that I don't have to run all my tests just to find out that I misspelled a variable name.
Re:Why I went from Python to Go (and not node.js) by zemo on Friday September 14, 2012 @04:28PM (#4523782)
>Lots of fluff, not much substance.

that was deliberate. There has been a glut of "introduction to Go" blog posts, and the documentation for introductory Go from the Go Team is quite good, so I didn't feel the need to author another introductory post. Most of the stories about why people use Go are bigger, established companies, so I wanted to show how it was perceived by a different audience. I don't remember where I saw it, but someone talked about using Go in contrast with Java, and the overwhelming reaction was "that's cool but I'm a Python programmer, I'm curious what Python programmers think", so I was just trying to give it that angle.

>Have a look at concurrent.futures

but this is part of the problem: it's a library. Concurrency deserves language-level support. Adding concurrency at the library level is like adding an object system at the library level.

Re:Why I went from Python to Go (and not node.js) by irahul on Friday September 14, 2012 @04:54PM (#4523908)
> I don't remember where I saw it, but someone talked about using Go in contrast with Java, and the overwhelming reaction was "that's cool but I'm a Python programmer, I'm curious what Python programmers think", so I was just trying to give it that angle.

I have seen more Python/Ruby programmers interested in Go than Java or C++ programmers. Rob Pike seems to have observed it as well.

I was asked a few weeks ago, "What was the biggest surprise you encountered rolling out Go?" I knew the answer instantly: Although we expected C++ programmers to see Go as an alternative, instead most Go programmers come from languages like Python and Ruby. Very few come from C++.

http://commandcenter.blogspot.in/2012/06/less-is-exponential...

Re:Why I went from Python to Go (and not node.js) by outworlder on Friday September 14, 2012 @04:36PM (#4523816)
> but this is part of the problem: it's a library. Concurrency deserves language-level support. Adding concurrency at the library level is like adding an object system at the library level.

Which is not a problem at all. Lisp and Scheme have been doing that since forever.

Re:Why I went from Python to Go (and not node.js) by scott_s on Friday September 14, 2012 @06:50PM (#4524381)
I assume they depend on macros to do so? That changes the game. Hans Boehm has an excellent paper on this issue titled "Threads Cannot be Imlemented as a Library": http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf That paper was published in PLDI (http://dl.acm.org/citation.cfm?id=1065042).

His arguments have much to do with what the compiler doesn't know, which could potentially be solved with macros.

Re:Why I went from Python to Go (and not node.js) by pcwalton on Friday September 14, 2012 @09:17PM (#4524839)
You don't need macros to solve this problem. You can use unique types, STM, etc. to forbid the data sharing at the type level and ensure a coherent memory model.
Re:Why I went from Python to Go (and not node.js) by scott_s on Friday September 14, 2012 @09:51PM (#4524922)
The paper's position is that you can't implement threads, safely, as a library because the compiler is not aware of the concurrency. My point was that this reasoning may not hold if your language has full macros. Your suggestions will work great, but those are in the compiler, not as a library.
Re:Why I went from Python to Go (and not node.js) by pcwalton on Friday September 14, 2012 @11:46PM (#4525219)
Well, the point is that concurrency primitives don't have to be built into the language to enable libraries to write safe concurrent abstractions. Rather, the type system features that enable it can exist in the compiler as general type system features unrelated to concurrency that just so happen to be able to ensure the safety of concurrent code if used properly.
Re:Why I went from Python to Go (and not node.js) by scott_s on Saturday September 15, 2012 @06:12PM (#4527471)
I take your point, but I find it unlikely that anyone would defined the correct language semantics that would guarantee correct results under concurrency without designing for concurrency. Which is the point of Boehm's paper: your language (and its compiler) need to know about concurrency in order to get it right.
Re:Why I went from Python to Go (and not node.js) by zvrba on Saturday September 15, 2012 @02:34AM (#4525519)
But these arguments are pretty much invalid today: C++11 introduces explicit support for concurrency, and the compiler MUST be aware of it, even though it may look (on the surface) as a "library".
Re:Why I went from Python to Go (and not node.js) by scott_s on Saturday September 15, 2012 @05:02PM (#4527289)
Note that the paper's author was one of the people who defined C++'s memory model for this very reason.
Re:Why I went from Python to Go (and not node.js) by reinhardt on Friday September 14, 2012 @06:15PM (#4524271)
Their (lack of) popularity suggests that the "at all" part might be a bit too absolute.
Re:Why I went from Python to Go (and not node.js) by xyproto on Friday September 14, 2012 @06:08PM (#4524245)
Not exactly prime choices for OO programmers, though
Re:Why I went from Python to Go (and not node.js) by ak217 on Friday September 14, 2012 @04:37PM (#4523821)
> Concurrency deserves language-level support.

I absolutely agree, which is why I said it needs more work.

Re:Why I went from Python to Go (and not node.js) by jfaucett on Saturday September 15, 2012 @10:11AM (#4526094)
I wonder if parent has ever coded with Go? You have to maybe learn a new syntax (partially), but once you have its incredibly readable. for instance, encapsulation is handled by giving semantic significance to the case (upper or lower) of the first character in a variable name. So "myFunc" is local and not visible whereas "MyFunc" is publicly accessible. This and many other features make Go extremely readable for me at least, although I admit, I did have to read the docs and program some of my own projects before I really got accustomed to the syntax.
Re:Why I went from Python to Go (and not node.js) by peter_l_downs on Friday September 14, 2012 @04:27PM (#4523777)
+1 for dabeaz's coroutines presentation. It's really well done, and if you write Python daily / monthly / even yearly it's worth reading.