News for hackers. Stuff that matters.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by grovulent on Tuesday November 16, 2010 @10:37PM (#1912784)
Having picked up python as my first programming language earlier this year I am always really surprised to hear how so many programmers hate the indentation.

I don't ever have indentation errors - or if I do, they aren't ever of a sort that pyscripter can't spot them.

Must be a what-you're-used-to thing...

Re:In praise of Go or "Why I moved from Python and C++ to Go" by FraaJad on Tuesday November 16, 2010 @10:41PM (#1912795)
"So the danger to paste stuff at the wrong indent level is far less than in Python. "

I would argue that this is actually a feature of the language. This "danger" actually forces the programmer to read through the code he is pasting by indenting.

Also, how many pairs of source code fragments share the same variable names? This argument is quite shallow.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by stcredzero on Tuesday November 16, 2010 @11:59PM (#1912984)
This "danger" actually forces the programmer to read through the code he is pasting by indenting.

Read through, or partly rewrite? More of the latter than the former, IMO. If you're only reading then 4 spaces is often indistinguishable from a tab.

Sounds like the "block indenting" style in Smalltalk. Kent Beck favored it because it made bad Smalltalk code look bad. (Hard to read.) I like the idea, but in reality, it's too idealistic and not nearly practical enough.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by yesimahuman on Tuesday November 16, 2010 @10:54PM (#1912828)
The biggest error I have with pasting is that the pasted code uses spaces where I use tabs. They look like the same indent level but they are not.

A good old ggVG= solves that though in vim

Re:In praise of Go or "Why I moved from Python and C++ to Go" by chunkbot on Tuesday November 16, 2010 @11:14PM (#1912880)
I use Emacs, and I can't remember the last time I manually indented a line of code. Most of my non-web programming is in Erlang, Lisp, and C. My editor does the indentation for me.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by hasenj on Tuesday November 16, 2010 @11:07PM (#1912869)
gg=G also works; one less character
Re:In praise of Go or "Why I moved from Python and C++ to Go" by Daishiman on Tuesday November 16, 2010 @11:17PM (#1912887)
:retab is your friend.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by jeberle on Wednesday November 17, 2010 @01:35AM (#1913183)
:set expandtab | retab
Re:In praise of Go or "Why I moved from Python and C++ to Go" by joe_the_user on Tuesday November 16, 2010 @11:40PM (#1912940)
I built a fairly large app with Python years ago. I was neither ecstatic with then nor did I hate it. I didn't love or hate the whitespace thing then. I managed everything so it just worked.

A couple of years ago, however, I tried to help a friend trace an error in code on an active server. It came down to rewriting the code so that it looked exactly the same as before but somehow had the right whitespace instead of the wrong whitespace.

That experience left me with the strong belief that Python's whitespace approach is totally wrong and broken. Things that break in ways that are difficult to understand I can accept. Things that break in ways that are impossible to understand as such are unacceptable.

Yes, the whitespace thing can always be fixed - except on the random server where it desperately needs fixing. Systems where symbols that are meaningful don't appear are broken - it's not that a given problem with said symbol will appear often. It's how extreme the problem is when it does appear.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by grovulent on Wednesday November 17, 2010 @12:10AM (#1913002)
I've never experienced anything like this - nor do I really understand what you mean (and nor could I without actually seeing some code).

Given this, it's impossible for me to understand your claim that the white space approach is 'totally wrong or broken'. The leap from vague example (with a sample size of one) to all encompassing abstraction is too great.

Having said that, I'm keen to ensure that I don't pursue the wrong path. I picked python because many people I respected said it was a good 'jam for beginners'. But that can't be true if it's 'totally wrong and broken'.

Care to pony up with a proper account of your position?

Re:In praise of Go or "Why I moved from Python and C++ to Go" by silentbicycle on Wednesday November 17, 2010 @12:49AM (#1913079)
I think it's a corner case.* While I don't personally care for Python anymore, I still think it's a good beginner language.

* And after debugging production issues with proprietary compilers that had almost perfectly reliable hot-code loading...that's pretty minor. Not mixing up tabs and spaces probably covers it.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by aaronblohowiak on Wednesday November 17, 2010 @12:40AM (#1913055)
It was probably a tabs vs spaces issue, leading to an oddity of a block of code at the wrong depth.

The fix is to simply accept only tabs OR spaces as valid whitespace... then again, this is one of the things that annoys me about make, but I digress..

Re:In praise of Go or "Why I moved from Python and C++ to Go" by joe_the_user on Wednesday November 17, 2010 @04:03PM (#1915739)
As I said, there are lots of fixes.

But all the fixes depend on completely controlling the environment and the code production process. They work but they add "global control" need that is a bit more extreme than other languages. This qualifies as a "weird fragility" in my mind. Considering how many other levels of any given system might have weird fragilities, why be willing to accept language that guarantees you'll need to deal with such fragility by it's very structure?

I'm sure I over-stated the problem when I first stated it ... but whenever I remember the situation, I feel the terribleness of it so I don't think it's unimportant.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by aaronblohowiak on Wednesday November 17, 2010 @04:21PM (#1915802)
I meant to suggest that the language be made in the language. Changing your process to accomodate a misfeature is not a fix, it is a work-around. We agree that this is a case where computer-enforced order is more important than programmer freedom, though you could create human processes to work around the danger that such freedom affords you.

I'm starting to get to the point of just wanting sexps everywhere...

Re:In praise of Go or "Why I moved from Python and C++ to Go" by xiongchiamiov on Wednesday November 17, 2010 @01:12AM (#1913133)
...or just use a semi-decent editor that tells you when your code is indented inconsistently.

I think we solved this problem like, 20 years ago or something.

Re:In praise of Go or "Why I moved from Python and C++ to Go" by dalke on Wednesday November 17, 2010 @04:11AM (#1913565)
Or start Python in '-t'/'-tt' mode to generate warnings/errors on inconsistent tab usage.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by silentbicycle on Wednesday November 17, 2010 @01:13AM (#1913134)
Well right, but make already had like six users, so it was too late to change. ;)
Re:In praise of Go or "Why I moved from Python and C++ to Go" by cdavid on Wednesday November 17, 2010 @12:06AM (#1912993)
I have programmed in python for almost 5 years, with medium-large (several 100kloc) projects, this has never ever been an issue. If you mix tabs/space, you can have issue, but that's nothing that any decent text editor cannot fix/highlight.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by silentbicycle on Wednesday November 17, 2010 @01:05AM (#1913111)
I don't think the indentation is a big deal. It's just a surface detail that people new to the language tend to bitch about, like all of those parens in Lisp, ; vs . in Erlang, indexing from 1 in Lua, + vs +. in OCaml, etc. Once you're using the language idiomatically, it isn't a big deal. Good semantics beat good syntax any day.
Re:In praise of Go or "Why I moved from Python and C++ to Go" by elai on Wednesday November 17, 2010 @02:10AM (#1913264)
The indentation issue is annoying when you use separate editors to edit the code and they have different indentation standards (2 space-tabs, 4-space tabs, tabstop tabs, etc). Also when you copy/paste code from another source (a website lets say) or download some other library, start editing it with your editor not realizing the tabs are different while your editing and then when trying to run it run into an indentation error. "Fix tabs" doesn't always work and it's not always evident how bad it is.