Earlier quoted context omitted.
Indeed it can use all the standard library modules, since the normal "require" functions are available. The other problem with the REPL is that all variable assignments are prefixed with "var", so they're always local to the function where the eval-ing is done, thus it's impossible to get variables to persist between REPL commands (without explicitly assigning to a property of "global"). One solution would be to add…
Alright -- this is fixed with the latest commit. I've enhanced the --no-wrap option to not emit "var" declarations at the top level. If you don't want the safety wrapper, then you probably intend to make them global in any case. bin/cs now works like a charm. I might pull it back into the main bin/coffee-script executable. Start a REPL if run without arguments ... --run for executing CoffeeScripts via Narwhal... some…
CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
51–60 of 67 posts
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#52CoffeeScript + node.js + V8 could produce one amazing language and implementation. Great job on the syntax, I think it's cleaner and more readable than JavaScript.
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#53Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#54I believe there is a bug in your object model for handling super. I have tested it and it does indeed work incorrectly (although not in the way I expected it to work incorrectly). Basically, your super calls only work if your class tree is 1 level deep. As soon as you have something like Animal -> Horse -> BigHorse, then it breaks down. This is because super() gets translated to: this.constructor.prototype.NAME.call(…
Thanks for that. You're absolutely right -- the javascript dynamically-scoped "this" keyword strikes again. I've fixed it in the last commit, by using prototype.__proto__, and adding an "extends" keyword for convenience. You can see it in action here: http://jashkenas.github.com/coffee-script/#inheritance It's out with version 0.1.2 now.
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#55I believe there is a bug in your object model for handling super. I have tested it and it does indeed work incorrectly (although not in the way I expected it to work incorrectly). Basically, your super calls only work if your class tree is 1 level deep. As soon as you have something like Animal -> Horse -> BigHorse, then it breaks down. This is because super() gets translated to: this.constructor.prototype.NAME.call(…
Thanks for that. You're absolutely right -- the javascript dynamically-scoped "this" keyword strikes again. I've fixed it in the last commit, by using prototype.__proto__, and adding an "extends" keyword for convenience. You can see it in action here: http://jashkenas.github.com/coffee-script/#inheritance It's out with version 0.1.2 now.
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#56Earlier quoted context omitted.
Thanks for that. You're absolutely right -- the javascript dynamically-scoped "this" keyword strikes again. I've fixed it in the last commit, by using prototype.__proto__, and adding an "extends" keyword for convenience. You can see it in action here: http://jashkenas.github.com/coffee-script/#inheritance It's out with version 0.1.2 now.
Be careful with __proto__, it's non-standard and will break in some engines.
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#57CoffeeScript's now up to 0.1.3, which includes --interactive to launch a CoffeeScript REPL, and --run to compile and execute scripts in a single pass. Both options depend on a working Narwhal installation.
Now, add a minifying pass after compilation for deployment and you'll have created a dream platform for client-side scripting (-:
edit: another suggestion since one of your goals is terseness: you may want to alias "prototype" to "proto".
edit2: as much as I like the column for asignment (present in both JS itself and Ruby 1.9), I'm not really fan of the +:, -:, etc. combined operators, at least in a math context. &&: and ||: look fine though so it's perhaps a matter of getting used to it.
edit3: I just discover your underscore.js library. Do you plan to include it in the CoffeScript standard lib?
edit4: oh... And I hope you like the color of this brand new bikeshed I just built in front of your coffe shop ;-)
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#58CoffeeScript's now up to 0.1.3, which includes --interactive to launch a CoffeeScript REPL, and --run to compile and execute scripts in a single pass. Both options depend on a working Narwhal installation.
Sweet! Now, add a minifying pass after compilation for deployment and you'll have created a dream platform for client-side scripting (-: edit: another suggestion since one of your goals is terseness: you may want to alias "prototype" to "proto". edit2: as much as I like the column for asignment (present in both JS itself and Ruby 1.9), I'm not really fan of the +:, -:, etc. combined operators, at least in a math cont…
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#59Heh... Might want to choose a file extension other than ".cs".
Yeah, all the good extensions are taken -- .cof and .cfs are already other things as well. None of the tooling in the compiler cares about what extension you use: you can call it .coffeescript if you'd like. I'm going to stick to .cs for the parallel to .js for the time being.
Re: CoffeeScript, a little language that compiles to JavaScript. Happy Holidays, HN
#60Cool. I've been dreaming of writing a similar python => javascript (which someone has probably done already). My only worry about something like this is the extra step of compiling, though I run a script that compresses via YUI comp. anyway... Thanks for sharing.
I had written a mostly functional python->JS translator using the compiler and compiler.ast packages, but I suspect this is more complete and actively developed.
My package is here if you wanted something stand-alone (but only 80% complete) to play around with: http://github.com/jeffjenkins/py2js