Clojure in Berlin: Red Pineapple Media

A PHP shop adopts Clojure

Jan 13, 2017
"Love that you can use the same language for both the front and the back end. This is the best decision this company has made."
Contact us to share your story
image

Targeted Video Advertising

Red Pineapple Media is a Berlin based video advertising company. They supply a video player with advanced tracking and targeted advertising capabilities, providing services to clients such as newspaper websites and gaming companies.

They have been going for 5 years and all of the original code was written using PHP. They started the switch to Clojure about two years ago and it’s becoming their primary programming language of choice.

To learn more about this Clojure adoption story I had a video chat facilitated by Head of Engineering Luis Soares, with full stack developer Damiano Rühl and recent hire Joaquim Torres.

Background

Jon: So what is the tech story of Red Pineapple Media?

Damiano: The original system was built using PHP, JavaScript and MySQL. Then we moved step by step to Clojure, still using MySQL. At some point we moved to Cassandra and now we are moving to Elasticsearch.

image

Jon: Why did you move away from PHP?

Damiano: The main reason was for performance; PHP has a model that doesn’t fit well for lots of requests on the same server, with each request requiring its own process. We knew we had to switch tech. We thought about Node.js and we also investigated Clojure. We had big debates.

Node.js was the obvious choice; everyone can do JavaScript so it was the safe decision.

Jon: And Clojure?

Damiano: A former colleague was advocating doing Clojure for the functional approach. We read a lot about it; we knew we wanted the Java ecosystem which we saw as a big benefit, but then no one wanted to do Java. In the end we decided to try Clojure, and if it didn’t work then we would go with Node.js.

Jon: How did you introduce it?

Damiano: We wanted to do some mobile web advertising and we chose Clojure for this.

image

After about two weeks with two of us, we were like: yes this feels right - we definitely have to do this with Clojure. It took us more time to understand the concepts and we made mistakes design wise such as how to structure code etc.

But from the beginning we were more productive and the code was better quality - already much better than PHP.

From there we re-implemented the whole of our tracking code and it looked much better. We then made the whole delivery of ads - the biggest part of the system - use Clojure.

Now our code is much cleaner, nicer, and easier to change, as well as being more easily testable. We have much more trust in the code that everything is fine.

We recently implemented a new way of delivering ads and it was really easy to add, especially when compared to the old OO approach in PHP.

image

PHP/OO Diversion:

Jon: OO in PHP? I had no idea.

Damiano: Yeah. PHP became an OO language at some point. Started as a template language then became OO.

Joaquim: We were using Laravel - the Rails of PHP. It has a hollistic approach like Rails

The JVM:

Jon: So you moved to the JVM. Did you have any concerns about it being too heavy?

Damiano: For me personally - yes. I was concerned about the JVM; I’d worked in a Java company before and I disliked Java.

But actually we didn’t feel the JVM so much. You have the project and Leiningen and the JVM; it all just worked. We didn’t have to understand the JVM internals.

The Java ecosystem is a big benefit. Whenever we have a big problem to solve - usually it’s solved in Java in a performant way.

I have a different feeling about the JavaScript ecosystem. I often find something I want to use but when I look into it I find it’s broken. In Java maybe they do things a bit more professionally. We really like the possibility of using Java libraries where we can.

Jon: The JVM isn’t too slow?

Damiano: Of course starting the REPL is slow. Then we read a post from Stuart Sierra on his REPL workflow - stopping and starting the app - so then we didn’t have to restart the REPL all the time.

ClojureScript

Jon: Have you guys looked into ClojureScript?

Damiano: Next year we want to use ClojureScript for the front end. We use ClojureScript for one internal tool, using React native.

Jon: What ClojureScript framework will you choose next year?

Damiano: Reagent and Re-frame. Om is a possibility, but we’ll probably go for Reagent.

image

Clojure

Jon: So overall has Clojure been good for you?

Damiano: A big part of Clojure is the advantage of FP over OO - a new thing for me and a rethink. It just feels right - it’s fun to do Clojure.

Luis: A common trait is that people say the language is very well balanced. Clojure has the nice strengths of FP, of dynamic languages, of Lisp, and now we’ve got spec. Put all of this on top of a super strong ecosystem - the JVM - it becomes very hard to beat. Clojure is such a well balanced language.

Damiano: I came from JavaScript. I never really liked Java - it’s too strict. JavaScript was super dynamic and I got the same feeling from Clojure; something I really enjoy coding. The problem of a lack of a type system has been solved by the community (Schema, spec).

I also love that you can use the same language for both the front and the back end. This is the best decision this company has made.

Hiring

Jon: How have you found hiring?

Damiano: It’s much easier now than hiring PHP devs. With PHP you find a lot of devs but not many that are so experienced or passionate. Also they often had the wrong idea of how experienced they were - super genius developers that were actually relatively junior. The hiring process improved a lot moving to Clojure.

Luis: When we started hiring we removed the constraint that the person needed to know Clojure - but rather that they wanted to learn. Hire for the attitude, train for the skill.

image

Training

Jon: How about training?

Joaquim: When I joined it was still the case that most developers didn’t know Clojure. We paired developers that were proficient with developers that were less proficient. People really enjoyed learning and it surpassed every expectation we had.

Luis: We started a reading group meeting every week. A chapter at home, then we do exercises together. Right now we’re going through the Joy of Clojure.

We also participate in local Clojure meet ups and tech talks in companies. We go to conferences such as EuroClojure.

IDE wars

Jon: What IDE do you guys use?

Luis: I’m using plain vanilla Emacs, two of us are using Spacemacs. One person is using Intellij and is slowly thinking of switching to Cursive.

Damiano: I just switched from Light Table to Spacemacs. Light Table was really good to start with; the REPL being in there was really nice, but this feature got removed at some point. It wasn’t super stable and was difficult to find documentation. Spacemacs added all these features so I knew I had to use it.

image

State of Clojure?

Jon: What’s the state of Clojure in Berlin?

Damiano: It’s a nice community but still quite small. When Zalando moved in it was a big thing. We have a small set of companies. Fy is one company I know of that’s been into Clojure from the beginning.

It’s small community but it’s growing.

Joaquim: We also have clojureD that is really cool with good talks.

Frustration

Jon: Any frustrations with Clojure?

Damiano: Error messages and stacktraces. Also even with Component you have to restart the REPL occasionally, it’s a bit annoying.

Jon: Is PHP better for error messages?

Damiano: Haha. Not good, but maybe better.

Technologies

Jon: What technologies would you like to give a shout-out to?

Damiano: One big learning that has helped us a lot is Schema. It helps us to design the code from the beginning and makes implementation easier. I’d like to move to spec but this is a big thing because we have a lot of code.

Luis: There was a talk in the Berlin Clojure meeting (2 nights ago) by Jan Stepien on Mutation Testing. It’s nice to see it’s possible to rewrite the problems as they are running. This is complimentary to traditional code coverage tools. I find it a really interesting idea. Maybe for me there are some doubts about scaling it on a bigger codebase, but we will see.

Timbre for logging is a nice library. I’m curious about Onyx. We did some experiments and liked it, it’s a possibility for us.

Joaquim: We are rooting for Clojure 1.9 to be released so that we can start seeing and playing with Spec.

Technologies

Check out the brand new Red Pineapple Media engineering blog. Luis also maintains a blog.

Feeling inspired?
Share your Clojure story with us!
Contact Us
Head Office
Norfolk House, Silbury Blvd.
Milton Keynes, MK9 2AH
United Kingdom
Company registration: 08457399
Copyright © JUXT LTD. 2012-2024
Privacy Policy Terms of Use Contact Us
Get industry news, insights, research, updates and events directly to your inbox

Sign up for our newsletter