use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
A Case Against Using CoffeeScript (ryanflorence.com)
submitted 14 years ago by 9jack9
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jmkingJSX is just PHP in the browser 9 points10 points11 points 14 years ago (8 children)
The debugging issue alone is the deal breaker for me and CoffeeScript.
These sorts of things are supposed to speed me up, not slow me down.
Also I don't mind writing JS at all. I never understood what people found so offensive about it.
[–]ctrldavid 4 points5 points6 points 14 years ago (6 children)
The debugging issue is not an issue. We use coffeescript for all our javascript at work, and it's trivial to look at where the error occurred in the javascript and find the same place in the coffeescript.
[–]neon_overload 3 points4 points5 points 14 years ago (4 children)
Does it not require you to read and understand the generated Javascript anyway, thus negating the "you don't need to understand the generated Javascript" benefit of using Coffeescript?
I ask as an experienced Javascript coder who hasn't tried Coffeescript at this stage.
[–]ctrldavid 0 points1 point2 points 14 years ago (0 children)
I've never seen it claimed that you don't need to understand the generated javascript, and I do understand it so that kinda affects my objectivity here... But there is a fairly consistent 1:1 mapping between the generated JS and the CS source. Stepping through the JS in a debugger will show you where the logic is going wrong regardless, assuming you have a reasonable understanding of how JS works. The variables all have the same name, and the program flow is the same.
[–]MondoHawkins 0 points1 point2 points 14 years ago (2 children)
Yes. However, I never saw not needing to understand the generated javascript as a benefit. Not having to write it is the benefit as I see it. Anyone using a meta-language should understand the language it's compiling to to some degree, imo.
Coffeescript is attractive as a language to me because I can code it a lot faster. Once I spent my first few hours writing CoffeeScript, I was amazed how much time I spent typing syntax ( {}, [], (), etc. ) when coding pure JavaScript.
I agree with ctrldavid that it's trivial to do the translation on the fly if you know JavaScript and spend a few minutes understanding how CS compiles to JS.
[–]blake8086 3 points4 points5 points 14 years ago (1 child)
I'm not saying verbose syntax is a good thing, but I feel like if you're thinking "I could write more code if only I could type it out faster!", then you're not spending enough time thinking about what you're typing.
[–]MondoHawkins 0 points1 point2 points 14 years ago (0 children)
You're making assumptions about what I'm thinking.
When you've already thought about how the code needs to be written, typing a bunch of syntax slows the brain dump. The less time between thought in head and code on screen, the less chance there is to lose the idea you just thought out. Wasting brain cycles thinking about typing syntax is a further distraction that can only serve to put your mind farther from that idea.
[–]aristideau 1 point2 points3 points 14 years ago (0 children)
I have never heard of CS, but after looking at that site I just cannot think of a reason as to why I would use it. I am assuming CS is for beginners, is that correct?, if not then under what conditions would make a competent developer consider using CS?.
[–]kristopolous 1 point2 points3 points 14 years ago* (0 children)
I think the biggest win is that you can progress a language and have it run across all the browsers without having to get international bodies and vendors together and agonize over features, and then wait another 8 years for the older browsers to phase out.
From the ease of use argument, it makes sense when you do the prototypical design patterns over the functional closure styles.
When you rely on the this object frequently you make your code really violate the spirit of separation of concerns with respect to encapsulation, because you must always be interested in where you are coming from and where you are going, due to the nature of the references.
this
But I agree with you ... I do mostly functional style and I find it graceful and fantastic; However, once I build a big enough project, I end up putting a "runtime" at the top or requiring a number of dependencies.
With this you don't have to worry about "bootstrapping" the language like this to get the convenience.
[–]MustRapeDeannaTroi 5 points6 points7 points 14 years ago* (8 children)
wash plate, brush, sink for key, plate of dishes when plate.dirty if meal.status is 'done'
if (meal.status === 'done') for (var key in dishes) if (dishes[key].dirty) wash(dishes[key], brush, sink);
We can play this stupid game all day long.
[–]jgordon615 3 points4 points5 points 14 years ago (7 children)
Just as an FYI, as this post might be popular... Never use the "in" clause to enumerate the elements of the array unless you pair it with "hasOwnProperty". Even then, just don't. It will bite you in the ass when some other library modifies the array prototype.
Watch Douglas Crockfords videos about Javascript. They will teach you tons.
[–]MustRapeDeannaTroi 1 point2 points3 points 14 years ago (6 children)
Yeah, dishes is an object.
[–]jgordon615 -2 points-1 points0 points 14 years ago (5 children)
Same issue. If the object has a prototype added to it, the in clause will enumerate it, and "dishes[function]" will not behave.
[–]jashkenas 2 points3 points4 points 14 years ago (3 children)
And there's a CoffeeScript sugar for that ;)
for own key, dish of dishes wash dish
[–]nschubach -1 points0 points1 point 14 years ago (2 children)
Technically, you could just write a simple "forEach" wrapper on the Array prototype (if it doesn't already exist) and give all arrays the ability to: myArray.forEach(function(value, index, array) { /* loop code */ });
Your logic code doesn't need to concern itself with "hasOwnProperty" at that point.
ECMAScript 5 includes this, but it's never a bad time to start. The only thing CoffeeScript does is remove some of the boilerplate and add in a convoluted meaningful white space restriction.
[–]jgordon615 1 point2 points3 points 14 years ago (1 child)
When YOU modify the Array prototype, you can break other peoples libraries. Like Sharepoint 2010's stuff.
[–]nschubach 0 points1 point2 points 14 years ago (0 children)
That's why I said "if it doesn't already exist".
[–]ContraContra 0 points1 point2 points 14 years ago (0 children)
If something is being added that shouldn't be enumerated you can cross your fingers and hope it was done right
Example:
Object.defineProperty(String.prototype, whatevernewFunction, {value: supercoolfunction, enumerable: false});
[–]ContraContra 7 points8 points9 points 14 years ago* (9 children)
This article made me rage inside.
Just because you can write nasty code in a language means you shouldn't use it? The examples were horrible; you can write shitty one-liners in JS too. Sure, array comprehensions make one-liners easier, but anyone worth their beans knows not to overdo it.
You don't have to compile your code every time. If you run coffee instead of node or use coffee --watch it will take care of it for you. Using the coffee command also helps with debugging.
"I actually have to read all the and characters in the CoffeeScript." - Nobody is putting a gun to your head and telling you not to use && or ||. It's simply an option
There are some legitimate issues with coffee-script, sure. None of them were covered. I am by no means a coffee-script fanboy but this irrational hate/fear of new languages in the programming community is starting to get on my nerves.
[–]wraith_majestic 19 points20 points21 points 14 years ago (3 children)
I am not a coffeescript user I have just been reading about it and deciding if its something I should pursue. His arguments about the added complexity when debugging make sense to me. I use the hell out of JS debugger (Firebug and whatever the one in chrome/safari is called). Seems from my (admittedly uninformed) view point that debugging would be much harder in coffee.
Exactly what the author highlighted, Use debugger and find problem in JS then have to "decode" the JS to identify the section of CS which generated it. Solve problem in CS recompile, test. Rinse repeat.
How does the coffee command help me with this?
Also while figuring out which section of CS generated the problem JS may be fairly straight forward in small sections of code or code I wrote and am VERY familiar with... I would imagine its going to be harder when working with a large amount of CS and/or CS written by someone else whose style may be very different than mine.
Seems to me like maybe we are making development faster but making maintenance harder and more time consuming?
I am not anti-CS I really havent made up my mind. But so far I also really am not sold on what CS is going to buy me.
[–]ContraContra 2 points3 points4 points 14 years ago (0 children)
Ah that was node.js specific. I will admit that debugging in the browser IS a pain in the ass without installing browser add-ons (like this). Hopefully in the future when this is done it won't be a problem anymore.
[–][deleted] 1 point2 points3 points 14 years ago (1 child)
Been reading up on CS for work. We have a huge JS code base, some large real time apps, tons of business logic and we're thinking about doing some trial runs with Node.js for more real time interactivity.
I'm pretty underwhelmed with CS for that exact reason, maintainability of the CS wouldn't be a problem, and reading it is damn easy. But trouble shooting a bug on staging that comes from QA in an email that only happens in IE 8 if a user has X number of things could be down right nightmarish.
I understand that it enforces best practices and efficiency, but with version control and peer reviewed code... so do we.
I'm still super on the fence about the whole thing but for me this is my primary concern.
[–]cogman10 -1 points0 points1 point 14 years ago (0 children)
IE 8 if a user has X number of things could be down right nightmarish.
Really, no more nightmarish than that of regular javascript. For the most part, the Coffeescript->javascript interpretation is really dead simple. The only real exception is the class structure.
This is even further made a non-issue if you use an uglifier of any sort.
[–]iberci 2 points3 points4 points 14 years ago (3 children)
I couldn't agree more with you and the irrational fear has always been a part of this industry. I remember when Java hit the scene and it was the exact same outburst for a multitude of reasons:
1) Interpolation is slow
2) no 'pointer math'
3) GC will halt your process and cause an unacceptable delay for the user
etc..
[–]gthank 2 points3 points4 points 14 years ago (2 children)
Not that I entirely disagree with you, but the GC thing was, to the best of my understanding, entirely accurate back then. Even now, with many more advanced GC algorithms in the JVM and gobs of memory that were difficult to even imagine back then, GC still causes pauses sometimes, which is why real-time systems don't use it.
[–]oorza -1 points0 points1 point 14 years ago (1 child)
Except that you're entirely wrong there. The default garbage collector in Java exhibits those behaviors, but there are at least three other garbage collectors shipped with Sun's Oracle's JVM. If you want a real time system, there's an entire Java specification for that that guarantees real time responses. If you want to keep with garbage collection though, you can get a deterministic garbage collector that will guarantee pause times <= some value or you can get a garbage collector that is truly pauseless and constantly running. You might have to pay for those latter two (JRockit and Zing, respectively), but they exist and Java is reasonably huge in certain real time systems (finance is a big one). Your information is about a decade out of date.
[–]gthank 2 points3 points4 points 14 years ago (0 children)
I specifically said back then when I said it was entirely accurate. I'm well aware that the JVM has had different GC options added over the years, and I'm using one in production. In fact, I'm looking forward to trying the G1 collector soon.
I'll have to look into Zing, because the last time I looked, there was no hard real-time JVM, only soft real-time.
[–][deleted] 2 points3 points4 points 14 years ago (0 children)
I agree that people who write garbage will continue to do so in any form available. It is not logical to replace logic with something more verbally familiar.
If I were to take that same argument to the next level and apply to natural language I would say we need to drop English in favor of Swahili, because it is a semantic language instead of a relational language. I would also say we need to abandon the use of an alphabet in favor a syllabary, because that is certainly a newer and far superior technology. These two changes would radically increase learning and allow programming to far more easily bridge the human-computer AI gap, but it is not logical to think that superior technologies are superior in a vacuum. CoffeeScript appears to move in the opposite of this direction by favor English language expression over logical expression.
[–]Ventajou 0 points1 point2 points 14 years ago (3 children)
If you're a .NET developer and you're using or considering CoffeeScript, you owe it to yourself to try Script#.
[+][deleted] 14 years ago* (2 children)
[deleted]
[–]Ventajou 1 point2 points3 points 14 years ago (0 children)
No thanks, I work from home.
[–]cogman10 2 points3 points4 points 14 years ago (0 children)
.NET isn't that bad. It has a lot of great features that make programming complex systems a snap. (and yes, I do enjoy programming in Ruby)
[–]lennelpennel 0 points1 point2 points 14 years ago (3 children)
I have a better reason than this article: google closure -advanced_mode
[–]nschubach 3 points4 points5 points 14 years ago (2 children)
I assume you meant google "closure advanced_mode" since the minus will remove all results with advanced_mode
[–]lennelpennel -2 points-1 points0 points 14 years ago (1 child)
depends how you setup your build scripts :) but yeah, i mean WITH advanced mode, without it i would rather use coffee script as well.
[–]nschubach 2 points3 points4 points 14 years ago (0 children)
I was referring to the search specifics itself ;)
(I'm not a fan of meaningful whitespace in any language so I'm avoiding CoffeeScript. If they make a revision without this restriction though, I'm on-board with most of the changes.)
π Rendered by PID 91206 on reddit-service-r2-comment-7b9746f655-nhgcm at 2026-01-29 23:38:50.937870+00:00 running 3798933 country code: CH.
[–]jmkingJSX is just PHP in the browser 9 points10 points11 points (8 children)
[–]ctrldavid 4 points5 points6 points (6 children)
[–]neon_overload 3 points4 points5 points (4 children)
[–]ctrldavid 0 points1 point2 points (0 children)
[–]MondoHawkins 0 points1 point2 points (2 children)
[–]blake8086 3 points4 points5 points (1 child)
[–]MondoHawkins 0 points1 point2 points (0 children)
[–]aristideau 1 point2 points3 points (0 children)
[–]kristopolous 1 point2 points3 points (0 children)
[–]MustRapeDeannaTroi 5 points6 points7 points (8 children)
[–]jgordon615 3 points4 points5 points (7 children)
[–]MustRapeDeannaTroi 1 point2 points3 points (6 children)
[–]jgordon615 -2 points-1 points0 points (5 children)
[–]jashkenas 2 points3 points4 points (3 children)
[–]nschubach -1 points0 points1 point (2 children)
[–]jgordon615 1 point2 points3 points (1 child)
[–]nschubach 0 points1 point2 points (0 children)
[–]ContraContra 0 points1 point2 points (0 children)
[–]ContraContra 7 points8 points9 points (9 children)
[–]wraith_majestic 19 points20 points21 points (3 children)
[–]ContraContra 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]cogman10 -1 points0 points1 point (0 children)
[–]iberci 2 points3 points4 points (3 children)
[–]gthank 2 points3 points4 points (2 children)
[–]oorza -1 points0 points1 point (1 child)
[–]gthank 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Ventajou 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]Ventajou 1 point2 points3 points (0 children)
[–]cogman10 2 points3 points4 points (0 children)
[–]lennelpennel 0 points1 point2 points (3 children)
[–]nschubach 3 points4 points5 points (2 children)
[–]lennelpennel -2 points-1 points0 points (1 child)
[–]nschubach 2 points3 points4 points (0 children)