6 ms·
I'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) o
by bengotow 13y ago
I'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.
- ilaksh 13y agoSeems like you really have a lot of contrast in that theme. Also I hope you will consider dropping the extra parentheses. And instead of dropping CoffeeScript I hope you will try out ToffeeScript. But just use the basic ! thing, you don't need the other stuff like auto callback. e, data1 = fs.readFile! 'foo' e, data2 = redisclient.get! "thekey" console.log data1 console.log data2
- city41 13y agoWhen I first started using CoffeeScript I dropped just about every optional character you could. Lately I've been going in the opposite direction and adding most of them back in. I find this is also a matter of taste and experience. Whether I add the parens or not depends a lot on what's going on at that point. I do appreciate how flexible CS can be here. I'm interested in things like ToffeeScript and JS generators. I do like what they do for code readability.
- ricardobeat 13y agoI'd add using four spaces and a slightly increased line-height has major benefits to readability.
- dham 13y agoI'll go ahead and back this point up also. The visual white space is actually making it harder to read the code.
- deleted 13y ago[deleted]
- yawboakye 13y agoDoes that suggest you don't indent your code at all? Do you miss out on the cheapest visual cue to understanding your code? If you indent code already (with all the curly braces) then significant whitespace means your normal indentation sans 2 curly braces every time.
- alptrv 13y agoI think that's not a problem with significant whitespace, but the problem with CoffeeScript syntax. I'm programming in Python and had been programming in Coffescript and I always found Coffescript code much harder to read than code in Python. I don't know exactly what causes this, but my guess is that indented blocks of code in CoffeScript can appear after any line, so you don't have visual anchors that will indicate where one block begins and other ends. In Python however, indentation is always comes after keywords like def, if, class, for etc... and those are always highlighted by your editor so your eyes can always catch the block start very quickly.
- bengotow 13y agoI totally agree with you about the spacing between methods. I've actually found myself putting a double-space between methods, but I do that in most languages so it hasn't bugged me as much. Thanks for posting the image!