Hacker News new | past | comments | ask | show | jobs | submit login

Normally, I'm skeptical of "change the syntax and your life will magically get better, no matter how headachey interacting with the rest of the world will become", but then Thomas showed me Sass and it was lifechanging. (After you've gotten around Sass, CSS looks like Assembly code to a web programmer. I mean, sure, you could write it... but you'd need a damn good reason to. If you haven't tried it yet, make yourself an excuse for a weekend project -- it will make your life better.) Has anyone found CoffeeScript to be lifechanging?



After a few months of CoffeeScript development I vastly prefer it to JavaScript. Jeremy, et. al., have done a beautiful job with it. I've used Sass/Less as well and believe the JavaScript/CoffeeScript divide is even more valuable.

Edit: I wrote about some of my favorite features of CoffeeScript when we added CoffeeScript support to our CMS app HiFi... http://www.gethifi.com/blog/hosted-cms-coffeescript-support

tl;dr:

1) Lightweight function declarations (with default values!)

2) Implicit Returns

3) Everything is an Expression

4) Object Literal YAML-like syntax

5) Simple, Classical OO Features (you don't have to use them and can still directly access prototypal features, too)

6) (Not in the post) Binding 'this' to the scope's 'this' using => is awesome.


Yes, CoffeeScript is amazing. No more headaches over missing semi-colons, callbacks feel significantly less "spaghetti-like". Syntactically it feels much cleaner and I've found that I end up staying much nearer to the left margin than I did with JavaScript.

Debugging has not been a problem for me yet, the generated JavaScript is very clean and easy to navigate.

That being said, I'm a Python fan, so I consider significant whitespace to be a feature, not an irritant.


It's hard to debug when you get compile errors though. I gave up on the language when I could not figure out why a script wouldn't compile; the errors given are basically worthless.

Later I opened the file on Windows (Notepad++) and saw that one line had not been indented, which wasn't showing up on Vim/Gedit. I never tested it to see if that was indeed the problem, I'd already moved on.


You should have gotten an error for missing an indentation on one line. For example, given this mis-indented script:

    if one
      if two
        two
    oops
      one
The error given is:

    Parse error on line 4: Unexpected 'INDENT'


Too bad you "already moved on". I coded in CoffeeScript in Gedit for a few weeks now. A CS compile error in the version I have does show the line number... and if it compiles and I have a runtime JS error (also with line-number in NodeJS) then opening the compiled JS file in my ./project/_js folder and jumping to the line is also not a Big Deal at all.

Since the compiled JS is just-the-code-I-wrote-myself only in a slightly more verbose curly syntax, troubleshooting my own CS code even when compiled in JS is totally not an issue. Thankfully Coffee does not minify or otherwise obscure the code.


Considering duolagies comment: was that recently or could it be that error messages have improved since then? It would be a shame to let a good thing go because it was insufficiently mature the first time you looked at it.


Thats almost the same as someone claiming Python is a huge fail - because he didn't know how to configure his editor properly.

Alas, poor error messages are a big -


I didn't say the language was a huge fail. I don't have a background with indented languages, and although the code looked correct to me, it wasn't, and not having the knowledge of what could be wrong, I was dependent on the compiler, which gave me no help. I'm ok with curly brackets and semi-colons, so there wasn't any reason to continue wasting my time in a fruitless attempt to figure out what I did wrong. I'm not down on the language at all, bad compiler errors are expected in one year old languages. I'll give it another look on my next project.


I think it's a valid point. Regardless of the fact his editor wasn't configured properly, the fact that the error messages that were generated did not IMMEDIATELY point him in the right direction is a problem with the language and the compiler. Any good product attempts to alleviate human error as much as possible. Obviously in this person's case that goal wasn't achieved.


Paste this line into your files:

    # vim: ts=2 sw=2 et :


I've been using list/listchars for a few years and have come to really like it:

  set listchars=tab:»·,trail:·
  set list
That will show tabs with a little double arrow and trailing dots, and show whitespace past the end of the line with dots.

Regardless, with coffee being default in Rails 3.1, I'm sure editor support will show up quickly. For the time being though, I just stumbled onto this: https://github.com/kchmck/vim-coffee-script (have not tried it myself).


I'm using the vim syntax file and plugins from vim-coffee-script and really like it so far. It even will mark trailing whitespace by highlighting it red (this is configurable as well).


Personal preference here, but I generally like to write the "full" version of configuration option names in my .vimrc (and when giving config advice to other Vim users), because after a month of not touching my RC file, it's easy to forget what those abbreviations stand for. (I tend to limit the shorthand versions of things to the interactive Vim commandline.)


Ok... care to explain?


It's a directive for VIM to set the tabstop to 2, the shiftwidth to 2 and to enable the expandtab option.

The tabstop variable sets the ratio of tabs to spaces (in this case, one tab is equivalent to two spaces).

The shiftwidth variable controls how much a line gets moved when it gets "shifted". In VIM pressing << in Normal mode on a line does a left shift. With a shiftwidth of two, it will move it over two spaces to the left. >> is right shift. There are many more ways of shifting, however.

The expandtab option sets it up so that every time you hit the tab key, VIM will insert the equivalent number of spaces according to the tabstop. In this case, pressing tab will give you two spaces.


This makes sure that your CoffeeScript files never end up with mixed tabs/spaces, which will result in the compiler getting confused, and your hair being pulled out from "invisible syntax errors"


It's a shame that this hack is necessary; it would have been so easy for the language designer to simply declare that any tab characters used as indentation result in a syntax error, and poof: a whole class of errors simply become impossible. Don't get me wrong; I will probably reach straight for coffeescript the next time I write code that runs in a browser, but this is the one thing that cools my enthusiasm for it.


It's a shame that this hack is necessary; it would have been so easy for the language designer to simply declare that any tab characters used as indentation result in a syntax error

then someone else would say that it's a shame that TABS aren't supported and that it would have been so easy for the language designer to support them. I'm sorry if it sounds snarky, but I find it arrogant to assume that design decisions are "easy" simply because they look easy to implement.



All that to say it seems pretty uncontroversial to say that Python and Make have shown that the problem is not necessarily with meaningful indentation itself, but with the ability to have two expressions that are visually identical with different meanings.


... unless, the person has a comic strip to back it up. :)


If using 'et', it's not necessary to make 'ts' equal to 'sw'. Just make 'sts' equal to 'sw' or use 'sta'.


I'd follow it up with:

  gg=G:retab!<CR>


The creator of CoffeeScript acknowledges debugging is a problem and somewhat "daunting" for beginners (though your issue sounds more like an editor config issue). http://thechangelog.com/post/849754840/episode-0-2-9-coffees...


Second that. Coffeescript is really life changing. A very DSL friendly language, where beautiful code can rival python's[1]

[1] http://metaphysicaldeveloper.wordpress.com/2011/03/31/354/


Now I have to put on my fruity hippie developer hat. I feel like it makes a big difference when a language implementor values beauty in code. CoffeeScript was created by someone who values the aesthetics of code, and it shows.

The CoffeeScript documentation is a fantastic exposition of that: http://jashkenas.github.com/coffee-script/


Indeed. Newcomers usually describe CS as "Pythonesque" (because of significant whitespace) or "Rubyish" (because of optional parentheses) depending where they're coming from. I find that a little funny.

Truth is, it's borrowed from both, and other languages besides, to synthesize a gorgeous syntax which is really its own.


It is not quite as big as CSS->Sass — that takes CSS from a dumb configuration language to a grown-up programming language with functions and variables. But it is a big difference, and it's not just syntactic.

First of all, I'd like to point out that syntax is not entirely irrelevant, at least not in the sense that CoffeeScript is "just a weird syntax" for JavaScript. Python decorators and list comprehensions are generally thought of as very nice features of the language, but they're really just a nice syntax for higher-order functions and iteration. That syntax makes a big difference. Just adding CoffeeScript's syntax for functions (including the do-operator) and the existential operator would noticeably reduce the size of most JavaScript code, without anything else.

But the difference isn't just syntactic. Here are a few semantic changes in CoffeeScript:

• Everything is an expression (a la Ruby)

• Equality is always strict

• A simplified class-based inheritance model on top of JavaScript's prototypal inheritance

• Switch is almost identical to Ruby's case expression rather than C's switch statement (i.e. clauses don't fall through and it's an expression rather than a statement), which makes it much more useful

I'll put it this way: I've been making websites since 1995 and am fairly proficient in JavaScript, but I have never really liked the language all that much. But CoffeeScript is a joy to use. I actually enjoy programming it, and it's just amazingly readable (both from the nicer syntax and the fact that CoffeeScript's sugar means you don't have to write as much code, and it's easier to understand five lines than 20, even if 15 of the 20 are boilerplate).


For someone who has little or no experience in JS and CS, how realistic is it to get away without learning JS and skip directly to CS ?


Not very realistic. CoffeeScript semantics are nearly identical to JavaScript semantics -- you'll have to understand them.


Hate to disagree with such a distinguished source, but having done it:

Very realistic. Looking at the compiled CoffeeScript taught me more Javascript than all of the tutorials put together, and CoffeeScript itself was a joy to learn. I think you're under estimating your own baby here, jashkenas.

I would point out that you're not so much 'skipping' learning JS, as that learning CS is the quickest way I've found so far to learn JS.


Hey, that's wonderful.

I'm just saying that you're not in any way going to avoid learning JS by starting with Coffee -- you still need to know:

  * How JS numbers work.

  * All about "this" (dynamic scope).

  * Function vs. block-level scope.

  * How the prototype chain is structured.
... and all those other un-obvious things about JavaScript.


True, but I would need to learn these regardless of which syntax I use to write my JavaScript. And coffee actually helped me to become aware of/understand some of these issues: -> vs. =>, for example, or the prototype code produced by your 'class' syntax.


Spend a couple hours reading "Javascript: The Good Parts" by Douglas Crockford. Read it twice, cover to cover.

The other option is to skip learning javascript properly, which I tried... and it came back hard at me when I tried going beyond enhancing my pages with jquery.


I'd say it is realistic for what you're probably trying to do off the bat with Javascript.

It's what I did. Since I'm already comfortably with Ruby and CoffeeScript's simple syntax, I used CoffeeScript's "Try CoffeeScript" console to insert Ruby-like code and get the Javascript equivalent. Helped me rapidly map Ruby-Javascript equivalences in my head.

Now that I'm quickly comfortable with Javscript's surface and my foot's in the door, diving deeper into the language isn't the obstacle I used to consider it as.


Very realistic until you need to debug your code. Debugging's JS-only, as far as I know, so you're picking through the compiled CS looking for errors.

edit: Well listen to the man himself, but I learned tons about JS's semantics by picking up (and picking apart) CS.


CoffeeScript "fixes" javascript in many very essential ways. The most important fix is the lack of global variables. It's all too easy to accidentally forget a var on an assignment and all of a sudden you get a global variable that can cause havok. CoffeeScript handles variable scoping extremely well, and if you need a global, you can use the more explicit: window.var = ....

Also it's class system and function binding (=>) is something I feel I can no longer live without.


I don't know any thing about CoffeeScript, but static analysis tools like the Google Closure Compiler can help you take care of global variable problems and a whole lot more. Using Closure Compiler, you are forced to document your code with their enhanced version of jsDocs, so CC will make sure that if your method returns null or a list of strings, that anywhere that method is used, you don't try to treat the returned value as a string or object, for instance.

How does coffee script play with existing object oriented JS libraries? Is there compile-time type checking?


I always thought it would be cool if CoffeeScript's generated JS code added Closure Compiler annotations, such as @const and @param types. Let the user minify/optimize the generated JS using their favorite tools.

https://code.google.com/closure/compiler/docs/js-for-compile...


This fork of CoffeeScript does: https://github.com/jstrachan/coffee-script/blob/master/TypeA.... I for one would also love it if this got rolled into mainline. I use Closure at work, and I'd love to be using CoffeeScript with it.


Thanks! I hadn't seen this "UberScript" before, though I was kinda hoping the Closure annotations could be inferred "for free" without changes to the CoffeeScript language. <:)


Automatically annotating JavaScript code for JSDoc would really helpful.


One of the niceties of CoffeeScript generated code is that it's totally readable and idiomatic Javascript with a dose of JSLint on top.

To misquote the "Pragmatic Programmer" book... don't use wizard code you don't understand. The opposite applies in my opinion.


The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. http://coffeescript.org


> "change the syntax and your life will magically get better, no matter how headachey interacting with the rest of the world will become"

Life won't get better if interacting with the rest of the world becomes headachery, but thankfully the products in question aren't too hostile to rest of the world. There isn't much of an impedance mismatch between CSS and Sass and following the generated code is easy.

From what little I have written of Coffeescript, it generates clean Javascript and should be easy to follow for anyone who knows Javascript. It's not lifechanging per se but there are things which are much more elegant in Coffeescript.

1) Convenient 'this' binding using =>

2) Lexical scoping. Not much of an issue since I use the 'var' keyword all the time; either that or window.foo or something similar depending on what I am trying to do.

3) I have coded in Python and the "mandatory indentation sans braces" is something I am used to and appreciate. It makes the nested event handling calls prettier.

4) I don't need to use underscore.js while using Coffeescript. The language has some essential feature built-in.

5) The existential operator. From the docs:

"It's a little difficult to check for the existence of a variable in JavaScript. if (variable) ... comes close, but fails for zero, the empty string, and false. CoffeeScript's existential operator ? returns true unless a variable is null or undefined, which makes it analogous to Ruby's nil?"

6) String iterpolation, here docs.


Definitely. We are a mostly-Clojure shop, but we do quite a bit of complex Javascript as well. Coffeescript makes it fun and productive.

Best of all, there are fewer lines of code to make mistakes in. And fewer stupid "forgot a semicolon" problems.

I'd suggest that people also look at Underscore.js (http://documentcloud.github.com/underscore/) and Backbone.js (http://documentcloud.github.com/backbone/). Same authorship, same quality code, great ideas, great execution.


I don't know if I'd consider it life-changing for the world of client-side javascript (I have yet to use it there), but using it in the callback-filled universe that is Node.js, its simplified and clean syntax is worlds better.


I'm hoping there will be a day where I can use:

  <script language="coffeescript">


You can do that now, with caveats:

http://jashkenas.github.com/coffee-script/#scripts


I've seen that, but I wonder why it says "not recommended for serious use". If it's just slower, I'd be ok using it for simple things, but if it's buggy I'll just use BistroCar.


It's not recommended for serious use because:

* You have to include the "coffee-script.js" compiler file, which is medium large (mostly the generated parse table).

* It's harder to debug, because you're debugging through an eval(), without the compiled JavaScript handy.

Those two caveats aside, it works fine. All of the interactions on the CoffeeScript.org homepage are powered by it.


Yes, it's my favorite language. Very fun and nice to work with. Lends itself well to another one of Jeremy's contributions, http://jashkenas.github.com/docco/, and his way of writing code as a story, which I try to mimick.

If you like Sass, you should check out Stylus. Similar, but better. http://learnboost.github.com/stylus/


I'm using LessCSS, not Sass. And I wouldn't consider Sass life changing.

    CSS looks like Assembly code ... you could 
    write it... but you'd need a damn good reason to
I think LessCSS is better because it keeps syntax compatibility, and you can take an existing CSS file and then gradually improve it. It's also, well, simpler.

That said, I can live without the improved CSS features. When I'm working on design-stuff, what really gets in my way is the lack of talent.

As for CoffeeScript, the language looks really interesting, but IMHO, it's just another tool that you need to add to an already HEAVY stack, another tool that breaks and needs special care from time to time, another tool to be learned.

And I'm not sure that CS is so life-changing. Does it fix browser incompatibilities for you? Does it optimize Javascript to run faster? Is it easier to debug? Does it have a kick-ass library that's optimized for it?

IMHO, syntactic sugar (without new paradigms) doesn't get you further than changing your text-editor / adding some newer snippets to it for the boilerplate.


The new, main syntax of Sass is now "SCSS", and is a superset of CSS3’s syntax, so every valid CSS3 stylesheet is valid SCSS as well.


From what I understand, the SCSS syntax is mainly just for compatibility with CSS. I'm sticking with SASS as long as it's officially supported, since I like getting rid of all of the curly braces and semicolons.


Officially SCSS is the "primary syntax" and SASS merely the "old syntax that is still supported".

I never understood the rationale behind this decision (does anyone prefer SCSS over SASS?), but who cares as long as SASS remains a first-class citizen.


SCSS lets me migrate an existing css file without rewriting anything and drop in random snippets I find on the web without translation. It solves exactly the problem I have (limited expressiveness) without introducing a new one (new syntax to learn).


sass-convert is your friend and takes care of both of your problems for you.


How, and with what input and output formats? I said I like SCSS.


If you output to a file with a .scss extension it will auto-detect.


I prefer SCSS to SASS, but I like braces. I also find being a superset of regular CSS to be a plus (even though it's not something I've actually used in practice).


I prefer to use the SCSS syntax rather than the SASS syntax (and I've used both) mainly because I don't use HAML and I have a deep distrust of significant whitespace that is syntactically significant.

The SCSS syntax works for me because it's like normal CSS but with extra useful features - functions, mixins, nesting, etc.


I've only ever used SCSS, mostly cause it was the "official" version when I first used it. I also think that SASS files look weird to me...for whatever that's worth. SCSS eing a superset of CSS is huge too, IMO, as one of the bigger push-backs I get from lots of people on SASS is it's "another language to learn" and you don't get any benefit unless you convert everything. That goes away with SCSS.


I'm never giving up the original SASS syntax. It mirrors HAML so closely it makes the separation of semantics and styling so easy and natural.

If I need to paste in some sample css from the web I just copy it to the clipboard and then:

    pbpaste | sass-convert | pbcopy
in the terminal, and the sass is ready to be pasted into the editor.


Scss also provides pretty good syntax compatibility with CSS. All it's features are a superset on top of CSS.


Can you explain why the syntax resembling CSS while having a different meaning is a good thing? I sincerely don't understand why so many people see that as a benefit. The syntax isn't actually compatible with CSS, in the sense that you can write Less or SCSS and a layout engine will be able to parse it and come out with a halfway correct result. It just looks like CSS.


The syntax of LessCSS is a superset of CSS, meaning it maintains backwards compatibility. It doesn't just look like CSS, it is CSS but with additions.

That means you can use that CSS file provided by the designer directly, and gradually improve it, or you can copy/paste examples given all across the web.


I guess that the benefit comes from being able to get regular CSS files a parse with LESS without syntax modification.

In some cases, that might be a good thing.


There are different vectors of attack when it comes to optimization.

The point of CS is to optimize for developer productivity and happiness, so I think your questions are largely missing the point. It's like asking "well that's a good screwdriver, but does it hammer nails?".

The correct question to ask is: what do I get from this syntactic sugar, and what do I trade. Or to stick with our metaphor:

"What does this screwdriver bring to the table, and does it INTERFERE with the hammering of nails etc?".

So as stated, CS lets you write code faster, express yourself more clearly, and removes headaches common to Javascript. These headaches are problems that are largely not addressed by other tools like jQuery (which have different goals).

To answer your questions:

> Does it fix browser incompatibilities for you

Yes, but only in terms of the language. CS compiles to lowest common denominator Javascript, so you know the compiled code will run just about anywhere.

So you don't have to worry about whether or not the browser's JS engine supports list comprehensions, because you're using CS.

The question is not so much "Does it fix browser incompatibilities for you".... but "Does it introduce browser incompatibilities?". To that, the answer is no.

>Does it optimize Javascript to run faster?

CS allows you to write really expressive code that gets compiled down to simple (but verbose) forms. This has the side-effect that CS code will generally be faster than Vanilla JS code that is written with a similar expressiveness.

In Vanilla JS you would generally have to introduce a library to get the same expressiveness, and that has a run-time penalty. For example: Something that is compiled to a simple for-loop in CS would require a bunch of function calls in a library in vanilla JS, adding a lot of overhead.

CS is not a tool to optimize code, so asking if it optimizes code misses the point. The real question is whether or not it introduces inefficiency, because if it does....that's a drawback that needs to be contrasted to it's benefits.

In this case, no it doesn't...and the code it produces is sometimes faster than similar vanilla JS code.

>Does it have a kick-ass library that's optimized for it?

CS is not meant to fill the same role as a library.

The question is not "does it have a library"...but "what's the implications of using CS vis a vis libraries?" The answer is CS interacts with JS seamlessly, use any library you like.

>Is it easier to debug?

No, because that's not the point of CS. CS is not a debugging tool. The right question is: "is it harder to debug?".

Here we hit what imho is the only real trade-off involved in CS.

Some will hem and haw about having an explicit compilation step; but the tooling support for CS is great and any serious JS developer can fit it into their dev process seamlessly (via commit hooks, watch, build scripts, etc).

Debugging problems is a legit concern, but in my experience it does not add significant problems. Errors in CS syntax are generally caught during compilation and other errors can often be easier to find because the CS code is cleaner and it's easier to catch errors in logic.

I think beginners will often hit problems with debugging and CS because it adds a layer to confuse them. Experienced JS devs on the other hand should be able to cleanly separate the layers and debug them effectively.

The tooling for debugging CS in the future looks promising and will improve the situation.

As for your suggestion that you could just improve your text-editor, use macros, etc....I think that's a good tool to have in your belt but it just doesn't compare to what CS brings to the table.

Either you'd be duplicating CS's efforts ...or you'd not hit the same level of capability...

In the first case, it'd be a pointless re-inventing of the wheel, but your wheel would have drawbacks CS lacks.

With CS there is:

- Lot's of editor support. Your suggestion is tied to 1 editor.

- Lot's of tooling support. There is framework support, and possible browser support in the future...etc etc. Yours would have none, or would need it written.

- Widespread use. Lots of coders will understand my CS code right off the bat, or can learn it easily. Not only will no one understand your crazy macros etc, there's little incentive to learn them.

In the latter case, it's not a valid comparison.

The real question here is what does CS bring to the table, and what do you trade for it. CS had demonstrable benefits and demonstrable drawbacks.

It's my opinion that the benefits dramatically outweigh the drawbacks, but that's a question every developer must ask and answer for themselves.

I get that your contention is somehow, "well if it doesn't do these specific things, it's not 'life changing'", but that seems a pretty arbitrary line to me.

I don't see how you can say developer productivity is not a vital factor in development....and that something that improves productivity, readability, development speed, etc...is not "life-changing", at least as much so as the other factors you mentioned.

When judged in terms of what it's goals are, I think CS is highly effective and far from "pure syntactic sugar" (which to me implies something that simply saves typing).


Dude, long post, little content.

    The point of CS is to optimize for developer 
    productivity and happiness.
That's a subjective claim that I also think is untrue.

CS doesn't have any new paradigms, the type system is the same as Javascript, scoping rules are the same, it's really nothing more than syntactic sugar over JS.

Even Ruby and Python have a lot more differences.

    well that's a good screwdriver, but does 
    it hammer nails
This analogy holds only when you're talking about (a) a screwdriver + (b) a hammer, i.e. totally different tools, with totally different use-cases.

Personally I never understood why people use it to make a point.


>Dude, long post, little content.

I find sometimes you have to repeat yourself a lot before people will understand a point.

> That's a subjective claim that I also think is untrue.

It's obviously my opinion, and I can't speak for the developer....but it's fairly accurate.

To say it's "untrue" it's just plain wrong, and if you're going to suggest that it's "untrue", you should offer your opinion as to what is "true".

Anyway, it's perhaps a simplification and incomplete, but it's demonstrably true.

If you go and read the docs for Coffeescript and what the creator has said, here is the general point made:

- Coffeescript is designed to make Javascript easier and faster to write.

- Coffeescript is designed to reduce some of the headaches associated with Javascript, and make it more expressive.

Those are the immediate goals, but the reason behind those goals is to increase productivity. Increased productivity is WHY those things are desirable.

Nobody just wants to type more JS code per minute for no reason at all.

>CS doesn't have any new paradigms

Well for one, that's not entirely accurate.

For one, In CS everything is an expression, which is not the case in JS.

However, even if we were to grant that point...it's moot.

See, this is why I have to repeat myself. Although it seems despite debunking this misconception over and over you still managed to maintain it.

CS isn't meant to be the latest and greatest language, or exist in a vacuum. If that was the point, why implement it on top of Javascript and put so much effort into making it compatible with Javascript?

CS doesn't introduce new "paradigms" (at least the kind you are getting at) because that's not what it's FOR.

CS isn't supposed to exist independent of Javascript, it exists to generate Javascript.

The fact of the matter is, for some reason some people don't analyze technology based on objective reasoning about it's merits.

In the Javascript world, jQuery and Coffeescript are prominent victims of this.

There's lots of reasons to dislike jQuery....but by far people hate on it for reasons entirely removed from facts.

Same with Coffeescript.

Remarking that Coffeescript doesn't optimize code is a complete non-sequitur.

More importantly this stupid implication that "syntactic sugar" is somehow pointless.

Haters always make some smug implication about CS being "only syntactic sugar", as if that's some sort of actual critique or something.

What these people don't understand is:

Syntactic sugar is a method whereby languages are improved.

There's nothing wrong with syntactic sugar, and it is very much a powerful and useful thing.

I can write list comprehensions in Cofeescript....you can't do that in vanilla JS unless you want your code to only run on certain engines.

That is one example of the power of "syntactic sugar".

People get confused because they mistake it for simple examples of syntactic sugar where

bar (x, foo(x, y, z))

is created from: foobar( x )

In that case the transformation is useful, but so sleight it's questionable whether the effort is worth it.

...but that's not what we're talking about.

>This analogy holds only when you're talking about (a) a screwdriver + (b) a hammer, i.e. totally different tools, with totally different use-cases.

YES... and that is what we are talking about. At least it's sure what I'm talking about.

When you compare Coffeescript to things like:

- Libraries - Code optimizing tools - Debugging tools - etc

Those are totally different tools with totally different use-cases.

If I'm curt it's because I'm sick of this nonsense every time CS comes up.

There's a few people who make actually informed points either for or against it based on facts and technical merits...

...and thens there's a bunch of techno-hipsters who either put it down or blindly adopt it without knowing what they are talking about. (not saying you are in this group, but read the comments any time CS is mentioned and you will see this group)


    When you compare Coffeescript to things like:
    - Libraries - Code optimizing tools 
    - Debugging tools - etc
    Those are totally different tools with 
    totally different use-cases
There's a world of difference between how typical projects are built in C++ versus Java, or in Java versus Ruby/Python, or in Ruby/Python versus Haskell.

And this has more to do with the capabilities of the runtimes, the introspection capabilities available, the available libraries, the debugging tools, the quality of the read-eval loop, the smartness of the compiler/VM to handle errors -- and a lot less to do with whether semicolons are optional.

You're trying to divorce these assets from the job of a programming language, or from the happiness experienced when using said language, but they are not divorceable, just as you can't separate a language from the compilers available (i.e. it's factually incorrect to say that languages themselves are not slow, as most languages in use have been influenced by known compiler/VM optimizations).

And my point about libraries does hold -- to use Rails, you need Ruby, and can't use it from Python because you would need a clone that's built for Python's capabilities, as while the type system is very similar, there are lots of differences (e.g. namespaces, scoping rules, decorators versus anonymous blocks, functions as first-class citizens versus Proc#call, mixins versus multiple-inheritance, method-dispatching itself, etc...).

But Javascript/CS are so similar that they can share libraries effortlessly. CS will never have the benefits of libraries, as those libraries will be usable from Javascript.

    If I'm curt it's because I'm sick of 
    this nonsense every time CS comes up
Dude, if it makes you happier, more productive, do whatever floats your boat. Tickling your aesthetic senses is a perfectly valid point for using a tool. I was just expressing my opinion on the matter.

And truth is I couldn't care less if it is being adopted as a default in Rails. Heck, I've been proven wrong before, and it may actually work out for the best.


Assembly : C :: CSS : Sass

(:: Javascript : CoffeeScript) would be a bit of a stretch IMO)


This guy.

Switching from Rails (et al) to Express (et al) can be a challenging prospect. Not having to give up your floaty modern scripting language syntax is a serious incentive. That aside from the fact that CoffeeScript almost forces you to write better JavaScript.


Making the switch from synchronous execution to asynchronous is the biggest switch for me so far. There doesn't seem to be many best practices yet and so I'm trying to figure out how to do things like ensure database access is available without opening a connection to the DB every time and setting up everything I want to happen in that call back. So far talking to people the consensus has been to just open it and pass around an instance of it. There may be errors if you start receiving requests before the DB is opened, but it will be a short window for this to occur. I'm not entirely happy with this, but am not really sure of a better solution.

With Rails these kinds of things (and other things like source layout and such) are just kind of taken care of for you. On the other hand, I'm having a blast doing some CoffeeScript + Node development.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: