Comments (38)
I think that would be pretty awesome, self-hosting the compiler would be like eating-your-own-dogfood and the language would be improved when issues arise in making an application with it
from coffeescript.
I'm not a big fan of dog food, I prefer to prepare tasty human meals, and this is one of the techniques that helps differentiate the two... plus it is a great test suite for a language ;)
from coffeescript.
It would be wonderful to try it. The lexer and code generation should be fairly translatable to CoffeeScript -- the trick is the parser. It would either have to use a JavaScript parser generator (I'm not sure if there are any yacc-equivalent ones in JavaScript), or we'd have to roll our own. I'm not going to be tackling this one any time soon, but if anyone wants to give it a shot they're more than welcome.
from coffeescript.
For me this is a chicken-vs-egg issue, I'd love to make the language self-hosted, but I do not want to install yet another interpreter (I mean Ruby) thus I'm waiting for it to get self-hosted.... and I do not want to waste time and write yet another bootstrap version of the interpreter/compiler in some other language just to throw it away when I'm done.
I'll think about this some more :)
from coffeescript.
However this will play out, I'd be very interested in helping. I think 2010 will be the year of the javascript superset languages.
from coffeescript.
JS is a really good language if you know how to use it, and if ECMA finally fixes several quirks that exist in the standard -- without creating an bloated elephant, which is the current draft .
IMHO, the only thing that can challenge JS at what it does, is something both more productive and efficient at the same time. and that is a real chore, because the simpler the work is the more one can do and the more one can do the more stress you apply to the VM, so efficiency, at some point will complicate things substantially.
I might not share your perspective on the L2 languages on top of JS, but this is something really fun and IMO quite worth a try! ;)
from coffeescript.
So is C, but I get a lot more done with Objective-C. And I can still just drop to C if I need to, same as I would like to do here. And although I trust these experts to come up with a great draft, I'd love many others to implement their own languages that I might like better and would work right away in every browser.
from coffeescript.
Well, ObjC is one great language and a great architecture... something I can't say of another "C based" language, the C++...
I'm not saying that it should not be done, rather that it should be tackled with care :)
from coffeescript.
I think I'll tackle this one in my free-time, no promises on a deadline since I'm super busy, but there is interest for sure. I'll plan to test on ES5 browsers and node.js for the initial prototype it shouldn't be too hard to expand it from there. http://bit.ly/5xMbaC
from coffeescript.
Great! One thing I've learnt reading these discussions is that everyone has his/her own ideas about how the language should work/look like, and would like to try out different things for that. So ideally it would be easy to define your own language for the compiler next to coffee-script.
from coffeescript.
Ok, I ported lexer.rb to lexer.coffee for a start. It's untested, so it probably doesn't work, but the coffee syntax compiles with the lastest ruby based compiler.
from coffeescript.
Awesome creationix!
from coffeescript.
Well, I never for the port of lexer.rb to run right, but I did right a nice lexer from scratch in CoffeeScript. It doesn't have all the features yet (like heredoc syntax) but it's quite easy to add. http://bit.ly/85ipYv
from coffeescript.
http://ajaxian.com/archives/jison-build-parsers-in-javascript
from coffeescript.
Jison looks really nice, but I don't want a dependency on a javascript tool that generates javascript. I really want my compiler to be written in pure CoffeeScript.
from coffeescript.
Hmm, I wonder if there's any possibility of a JS->CoffeeScript compiler.
from coffeescript.
There is for a subset of JavaScript, but since it's not a direct one-to-one translation it would be tricky.
from coffeescript.
Alpha release at http://bit.ly/7k5TA4. Enjoy!
from coffeescript.
cat's MEOW! thanks Tim!
from coffeescript.
btw, this is the first thing I tried to compile: http://gist.github.com/281210 an infix to postfix converter (which may be b0rken...) It didn't quite make it.
from coffeescript.
Can Coffeepot compile its own code?
from coffeescript.
Not hardly, but it's making progress. Currently I'm looking to using jison to improve my parser. That should help implement features a lot faster.
from coffeescript.
Ok, I rewrote the parser to use Jison, it's moving along faster now. Also, I put up a fun test site to see the progress of the language. (And play with fun css3 things).
http://trycoffee.org/
Tested on Firefox 3.5, Safari 4.0.4, Chrome 4.0249, and mobile Safari on an iPod Touch.
from coffeescript.
I love the look :-) what do you think of not using the minified version, and linking up the error messages like at http://trycoffee.org/coffeepot-min.js:35:313 that would be cool. So how long do you think it will be for coffeepot to compile itself? great work!
from coffeescript.
Status update:
For a related ticket, see here:
http://github.com/jashkenas/coffee-script/issues#issue/135
On the current node
branch I'm a bit stalled out. We've got a working Lexer and Rewriter, written in CoffeeScript, and a complete Jison translation of the parser. Unfortunately our grammar is too large and semi-ambiguous for Jison in its current state to handle. It'll happily peg your CPU, computing parse tables and lookahead rules until you decide to put it out of its mercy.
Ideally, we'd be able to simplify the grammar rules in some fashion, so that Jison can parse it in a reasonable amount of time. Another alternative that I've played with is ANTLR, but because it's LL*, we'd need to a ton of transformations to the grammar structure -- almost everything is a left-recursive "Expression", at the moment.
So, that's where things stand with CoffeeScript-in-CoffeeScript.
from coffeescript.
After talking to Zach, the Jison parser is back on track, adding to it bit by bit, most of the grammar currently compiles in about three seconds. So, that's the current focus -- finishing up the parser and starting on the code generation.
from coffeescript.
Status update:
CoffeeScript-in-CoffeeScript compiled its first expression last night. It's up to the point where it can handle this:
# I'm a comment.
@meth obj.prop[10]
And things are streaming along. If anyone wants to play with it, or continue to port over nodes.rb, here's the test setup I'm using. You'll need to have a check-out of the latest Jison (eventually we'll vendor it as a library).
require.paths.unshift '/path/to/jison/lib'
require.paths.unshift '/path/to/coffee-script/lib/coffee_script'
lexer: new (require('lexer').Lexer)()
parser: new (require('parser').Parser)()
code: '''
@meth obj.prop[10]
'''
tokens: lexer.tokenize code
puts 'TOKENS:'
puts tokens.join(' | ') + "\n"
nodes: parser.parse tokens
puts nodes.compile()
from coffeescript.
If it's able to run in a browser, I can drop it in to replace coffeepot on trycoffee.org so people can play with it easier.
from coffeescript.
I'd imagine the dependency on node.js and therefore v8-javascript keeps it (along w/ jack) off all browsers but chrome.
If coffee-script is to become the bash of the web it needs to compile and run all in the browser. Hence the awesomeness of the coffeepot approach.
from coffeescript.
There isn't much that's Node.js specific in there. It'll definitely be able to run in the browser ... eventually.
One thing at a time though -- first it has to run, then it needs to pass the test suite, then we'll worry about Narwhal, and then the browser.
from coffeescript.
Alright folks -- it's done, and it's lightning fast.
CoffeeScript in CoffeeScript has now recompiled itself dozens of times, and produces nearly-identical code to the Ruby compiler (there's a couple of whitespace tune-ups).
It compiles and passes all the execution tests in 0.3 seconds.
Here's some things you can do with it. The main executable is bin/node_coffee
for now.
- To have CoffeeScript recompile itself:
bin/node_coffee -o lib/coffee_script/ src/*.coffee - To run all the execution tests:
bin/node_coffee -r test/fixtures/execution/* - To print out the tokens or the parse tree, use
--tokens
or--tree
- To launch the (much faster) repl:
bin/node_coffee --interactive
- To pipe a CoffeeScript through JSLint:
bin/node_coffee --lint
So most of the flags will stay the same.
The implementation can still use some cleanup and removal of Rubyisms, but if you'd like to hack on it, the main files within src
are: lexer, grammar, rewriter, and nodes.
Cheers.
from coffeescript.
simply amazing! great stuff Jeremy! thanks.
from coffeescript.
I've successfully embedded Coffee within Komodo Edit and I can compile files on Ctrl+S. Great. I must admit I don't understand the need for Node.js nor for any of the build scripts... perhaps reason being I am running Cygwin on Windows so there is no Node.js for me (well, not out-of-the-box anyway).
from coffeescript.
As of this moment, the Ruby version is gone. bin/coffee
is now the CoffeeScript-in-CoffeeScript compiler. Instead of rake
to build various portions, use bin/cake
. Try bin/coffee --help
to see all of the options.
Edit:
To install a local version of CoffeeScript, now that the gem is gone, use sudo bin/cake install
, to install into /usr/local/lib
, and /usr/local/bin
. Once you've done that, you can use cake
and coffee
straight up.
from coffeescript.
Bravo.
from coffeescript.
Alright -- this is the issue that's certainly going to give me the greatest pleasure to close. 0.5.0
is out this evening, which is the first release of CoffeeScript-in-CoffeeScript. Check out the new docs, and give it a spin with the latest Node.js. Closing this ticket.
from coffeescript.
finished some of the more pressing work taking up my time, so I'm back to tracking this project...
Congrats on your progress!! :)
from coffeescript.
This discuss gives me much confidence on my work: I'm writing the compiler for my dao language with coffeescript, and I'll finish it soon. Thank all of you very much.
from coffeescript.
Related Issues (20)
- Bug?: Postfix conditional difference between try/iteration statements HOT 2
- Bug: Poor error message for invalid use of `then` keyword HOT 2
- Bug: Excess variable introduced in destructured `for ... from` loop
- Bug: Chained comparison doesn't work with `in` binary operator HOT 1
- Bug?: Cannot Base64 encode value: 0 (Legacy browser/WSH) HOT 2
- Unnecessary `splice` ref added for Array destructuring with rest element not in last position HOT 4
- Bug: Re-ordered nested non-end BindingRestElement doesn't get transpiled HOT 1
- CoffeeScript is fantastic, please donβt give it up HOT 1
- How to imitate `let` behavior in loops? HOT 5
- Proposal: Alternative file extension HOT 1
- Bug: Excessive variable and shallow copy for leading or middle rest parameter
- Proposal: Introduce `let` statement. HOT 6
- Proposal: Document Existential Operator Assignment
- Site issue: code blocks twitch on hover HOT 2
- Proposal: cake command should support ES6 modules HOT 2
- Need help understanding class member meanings HOT 1
- CLI `npm` `scripts` and input `.coffee` file/s as last argument conflicting with `--watch` HOT 2
- Bug: wrong code is transpiled for function call without parentheses HOT 2
- Proposal: Add end word to close method or class HOT 2
- Bug: Invalid indentation allowed after `do`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coffeescript.