Skip to content

Comment on A Python programmer’s first impression of CoffeeScript

Comments

I rewrote the JS of a webapp in javascript today, enjoyed it a lot. The only thing I'm puzzled about is how you do ajax callbacks (with jQuery). Like how you would add an anonymous callback function. But it makes a good excuse for refactoring messy javascript, and it's not hard to pick up. I'd say the readability improvement is instant and applies to readers who've never tried Coffeescript, even if they know JS.

    $.getJSON url, (response) -> ...

    # Or, more detailed...

    $.ajax
      url: "/query.json"
      type: "GET"
      success: (response) -> 
        process response
      error: -> 
        alert "trouble!"
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.