Brians Brain on Clojurescript

In this post you’ll find a 20 minute screencast which demonstrates how to port a Swing UI app to Clojurescript and HTML5/Canvas. My weapon of choice for this excercise is LightTable which Im currently trying out instead of Emacs. I’ll show off a few of its features, but more to come on LightTable in the future.

Preface

Followers of this blog will have noticed that I’ve redesigned Bestinclass.dk and reimplemented it on a new CMS platform. During this process I killed a lot of my old blogposts, but you can still find them here: http://blog.bestinclass.dk

Picking up on one of the blogposts that I did carry with me to this new site, I’ll show you how to get started with LightTable and port a Clojure Swing UI application to Clojurescript and HTML5. Introducing: Brians Brain on Clojurescript!

I apologize in advance for the poor sound quality – I’ll be sure to get a quality mic for future screencasts.

A word on Clojurescripts/HTML5 performance

This is a naive port, which simply demonstrates how to move a computationally heavy app off your server and into the browser. The implications for server performance and scalability are huge, since all computations are now outsourced. The application itself requires an overhaul to fully leverage the power for Javascript/HTML5 but this is the topic of a future blogpost. Nothing in the code is Windows/IE specific, but in my experience then if it works here, then it works everywhere.

In version 1.0.0 I expect to enable the Canvas doublebuffering as well as migrate to native Javascript arrays instead of Clojures immutable collections, which essentially is the cause of poor performance since the step function cannot be parallized in Javascript. Clojurescript channels provide the idea of multithreading, but it is still only using a single thread which buys us no performance. Lastly, the compiler itself is currently not using any kind of optimization, but the main disadvantage here is filesize, not speed of execution.

Git repo here: https://github.com/LauJensen/briansbraincljs

Hope you enjoyed following along,

Lau

About the author

Lau Jensen is the owner of Best In Class, an avid Clojure Developer well experienced in project management and also the primary author of ClojureQL. You are very welcome to follow his posts on this blog or get in touch directly on lau.jensen@bestinclass.dk