Ever have one of those days where everything you check into source control is wrong?
Also, how exactly is that day is different from any other? But seriously.
Code that is visible is code that can be wrong. No surprise there. But did you know that even the code you can't see may be wrong, too?
These are the questions that drive young programmers to madness. Take this perfectly innocent code, for example.
Looks fine, doesn't it? But hold on. Wait a second. Let's take another, closer look.
OH. MY. GOD!
If you're not a programmer, you may be looking at these two images and wondering what the big deal is. That's fine. But I humbly submit that, well, you're not one of us. You don't appreciate what it's like to spend every freaking minute of every freaking day agonizing over the tiniest details of the programs you write. Not because we want to, you understand, but because the world explodes when we don't.
I mean that literally. Well, almost. If one semicolon is out of place, everything goes sideways. That's how programming works. It's fun! Sometimes! I swear!
We got into this industry because, quite frankly, we are control freaks. It's who we are. It's what we do. Now to imagine, to our dismay, that there's all this stupid, useless whitespace at the ends of our lines. Stuff that's there, but we can't see it. Well, those are the nightmares OCD horror movies are made of. I have a full-body itchiness just talking about it.
Depending on how far down the rabbit-hole you want to go, there's any number of things you could do here:
\s*?$ in it, that auto-cleans extra spaces checked into source control
OK, fine, so maybe the world won't explode if there are a few extra bits of whitespace in my code.
But all the same, I think I'll go back and make extra double plus sure no more of that pesky whitespace has accumulated in my code when I wasn't looking. Just because I can't see it doesn't mean it's not out to get me.
The problem, at least as I see it, is that it is an awfully bad hack to start sticking lines of code into markers. The whole thing is so utterly cryptic that it's a wonder you can type it in at all. It's an example of bad technology (from poor syntax), not of problems with whitespace. The whitespace issues are secondary (the symptom of the disease).
If the technology sucks, one sure sign is that little changes can cause mystifying effects. That type of embedded instability makes it hard to deploy consistently, which makes it very stressful to use. If it wasn't for the Internet (and easy access to answers) we'd no doubt avoid these types of crappy technologies, and they'd die natural (and much deserved) deaths.
We should really start a "just say no to super-fugly technologies" campaign. They seem to linger far too long these days.
Paul.
Seeing as how nobody has attempted to bring the joy of Spark into this thread I will have a go.
There are view engines for MVC that suck less, handing the integration of code and markup much more cleanly than the multiline beesting nastyness of the default view engine.
At least in corporate "enterprise application" code, the problem with trailing whitespace is that it often indicates cruddy, cut-n-paste coding by cut-rate, one-size-fits-all, lowest-bid consultants.
Invisible trailing whitespace often indicates randomly indented code too.
Both of these things (cut-n-paste shortcutting know-nothing quick fixes, and semi-random indentation) cause different problems, but have some of the same "leading indicators", including trailing whitespace.
Bruce Ediger on November 9, 2009 7:38 AMThrow this in your .vimrc, problem solved:
autocmd BufWritePre *.cs :%s/\s\+$//e
autocmd BufWritePre *.aspx :%s/\s\+$//e
I'm afraid I'd have to argue against any extra whitespace (trailing or leading) when dealing with HTML generating code.
I know that bandwidth isn't a major concern for many people, but when generating the HTML in a loop, please remember that every bit of extraneous whitespace is an extra byte (or two) of data that must be transmitted that has no purpose to the end-user (it just makes the generated HTML easier to read).
The example above would generate 24 bytes of "end-user useless" whitespace per iteration of the loop. If the loop executed 10 times per page view, that's 240 bytes. 5,000 page views x 240 bytes = 1,200,000 bytes (1.14 MB)
I would at least consider having a process that would remove the leading whitespace in production code, or alternately, a process that would add the whitespace to the source dump of code for testing.
Scott on November 9, 2009 7:49 AMI fail to see the problem in the snippet you provided. Unless it is important in the look of the generated HTML.
Well, a long time ago, I have set the option in my text editor, SciTE, to strip trailing whitespace, and I happy with this setting. That's an alternative to your options (ie. a built-in feature of the editor).
And I don't have the problem of Barry Kelly: it is smart enough to keep the indentation of the last line with indentation, and to keep the caret position when running over empty lines.
In Eclipse, I use AnyEdit Tools to take care of these extra spaces.
PhiLho on November 9, 2009 7:57 AMFunny, my first thought was "what's wrong?"... and then as I read on, I realized I'd subconsciously assumed that, had I gotten my hands on that code, I would've instinctively deleted those spaces. That stuff drives me nuts too.
Daniel on November 9, 2009 8:17 AMThere are html optimizers for web servers that can be employed on the job (although general value additions is quite negligible). Also I found following CodeProject article trying to do similar stuff.
http://www.codeproject.com/Articles/38067/Compress-Response-And-HTML-WhiteSpace-Remover.aspx
Oh. My. GOD! You care more about meaningless whitespace than using semantically correct markup. What a noob!
Josh Stodola on November 9, 2009 8:31 AMHaha, so true!
Ian Devlin on November 9, 2009 9:12 AMIf white-space causes such issues and this many comments, the programming world indeed has gone backwards...
Steve on November 9, 2009 9:20 AMCheck out Perl::Tidy, and to a greater OCD extent, Perl::Critic. It turns out your language can AUTO-FORMAT ITSELF ANY WAY YOU WANT IT TO if it were a little bit smarter. You want cuddled elses but your colleagues don't? No problem, just Tidy it to the group's standard when you commit (which Eclipse will do for you) and Tidy it back on update. Works for all whitespace and all punctuation, plus comments, array formatting, etc.
Oh, and if you really want to see some whitespace coding horror, check out the Acme::Bleach novelty module on CPAN. It replaces your source code with a series of non-printable whitepaces which, when interpreted, produce the same run-time as the original code.
use perl on November 9, 2009 9:47 AMOnly downside to that /\s+$/ search:
What about languages that let you specify blocks of text? That whitespace may be useful for display-formatting purposes. Suddenly that simple regex gets a lot nastier (if it can even be done in regex).
Granted, that likely means you're doing something wrong, but sometimes adding a space or two to align things is the easiest fix.
Otherwise, I completely agree, and have done similar things for a while. But I must admit, my first shock-reaction was "OMG spaces not tabs!" Spaces are a royal pain, as they lock-in the layout of your code. Use tabs, and IDEs can display them however you like, and usually auto-align things correctly, where spaces explicitly break auto-formatting behavior.
Yes, some languages freak at tabs. Clearly they're exceptions.
Maybe, some day, we'll get elastic tabstops in regular editors. They rather nicely eliminate repetitive tabs / spaces.
and that from a freaking coder who thinks two whitespaces is good for users to use as markup language
sunfire on November 9, 2009 10:24 AMOkay, I'm now forcing my VS to indent code with 5 whitespaces instead of 3
offler on November 9, 2009 10:32 AMI leave whitespace visible but set the color to a very low contrast with the back-ground--e.g., light, light gray against white. I can see it quickly by squinting but it doesn't get in the way when I'm concentrating on the code.
If only I could set whitespace color in Eclipse :p .
Brett on November 9, 2009 10:50 AMDid we all get in to this industry because we are 'control freaks?'
Igore on November 9, 2009 11:06 AMReally? I mean ... really?!?!
Dave on November 9, 2009 11:20 AM"If you're not a programmer, you may be looking at these two images and wondering what the big deal is. That's fine. But I humbly submit that, well, you're not one of us."
I humbly submit that you're not one of us either...
lolatwood on November 9, 2009 11:39 AMGool old Notepad2:
Auto strip trailing blanks option (File, Line Endings, Default)
zzz... I thought this post was going somewhere - but then it didn't. I was wondering 'what am i missing' and when the big reveal was some whitespace I died a little.
@lolatwood - funny :)
sleepysmurf on November 9, 2009 12:04 PMKDevelop has a setting to strip all trailing whitespace on saving. However this won't be visible in the IDE until you close and reopen the file. I like the idea of a code cleaning bot that runs via commit hook/cronjob and tidies up with simple rules like trailing whitespace, extra line break at the end of each text file, tabs to spaces etc.
Srsly kdiff3 can ignore whitespace. I'm sure any decent diff/merge tool can. Who cares?
Nick on November 10, 2009 1:03 AMTo Nick: any difftool can ignore whitespaces I guess too, unfortunately ignoring whitespaces that aren't at the end of lines can hide important changes and thus should perhaps not be done.
Marc on November 10, 2009 1:14 AMI might be wrong, but isn't \s*?$ a non-greedy match to any number of trailing whitespace? Won't this always match exactly 0 characters of whitespace? Shouldn't it be: \s*$
Oliver on November 10, 2009 2:11 AMWhat whitespace at the end of the lines?
signed: the VB guy
(I know, I know... in the example above, also for VB guys the whitespace would not be trimmed)
Dejan on November 10, 2009 2:31 AMI submit that an important part of being a nerd is knowing which things to obsess over and which things to let go. To paraphrase Dave Chappelle, pick your spots.
If you're using a language in which whitespace is not significant, I recommend choosing something else to obsess over.
KT on November 10, 2009 2:32 AMIt is nice to know I'm not alone in my Code Whitespace OCD.
Dave on November 10, 2009 3:59 AMLocking? Surely you are joking, mr PRMan. I thought no one used locking version control since about the time fire was discovered...
Joe on November 10, 2009 4:10 AMCtrl+E,D
tb on November 10, 2009 4:14 AMGuess I'm not one of you ... Thank goodness too 'cause otherwise I'd have to have myself committed for being overly anal.
any mouse on November 10, 2009 4:20 AMOther than the fact that whitespace, like case (...yes I said CASE...why should GROSSPAY, grosspay, GrossPay, or grossPay mean different things or be scoped differently? Why? WHY!? Ok...I got off on a bit of a tangent. Sorry.) shouldn't matter, it can cause problems.
I remember beating my head for two days over a piece of code that refused to compile. I'd stare at the line and tweak it one way or the other to no avail. Out of desperation I deleted the entire line and retyped it from scratch. It worked. Comparing the old and new code, I found ONE SPACE at the end of the line that didn't work.
It's hard to debug something you can't see.
May be worth saying too that most companies (and here I'm thinking those situation where there's more than one person committing to the repository) enforce the removal of trailing whitespaces on their code guidelines documentation.
This is also, as far as I know, a common guideline among open source projects.
I'm surprised however as to why Jeff ignored the setting on most editors used for coding (modern and old alike) that automatically remove these on save. This setting alone removes the need for his three proposed solutions.
But assuming such an editor feature wasn't present or couldn't be present for some reason, it's worth saying that most diff tools can also ignore trailing spaces at our request.
Mario on November 10, 2009 6:48 AMI've recently switched to tab formatting in designer HTML in Visual Studio, and the reason is simply payload size of the page. Using Jeff's example, the the 48 space characters (not including the offending trailing white space on Line 2) could be replaced with 6 tab characters (assuming the Visual Studio default formatting setting of 1 tab == 4 spaces) and still retain the same visual layout. That amounts to a 12.5% reduction in size just on formatting. How's that for OCD?
I'd like to minify all my .as?x files, like I'm doing with all CSS and JavaScript files, as part of a build step, but haven't built/found a tool for that yet.
Craig Boland on November 10, 2009 7:18 AMWhat I find most shocking about this is that anyone gives a sh*t. Nothing better to do, I guess.
MR on November 10, 2009 8:15 AMJust thought my captcha was amusing:
heinie but
Joe on November 10, 2009 8:30 AMSounds to me like you are complaining about the symptoms, not the problem.
Here are the problems as I see them:
1. You are using a language with ASP-style syntax. Didn't you get the memo that those suck? They eventually trend toward unmaintainable.
2. You are using a merging repository with 10 developers. You aren't writing the freaking Linux kernel!!! You don't need merging, it just causes all kinds of problems. Tried and true locking is the best solution when you can easily divide the work between modules. I love locking, because then I can just set Visual Studio to conform the code to the way I like, and the next guy the same. Ctrl-K Ctrl-D and it's all good.
3. Was your diff tool written in 1990? Because WinMerge has been ignoring whitespace, blank lines and CR vs CRLF for at least that long. Seriously, there are diff tools that can't do this in 2009? I would have never guessed.
4. You are using an IDE which doesn't do code cleanup for you. Set your style and have the IDE conform the code to it for you. Nice and consistent.
5. Somebody checked in a bunch of spaces at the end of a line.
PRMan on November 10, 2009 9:01 AMYou left out one option regarding what to do to solve the whitespace problem. When I code, I use the Home and End keys ridiculously often. If you're like me, it's quite simple to see when you have some trailing spaces - chances are you'll see it by chance when you're just navigating the code! A lot of IDE's have customized it by default to make the Home and End keys ignore whitespace - so Home will take you to the start of code -following- the indentation, and End takes you as far as the start of trailing spaces. Usually double-tapping Home or End will take you to the -real- start or end, though, so I've become rather accustomed to that as well.
JaredMT on November 10, 2009 9:09 AMEven at the start/end of scriptlets, we are inserting a new lines which are unnecessary. That costs us few bytes.
Jai on November 10, 2009 9:21 AMOh, this is definitely my favorite blend of OCD. Fits snuggly right next to lining up opening and closing brackets to suite your particular tastes. Nothing is quite as satisfying as knowing that everything you don't see is in order. Until you do something with it that is... Which is why you'd better make the invisible bits visible.
A very good idea for a post! You could've gone on longer though..
JPH on November 10, 2009 9:42 AMWow, you people are all crazy :)
Doug on November 10, 2009 10:18 AMWhy haven't you started putting those ) chars hard up against the preceding (following) elements? All those newlines and spaces in front of (after) them are also getting sent to clients, you know. As an added benefit, doing this as part of your coding standard would fix the strange-space-between-my-images issue that crops up from time to time. Doing this doesn't have to make your code unreadable dross.
Using your example, the code would change to:
" class="comment">
Now any extra trailing whitespace on most lines here is server side only (the closing table tag could leak spaces to the client), and your bandwidth consumption will drop by a tiny fraction more.
Richard Atkins on November 10, 2009 10:42 AMI'm a programmer, and I don't give a damn about terminal whitespace.
I only care about indentation because it improves comprehensibility.
(And seriously, what PRMan said. ASP syntax? You have far bigger problems than terminal whitespace.
But I completely disagree with the idea that smaller teams don't need merging... at least unless you've broken all your code into a few thousand 50-line modules. Which is its own unique and pointless hell.)
Sigivald on November 10, 2009 10:43 AMThis has to be a joke. Almost immediately after a post where you were deluged with complaints about how absurd the markup requirement to put whitespace at the end of lines to get line breaks, you make a post complaining about whitespace at the end of lines?
Then seeing all the OCD people complaining about whitespace who also support something as "unclean" as indenting with spaces is just...strange.
Anonymous on November 10, 2009 12:22 PMTrailing spaces do not matter really. I, personally, think that programmer should suppress all this control freakness in himself. It is a step to become professional. If you can't make a difference between important and non-important, you can't make anything real, it will always force you to rewrite infinitely to make code "perfect". But the real code is the one which released and works, it does not need to be perfect. The cost of perfectionism is too high.
vtolkov on November 11, 2009 1:16 AMI pad all my code to the 80th column with spaces. Cheaper than medication.
Dave on November 11, 2009 1:47 AMIn vim you can get rid of any trailing whitespace by adding the following to your ~/.vimrc
autocmd BufWritePre * :%s/\s\+$//e
petepete on November 11, 2009 3:19 AMThe problem with trailing white space is that it can ruin the formatting of the code when you're adding/deleting parts of it. Bad formatting can RUIN readability and absolutely grate on the nerves of people with OCD. Fixing bad formatting takes precious time and developmental resources.
John on November 11, 2009 5:40 AMThe problem with trailing white space is that it can ruin the formatting of the code when you're adding/deleting parts of it. Bad formatting can RUIN readability and absolutely grate on the nerves of people with OCD. Fixing bad formatting takes precious time and developmental resources.
John West Minor on November 11, 2009 5:41 AMThe problem with trailing white space is that it can ruin the formatting of the code when you're adding/deleting parts of it. Bad formatting can RUIN readability and absolutely grate on the nerves of people with OCD. Fixing bad formatting takes precious time and developmental resources.
John West Minor on November 11, 2009 5:41 AMThe problem with trailing white space is that it can ruin the formatting of the code when you're adding/deleting parts of it. Bad formatting can RUIN readability and absolutely grate on the nerves of people with OCD. Fixing bad formatting takes precious time and developmental resources.
John West Minor on November 11, 2009 5:42 AM"We got into this industry because, quite frankly, we are control freaks. It's who we are. It's what we do."
lol. Yes, that's who we are!
World Cruises on November 11, 2009 7:20 AMThe problem with "strip spaces on save" is that it only works it everyone on the team is using it and since the beginning of the project.
If you have an existing codebase with trailing spaces and turn this setting on, you'll have tons of spurious, unrelated "diffs" even for a one-line fix.
Daniel Serodio on November 11, 2009 7:25 AMI didn't see the problem with the code, mostly because I was expecting something that would actually cause an _error_. When you finally started talking about trailing whitespace though, my brain caught up and yea... that pisses me off to.
The real problem is Visual Studio creating it seemingly at random every time you turn around.
Actually, it wouldn't bother me if it didn't screw up keyboard navigation. End should take me to the end of the text, not to the end of crappy unnecessary trailing whitespace!
Telos on November 11, 2009 8:49 AMDon't care... extra white space is ignored, I'm sure it doesn't end up in your compiled code and that's all that matters.
Kris on November 11, 2009 10:32 AMWhy not diff -bB, that seems to ignore most whitespace differences.
Hugh Gallagher on November 11, 2009 11:44 AMwhitespace at end of line doesn't bother me that much, but if the code contains tab indented lines, and space indented lines, then I go mad! It's not that I prefer one over the other; in some projects I use one tab, in others I use two spaces.
Marius Gundersen on November 12, 2009 1:03 AMThis is the spergin'ist topic I have ever seen on this site, and thats saying a lot.
ADINSX on November 12, 2009 1:55 AMWhitespace schmitespace! I went like "OH MY FREAKIN GOD" ( y Jesucristo, Madre Maria y Todos Santos) when I saw pre-dot-net style old asp with the VB code and the markup together and no separate code-behind file. Eeew! How "Artist-Formerly-Known-As-Prince", as in "Tonight we're gonna web-code like it's 1999!"
So, um, Jeff, are you like trying out for US Shark Jumping team for the 2010 Winter Olympics in Vancouver?
José on November 12, 2009 4:43 AMThat's not really a hard problem to solve:
* Mutually accepted coding conventions.
* Automatic code formatting before committing.
* Everybody in the team made to setup their IDE right.
Biggest hurdle is getting everybody to accept the coding conventions.
Whitespace definitely is not a non-issue, although trailing whitespace is lot less a problem than wrong indentation.
Jukka Dahlbom on November 12, 2009 5:42 AMIm more worried about the horrible spaghetti code you seem to write, what happend to code separation ?
Are you really doing this with code you sell to customers ??
The real thing to blame here is the fact that version control systems are still in the 80's and match source code as if it were simple text. If Version control systems were not language agnostic, they would never flag trailing whitespaces as diferences, neither putting "{" on the same line vs next line, etc.
One could checkout code and see and edit it with his/her preferences and upon commit it would be converted to an internal representation that abstracted all those differences that did not affect program semantics.
Even if you commit code with lots of spaces in the end (for some weird reason), if those spaces did not affect the program, they would be deleted.
Tiago Almeida on November 12, 2009 6:45 AMAs much as I agree, (if I saw that whitespace, I would almost certainly delete it, even if it was just some irrelevant sample code I was looking at) a commit where the only thing changed was a bunch of whitespace taken out is one of the most ridiculous things ever.
Ortzinator on November 12, 2009 6:46 AMLove it. I recently forced all the programmers on my team to make sure their VS options had tabs NOT SPACES due to the repeated "conflicts" when updating source control. What? the whole file is in conflict?! WTF!?
misteraidan on November 12, 2009 6:46 AMafw wfwqf wqf
fwqf
wqf
fwq
wfwf
wf
fwq
fw
wqfw
f
fw
admin on November 12, 2009 7:13 AMThanks
sanalcasus on November 12, 2009 7:15 AM"We got into this industry because, quite frankly, we are control freaks. It's who we are. It's what we do."
lol. Yes, that's who we are! Good idea...
I've learned over the years to to ignore whitespace, and most other formatting issues foudn in OPC. I'm going to apply that same discipline to ignoring all the incorrect arguments attempting to justify it. Also surprisingly difficult to do.
Kevin Thex on November 12, 2009 8:17 AMGood information...
sex hikayeleri on November 12, 2009 8:18 AMThe real problem here is the use of space characters and not proper tabs. Have you ever gazed upon the horror of source code maintained by two people that both use soft tabs, but have them configured for different widths? Hard tabs, people. Separate the data from the presentation.
db2 on November 12, 2009 8:30 AMYes you are once we spent hours after site was suddenly crashed just to find out that we had mistakenly put 2 white spaces after PHP closing tag...
But after all we all love web designing and will go on coding...
www.simplify.co.in
Simplify Solutions on November 12, 2009 11:20 AMJohn. Judging by your quadruple posting above, I'd say that trailing white space is the least of your problems. For most people (but evidently and surprisingly not everyone) they are a trivial irrelevance that is easily dealt with - if they are even noticed.
Vince on November 12, 2009 12:50 PMgbfd jkhgıugib ihboıih
sanalcasus on November 13, 2009 1:00 AMewwegtwehren 4t443h43
sanalcasus on November 13, 2009 1:01 AMSolution: auto-convert the code to a very strict canonical format before commit. There should be one and only one way to represent the same functional code structure.
adi on November 13, 2009 1:44 AMAs long as the white space isn't case sensitive I will get some sleep at night
Rene on November 13, 2009 2:30 AMBeware not to remove intentional trailing whitespace characters in verbatim string literals (i.e. @"text").
Example:
More on C#'s verbatim string literal syntax:
http://msdn.microsoft.com/en-us/library/aa691090(VS.71).aspx
This is my take on the maddening side of the smallest mistake in my code:
http://blog.openmountain.com/2009/11/09/the-funny-side-of-web-development-and-multiple-languages/
IN this post I compare Web coding to a Robin Williams routine on golf. Fixing a mistake in some minor part of code is like trying to hit a tiny ball 350 yards into a small hole.
Cheers!
Bob Benedict on November 13, 2009 3:30 AMWhat's with wall the freaks using spaces instead of tabs? It's sick I tell you, sick!
Nobody on November 13, 2009 5:00 AMIn our java builds, we have checkstyle (a style checker, duh) built into our build process to enforce our style standard, and it has rules to check for trailing whitespace. If you don't fix before checking in.... BOOM broken build :D
For once I concur with Jeff: http://dabr.co.uk/status/5387659406
Eddy Young on November 13, 2009 5:56 AMWhy are OCD types using spaces over tabs for indentation? Using spaces is a dirty hack.
Anonymous on November 13, 2009 6:14 AMperhaps i've been out of the game too long, what exactly is wrong with this code?
i see the extra whitespace on the foreach line, but does this actually break functionality or make the html render incorrectly?
former web developer on November 13, 2009 6:26 AMHere is why tabs are better than spaces for indenting code. Let's assume that tabs are set to 4 spaces. When indenting code, it is unlikely that one would want to insert code or select text starting in the middle of a tab. The programmer will most likely want to select at the beginning of a tab or at the end of a tab. When spaces are used, the programmer will have to click in an area that is half the width of a character to insert the cursor before an indent or after an indent. Using tabs, the programmer has 2 character widths where they can click to insert the character. That's 4 times as much space. Also, fewer keystrokes are required to navigate tabs than spaces (though, some editors can make the spaces act like tabs in this regard).
The only reason I can think of to not use tabs (aside from being anal-retentive) is because different text editors can have different tabs set. However, if you're consistent with the use of tabs, this should make no difference. If programmer A likes 4 spaces and programmer B likes 2 spaces, they can both do their work the way they want without affecting the other. The problem occurs when one programmer decides to use spaces when the rest of the code is in tabs. This is more of a personnel issue, I think. If the developers can't agree on a standard then they have bigger problems.
Dave on November 13, 2009 8:30 AMthis blog sucks ass
whocares on November 13, 2009 8:58 AM"Hard tabs, people. Separate the data from the presentation."
Tabs are all about presentation (in languages that ignore whitespace).
Thus, you violate your own maxim by using tabs (or even newlines, in most cases).
Anonymous on November 13, 2009 11:45 AMgwwegweg weg weg wge gwe gwe wge ge
sanalcasus on November 13, 2009 12:59 PMI think some of you guys are missing the point. It's how something as innocuous are whitespaces can be such a big headache. Sheesh
Visual C# Kicks on November 14, 2009 6:27 AMas*
Visual C# Kicks on November 14, 2009 6:28 AMThis is mainly a problem in template languages as per the example. A particular example in PHP is where files end in "?>" followed by whitespace. Perhaps tolerable if you're just printing HTML, but if you're trying to print an image or other binary, for example, the whole world explodes. And, worse yet, you might not notice until you get phone calls exclaiming "Our PDFs are broken!".
Perhaps avoided by rigorous testing, but, really, who has time for that?
Schalken on November 15, 2009 2:38 AMOne reason to use library construct like "String.EMPTY" is that it is statical analysis friendly, and can be easily searched for.
Chuan Li on November 15, 2009 6:46 AMThe extra spaces in sourcecode is how the csharpians communicate with me!
Mostly to tell which process NEEEDS TO DIE next.
tINfOILhAT on November 15, 2009 9:32 AMHow far we have sunk in our professional thinking to post this many comments about white space.
Steve on November 15, 2009 10:04 AMI hate unnecessary whitespace at the end of lines too!
It seems completely irrational take make it such a big concern, but who really cares about rationality!? We know it rashes us, and we know the their nagging existance will not be silenced until they are removed.
Good to hear other people have the same level of OCD I do.
Daniel Carvalho on November 16, 2009 2:11 AMWow, I thought I was the only web developer in the ASP.NET world who cared about good client-side code!
It's too bad Microsoft is so clueless. VS2008's default setting inserts four spaces when the tab key is pressed, there's still no minimal CSS auto-formatting option, and .NET's auto-generated JavaScript is still a hideous mess written by people who think whitespace-laden C# syntax is acceptable for JavaScript. Apparently MVC in VS2010 has some minifying functionality, but I haven't seen it yet.
If you don't understand why lean client-side code matters, just wait until next year, when Google starts using file size/download time as part of their search result ranking criteria. When you see all your sites drop a notch, don't come crying to all the real web developers - we'll just say "I told you so, web n00b!"
Droog on November 16, 2009 8:37 AMActually, this is trolling in a way, but it is necessary.
CH comments are sooo many that I just don't ever seem to be able to read them all. It's too much. So I end up violating the first-do-a-search rule at the page level.
So, as many may have requested before, I shall repeat:
Please allow some markup in comments and let us hope that commenters who want to say something useful take the additional trouble to use *bold*, /italic/ or _underline_
Over a period of time, and over a variety of topics, i estimate that casual comments coming from lazy commenters will have less or no markup (i hope, let's all discuss this) and so it will be easy to filter comments.
Want some marketing? Here:
*****
Responsible Markup Initiative @ CH blog
*****
Again, the complaint is that there are too many comments to read and many comments without lot of useful content.
Assumption:
------------
Trolls when left hungry for some time, will die of hunger.
Eclipse Ganymede handle very well those issues, it can be configured to remove end line white spaces and bottom of file empty lines.
Also it as a pretty nice eature for auto indenting code.
I use both functionnality on php/PDT projects and they are just fine for me :)
For sure I use other editors for python, one showing me every tab, I tend to do the same for YAML files.
Benoit on November 17, 2009 1:24 AM(add-hook 'before-save-hook 'delete-trailing-whitespace)
Marius Andersen on November 17, 2009 6:05 AMI think the user of PHP is more popular with the days elapse.
Laptop-battery on November 18, 2009 2:09 AMThe comments to this entry are closed.
|
|
Traffic Stats |