5 ms·
"As my project grows in size, significant whitespace becomes more and more of a problem. It’s just plain not readable or visually parsable. Your files become a
by omni 13y ago
"As my project grows in size, significant whitespace becomes more and more of a problem. It’s just plain not readable or visually parsable. Your files become a wall of dense text. Damn you Python, damn you to hell!"
I would appreciate an explanation of this paragraph. How exactly does project size compound issues with significant whitespace? Are you indenting five levels or something?
- elwell 13y agoI would agree that the indentation in CoffeeScript causes confusion, especially since the recommended size is 2 spaces.
- anko 13y agoI don't know any worthwhile editor that can't show tabs.
- tghw 13y agoI don't think indentation is a problem particularly. Once you're familiar with languages that use it, e.g. Python, it gets pretty natural. I did run into problems with the 2 space indentation, however, because with certain character combinations, it's difficult without a second look to be sure. I would argue there are bigger problems with CoffeeScript, such as empty blocks being legal. For example: if foo bar() Is totally legal. But 99% of the time, you really mean: if foo bar() In Python, the former is a syntax error and there is an explicit pass call to demonstrate that the block is empty. But in coffeescript, it's easy to accidentally write that code and it looks right when you're doing a quick read through. Again, I think 4 spaces would help as you would be expecting a larger indentation.
- rmrfrmrf 13y agoThat's not legal in CoffeeScript either. I just tried it on the CS website and got the message "ERROR ON LINE 1: UNEXPECTED POST_IF".
- tghw 13y agoThat might be new. We definitely had a bug in earlier versions of Trello due to that, so it stuck out in my mind as one of the places that Python did it better.
- elwell 13y agoDoes anyone know of any text editors that have vertically spanning highlight bar to show clearly where your cursor x-position is from the bottom of the page up to the top? I think it would help with matching up indentation especially in CoffeeScript.
- bengotow 13y agoI'm curious about this statement as well. It sounds like the author might be: - Creating big complex methods instead of breaking code into smaller (testable) ones? - Nesting callbacks multiple levels deep, instead of using something like Node Async to flatten out code flow? - Choosing a Coffeescript code style that leads him to put callbacks on their own line, or something like that? - Something else? Not implying the author is wrong by any means - there are probably some scenarios where coffeescript isn't the best whitespace-wise. The thing is, readability is one of the huge reasons I use coffeescript, and I feel like it's largely compatible with the whitespace patterns I used in javascript. Even for large NodeJS or Angular projects, I've found that it is consistently easier to read and edit than Javascript.
- city41 13y agoI'm the author of the blog post. Significant whitespace is pretty dividing, and really boils down to preference. I have a strong dislike for it, and have avoided any language with it, CoffeeScript being the only exception. Here is a typical snippet of my code as seen in my editor: http://i.imgur.com/2yVhgcz.png http://i.imgur.com/2yVhgcz.png IMO, those four methods really bleed together and are hard to discern, not to mention the if statements. I also think for the most part I stick with code that's "whitespace friendly", getAll there is a really long method by my standards. Yeah, I could put more blank lines between the methods and probably some other things. But I also think a closing brace or an 'end' makes a world of difference. Really helps break up the space and compartmentalize it. Not everyone thinks this of course. For many code like this is just fine. Like I said, it's all preference.
- suchow 13y agoTry removing the indentation guides or decreasing their contrast so that they are just barely visible. They appear to cause strong visual grouping between code blocks and make it harder to see what's what.
- city41 13y agoThat's a fair point. I will try that and maybe some more tweaks too.
- jarrett 13y agoI did find that odd. Whitespace helps you get away from "a wall of dense text." I'm not clear on how mandatory whitespace could exacerbate the "wall of dense text" problem. Does the author want to skip the indentation some of the time? I can think of a few marginal cases where that would be preferable. But in the vast majority of cases, you should indent any nested structure that has its own line(s). Indentation is essential for readability.
- flywheel 13y agoIt's really really simple. Significant whitespace has no punctuation to visually queue the reader of the code as to where things begin and end. It is much easier to read Javascript than Coffeescript because well written Javascript includes curly brackets, and other delimiting characters to aid in reading the code. Coffeescript and significant whitespace eschew delimiters for indentation and other gimmicks, and the end result is something that is more difficult to read. I totally agree with the author on this fact. I only see a "wall of dense text" when I read coffeescript, and when I read Javascript it is much easier to parse.
- zachwill 13y agoI'd really like further explanation, too. If you're not properly indenting code in large projects — whatever the programming language is — I'd really hate working with you.
- fat0wl 13y agojust want to drop another vote against against significant whitespace... i find it slows down my coding because rather than coding & then quickly tidying i instead have to obsess over this tidying at every step or the code won't work in the first place. I find it more efficient to do the code grouping as a "post-POC" task (or when things are starting to look confusing) and to leave the visual look to my discretion. I feel like whitespace languages are kindof subliminally forcing you toward 1 code style. There are some complex functions that look better to me certain ways -- specifically in cases where a group of commands are essentially executing one simple function. Once they work they can be forgotten & the programmer can de-emphasize them in some way according to taste anyway, I am not a CoffeeScript guy. I've been avoiding it and waiting for Dart or something like that to take hold, since I'd like to see some serious language benefits if I'm going to have to introduce a compilation step. It's one of those things I remain slightly bitter about because some shops judge you for not being into it (as well as Sass, Haml) even though they offer negligible benefits for many projects. That said, I can imagine cases where CoffeeScript would offer significant benefits (they are right there in the tutorials) but I haven't really found those types of situations too much in the wild (tons of array math etc.), and if so they can often be simplified via jQuery or the like anyway. So yea if it works for you, great, but I am glad whitespace syntax is not de-facto in the js world. I think js should remain as Java is -- other languages can be built on top of it with their own syntax types but developers still have the choice to ignore these supposed advancements & cherry-pick the ones they like (in my case progress in pure js + Dart will be where i focus my learning).
- subsection1h 13y ago> i instead have to obsess over this tidying I don't mean this as a personal attack, but your comment contains plenty of spelling errors, incorrect punctuation and capitalization, and inconsistency (e.g., use of both "&" and "and"). In my experience, people who aren't careful with syntax tend to detest significant white space, which is understandable.
- reeses 13y agoAnyone who has maintained Makefiles will have a strong opinion on semantic whitespace. Maybe not opinion, but reaction. Generally involving visceral fear or anger. It's not that it's always bad, every hour of every day. It's that one time, at 1am, when you shouldn't be working but you are, something doesn't behave properly, and it turns out Bob the Intern re-indented a block of code to use tabs instead of spaces[1], but you couldn't see it because your editor is configured to use four spaces per tab and your coding standards dictate four spaces per level of scope. [1] Why are you using spaces anyway, you complete and utter savage?
- aiiane 13y agoWhich is why you set your editor to use something other than the same number of spaces as your indent levels. It works especially well if one isn't a multiple of the other - e.g. having the editor display tabs as 5-space width.
- read 13y agoAnyone who has maintained Makefiles will also have a strong opinion on compiled languages.
- deleted 13y ago[deleted]