Clojure Gazette 132: Integrating ClojureScript with the Javascript ecosystem

Integrating ClojureScript with the Javascript ecosystem


Issue 132 - July 13, 2015

Hi ClojureScripters!

I was fortunate enough to interview Maria Neise who has been working on a Google Summer of Code project. Her project is to bring Javascript modules to ClojureScript.

Please enjoy the issue!

Rock on!

PS Want to be more attractive? Subscribe !
PPS Want to advertise to smart, talented, attractive Clojure devs ?


Sponsor: Homegrown Labs

Unit tests exercise the individual parts of your system. And acceptance tests make sure the business requirements are met. If you're worried about how much failure in production will cost in your complex, distributed, and unpredictable system, Homegrown Labs can help build your confidence. Homegrown Labs specializes in Simulation Testing, which tests your system as a whole by simulating a realistic workload. Please support the Gazette by visiting Homegrown Labs and signing up to learn more about Simulation Testing at the bottom of the page.

LispCast: How did you get into Clojure?

Maria Neise: I've always been interested in different programming languages and made my first contact with functional programming and Lisp through Emacs. About a year ago, we started to have Clojure meet-ups in Auckland where I started to learn Clojure by solving Clojure koans. Then, in the beginning of 2015, my company decided to switch to Clojure, which allowed me to learn and write Clojure and ClojureScript full time.

LC: Can you describe the project you're doing for GSoC?

MN: In summary, my GSoC project is about improving the integration of ClojureScript with the existing JavaScript ecosystem. My mentor for this project is David Nolen, who also provided the project idea.

We've split the project into two main parts: adding support for CommonJS, AMD and ECMAScript 2015 modules, and generating externs for foreign JavaScript libraries.

To add support to ClojureScript for different JavaScript module systems, we are using existing functionality of the Google Closure compiler to convert CommonJS, AMD and ECMAScript 2015 modules to Google Closure modules. So my project consists of both, getting familiar with the ClojureScript code base and digging into the Google Closure compiler implementation, which I both quite enjoy :)

LC: What is the main motivation for integrating ClojureScript with Javascript module systems?

MN: The main motivation is to be able to reuse existing JavaScript code that has been written using one of the JavaScript module specifications. With Node.js and RequireJS, module specifications such as CommonJS and AMD have become quite popular and there are many libraries that target one of those or even both module specifications. For example, a project that uses CommonJS is React Native. Adding CommonJS support to ClojureScript will hopefully simplify the use of React Native from ClojureScript.

LC: What are the main challenges?

MN: In general, we need to make sure that the JavaScript libraries that are actually out there, can be included in a ClojureScript project. For example, AMD and CommonJS are both quite popular, so a lot of people write their libraries using the UMD pattern to support both module specifications. The Google Closure compiler, which we are using to convert CommonJS and AMD modules to Google Closure modules, can not deal with this pattern at the moment, which results in the Google Closure modules not being useful. So we need to add functionality to the Google Closure compiler to recognise the UMD pattern when converting an AMD or CommonJS module and make sure the resulting Google Closure module can be used properly.

LC: How has the progress been? Where do you think you'll be at the end of the project?

MN: I think we are making good progress. We've added support for CommonJS, AMD and ECMAScript 2015 so far. Of course, there are still some enhancements we need to make and some bugs we need to fix in this regard. I hope we can submit another pull request to the Google Closure compiler soon that handles the UMD pattern. Then, I will work on adding support for JavaScript dialects, such as JSX and TypeScript, which first need to be transformed into regular JavaScript before we can use them. And finally, I would like to work on the automatic generation of extern files for foreign libraries. Overall, I hope in the end it will be easier for users to include existing JavaScript libraries into their ClojureScript projects.

LC: What do you like most about ClojureScript?

MN: To be honest, I really like the ClojureScript community and the innovation that goes with it. There are so many people working on great projects and everyone seems to be really excited about where ClojureScript is headed. That's very contagious :)

LC: If Clojure were a superhero, what would its superpower be?

MN: Mh, maybe time travel? Well, it's at least a superpower that Datomic and Om have :)

LC: If people want to follow the project, where should they go?

MN: I've been trying to publish a post each week about the project on . So that would be a good place to have a look.

LC: And if someone wanted to follow you online, where could they find you?

MN: I am on Twitter ( @mayaneise ) and GitHub ( mneise ). And you can also find me on the Clojure Slack community as "maria" if someone wants to chat.

Thank you for interviewing me, it has been fun! I've always enjoyed reading the interviews you've done and it's exciting to be featured in one myself :)

LC: Thanks for the great interview.