Hacker News new | comments | show | ask | jobs | submit login
Show HN: Clojure parser and core library in JavaScript, live on CodeCombat (vickychijwani.github.io)
57 points by vickychijwani on June 13, 2014 | hide | past | web | favorite | 10 comments



Author of said project here. Some additional info: the library is live on CodeCombat (http://blog.codecombat.com/new-experimental-languages-python...), which means you can now code your CodeCombat games in Clojure! Happy hacking! ;)


So this is a Clojure compiler in javascript? How cool. Did you implement the whole Clojure.core? Also, is this like ClojureScript (cljs.string) or Clojure (clojure.string)? Good work!


> So this is a Clojure compiler in javascript?

It's not a full compiler. It's a parser that plugs into http://aetherjs.com/, which transpiles the Clojure code to JavaScript and then executes it.

> Did you implement the whole Clojure.core?

Not all of clojure.core is implemented -- a list of what's implemented is available at http://vickychijwani.github.io/closer.js/spec_runner.html?sp....

> Good work!

Thanks :)


This is really cool.

I'm looking forward to when they make the UI properly support it. They haven't changed much in the UI other than letting you type code in other languages. My issues:

1. When you change the language for the current level, it doesn't change the default code. You have to delete the Javascript by hand, including the comments.

2. New levels don't have the default code be other languages.

3. editor "Smart Behaviors" (in Editor Configuration) doesn't work in Clojure. When I type an opening parenthesis, there is no closing parenthesis automatically inserted.

4. The "available spells" are in JS. If I didn't already know that "this.moveRight();" in Javascript translated to "(.moveRight this)" in Clojure, I would've had no idea how to do anything.

5. Errors aren't especially useful. In Clojure, typing "(.attackNearbyEnemy)" results in "parse error: expecting IDENTIFIER, COLON, ANON_ARG..." Obviously, this is a hard problem, but I'd rather see something like "you called a one-argument function with zero args".

6. In Emacs keybindings, if point is at the a line with text in it, C-k doesn't delete the newline character, moving the next line to the end of the current one -- it does nothing.

These are all things I expect to be fixed soon. There's a lot of work to be done to add multi-language support, and it's awesome it's getting done.


Yeah, all of this is being tackled as we speak. I've already submitted default Clojure code for many of the levels, so selecting Clojure from the drop-down should soon switch the sample code as well. The Greed tournament was meant to stress-test the parsers; now it's time to polish the UI and make everything work smoothly.


This is really awesome! I learned about this from Codecombat's newsletter[0] and I have to say those guys are doing superb work in getting people to contribute to open source. With this library supporting for more than 100 functions from the Clojure core and persistent data structures Codecombat is even more fun now!

[0] - http://us3.campaign-archive2.com/?u=c86c5e56e46659873417a8f1...


Thanks!


Great work! There are a couple of other projects like this. Are you familiar with Wisp or Outlet? This is good work; I've been trying to hack my own Lisp -> JS transpiler, and not having much work.

Your 'Nodes' file shows a strong familiarity with what's going on inside Coffeescript, too. :)


> Great work!

Thanks!

> There are a couple of other projects like this. Are you familiar with Wisp or Outlet?

The thing is, Closer was created for use on CodeCombat, which expects the parse tree to be in the standard Mozilla AST format [1]. As far as I know, none of the projects you mention satisfy this requirement.

> Your 'Nodes' file shows a strong familiarity with what's going on inside Coffeescript, too. :)

Actually it was lifted verbatim from [2] -- I just converted it to CoffeeScript :)

[1]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Sp... [2]: https://github.com/zaach/reflect.js


> The thing is, Closer was created for use on CodeCombat, which expects the parse tree to be in the standard Mozilla AST format. As far as I know, none of the projects you mention satisfy this requirement.

I don't know anything about Outlet, but the Wisp compiler actually makes use of Escodegen [1] – which expects input to be provided in the Mozilla AST format – to generate JavaScript. You can peek at writer.wisp [2] in the compiler codebase to see how it's done.

[1] https://github.com/Constellation/escodegen [2] https://github.com/Gozala/wisp/blob/master/src/backend/escod...




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

Search: