Remix.run Logo
jihadjihad a day ago

Rob Pike on why Go is indented with tabs [0]:

> How wide should the indentation be? 2 spaces? 4? 8? Something else?

> By making the indent be a tab, you get to decide the answer to that question and everyone will see code indented as wide (or not) as they prefer.

> In short, this is what the tab character is for.

0: https://groups.google.com/g/golang-nuts/c/iHGLTFalb54/m/zqMo...

throwawayqqq11 a day ago | parent | next [-]

Exactly.

Indentation != spacing.

And thats all the argument i need. I dont understand why people argue with consistent text layout for all-spaces. You can use tabs to indent and spaces to align after that, in most cases.

thih9 a day ago | parent | next [-]

> You can use tabs to indent and spaces to align after that, in most cases.

In practice this is difficult; since the characters are invisible by default, people will inevitably mix up the two. Looks like the industry standard is to give up and use spaces everywhere, unless strict and mandatory tooling exists.

Izkata a day ago | parent | next [-]

And that was (one of the reasons) why spaces won: alignment always worked.

But the new problem is linters and formatters don't understand alignment, so they always want those extra spaces removed, making a mess.

thih9 a day ago | parent [-]

> linters and formatters don't understand alignment, so they always want those extra spaces removed, making a mess.

I’m not sure what are you referring to, could you give an example?

1718627440 a day ago | parent | prev | next [-]

That's on you though, in the editors I use they are visible and not just in my default IDE.

geon a day ago | parent | prev [-]

Stop aligning stuff. I don’t even use a monospaced font.

g-b-r a day ago | parent [-]

Yeah, let's just give up on readability

geon 6 hours ago | parent [-]

Alignment does not improve readability. Indentation is crucial, alignment is asinine.

g-b-r an hour ago | parent [-]

> Alignment does not improve readability. Indentation is crucial, alignment is asinine.

What? Well aligning e.g. a long SQL statement is asinine and does not improve readability??

vbezhenar a day ago | parent | prev | next [-]

https://www.reddit.com/r/ProgrammerHumor/comments/1sq7sp/tab...

deafpolygon a day ago | parent | prev | next [-]

honestly, spaces shouldn't be used; it's a design issue- use tabs only for indentation, then the language should ideally support not having to use spaces for manual alignment.

throwawayqqq11 a day ago | parent [-]

But this depends on the identifiers you choose. Languages cant help here, or better should not.

lesuorac a day ago | parent | prev | next [-]

You use tabs to delimitate tabular data.

Unless you're trying to argue that your code is a tsv file then tabs is the wrong thing to use.

rafram a day ago | parent [-]

You use line feeds (\n) to instruct your teletype machine to feed in one more line of paper. Unless you're trying to argue that your text editor is a teletype machine, then line feeds are the wrong thing to use.

lesuorac a day ago | parent [-]

I think most people are pretty amenable to the argument that text editors are teletype machines.

Nobody cares that phone calls happen over fiber now instead of telephone lines. So, same should apply to teletype. Nobody is going to care you're reading this over fiber instead of a telephone line.

Now, people do care if they're trying to read a csv document and somebody didn't quote their commas within strings and now the values are in the wrong columns which could've been avoided by using tabs to store tabular data.

g-b-r a day ago | parent [-]

> I think most people are pretty amenable to the argument that text editors are teletype machines.

So you're ok if your text editor interprets the LFs of a Unix text file as mere line feeds, without ever going back to the beginning of the lines?

xipix a day ago | parent | prev [-]

You can't use spaces to align because you can't assume a monospaced font will always be used. You can't use tabs either for that matter. If you need structure, use the language's punctuation and line breaks.

idbehold a day ago | parent | next [-]

I can and do assume a monospaced font when using spaces to align code. Folks using variable width fonts will get what they deserve.

eviks 17 hours ago | parent | prev [-]

You can use tabs, that’s exactly their role, but only in theory since in practice elastic tab stops that would work with proportional fonts aren’t implemented anywhere in code, only word processors

vvillena a day ago | parent | prev | next [-]

Funny that the language famous for enforcing standard formatting allows freedom for this one particular thing.

suralind a day ago | parent [-]

It is standardized tho. Tab width in the editor is a preference just like the theme or a font each dev uses.

frizlab a day ago | parent | prev | next [-]

I don’t like go, but at least they got that right!

tsss a day ago | parent | prev [-]

[flagged]