Giter Site home page Giter Site logo

Two spaces proof about code-guide HOT 16 CLOSED

mdo avatar mdo commented on July 19, 2024
Two spaces proof

from code-guide.

Comments (16)

bbertucc avatar bbertucc commented on July 19, 2024 1

@mdo - Could your syntax tab rules be simplified to "Use soft tabs—they're the only way to guarantee code renders the same in any environment." ?? The reason for "two" also confounded me when I started learning your standards. Most other style choices seem to have a practical reason beyond your initial feeling.

from code-guide.

mdo avatar mdo commented on July 19, 2024

I don't mean to sound dick-ish or arrogant, it's simply matter of fact. If you use tabs, someone's dev environment might have 8-space tabs and you 4-space. With soft tabs, the same spaces in one piece of code can be copy-pasted to another person's computer and will render the exact same because a space is a space. One person's tab doesn't always equal another person's tab.

from code-guide.

josh18 avatar josh18 commented on July 19, 2024

Out of curiosity is there any particular reason that you use 2 spaces instead of 4? For me personally I find it harder to see indentations when they are only 2 spaces long but it could just be what I am used to.

from code-guide.

zg avatar zg commented on July 19, 2024

You can fit more onto the screen, and you also save space by having two spaces instead of four.

from code-guide.

Ganginator avatar Ganginator commented on July 19, 2024

I disagree.

It is more readable to use hard indents, and then mnify your code for
production.

Human readability is more important during development, and simple
minification like Grunt solves any specific issues for production.

Ganginator

Jesse Gangi
jessegangi.com
(218) 310-2447
[email protected]
@Ganginator https://twitter.com/Ganginator

On Sun, Jul 27, 2014 at 9:09 PM, Zack Gold [email protected] wrote:

You can fit more onto the screen, and you also save space by having two
spaces instead of four.


Reply to this email directly or view it on GitHub
#102 (comment).

from code-guide.

zg avatar zg commented on July 19, 2024

Why don't you prefer the number of spaces I prefer!?

from code-guide.

josh18 avatar josh18 commented on July 19, 2024

Sorry, didn't mean to start a war, was just wondering if there is any major benefit or logical reasoning behind using 2 spaces instead of 4. IMO the benefits that @zg mentioned are very minimal compared to the decrease in legibility that it causes (for me anyways).

from code-guide.

Ganginator avatar Ganginator commented on July 19, 2024

I understand that everyone has their preference.
And I have much respect for you all, so I must state that there is no
negativity.

However, I do choose to do hard tabs in development for readability, and
then choose to minify in production after for performance.

Ganginator

Jesse Gangi
jessegangi.com
(218) 310-2447
[email protected]
@Ganginator https://twitter.com/Ganginator

On Sun, Jul 27, 2014 at 9:45 PM, Josh [email protected] wrote:

Sorry, didn't mean to start a war, was just wondering if there is any
major benefit or logical reasoning behind using 2 spaces instead of 4. IMO
the benefits that @zg https://github.com/zg mentioned are very minimal
compared to the decrease in legibility that it causes (for me anyways).


Reply to this email directly or view it on GitHub
#102 (comment).

from code-guide.

pixelastic avatar pixelastic commented on July 19, 2024

I don't think there is any particular reason to have 2 spaces instead of 4. Use what suits you (and your team) best. The goal of any style guide is to have a commonly agreed set of rules. Same goes for tabs. The important thing here is that all code in the project must look like it has been written by the same person.

from code-guide.

zg avatar zg commented on July 19, 2024

This issue was closed, and hasn't been reopened, so clearly he's going with two spaces.

from code-guide.

josh18 avatar josh18 commented on July 19, 2024

I'm not debating that it should be anything else I am just asking what the reasoning was (if any) behind using 2 spaces instead of 4. He explained above why he chose spaces over tabs but he didn't really say why he chose 2 spaces over 4 spaces.

from code-guide.

zg avatar zg commented on July 19, 2024

#102 (comment)

from code-guide.

josh18 avatar josh18 commented on July 19, 2024

^ ?

from code-guide.

mdo avatar mdo commented on July 19, 2024

Two spaces feels less of a waste of space and makes small chunks of code feel more related to each other. I'm just super used to it at this point—the number of spaces doesn't matter as much, so long as they are spaces.

from code-guide.

josh18 avatar josh18 commented on July 19, 2024

@mdo thanks for your input. I'm a fairly new coder and am just trying to make sure I don't adopt bad habits that are much harder to break later on.

from code-guide.

Alhadis avatar Alhadis commented on July 19, 2024

Use tabs to indent, and spaces to align. Make sure the two don't touch. Simple.

That way, anybody can use whatever indentation size they want without breaking column alignment. Also, I can't stand reading code indented with 2-space soft-tabs. It drives me CRAZY.

from code-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.