Clojure Gazette 1.57

Free Beginner Workshop

From OO to Clojure Workshop!

Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.

Kevin Lynagh interview

Clojure Gazette

Issue 1.57
October 30, 2013


Editorial

Dynamically Typed Greetings,

I started this interview with Kevin Lynagh back in June. Various things intervened in the meantime, but it finally came together.

Kevin Lynagh is known for hispresentations aboutdata visualization and for releasing theC2 library. He has recently (a few months ago) released a weather app calledWeathertron which is written in ClojureScript and Angular.js. He also hasThe DevOp, which teaches good development and sysop practices for a low fee. He also appeared in theCognitect podcast. It was a very interesting interview.

Enjoy!

Sincerely,
Eric Normand
<ericwnormand@gmail.com>
P.S. I love hearing from readers. Just reply to this email!

The Interview

Clojure Gazette: You just released Weathertron and wrote up a post about making it using ClojureScript + AngularJS. Congratulations! In your post, you talk about the great interop between ClojureScript and Javascript. What is the most challenging part of writing performant ClojureScript? Were there any challenges?

Kevin Lynagh: The v8 JavaScript engine is insanely fast; for the Weathertron almost all of the bottlenecks were related to graphics rendering and DOM manipulation rather than JavaScript performance.  In fact, this is where using a higher-level language like ClojureScript and a framework like Angular.js pays off.  There are performance costs to Clojure's persistent data structures and Angular's digest loop, but they let you think at a level where you can make much larger performance wins around minimizing browser repaints and reflows.  (Similar to how garbage collected languages empower mortals to implement more powerful algorithms---what perf you lose in the small you can make up for in the large.)
 
The only major performance problem we had with ClojureScript was with the EDN reader.  We wanted to use EDN as a serialization format so that we could handle dates + timezones easily and have the Weathertron show the current time relative to whatever city you were looking at, regardless of the device timezone.  However, deserializing the forecast data took about 100x the native JSON deserialization time (about 5s on the phone, which was unacceptable).  I ended upimplementing the ideas underlying EDN on top of JSON so that we could have the expressiveness of EDN with the speed of the browser-native parser.
 
Finally, to make sure that we came out of the gate with adequate performance we did most of the development and testing on last-generation iPod touches (which are significantly slower than iPhones).  Thus, we'd optimize the hell out of our code and design features around the capabilities of the iPod to ensure the app would be responsive on all the iPhones and iPads, which make up almost all the sales.  Currently, 1.5% of our app sessions are from iPod touch, and I'm pretty sure most of those are Keming Labs =P
 
CG: How did you come to Clojure and why do you stay?
 
KL: I'd played around with Clojure in 2010, but I only started doing serious work with the language after ClojureScript was released.  At that time I was working on increasingly complex interfaces and data visualization systems on top of the web stack withD3.js.  CoffeeScript was helpful for organizing code and avoiding some common pitfalls, but doesn't offer much with respect to architectural concerns, so I was very excited to pick up ClojureScript as soon as it came out.
 
The benefits of Clojure the language have been very well articulated by Rich and others, so I won't rehash those points.  The technical reasons are one thing, but the primary reason I've stayed with the language is the community.  Clojurists (maybe early adopters in general) come from a diverse set of backgrounds, and people appreciate a broad range of perspectives.  Whenever someone brings up an idea X, two or three people pop up and say, "Yeah, these dudes tried that with {{language I've never heard of}} back in 1976; go check out these papers".  I absolutely love that about the Clojure community.
 
My background is in physics, and I've never formally studied computer science.  But hanging out in #clojure on IRC or talking with folks at the conferences, I get this awesome sense of history and perspective that I've never felt in other programming language communities.
 
CG: I'm glad you find the community helpful.
 
Your work tends to be very visual. The slides of your presentations are beautiful, you made C2, a visualization library, and your client work is typically well designed. Where does this talent with the visual come from and how does it play into your programming?
 
KL: Data visualization and design in general, like programming, are ultimately practical pursuits: how can we solve this particular problem?  What needs to exist to help someone make a decision?  What kinds of questions should this visualization help someone answer?
 
In both pursuits, the key to good work is stepping back from assumptions and evaluating each part of your potential solutions relative to the problem at hand.  For instance, I used mutable state in all sorts of languages without even realizing that mutability was a choice I was making and that the alternative---immutability by default---simplified my programs (thanks Rich!).  I don't have a "talent with the visual", it's just that most people don't even consider that visuals are an option.  All they have in their toolbox is printf, and they don't realize how it warps their thinking.
 
CG: What are you working on now?
 
Is there anything you would like to see happening in Clojure or ClojureScript?
 
And do you have a recommendation for the readers that you think everyone should know about?
 
KL: Lately I've been exploring core.async;wrapping up ZeroMQ to be threadsafe and making a symmetric Clojure/ClojureScriptcore.async interface for websocket communications.
 
Outside of libraries, we are gettingThe DevOp out of beta. The idea behind that site was something I was trying to buy, actually. I had a ton of loose ends around automated backups, secure SSH key management, server provisioning, &c., and I was hoping I could just throw down a few hundred bucks to get a suite of tested open source software and good step-by-step documentation. I couldn't find anything like that on the market, though, so we ended up doing the work ourselves and putting it together. Hopefully it'll save a lot of developers in a similar position a ton of time and pain.
 
As for what I'd love to see in Clojure/ClojureScript, I'm still looking for a robust, functional UI architecture. Angular.js's approach to the DOM is the best one I've seen thus far, but that library rests on mutable state and the primitive data structures of JavaScript. Functional architectures for interactive UIs have been on my mind quite a bit lately, though I'm not sure exactly how they will play out on real applications.
 
CG: Cool! Is there anything else you'd like to mention? And where can we find you (online, etc).
 
KL: That's about it for now.
 
As for finding me online:
 
Twitter:@lynaghk
 
Thanks for the two month interview Eric, I hope it was helpful = )
 
Copyright © 2013 LispCast, All rights reserved.
unsubscribe from this list    update subscription preferences