Pretty-printing in Clojure logs

Cross-posted from Zolo Labs.

Logging is an obvious requirement when it comes to being able to debug non-trivial systems. We’ve been thinking a lot about logging, thanks to the large-scale, distributed nature of the Zolodeck architecture. Unfortunately, when logging larger Clojure data-structures, I often find some kinds of log statements a bit hard to decipher. For instance, consider a map m that looked like this:

When you log things like m (shown here with println for simplicity), you may end up needing to understand this:

Aaugh, look at that second line! Where does the data-structure begin and end? What is nested, and what’s top-level? And this problem gets progressively worse as the size and nested-ness of such data-structures grow. I wrote this following function to help alleviate some of the pain:

Remember to include clojure.pprint. And here’s how you use it:

That’s it, really. Not a big deal, not a particularly clever function. But it’s much better to see this structured and formatted log statement when you’re poring over log files in the middle of the night.

Just note that you want to use this sparingly. I first modified things to make ALL log statements automatically wrap everything being logged with pp-str: it immediately halved the performance of everything. pp-str isn’t cheap (actually, pprint isn’t cheap). So use with caution, where you really need it!

Now go sign-up for Zolodeck!

Make something people want

Cross-posted from Zolo Labs.

I’ve been reading Paul Graham’s essays for a long time: since 2001, when an old friend introduced them to me. I was excited by the way he writes about startups and what startups can accomplish. In my head, startups are like the Rebel Alliance, with the odds heavily stacked against them, and they battle the various Death Star corporations for a slice of the business, to institute a smarter way of doing things.

I was also heavily influenced by his articles on Lisp, particularly this one. It’s why I started playing with various Lisps, and why I was so excited by Clojure, and why I wholeheartedly embraced it.

But this post isn’t about technology. It’s about the Rebel Alliance. It’s about two guys in a makeshift office, in the proverbial garage somewhere. Startup statistics can be quite depressing, with 19 of every 20 startups doomed to failure. With such a low rate of success, how do the successful ones do it?

I remember reading this article by Paul Graham, and thinking it makes sense. I remember it making sense in a very superficial, non-committal sort of way. The core of the statement: “Make something people want” seemed perfectly obvious to me. How could you succeed if you didn’t make something people wanted? Duh. Right?

I’ve been spending a lot of time thinking about Zolodeck, the depth of this idea is actually hitting me quite hard. There are two parts of any tech startup: the product side, and the distribution side. The product side is about finding the product/market fit, about making sure the experience is right, and that what you charge for the product is more than what it costs to make. The distribution side is about customer acquisition. Obviously, there’s interplay between the two sides.

“Make something people want” is a simple recipe for success. It seems to distill everything the Lean movement talks about into a single sentence: is your startup making something people want? Everything else is details (of course, the devil is in the details, and you need the details to succeed). In the end, you have to collect and collate the metrics that will point you to what it is that people want, and that will tell you how and what your startup should be doing. But the overarching guiding principle is very sound: make something people want.

And yet, a lot of startups fail because ultimately they don’t end up building something that enough people find value in. Or perhaps at a cost that was lesser than what they could charge for it. ┬áMaking something people want doesn’t mean that if you build something incredibly powerful and useful, but at a gargantuan price, you’ll succeed. The something you build for people needs to solve an equation that involves cost, price, scale, and utility.

So back to the two guys in their garage. If you’re a tiny startup (in reality or in spirit), you can greatly increase your chances of success by using this mantra as a guiding light: make something people want. And make use of Lean metrics to see if you’re trending towards a success or failure. I really do believe that if done right (pick the right metrics, and make adjustments based on what they say), a startup can succeed. And given the stats on startups, this is a bold claim.

I plan to share our Lean metrics dashboard and overall progress as we continue to work on Zolodeck. I think of it like a public experiment. Hopefully, we’ll discover something of value, and others can benefit too! Go Rebel Alliance!