[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Click for more| Home]

Tabs vs. spaces

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 94
Thread images: 7

File: keebord.png (19KB, 800x227px) Image search: [iqdb] [SauceNao] [Google]
keebord.png
19KB, 800x227px
Simple question - what do you use in programming and why?
Is that tabs or spaces?
>>
Spaces are the only thing that looks consistent across editorn. Else adapt to whatever the project you're working on is using
>>
>>42899793
tabs is faster, don't give a fuck what my hobby code looks like on some other scmuck's editor
>>
>>42899793
Tabs could save a few precious kbytes, it's important if you live in the early 90s.
>>
>>42899847
Don't ever work with other people
>>
Tabs 2:1 Spaces
bump
>>
>>42899793
both
also carriage returns and line feeds
>>
set ts=2
set sw=2
set expandtab
>>
>>42899793
Tabs makes it look cleaner.
>>
>>42900192
>carriage returns and line feeds
>not only carriage return
What has this world come to
>>
>>42900201
what's this?
>>
>>42900280
The only correct way to do it.
>>
>>42900280
vim options

Spaces
>>42899847
>tabs is faster
literally every editor emulates tabs when you set it to use spaces, they're the same speed.

Spaces though because I'm an asshole and like to impose my 2 space tabs on everyone
>>
>>42900280
vim
But he's doing it wrong, it should be
set ts=4
set sw=4
set expandtab
>>
>>42900302
>Wasting all that horizontal space

Please
>>
>>42899793
Depends on the language.
>C
1 Tab à la 8 spaces.
>Go
1 Tab à la 8 spaces.
>C++
2 spaces.
>Rust
4 spaces.
>Ruby
4 spaces.
>>
>>42899793
4 spaces in Python.
Tabs in everything else.
>>
>>42900329
>not two spaces in python
don't you like danger in your life?
>>
>>42900316
Correction:
>Go
1 Tab à la 4 spaces.
>>
>>42900201
>Makefiles
>>
>>42900294
a lot of editors only emulate them on insert but not for deletion or movement
>>
>>42900345
What?
>>
>>42900334
No.
>>
>>42900334
2 spaces is too little, 4 too much

3 spaces is the sweet spot
>>
>>42900359
Most edgy shit I've read all day.
>>
>>42900329
Tabs set to 4 blocks, for every prog lang I use, mainly being C.

Fucking LEFT,LEFT,LEFT,LEFT fgts using 4 spaces. And no I refuse to use shitty shortcuts like CTRL+LEFT to jump 4 spaces, when you shouldn't be using shitty workarounds in the first place to deal with multiple space indentations.
>>
>>42900370
>edgy
fedora is the new generic insult that lost all meaning
get with the times
>>
Tabs because Documentation/CodingStyle
>>
>Everything that isn't XML
8-space tabs
>XML
4-space tabs
>>
Tabs for indentation
Spaces for alignment
>>
>>42900345
Fuck Makefiles

But it's not like you can't just "set noexpandtab" for when you need to.
>>
>>42900378
*tops fedora*
>>
>>42900390
>>42900345
Nobody mentioned makefiles...

Makefiles are nice.
>>
>>42900402
Nigga just create a makefile.sh, chmod +x
Do whatever the fuck you want and clean afterward
>>
I set tab as 2 spaces in my editor... faggots it's the only truly bestest way to nirv_fucking_vana!
>>
Tabs.

Single keystroke per indent.

Obvious how much a line is indented, e.g. can't mistake 4 spaces for 5 ( which is the argument behind double space indenting ).
>>
>>42900411
What would some shitty, non-portable shell script do that a simple makefile can't?
CC = gcc
CFLAGS = -c -Wall -O2
CPPFLAGS =
LDFLAGS = -pthread
SOURCES = $(wildcard src/*.c)
OBJECTS = $(SOURCES:.c=.o)
EXECUTABLE = program

all: $(SOURCES) $(EXECUTABLE)

debug: CFLAGS += -g -Wextra
debug: CPPFLAGS += -DENABLE_DEBUG
debug: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
@echo " LD [email protected]"
@$(CC) $(OBJECTS) -o [email protected] $(LDFLAGS)

.c.o:
@echo " CC [email protected]"
@$(CC) $(CFLAGS) $(CPPFLAGS) $< -o [email protected]

clean:
@rm -f $(OBJECTS) $(EXECUTABLE)
>>
>not knowing the power of set autoindent
All those wasted keystrokes, geez, it's like you don't care about your career
>>
>>42900445
Makefile are in the public subconscious as a medium step in autotools. People don't realized they existed previously to it and can be use to script common actions on a project.
>>
File: gcc_sm.png (123KB, 550x470px) Image search: [iqdb] [SauceNao] [Google]
gcc_sm.png
123KB, 550x470px
>>42900445
>using a deprecated compiler
>>
>>42899793
my editor is configured to insert spaces when i press tab
>>
File: RAG3.png (19KB, 300x309px) Image search: [iqdb] [SauceNao] [Google]
RAG3.png
19KB, 300x309px
>ITT FUCKING IDIOTS THINKING 4 SPACES MEANS HITTING THE SPACE KEY 4 TIMES
>JESUS FUCKING CHRIST
>USE A FUKIN PROPER EDITOR THAT REMOVES 4 SPACES WHEN YOU HIT BACKSPACE ON IT
>4 SPACES IS THE STANDARD FOR CONSISTENCY ACROSS ALL EDITORS AND MACHINES REGARDLESS OF YOUR DIP SHIT SKIN COLOUR!!
>>
>>42900506
I've missed you, anon.
Why don't you make threads anymore?

I have clang installed...
>>
>>42900506
I think reload.c is a C programming gem.
>>
File: 1361104212788.gif (58KB, 752x752px) Image search: [iqdb] [SauceNao] [Google]
1361104212788.gif
58KB, 752x752px
>>42900294
>2 space tabs
>>
File: 1371496736567.jpg (104KB, 680x680px) Image search: [iqdb] [SauceNao] [Google]
1371496736567.jpg
104KB, 680x680px
>>42900521
>wasting space on 4 characters, when you can use 1
>>
>>42900542
>inb4 MUH GIGAHARDDRIVES
>>
>>42900528
Step it up.
https://archive.rebeccablacktech.com/g/thread/S42882540
>>
>>42900556
Oh yeah, I forgot about that thread.

It used to happen every 3 days or so.
>>
How are you people using an IDE where you can't set up the tab key to produce space characters?

Filling your code with tab characters, actual characters of the character code 9, is a sin. Just make your tab key produce 2, or 4, spaces.
>>
>>42900592
>Filling your code with tab characters, actual characters of the character code 9, is a sin.
*tips fedora*
>>
>>42900592
>How are you people using an IDE where you can't set up the tab key to produce space characters?
I use VIM. It can do that, but I choose not to.

>Filling your code with tab characters, actual characters of the character code 9, is a sin
No. Filling source code files with fuck loads of unnecessary spaces is a sin.
>>
>>42900592
>sin
keep your religion out of my source code
>>
Using tabs solely for indentation is just more semantic; You encounter a tab character, you know this is a indent. If you use space for it too, it could be indent but also alignment or other formatting.
>>
ITT: bikeshedding.
>>
File: terriADavis.jpg (76KB, 500x335px) Image search: [iqdb] [SauceNao] [Google]
terriADavis.jpg
76KB, 500x335px
>>42900663
>>
>>42900688
>bike
>>>/n/
>>
with tabs everyone can set his preferred tabwidth and I won't have to pry my eyes out if some retard thinks he has to indent by 6 spaces or something retarded like that.
>>
I use tabs.
>>
>>42899822
Use tabs to indent code. Use tabs and spaces exceptionally to visually align blocks of characters.
>>
>>42900688
But anon, indenting style is FAR more important than actual source code.
For this very reason, I program with nothing but Whitespace.
>>
Hey guys, some of you said
>use tabs for x and spaces for y
but what about not mixing this two elements in one source code?
I heard it's bad practice, why?
>>
>>42900759
>https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29
Hardcore.
>>
>>42900759
>>42900688
>stop arguing about unimportant shit

why are you even on /g/?
>>
>>42900759
Fucking Stroustrup refused to make the whitespace operator overloadable in C++.
>>
File: thisDeviant.jpg (8KB, 223x218px) Image search: [iqdb] [SauceNao] [Google]
thisDeviant.jpg
8KB, 223x218px
>>42900345
>>
>>42899863

Tabs don't save shit after you compile.
>>
>>42900344
Also gofmt
>>
>>42900788
top jej
>>
>>42900792
top heh
>>
>>42900804
>>42900792
top meh
>>
>>42900810

I think the next logical step was, top geg, but thanks for playing.
>>
>>42899793
Tabs (4 spaces) for indentation then spaces for any alignment, because anything else is wrong.
>>
>>42900316
>>Ruby
>4 spaces.
>>
3.9 spaces masterrace
>>
>>42900781
to laugh
>>
>>42900835
>Tabs (4 spaces) for indentation then spaces for any alignment, because anything else is wrong.
This is the worst of the two possible worlds. You will have a independent component that will work nice with you but also a dependent component that will mess up with your output.
>>
>>42900856
>3.9? spaces
FTFY
>>
>>42900872
No, it is the only correct way. If you set tabs to anything but 4 spaces you are the same kind of person that uses non-monospaced fonts.
>>
>>42900908
>setting tabs to 4 spaces
[fedora intensifies]
>>
Ruby and Coffeescript - Soft tab
Everything else - Smart tab (Hard tab indent, soft tab alignment)
>>
>>42900917
Whenever you feel like eating a jam sandwich, I bet you use one slice of bread with jam on both sides.
>>
>>42900932
>not maximizing the amount of jam on the slice
>>
>>42900932
I put jam on all 6 sides
>>
>>42900932
???
>>
>>42900941
Because you apparently enjoy doing things the horrible and wrong way rather than the wonderful and correct way.
>>
>>42900955
>horrible and wrong way
that's fun
>wonderful and correct way
that's boring
>>
>>42900955
You could have come up with a far better and more clear analogy than that.
I bet you were just eating a sandwich at the time.
>>
>>42900955
Atheists eat jam sandwiches.
>>
>>42900974
That's the difference between us. My keyboard is clean while yours is covered in jam. Wrong opinion: Not even once.
>>
Raspberry jam is best jam.

Plum jam is worst jam.
>>
>>42900977
But if athiests is an anagram for eat shits, umena

> `eat shits` eats jam sandwiches
>>
>>42901106
where did you get that extra space from?
>>
>>42901136
I saved it by using tabs instead of spaces.
Thread posts: 94
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.