One to watch: Pedestal, a new Clojure web toolset
We speak to the lead developer of Pedestal, a new open source project taking a fresh approach to Clojure web app development.
Last week saw the high-profile launch of Pedestal, a new open-source Clojure toolset. Developed by software house Relevance, and revealed at Clojure/West, it immediately gathered plenty of attention (and criticism). We got in touch with Tim Ewald, who led the development of Pedestal, to find out more.
Why did you develop Pedestal?
Tim: We built Pedestal because the existing infrastructure for Web development in clojure didn’t provide features we needed. Specifically, for developing Web services, we needed the ability to decouple HTTP request processing from a specific thread os that we could handle long polling and server-sent events efficiently. Ring is the de facto standard library for HTTP request processing on a server, but it can’t provide this functionality because its processing model couples a request to a single Web server thread. That said, Ring does provide a ton of useful functionality for HTTP request processing (e.g., cookie and session management, file and resource handling, etc). So the Pedestal service library builds on Ring. We worked with the Ring maintainers to refactor the HTTP processing code so that it would work across threads in Pedestal, but also still work with Ring. In addition, we needed a request routing layer that can generate URLs, so we built one of those too.
On the application side of things, in the browser, we needed a way to organize and structure clojurescript code “in the large”. The Pedestal application library is focused on creating interactive dynamic browser-based apps using a data flow programming model. The biggest feature in the application model is the separation of application logic from rendering, and support for representing changes to the rendering as data. This allows us to step forward and backward through rendering changes to see how the UI reacts to changes in the underlying application state. This is very useful for development and debugging. The split also allows us to build and test the bulk of the application outside the browser.
Why is it important to work with the same language on both the client and server?
Using the same language on both the client and server simplifies development and makes it possible to share code. We do most of our app development outside the browser. That code is written as clojure, but when we use it in the browser it is compiled as clojurescript. We can write logic that can be moved from the browser to the server, if desired, or can run in both places if necessary. It also helps unify the testing story – the bulk of the client application code is tested outside the browser using the same testing tools we use for server-side code.
Clojure is a simple, expressive, powerful dynamic language that makes it easier for us to build solutions for customers. It takes advantage of an industrial strength runtime, the JVM, and fits directly into the Java ecosystem widely used by businesses.
How does Pedestal help with scalability?
Pedestal applications move work into the browser, which aids service scaling – the services aren’t doing any UI rendering work. When we use Pedestal services with Datomic, we get a great horizontal scale-out story. We can scale read access without having to add replicas, as you would with a traditional SQL database.
Do you use Pedestal in-house?
Yes. We built Pedestal to make it easier to for us to build the kinds of systems our customers are interested in.
What is the learning curve like?
Pedestal is brand new, and it’s an early release – there is definitely a learning curve. The service side of things isn’t too difficult to pick up – on the surface it looks like a lot of other HTTP processing stacks. The application model is more complex – partly because it takes a different approach to structuring an app based on data flow programming that many developers aren’t familiar with. There is definitely work to do to make the application story simpler, and we’re working on it.
Where do you hope to take Pedestal?We built Pedestal because we needed a way to build systems for ourselves and our customers. We released it because we think it’s generally useful. Hopefully others will think so too and will use it to build their systems.