News for hackers. Stuff that matters.
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.