javascript to clojurescript transpiler

569 views
Skip to first unread message

Tom Connors

unread,
Nov 6, 2014, 6:24:36 PM11/6/14
to clojur...@googlegroups.com
I've got a project right now that uses javascript on the client and server and I'd love to be able to migrate to clojurescript. I'm wondering whether anyone is aware of any software that will transform the js into clojurescript. I wouldn't be surprised to learn that transforming clojure to javascript is easier than the opposite, but I figured it's worth putting this out there.
If such a project doesn't exist, would anyone like to work with me to make something like this? I know next to nothing about this problem space, but I'd be happy to learn.
While doing cool things like converting common js "require" calls into parts of ns definitions and converting js objects into cljs maps would be awesome, the bare minimum conversion would be plenty to ease the migration.

Micha Niskin

unread,
Nov 7, 2014, 5:59:41 PM11/7/14
to clojur...@googlegroups.com

(js* "contents of js files here")

:)

Tom Connors

unread,
Nov 7, 2014, 6:09:02 PM11/7/14
to clojur...@googlegroups.com
Ha! Make a lein plugin for it and we're set.

Thomas Heller

unread,
Nov 8, 2014, 6:04:56 AM11/8/14
to clojur...@googlegroups.com

Hey,

why convert at all? Just write new parts in ClojureScript and continue using the old JS bits.

I mean ClojureScript gets compiled to Javascript anyways and its integration with JS is pretty solid. "require" is difficult to combine with CLJS but not impossible. Google Closure even has options for that although I never looked into it. Probably easier to annote the old code with goog.provide/goog.require statements.

I'd think you'd run into alot of trouble trying to turn normal JavaScript code into CLJS by way of a tool due to the drasticly different code idioms used.

Just my 2 cents.

/thomas

Tom Connors

unread,
Nov 12, 2014, 7:21:57 PM11/12/14
to clojur...@googlegroups.com
I wouldn't expect the tool to transform the js into _good_ clojurescript, just a syntax transformation to make the transition a bit easier.. it looks like I'll probably have to do what you mentioned and have both js and cljs in the code base. Thanks for the input.

p...@banphim.net

unread,
Nov 26, 2014, 3:53:10 AM11/26/14
to clojur...@googlegroups.com
Hi Tom,
Two years ago I contributed to ChlorineJS, a naive Clojure -> JS tool. The project has a library to convert JS -> ChlorineJS, too.
https://github.com/chlorinejs/chlorinate
Its command-line interface for the library:
https://github.com/chlorinejs/chloride
However, imo you can only benefit from understanding the javascript mess ;) making the converter smarter may not not worth the effort

Tom Connors

unread,
Nov 29, 2014, 12:35:43 PM11/29/14
to clojur...@googlegroups.com
Chlorine seems like a cool project. Thanks for pointing me toward it. I'll post back here with my results of using it once I get a chance to take if for a spin.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages