Live data from Hacker News

Tabs or spaces – Parsing a 1B files among 14 programming languages

medium.com

111–120 of 124 posts

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#111
post #34

I find it interesting that C++ using the .cc extension has about 7% tabs, whereas C++ using the .cpp extension has about 36% tabs. I wonder what else is different about these two groups.

Well, one correlation is that Google's coding style for C++ uses spaces and the .cc extension. It stands to reason that some fraction of Google alumni would continue to use both practices in their own work. I don't know if its enough to push a 36% tab usage to 7%, but might account for a solid fraction thereof.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#112

Earlier quoted context omitted.

That's also hazardous when you later add an_even_longer_variable and then have to modify three extra lines to make them align.

Exactly. To be fair, I believe most popular editors have plugins/shortcuts to do this. Or at least I hope people aren't doing this manually.

But if anyone looks at a diff, it looks like all the lines have changed, instead of just one, taking just a tiny bit more cognitive overhead.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#113
post #91

Neither! http://nickgravgaard.com/elastic-tabstops/ “ A better way to indent and align code ” When I saw this, it was obvious to me that this was the true solution to the problem which both space and tab proponents try to solve.

Essentially, this is suggesting to implement in text editors what word processors have done for almost forever, with some additional automation.

It's sad that this hasn't seen any traction in the past 10(!) years. It seems so much better than the current mess.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#115
post #12

After 20+ years of listening to the tabs-vs-spaces debate and considering all the legitimate points that both sides have, many have made the following observation and it's what resonates with me the most: In an ideal perfect world, _all_ of programmers and _all_ text editor tools would use tabs specifically for indentation and spaces specifically for alignment. But, we don't live in that perfectly coordinated world s…

Personally, I don't find the value in alignment - indentation is all I do. I especially dislike alignment of this sort: var a_variable = 1; var another_variable = 2; var yet_another_variable = 3; which is just too fiddlesome and in fact makes it _harder_ for me to read.

That's what code formatting tools (cncrustify, clang-format, etc) were built to fix - let the computer have perfect and consistent formatting, you just need to record your intention.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#116

Earlier quoted context omitted.

Exactly. To be fair, I believe most popular editors have plugins/shortcuts to do this. Or at least I hope people aren't doing this manually.

But if anyone looks at a diff, it looks like all the lines have changed, instead of just one, taking just a tiny bit more cognitive overhead.

`git diff -w`

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#117
post #100
post #98

Earlier quoted context omitted.

That particular form of formatting is part of Python's PEP-8, which has tooling around it. Maybe not all editors have something built it, though.

Editor is one thing and most fully featured editors probably have an indent mode like this. Then there's all the other tools, like diff/merge tools, automatic refactoring scripts, etc which don't work as well. I'm not a fan of Python's significant whitespace or PEP-8 in the first place. It puts too much emphasis on aesthetics at the cost of practicality. Writing a parser or any tooling for that is just a pain in the…

I disagree. I moved form Perl to Python and disliked the whitespace to begin with. It does solve a couple of problems - it forces inexperienced coders to indent properly (I had one colleague who didn't when she used Perl). It also solves the missing brace problem when moving blocks of code around, which for me makes it worthwhile. It does make moving blocks around and commenting sections out a bit more effort, but way less effort than trying to work out where the brace has gone.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#118
post #12

After 20+ years of listening to the tabs-vs-spaces debate and considering all the legitimate points that both sides have, many have made the following observation and it's what resonates with me the most: In an ideal perfect world, _all_ of programmers and _all_ text editor tools would use tabs specifically for indentation and spaces specifically for alignment. But, we don't live in that perfectly coordinated world s…

Personally, I don't find the value in alignment - indentation is all I do. I especially dislike alignment of this sort: var a_variable = 1; var another_variable = 2; var yet_another_variable = 3; which is just too fiddlesome and in fact makes it _harder_ for me to read.

There's different kind of alignment, the one you get from breaking too long line.

  // some code
  // ...
  var some_call_result = some_object.a_method(with, quite_long, list_of,
                                              parameters)
In the second line you get indent (up to `var' keyword level), and then alignment. The former would be fine with tabs, but the latter must be spaces.

Unfortunately there's no editor that deals with tabs in this situation correctly, which means spaces is the only way to go.

Re: Tabs or spaces – Parsing a 1B files among 14 programming languages

#120
post #91

Neither! http://nickgravgaard.com/elastic-tabstops/ “ A better way to indent and align code ” When I saw this, it was obvious to me that this was the true solution to the problem which both space and tab proponents try to solve.

I love this concept--I'd be using it daily, but last time I tried it the Sublime Text implementation was unusably slow.

Admittedly, I am pretty picky on what's unusable. Also, this page lists it as an "incorrect implementation".

Post reply on HN