Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
<script type="text/coffeescript"> (jashkenas.github.com)
37 points by meddah on Feb 25, 2010 | hide | past | favorite | 10 comments


I think this should probably point here:

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

The salient point is that CoffeeScript now automatically compiles any code in a script tag with type text/coffeescript. Pretty cool.


The gist of it is this. If you include the minified version of the CoffeeScript compiler on a webpage (43k, gzipped), it will compile and evaluate the inline coffeescripts on the page. That documentation site uses it to hook up the menu and the "Try CoffeeScript" demonstration in the toolbar.

If you view source, you'll see something along these lines:

    <script type="text/coffeescript">

      window.repl_run: ->
        try
          eval window.compiled_js
        catch error then alert error

      close_menus: ->
        current_nav.removeClass 'active' if current_nav
        current_nav: null

      $(document.body).click -> close_menus()

    </script>


While I like the concept of simplifying to increase productivity, I am not sure the source code of Coffeescript is any better than the original source code of JavaScript itself. The idea should be to simplify the languages, but as far as simplification is concerned, I think JavaScript is incredibly easy to learn and needs little simplification to its core syntax. There have been other projects, such as Dojo that make the complex tasks of JavaScript easier, and these I find incredibly useful, but to change the syntax of the language without significantly reducing the code size and complexity does not present a lot of value for the project. If this is expanded with one line AJAX scripts, the potential would be vastly improved for acceptance of this type of syntax replacement scheme.



I think the OP was pointing out that you can now use CoffeeScript in <script> tags.

I did something like this for Objective-J awhile back, but it's not particularly useful (http://github.com/tlrobinson/cappuccino-experiments/blob/mas...)


Yep, it's not particularly useful -- there's no case I can think of where you wouldn't be better off compiling your scripts to JavaScript first.

But if you just want to play with it, or prototype a web page, it's fun for that.


It's hard to take this seriously when the CSS gets in the way...


How does this compare with parenscript?


much fewer parens :) Seriously, though- no macros here.


Any real languages targeting PHP as a backend? this piss poor excuse for a templating language is making my life harder than it needs to be.




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

Search: