<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seán Hayes &#187; whitespace</title>
	<atom:link href="http://seanhayes.name/tag/whitespace/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanhayes.name</link>
	<description>Web Developer in Rochester, NY (Django, JavaScript, LAMP)</description>
	<lastBuildDate>Fri, 06 Jan 2012 00:45:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Whitespace Management: Use Tabs, Spaces Considered Harmful</title>
		<link>http://seanhayes.name/2009/10/09/spaces-considered-harmful/</link>
		<comments>http://seanhayes.name/2009/10/09/spaces-considered-harmful/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 05:33:09 +0000</pubDate>
		<dc:creator>Seán Hayes</dc:creator>
				<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[considered harmful]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[spaces]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[whitespace]]></category>

		<guid isPermaLink="false">http://seanhayes.name/?p=93</guid>
		<description><![CDATA[At one of my previous jobs I worked on dozens of websites that had been created by other people. I prefer to use tabs instead of spaces when indenting code, and I can get a little OCD sometimes, so every &#8230; <a href="http://seanhayes.name/2009/10/09/spaces-considered-harmful/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At one of my previous jobs I worked on dozens of websites that had been created by other people. I prefer to use tabs instead of spaces when indenting code, and I can get a little <acronym title="Obsessive Compulsive Disorder">OCD</acronym> sometimes, so every time I edited a file I would do a search and replace to change every 4 spaces to a tab character. I didn&#8217;t like the idea of having some files use spaces while others used tabs, so when I wrote a bash script for recursively searching and replacing inside text files throughout an entire directory structure, I added some code that would clean up the white space as well. The actions it performed were:</p>
<ul>
<li>Converting from Windows (&#8220;\r\n&#8221;) or Mac (&#8220;\r&#8221; on older versions) end of line encodings to Unix style encodings (just &#8220;\n&#8221;)</li>
<li>Removing trailing whitespace from the end of lines</li>
<li>Condensing multiple blank lines to single blank lines</li>
<li>And most importantly, converting every 4 spaces to a tab character</li>
</ul>
<p>I had anticipated that this would save some disk space, but I was surprised by how much; after running the bash script, the total size of each website would decrease by 10-50% (that&#8217;s not a typo, fifty), and that&#8217;s including binary files such as images and PDFs which were unchanged. Think about the impact that has. Every individual whitespace character takes up 1 byte, bytes which have to be stored on disk, loaded into memory, transferred over a network, loaded into the client&#8217;s memory, and iterated past when it gets processed by the browser. Whitespace management saves:</p>
<ul>
<li>Disk Space</li>
<li>RAM</li>
<li>Processing Power</li>
<li>Bandwidth</li>
</ul>
<p>which in turn helps save:</p>
<ul>
<li>Money</li>
<li>Electricity</li>
<li>the Environment</li>
</ul>
<p>It also helps you provide a better user experience. When browsing the Internet, I&#8217;d much rather download a 5KB HTML file than a 10KB one, since it&#8217;ll download faster and render faster.<br />
(On a side note, generally these are all also benefits of writing standards compliant, semantic XHTML with external CSS and JS.)</p>
<p>Another reason I prefer tabs to spaces is, when browsing code it&#8217;s easier to tell if the proper levels of indentation are being used. If there&#8217;s one space missing or one additional space it can sometimes be hard to tell, but if a tab character is missing it&#8217;s very obvious. Also, most text editors allow you to specify how wide a tab character should be displayed, so if one developer likes 8 space indentation width, another likes 4 spaces, and another likes 2 spaces, they can all use the same code containing tabs and configure their respective editors to display the tab character at their preferred width. If you were to use 4 space characters for each indentation level, the developers who like 8 and 2 spaces are forced to use it as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanhayes.name/2009/10/09/spaces-considered-harmful/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

