August 6, 2021The good recruitment experience
August 11, 2020Handling promises in Sagas
August 11, 2020Modern Frontend Architecture Part 1: API
May 5, 2020Frontend Pattern: Route Object
May 1, 2020Frontend skills for the Web Designer
April 10, 2020Learning Frontend Path
January 26, 2020Podcasts I listen to (Jan 2020)
January 23, 2020Are you too old to start programming
January 22, 2020Use tabs not spaces
October 18, 2019Refactoring Overgrown React Components slides
October 2, 2019Book Review: Factfulness
October 1, 2019Yes, it's a good time to add TypeScript to your project
September 24, 2019Code Review – Best Practices, Guidelines & Process Insights
June 10, 2019Why I read on the iPad
March 18, 2019Software & Hardware I use
March 16, 2019Why I dont use React Router Link component
November 15, 2018Why public money software is not open source?
July 5, 2018How learning Angular made me better React developer
May 23, 2018My 12 tips how to increase your frontend coding productivity


Use tabs, not spaces!

Tabs vs spaces are the most ridiculous thing I have ever seen in IT.

There is a famous scene in Silicon Valley, where Richard says his main goal in engineering is do decrease size, so he can't stand how people can use 2 or 4 characters instead of one. It's funny, but probably not exactly valid (compression handles this).

The real problem is that some people prefer 2 spaces, some prefer 4. Also, some language just looks better with a wider indent, some are better in with shorter. I even know people who use 2 spaces in JavaScript and 4 spaces in CSS.

So people keep arguing. "4 is better because indent is more clear". "2 is better because with 4 the code growth horizontally instead vertically", "Bla Bla Bla".

Both 4 and 2 spaces are correct. Everyone is right. Everyone can have some preferences.

It just doesn't matter.

I know why people argue - when I use 4 spaces for a long time, I get used to it and I want to use 4 spaces. Others do the same. And this is the matter of preference, so we can't solve it.

This is why there are tabs

The tab is a single character, but you set its size on your local machine.

If you like 2 spaces, you set in your IDE that tab should be the size of 2 spaces.

If you like 4, you set 4. You can even set 20 if you like. Your choice will not affect others.

How about code reviews?

Indeed browsers (at least Chrome) sets the huge size of the tab which is something about 8 spaces.

Just use some Chrome Extension and you are fine.

Ask good questions

The question wasn't if you should use 2 or 4 spaces or tabs. The question is how to make people comfortable with their code style and how to make their environment local, not affecting others.

I think it's quite simple, but I don't see many people realizing that.