<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Clojure on Martin_Trojer</title><link>http://martintrojer.github.io/tags/clojure/</link><description>Recent content in Clojure on Martin_Trojer</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 14 Jun 2016 00:00:00 +0000</lastBuildDate><atom:link href="http://martintrojer.github.io/tags/clojure/index.xml" rel="self" type="application/rss+xml"/><item><title>Some thoughts on clojure.spec</title><link>http://martintrojer.github.io/post/2016-06-14-some-thoughts-on-clojurespec/</link><pubDate>Tue, 14 Jun 2016 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2016-06-14-some-thoughts-on-clojurespec/</guid><description>&lt;p&gt;Some of the readers of my &lt;a href="http://martintrojer.github.io/categories/beyond-clojure/"&gt;Beyond Clojure&lt;/a&gt; blog series have asked about my opinion on clojure.spec, and if it solves Clojure&amp;rsquo;s &amp;rsquo;type problem&amp;rsquo;. Implying whether its presence makes me look more favorably on Clojure. Here are some of my thoughts.&lt;/p&gt;</description></item><item><title>Beyond ClojureScript: Elm</title><link>http://martintrojer.github.io/post/2016-05-03-beyond-clojurescript-elm/</link><pubDate>Tue, 03 May 2016 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2016-05-03-beyond-clojurescript-elm/</guid><description>&lt;p&gt;This is a post in the &lt;a href="http://martintrojer.github.io/categories/beyond-clojure/"&gt;Beyond Clojure&lt;/a&gt; blog series, in which a Clojure developer looks at typed languages for web app development. In this episode we look at front-end development in the language Elm.&lt;/p&gt;
&lt;p&gt;Front end development targeting web browsers is a ghetto, everybody seems to agree. The core tools at our disposal are the amalgamation of ideas and accidents thrown together without much overall strategy. One positive development in recent years has been the drastic improvement of the JavaScript (JS) engines in popular browsers. They have now gotten so good that it&amp;rsquo;s a valid option to treat JS as a compilation target. This fact is one of the drivers behind the explosion of JS transpilers, there are now literally hundreds of languages that (either primarily or as an after-though) can compile to JS. These languages range from light syntax improvements (ala &lt;a href="http://coffeescript.org/"&gt;CoffeScript&lt;/a&gt;) to full blown languages with big runtimes and everything in between.&lt;/p&gt;</description></item><item><title>Beyond Clojure: Haskell</title><link>http://martintrojer.github.io/post/2016-04-21-beyond-clojure-haskell/</link><pubDate>Thu, 21 Apr 2016 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2016-04-21-beyond-clojure-haskell/</guid><description>&lt;p&gt;This is a post in the &lt;a href="http://martintrojer.github.io/categories/beyond-clojure/"&gt;Beyond Clojure&lt;/a&gt; blog series, in which a Clojure developer looks at typed languages for web app development. This is by no means a complete survey of the Haskell web development landscape, rather a random collection of thoughts.&lt;/p&gt;
&lt;p&gt;If you are interested in typed functional languages one stands taller than the rest. It&amp;rsquo;s impossible not to get sucked into the Haskell vortex, but why fight it? In spite of its reputation of being extremely hard to learn and even harder to master, there are several excellent resources out there and you are guaranteed to learn lots of very valuable lessons.&lt;/p&gt;</description></item><item><title>Beyond Clojure: Prelude</title><link>http://martintrojer.github.io/post/2016-04-19-beyond-clojure-prelude/</link><pubDate>Tue, 19 Apr 2016 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2016-04-19-beyond-clojure-prelude/</guid><description>&lt;p&gt;Here we are, after five years of learning and later doing Clojure full time, I&amp;rsquo;ve come to the point where I am seriously looking around for alternatives. I&amp;rsquo;ve gotten very comfortable working in Clojure, and it has and will continue to serve me very well. But getting comfortable has a flip-side, you stop caring.&lt;/p&gt;</description></item><item><title>Datomic Do's and Don'ts</title><link>http://martintrojer.github.io/post/2015-06-03-datomic-dos-and-donts/</link><pubDate>Wed, 03 Jun 2015 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2015-06-03-datomic-dos-and-donts/</guid><description>&lt;p&gt;I recently tried to use Datomic in anger in a project. Here are some things I learned.&lt;/p&gt;</description></item><item><title>Clojure and Emacs without Cider redux</title><link>http://martintrojer.github.io/post/2015-02-14-clojure-and-emacs-without-cider-redux/</link><pubDate>Sat, 14 Feb 2015 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2015-02-14-clojure-and-emacs-without-cider-redux/</guid><description>&lt;p&gt;It&amp;rsquo;s been a couple of months since I&amp;rsquo;ve stopped using &lt;a href="https://github.com/clojure-emacs/cider"&gt;Cider&lt;/a&gt; for Clojure development in Emacs. I find a simple &amp;lsquo;inferior lisp&amp;rsquo; setup faster and more reliable. For a good summary of why one would consider not using Cider, see &lt;a href="https://gist.github.com/levand/b1012bb7bdb5fcc6486f"&gt;Luke VanderHart&amp;rsquo;s excellent summary&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Developing Clojure in the Cloud</title><link>http://martintrojer.github.io/post/2014-12-04-developing-clojure-in-the-cloud/</link><pubDate>Thu, 04 Dec 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-12-04-developing-clojure-in-the-cloud/</guid><description>&lt;p&gt;Recently, I gave a talk at the &lt;a href="https://skillsmatter.com/conferences/1956-clojure-exchange-2014"&gt;Clojure eXchange 2014&lt;/a&gt; titled &amp;lsquo;Developing Clojure in the Cloud&amp;rsquo;. I described a way of creating and using (Clojure) development environments inside VMs. I&amp;rsquo;ve been developing like this for the last year (spanning 2 projects).&lt;/p&gt;</description></item><item><title>Kebab-case keywords in nested Clojure data structures</title><link>http://martintrojer.github.io/post/2014-10-18-kebab-case-keywords-in-nested-clojure-data-structures/</link><pubDate>Sat, 18 Oct 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-10-18-kebab-case-keywords-in-nested-clojure-data-structures/</guid><description/></item><item><title>Clojure and Emacs without Cider</title><link>http://martintrojer.github.io/post/2014-10-02-clojure-and-emacs-without-cider/</link><pubDate>Thu, 02 Oct 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-10-02-clojure-and-emacs-without-cider/</guid><description>&lt;p&gt;I&amp;rsquo;ve been hacking Clojure for many years now, and I&amp;rsquo;ve been happy to rekindle my love for Emacs. The Clojure/Emacs toolchain has come a long way during this time: swank-clojure, nREPL, nrepl.el, and now Cider. The feature list is ever-growing, and every time you look, there are some new awesome shortcuts that will &amp;lsquo;make your day&amp;rsquo;.&lt;/p&gt;</description></item><item><title>Book Review: Clojure Cookbook</title><link>http://martintrojer.github.io/post/2014-04-06-book-review-clojure-cookbook/</link><pubDate>Sun, 06 Apr 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-04-06-book-review-clojure-cookbook/</guid><description>&lt;figure class="floatright"&gt;&lt;img src="http://martintrojer.github.io/assets/images/cookbook/cover.png"&gt;
&lt;/figure&gt;

&lt;p&gt;The Clojure Cookbook is part of the O&amp;rsquo;Reilly cookbook series. I&amp;rsquo;d describe this format as a &amp;lsquo;curated wiki in print&amp;rsquo;. The wiki analogy is especially true for this volume since its contents were contributed by some 60 different developers. It&amp;rsquo;s packed with small, bite-sized recipes for solving common problems in Clojure. This is useful for developers across the entire spectrum from beginner to expert.&lt;/p&gt;
&lt;p&gt;The content is organized into 11 chapters, each containing a number of recipes. The chapter layout is clear and serves its purpose when looking for content. The book covers a lot of ground, from working with primitives and basic data structures to dealing with databases, writing web apps, and running Hadoop jobs. Each recipe comes with code and/or REPL examples, so it&amp;rsquo;s very easy and enlightening to &amp;lsquo;play along&amp;rsquo;. In contrast to other books with code snippets, the authors have made all recipes self-contained (no other projects/files need to be created and run for the examples to work), which makes it very easy to dive in at any point in the book.&lt;/p&gt;</description></item><item><title>The Clojure REPL; a blessing and a curse</title><link>http://martintrojer.github.io/post/2014-04-05-the-clojure-repl-a-blessing-and-a-curse/</link><pubDate>Sat, 05 Apr 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-04-05-the-clojure-repl-a-blessing-and-a-curse/</guid><description>&lt;p&gt;All Clojure developers swear by their REPL; it&amp;rsquo;s one of the most powerful tools in our arsenal. Coming from traditional edit/compile/launch languages, it is also a great productivity boost. The Clojure community takes non-AOT (ahead of time compilation) to the extreme. By default, we ship Clojure source code in our development and production jars and thus leave compilation to the very last minute (when the program launches). This gives us lots of power and flexibility; if you&amp;rsquo;ve ever navigated into a library in Emacs and fixed a bug, re-evaled the form and carried on working, you know what I&amp;rsquo;m talking about.&lt;/p&gt;</description></item><item><title>Working with core.async: Blocking calls</title><link>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-blocking-calls/</link><pubDate>Sun, 09 Mar 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-blocking-calls/</guid><description>&lt;p&gt;You can&amp;rsquo;t do anything even remotely blocking inside go-blocks. This is because all the core.async go blocks share a single thread pool, with a very limited number of threads (go blocks are supposed to be CPU bound). So if you have hundreds/thousands of go blocks running concurrently, just having a few (a handful really) block &amp;ndash; &lt;em&gt;all&lt;/em&gt; go blocks will stop! For a more in-depth explanation see &lt;a href="http://martintrojer.github.io/post/2013-07-07-coreasync-and-blocking-io/"&gt;this previous post&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Working with core.async: Chaining go blocks</title><link>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-chaining-go-blocks/</link><pubDate>Sun, 09 Mar 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-chaining-go-blocks/</guid><description>&lt;p&gt;One particularly annoying difference between core.async and &lt;a href="http://golang.org"&gt;Go&lt;/a&gt; is that you can&amp;rsquo;t wrap function calls with the &lt;code&gt;go&lt;/code&gt; macro. This is due to implementation details of core.async, which can only see the body &amp;lsquo;inside&amp;rsquo; the macro and not the functions it may call. This is obviously not a problem if the called function doesn&amp;rsquo;t interact with any channels, but if it does, then you might be in trouble. I&amp;rsquo;ve touched on this subject in a &lt;a href="http://martintrojer.github.io/post/2013-07-17-non-tailrecursive-functions-in-coreasync/"&gt;previous post&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Working with core.async: Exceptions in go blocks</title><link>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-exceptions-in-go-blocks/</link><pubDate>Sun, 09 Mar 2014 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-exceptions-in-go-blocks/</guid><description>&lt;p&gt;Dealing with exceptions in go blocks/threads is different from normal Clojure core. This gotcha is very common when moving your code into core.async go blocks &amp;ndash; all your exceptions are gone! Since the body of a go block is run on a thread pool, there&amp;rsquo;s not much we can do with an exception, thus core.async will just eat them and close the channel. That&amp;rsquo;s what happened in the second snippet &lt;a href="http://martintrojer.github.io/post/2014-03-09-working-with-coreasync-chaining-go-blocks/"&gt;in this post&lt;/a&gt;. The &lt;code&gt;nil&lt;/code&gt; result occurs because the channel we read from is closed.&lt;/p&gt;</description></item><item><title>Testing an API with Simulant</title><link>http://martintrojer.github.io/post/2013-09-29-testing-an-api-with-simulant/</link><pubDate>Sun, 29 Sep 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-09-29-testing-an-api-with-simulant/</guid><description>&lt;p&gt;tl;dr I present a new &lt;a href="https://github.com/martintrojer/simulant-bootstrap"&gt;Simulant example project&lt;/a&gt;, testing a simple web API.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All programs are simulation tested, at least once.
&amp;mdash; Stu Halloway&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Simulation testing is an interesting field that has a lot going for it. While most website/API developers write many tests at the unit level (an old Rails habit), testing and understanding a whole system is often not done. Most systems we build nowadays consist of many (mega/micro) services/databases glued together. Getting a deeper understanding of how a system actually works and being able to simulate production-like scenarios is very useful.&lt;/p&gt;</description></item><item><title>Retrofitting the Reloaded pattern into Clojure projects</title><link>http://martintrojer.github.io/post/2013-09-07-retrofitting-the-reloaded-pattern-into-clojure-projects/</link><pubDate>Sat, 07 Sep 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-09-07-retrofitting-the-reloaded-pattern-into-clojure-projects/</guid><description>&lt;p&gt;&lt;a href="https://twitter.com/stuartsierra"&gt;Stuart Sierra&lt;/a&gt; has done a great job with &lt;a href="https://github.com/clojure/tools.namespace"&gt;clojure.tools.namespace&lt;/a&gt; and the &lt;a href="https://github.com/stuartsierra/reloaded"&gt;reloaded&lt;/a&gt; Leiningen template. If you haven&amp;rsquo;t heard about this before, please have a look at c.t.n&amp;rsquo;s readme and watch &lt;a href="http://www.infoq.com/presentations/Clojure-Large-scale-patterns-techniques"&gt;this presentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I have retrofitted this pattern into two rather large Clojure projects (20,000 and 5,000 lines) with several modules, and here are some of my findings.&lt;/p&gt;
&lt;h2 id="removing-global-state"&gt;Removing global state&lt;/h2&gt;
&lt;p&gt;The first step is to find all resources that need to be &amp;ldquo;lifecycled.&amp;rdquo; Typical examples are Jetty servers, database/message bus clients, etc. It&amp;rsquo;s common that these resources are in a &lt;code&gt;(defonce server (atom ...))&lt;/code&gt; form. I tend to grep for &lt;code&gt;defonce&lt;/code&gt; and &lt;code&gt;atom&lt;/code&gt; to find these items.&lt;/p&gt;</description></item><item><title>Non tail-recursive functions in core.async go blocks</title><link>http://martintrojer.github.io/post/2013-07-17-non-tailrecursive-functions-in-coreasync/</link><pubDate>Wed, 17 Jul 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-07-17-non-tailrecursive-functions-in-coreasync/</guid><description>&lt;p&gt;I&amp;rsquo;ve been using various &lt;a href="http://go-lang.org/"&gt;Go&lt;/a&gt; examples and tutorials to take a deeper look into &lt;a href="https://github.com/clojure/core.async"&gt;core.async&lt;/a&gt;. The &lt;a href="http://en.wikipedia.org/wiki/Communicating_sequential_processes"&gt;CSP&lt;/a&gt; pattern is very interesting and powerful; it&amp;rsquo;s a good move for Clojure to &amp;ldquo;throw in&amp;rdquo; with Go and push this style of programming.&lt;/p&gt;
&lt;p&gt;core.async works at the s-expression level, where some other JVM solutions (&lt;a href="http://www.malhar.net/sriram/kilim/"&gt;Kilim&lt;/a&gt;, &lt;a href="https://github.com/puniverse/pulsar"&gt;Pulsar&lt;/a&gt;) do the same at the byte-code level. The main benefit of doing these transforms at the s-expression level is that they are applicable to ClojureScript, where CSP can be a very neat way out of callback hell. &lt;a href="http://swannodette.github.io/2013/07/12/communicating-sequential-processes/"&gt;David has written about this&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>core.async and Blocking IO</title><link>http://martintrojer.github.io/post/2013-07-07-coreasync-and-blocking-io/</link><pubDate>Sun, 07 Jul 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-07-07-coreasync-and-blocking-io/</guid><description>&lt;p&gt;Some time ago I wrote about &lt;a href="http://martintrojer.github.io/post/2011-12-22-asynchronous-workflows-in-clojure/"&gt;Asynchronous workflows in Clojure&lt;/a&gt;. With the recent release and excitement of &lt;a href="https://github.com/clojure/core.async"&gt;core.async&lt;/a&gt;, I thought it a good time to revisit that post.&lt;/p&gt;
&lt;p&gt;While there are already some good examples and comparison-with-&lt;a href="http://golang.org"&gt;go&lt;/a&gt; posts out there, I&amp;rsquo;d like to focus on an area often misunderstood, namely async frameworks and blocking APIs (most commonly blocking IO). It&amp;rsquo;s important to understand the implications of blocking IO and its effects on &amp;lsquo;async code&amp;rsquo;, in this case core.async.&lt;/p&gt;</description></item><item><title>Datomic Bootstrap</title><link>http://martintrojer.github.io/post/2013-07-05-datomic-bootstrap/</link><pubDate>Fri, 05 Jul 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-07-05-datomic-bootstrap/</guid><description>&lt;p&gt;A simple SQL scenario;&lt;/p&gt;</description></item><item><title>Comparing FP REPL Sessions</title><link>http://martintrojer.github.io/post/2013-06-04-comparing-fp-repl-sessions/</link><pubDate>Tue, 04 Jun 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-06-04-comparing-fp-repl-sessions/</guid><description>&lt;p&gt;Functional programming is great; higher-order functions, closures, immutable data-structures, lazy sequences etc.&lt;/p&gt;
&lt;p&gt;Most languages comes with a REPL (or &amp;lsquo;interactive&amp;rsquo; prompt), where you can play with these features at your leisure. Dynamically typed languages are a bit more convenient in the REPL, but not by as much as you might think. Also, F# type providers closes the gap even further.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s a typical, hit-a-JSON-endpoint-and-look-at-the-data session in Clojure;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-clojure" data-lang="clojure"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ lein repl
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;user=&amp;gt; (&lt;span style="color:#66d9ef"&gt;def &lt;/span&gt;res (slurp &lt;span style="color:#e6db74"&gt;&amp;#34;http://www.bbc.co.uk/tv/programmes/genres/drama/scifiandfantasy/schedules/upcoming.json&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;user=&amp;gt; (&lt;span style="color:#a6e22e"&gt;require&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;clojure.data.json&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;clojure.walk&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;user=&amp;gt; (&lt;span style="color:#66d9ef"&gt;def &lt;/span&gt;json (&lt;span style="color:#a6e22e"&gt;-&amp;gt;&amp;gt;&lt;/span&gt; res clojure.data.json/read-str
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; clojure.walk/keywordize-keys))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;user=&amp;gt; (&lt;span style="color:#a6e22e"&gt;-&amp;gt;&amp;gt;&lt;/span&gt; json &lt;span style="color:#e6db74"&gt;:broadcasts&lt;/span&gt; (filter &lt;span style="color:#f92672"&gt;#&lt;/span&gt;(&amp;gt;= (&lt;span style="color:#e6db74"&gt;:duration&lt;/span&gt; %) &lt;span style="color:#ae81ff"&gt;6300&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; (map &lt;span style="color:#e6db74"&gt;:programme&lt;/span&gt;) (map (&lt;span style="color:#a6e22e"&gt;juxt&lt;/span&gt; &lt;span style="color:#e6db74"&gt;:title&lt;/span&gt; &lt;span style="color:#e6db74"&gt;:pid&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;([&lt;span style="color:#e6db74"&gt;&amp;#34;Lady in the Water&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;b00l5wdn&amp;#34;&lt;/span&gt;] [&lt;span style="color:#e6db74"&gt;&amp;#34;Lady in the Water&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;b00l5wdn&amp;#34;&lt;/span&gt;] [&lt;span style="color:#e6db74"&gt;&amp;#34;Lady in the Water&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;b00l5wdn&amp;#34;&lt;/span&gt;] [&lt;span style="color:#e6db74"&gt;&amp;#34;Lady in the Water&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;b00l5wdn&amp;#34;&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nice, clean and very powerful, virtually zero ceremony. Doing the same in Scala, is just a little bit more awkward;&lt;/p&gt;</description></item><item><title>Scala and me</title><link>http://martintrojer.github.io/post/2013-06-01-scala-and-me/</link><pubDate>Sat, 01 Jun 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-06-01-scala-and-me/</guid><description>&lt;figure class="floatright"&gt;&lt;img src="http://martintrojer.github.io/assets/images/scalame/martin.png"&gt;
&lt;/figure&gt;

&lt;p&gt;This epic journey (yeah right) began at university with discovering the mighty &lt;a href="http://mitpress.mit.edu/sicp/"&gt;SICP&lt;/a&gt;, still the best book on programming I&amp;rsquo;ve read (and let&amp;rsquo;s face it, the best I will ever read). After that profound experience, I kept an eye on the Lisp/FP world and wrote some toys in &lt;a href="http://plt-scheme.org/"&gt;Scheme&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Emacs_Lisp"&gt;ELisp&lt;/a&gt;, and &lt;a href="http://ocaml.org/"&gt;OCaml&lt;/a&gt; every now and then. One thing that dawned on me was that none of these languages had much practical use; they weren&amp;rsquo;t very applicable to real-world software problems. While very clever and mind-expanding, they seemed mainly an academic exercise. There were zero jobs out there using these languages. Heck, hardly any of my peers had heard of or cared about them.&lt;/p&gt;</description></item><item><title>Clojure Hacking on the Samsung ARM Chromebook</title><link>http://martintrojer.github.io/post/2013-04-06-clojure-on-the-samsung-arm-chromebook/</link><pubDate>Sat, 06 Apr 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-04-06-clojure-on-the-samsung-arm-chromebook/</guid><description>&lt;figure&gt;&lt;img src="http://martintrojer.github.io/assets/images/chromebook/cb.jpg"&gt;
&lt;/figure&gt;

&lt;p&gt;I recently switched to the &lt;a href="http://www.samsung.com/uk/consumer/pc-peripherals/chrome-devices/chrome-devices/XE303C12-A01UK"&gt;Samsung ARM Chromebook&lt;/a&gt; for all my laptop needs. The pitch is quite appealing: £200, dual-core ARM Cortex-A15s, good keyboard, totally fanless (CPU is passively cooled), good battery life, and 1kg weight. The one downside is its quite limited RAM size, just 2GB. But with a decent swap file, I&amp;rsquo;m running multiple JVMs (with Datomic, Elasticsearch, &lt;a href="https://github.com/clojure/clojurescript"&gt;CLJS&lt;/a&gt; compiler, etc.) without any hiccups.&lt;/p&gt;
&lt;p&gt;Out of the box, it runs &lt;a href="http://en.wikipedia.org/wiki/Google_Chrome_OS"&gt;ChromeOS&lt;/a&gt;, which I have to say is pretty stellar for browsing and consuming content on the web. It is also possible to run any Linux distribution you wish on this machine; Google has an &lt;a href="http://www.chromium.org/chromium-os/chromiumos-design-docs/developer-mode"&gt;outspoken strategy&lt;/a&gt; to enable it.&lt;/p&gt;</description></item><item><title>Flexible multi consumer/producer pipelines</title><link>http://martintrojer.github.io/post/2013-03-16-flexible-multi-consumerproducer-pipelines/</link><pubDate>Sat, 16 Mar 2013 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2013-03-16-flexible-multi-consumerproducer-pipelines/</guid><description>&lt;p&gt;TL;DR: &lt;a href="https://github.com/martintrojer/pipejine"&gt;Pipejine&lt;/a&gt; - a lightweight Clojure library for multi-threaded producer/consumer pipelines supporting arbitrary DAG topologies.&lt;/p&gt;
&lt;p&gt;Recently, a &lt;a href="https://twitter.com/jonpither"&gt;colleague&lt;/a&gt; and I faced a problem where we needed to optimize the total running time of a complicated calculation. This calculation involved several asynchronous steps getting data from other systems (like Elasticsearch and other home-grown services), along with some number crunching and tallying up the results at the end. Here is a simplified example of the system:&lt;/p&gt;</description></item><item><title>The M Word</title><link>http://martintrojer.github.io/post/2012-11-24-the-m-word/</link><pubDate>Sat, 24 Nov 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-11-24-the-m-word/</guid><description/></item><item><title>Some core.logic graph code</title><link>http://martintrojer.github.io/post/2012-09-27-some-corelogic-graph-code/</link><pubDate>Thu, 27 Sep 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-09-27-some-corelogic-graph-code/</guid><description/></item><item><title>Some more Datalog</title><link>http://martintrojer.github.io/post/2012-08-28-some-more-datalog/</link><pubDate>Tue, 28 Aug 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-08-28-some-more-datalog/</guid><description>&lt;p&gt;I&amp;rsquo;ve &lt;a href="http://martintrojer.github.io/post/2012-07-17-replicating-datomicdatalog-queries-with-corelogic-take-2/"&gt;written about Datalog&lt;/a&gt; and &lt;a href="http://www.datomic.com"&gt;Datomic&lt;/a&gt; recently. To conclude, here&amp;rsquo;s another post comparing execution speed with the contrib.datalog library by Jeffrey Straszheim. Clojure 1.4-ready source can be found &lt;a href="https://github.com/martintrojer/datalog"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The example I&amp;rsquo;m using in my benchmark is a simple join between two relations. In Datomic/Datalog, it would look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-clojure" data-lang="clojure"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(&lt;span style="color:#a6e22e"&gt;q&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;#39;&lt;/span&gt;[&lt;span style="color:#e6db74"&gt;:find&lt;/span&gt; ?first ?height
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;:in&lt;/span&gt; $a $b
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;:where&lt;/span&gt; [$a ?last ?first ?email] [$b ?email ?height]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;John&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Jane&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;73&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;71&lt;/span&gt;]])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;;; #&amp;lt;HashSet [[&amp;#34;Jane&amp;#34; 73], [&amp;#34;John&amp;#34; 71]]&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In contrib.datalog, the same query requires more ceremony. You can write it like this:&lt;/p&gt;</description></item><item><title>cKanren time!</title><link>http://martintrojer.github.io/post/2012-08-12-ckanren-time/</link><pubDate>Sun, 12 Aug 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-08-12-ckanren-time/</guid><description>&lt;p&gt;Mr. David Nolen recently published core.logic 0.8.alpha2, with added cKanren (c for constraints) support. To celebrate this glorious event, I&amp;rsquo;m writing up some core.logic/cKanren stuff I&amp;rsquo;ve been looking at recently.&lt;/p&gt;
&lt;h3 id="enter-the-queens"&gt;Enter the Queens&lt;/h3&gt;
&lt;p&gt;If you&amp;rsquo;ve followed this blog, you&amp;rsquo;ve perhaps seen my previous posts on solving N-Queens in core.logic (&lt;a href="http://martintrojer.github.io/post/2012-07-16-replicating-datomicdatalog-queries-with-corelogic/"&gt;part 1&lt;/a&gt; and &lt;a href="http://martintrojer.github.io/post/2012-07-17-replicating-datomicdatalog-queries-with-corelogic-take-2/"&gt;part 2&lt;/a&gt;). How will this look and perform using the new shiny cKanren extensions in core.logic 0.8? Obviously, there are many (new) ways to solve this problem. Here&amp;rsquo;s a core.logic-styled version of the solution described in the &lt;a href="http://www.schemeworkshop.org/2011/papers/Alvis2011.pdf"&gt;cKanren paper&lt;/a&gt; (please read paragraph 4.2 for an in-depth explanation):&lt;/p&gt;</description></item><item><title>Untying the Recursive Knot</title><link>http://martintrojer.github.io/post/2012-07-23-untying-the-recursive-knot/</link><pubDate>Mon, 23 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-23-untying-the-recursive-knot/</guid><description>&lt;p&gt;Here I present a couple of examples of the functional design pattern &amp;ldquo;untying the recursive knot.&amp;rdquo; I&amp;rsquo;ve found this useful on several occasions, for instance, when breaking apart mutually recursive functions. This material was inspired by Jon Harrop&amp;rsquo;s excellent &lt;a href="http://www.ffconsultancy.com/products/fsharp_for_technical_computing/"&gt;Visual F# for Technical Computing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First, let&amp;rsquo;s look at a simple factorial implementation using direct recursion:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-clojure" data-lang="clojure"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(&lt;span style="color:#66d9ef"&gt;defn &lt;/span&gt;fact [n]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; (&lt;span style="color:#66d9ef"&gt;if &lt;/span&gt;(= n &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; (* n (&lt;span style="color:#a6e22e"&gt;fact&lt;/span&gt; (dec n)))))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can break the direct recursive dependency by replacing the recursive calls with calls to a function argument:&lt;/p&gt;</description></item><item><title>Replicating Datomic/Datalog queries with core.logic, take 2</title><link>http://martintrojer.github.io/post/2012-07-17-replicating-datomicdatalog-queries-with-corelogic-take-2/</link><pubDate>Tue, 17 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-17-replicating-datomicdatalog-queries-with-corelogic-take-2/</guid><description>&lt;p&gt;This is a follow-up to my &lt;a href="http://martintrojer.github.io/post/2012-07-16-replicating-datomicdatalog-queries-with-corelogic/"&gt;previous post&lt;/a&gt; on datalog-equivalent queries in core.logic.&lt;/p&gt;
&lt;p&gt;Here I present an alternate way to do the unification and join inside core.logic (without having to use clojure.set/join). It uses the relationships/facts API in core.logic, &lt;a href="https://github.com/clojure/core.logic/wiki/Features"&gt;described here&lt;/a&gt;. First, let&amp;rsquo;s consider this Datomic query:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-clojure" data-lang="clojure"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(&lt;span style="color:#a6e22e"&gt;q&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;#39;&lt;/span&gt;[&lt;span style="color:#e6db74"&gt;:find&lt;/span&gt; ?first ?height
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;:in&lt;/span&gt; [[?last ?first ?email]] [[?email ?height]]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;John&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Jane&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;73&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;71&lt;/span&gt;]])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;;; #&amp;lt;HashSet [[&amp;#34;Jane&amp;#34; 73], [&amp;#34;John&amp;#34; 71]]&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In core.logic we start by defining the relationships between our 2 datasets:&lt;/p&gt;</description></item><item><title>Replicating Datomic/Datalog queries with core.logic</title><link>http://martintrojer.github.io/post/2012-07-16-replicating-datomicdatalog-queries-with-corelogic/</link><pubDate>Mon, 16 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-16-replicating-datomicdatalog-queries-with-corelogic/</guid><description>&lt;p&gt;I&amp;rsquo;ve been toying with &lt;a href="http://datomic.com/"&gt;Datomic&lt;/a&gt; recently, and I particularly like the power of its query language (~&lt;a href="http://en.wikipedia.org/wiki/Datalog"&gt;Datalog&lt;/a&gt;). Mr. &lt;a href="https://twitter.com/stuarthalloway"&gt;Halloway&lt;/a&gt; showed a couple of months ago how the query engine is generic enough to be run on standard Clojure collections, &lt;a href="https://gist.github.com/2645453"&gt;gist here&lt;/a&gt;. Here is an example from that page of a simple join;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-clojure" data-lang="clojure"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(&lt;span style="color:#a6e22e"&gt;q&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;#39;&lt;/span&gt;[&lt;span style="color:#e6db74"&gt;:find&lt;/span&gt; ?first ?height
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;:in&lt;/span&gt; [[?last ?first ?email]] [[?email ?height]]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;John&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;Doe&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Jane&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#e6db74"&gt;&amp;#34;jane@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;73&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;jdoe@example.com&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;71&lt;/span&gt;]])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;;; #&amp;lt;HashSet [[&amp;#34;Jane&amp;#34; 73], [&amp;#34;John&amp;#34; 71]]&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A question you might ask yourself is how can you use &lt;a href="https://github.com/clojure/core.logic"&gt;core.logic&lt;/a&gt; to do the same kind of queries? It turns out that it&amp;rsquo;s pretty straightforward, and also very fast. Core.logic provides some convenient helper functions for &lt;a href="https://github.com/clojure/core.logic#unification"&gt;unification&lt;/a&gt; that we are going to use. Here&amp;rsquo;s an example of how to get a binding map for some logical variables over a collection;&lt;/p&gt;</description></item><item><title>N Queens with core.logic, take 2</title><link>http://martintrojer.github.io/post/2012-07-11-n-queens-with-corelogic-take-2/</link><pubDate>Wed, 11 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-11-n-queens-with-corelogic-take-2/</guid><description>&lt;p&gt;This post is a follow-up to my &lt;a href="http://martintrojer.github.io/post/2012-07-07-n-queens-with-corelogic-take-1/"&gt;previous post on N Queens and core.logic&lt;/a&gt;, in which I tried to find solutions using &amp;ldquo;pure&amp;rdquo; logic (without arithmetic goals) and basic miniKanren/Reasoned Schemer building blocks.&lt;/p&gt;
&lt;p&gt;After excellent feedback and hints from &lt;a href="https://twitter.com/swannodette"&gt;David Nolen&lt;/a&gt; (big thanks), I present a greatly simplified (and faster) way of using core.logic to find all solutions. Credit also goes to &lt;a href="http://www.amazon.co.uk/Programming-Artificial-Intelligence-International-Computer/dp/0321417461/"&gt;good old Bratko&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First, let&amp;rsquo;s fix the safeo function (and def-subo macro). In miniKanren, you can use arithmetic goals given two prerequisites: the fresh variable must be bound to a finite (number) space, and we must use &lt;em&gt;project&lt;/em&gt; to bind the values. This means we can get rid of subo altogether.&lt;/p&gt;</description></item><item><title>N Queens with core.logic, take 1</title><link>http://martintrojer.github.io/post/2012-07-07-n-queens-with-corelogic-take-1/</link><pubDate>Sat, 07 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-07-n-queens-with-corelogic-take-1/</guid><description>&lt;p&gt;I&amp;rsquo;ve been &amp;ldquo;hammock-reading&amp;rdquo; the excellent &lt;a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;amp;tid=10663"&gt;Reasoned Schemer&lt;/a&gt; book these last couple of months, on my quest to develop a gut feel for when logic programming, as defined by miniKanren/core.logic, is applicable.&lt;/p&gt;
&lt;p&gt;My first attempt is to apply it to a problem where (as it turns out) miniKanren isn&amp;rsquo;t a good fit: &lt;a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle"&gt;n-queens&lt;/a&gt;. What you really need for this problem in the logical programming world is something called constraint logic programming (CLP), which is implemented (for example) in &lt;a href="http://www.schemeworkshop.org/2011/papers/Alvis2011.pdf"&gt;cKanren&lt;/a&gt;. The good people at core.logic are working on integrating CLP and cKanren in core.logic &lt;a href="https://github.com/clojure/core.logic/"&gt;in version 0.8&lt;/a&gt;, so I intend to revisit this problem as that work progresses.&lt;/p&gt;</description></item><item><title>Some thoughts on logging</title><link>http://martintrojer.github.io/post/2012-07-03-some-thoughts-on-logging/</link><pubDate>Tue, 03 Jul 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-07-03-some-thoughts-on-logging/</guid><description>&lt;p&gt;Have you ever tried to log from a multi-threaded program? Have you tried to make sense of log output when multiple subsystems were logging to it? Have you tried to do average latency calculations based on that log file?&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re reading this blog, I&amp;rsquo;m guessing you answered yes to a couple of the questions above.&lt;/p&gt;
&lt;p&gt;There are multiple problems here: multiple producers (race conditions), out-of-order logs, conflated subsystems in the same logs, etc. You have to put a lot of effort into your log post-processor to make any sense of the data, decorating it with various metadata to make it possible at all.&lt;/p&gt;</description></item><item><title>Distributed Actors in Clojure</title><link>http://martintrojer.github.io/post/2012-05-17-distributed-actors-in-clojure/</link><pubDate>Thu, 17 May 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-05-17-distributed-actors-in-clojure/</guid><description>&lt;p&gt;Here&amp;rsquo;s another post on a topic that has been discussed since the &lt;a href="https://groups.google.com/d/msg/clojure/Kisk_-9dFjE/_2WxSxyd1SoJ"&gt;dawn-of-time&lt;/a&gt;: is there a nice and idiomatic way to write Erlang/Actor-style distributed programs in Clojure? There have certainly been a few attempts, but Rich&amp;rsquo;s post (above) still holds true today.&lt;/p&gt;
&lt;p&gt;First, some clarification: I am not primarily thinking about number-crunching, map/reduce-style stuff, where Clojure has a pretty good story:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/stuartsierra/clojure-hadoop"&gt;clojure-hadoop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/amitrathore/swarmiji"&gt;swarmiji&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nathanmarz/cascalog"&gt;cascalog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/liebke/zookeeper-clj"&gt;zookeeper-clj&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nathanmarz/storm"&gt;storm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="akka-and-the-erlang-legacy"&gt;Akka and the Erlang legacy&lt;/h3&gt;
&lt;p&gt;I am trying to write programs that solve problems in the areas where &lt;a href="http://www.erlang.org/"&gt;Erlang&lt;/a&gt; typically excels, such as:&lt;/p&gt;</description></item><item><title>Enumerate N Queens solutions</title><link>http://martintrojer.github.io/post/2012-03-25-enumerate-n-queens-solutions/</link><pubDate>Sun, 25 Mar 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-03-25-enumerate-n-queens-solutions/</guid><description/></item><item><title>Adding Live Unit Feeds to Frinj</title><link>http://martintrojer.github.io/post/2012-03-14-adding-live-unit-feeds-to-frinj/</link><pubDate>Wed, 14 Mar 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-03-14-adding-live-unit-feeds-to-frinj/</guid><description>&lt;p&gt;A couple of weeks have passed since I pushed &lt;a href="https://github.com/martintrojer/frinj"&gt;Frinj to github&lt;/a&gt; and blogged/tweeted about it. The response has been pretty awesome, one highlight being when &lt;a href="https://twitter.com/#!/stuarthalloway"&gt;@stuarthalloway&lt;/a&gt; showed me a &lt;a href="https://gist.github.com/1980351"&gt;frinj+datomic example gist&lt;/a&gt; on the #datomic IRC channel. In short, the Clojure community is #badass.&lt;/p&gt;
&lt;p&gt;Frinj comes with a big database of units and conversion factors, and while many conversion factors are &amp;ldquo;eternal&amp;rdquo;, others aren&amp;rsquo;t. Exchange rates, for instance, have to be kept up to date to be relevant. The Frinj unit database was designed to be updatable, both for usability when doing various calculations and for rates that constantly change. This is the reason the frinj.calc namespace exposes the (frinj-init!) function to reset the unit database to a known baseline (in case you write over some factors, etc.). Clojure&amp;rsquo;s support for atomically updating state is ideal for this purpose; the calculator&amp;rsquo;s state is &lt;a href="https://github.com/martintrojer/frinj/blob/master/src/frinj/core.clj#L17"&gt;kept in a number of refs&lt;/a&gt; and, thanks to the STM, always kept consistent.&lt;/p&gt;</description></item><item><title>Announcing Frinj, a practical unit of measure calculator DSL for Clojure</title><link>http://martintrojer.github.io/post/2012-03-03-announcing-frinj-a-practical-unit-of-measure-calculator-dsl-for-clojure/</link><pubDate>Sat, 03 Mar 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-03-03-announcing-frinj-a-practical-unit-of-measure-calculator-dsl-for-clojure/</guid><description>&lt;p&gt;I am proud to announce a new Clojure project called &amp;ldquo;Frinj&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Frinj is a practical unit-of-measure calculator DSL for Clojure.&lt;/p&gt;
&lt;p&gt;Key features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tracks units of measure through all calculations allowing you to mix units of measure transparently&lt;/li&gt;
&lt;li&gt;Comes with a huge database of units and conversion factors&lt;/li&gt;
&lt;li&gt;Inspired by the &lt;a href="http://futureboy.us/frinkdocs/"&gt;Frink project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Tries to combine Frink&amp;rsquo;s fluent calculation style with idiomatic Clojure&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Full source code available on &lt;a href="https://github.com/martintrojer/frinj"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To whet your appetite, head straight over to the &lt;a href="https://github.com/martintrojer/frinj/blob/master/src/frinj/examples.clj"&gt;sample calculations&lt;/a&gt; page to see what Frinj can do!&lt;/p&gt;</description></item><item><title>ASCII Mandelbrot Set</title><link>http://martintrojer.github.io/post/2012-02-21-ascii-mandelbrot-set/</link><pubDate>Tue, 21 Feb 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-02-21-ascii-mandelbrot-set/</guid><description/></item><item><title>Some thoughts on Clojure performance</title><link>http://martintrojer.github.io/post/2012-02-18-some-thoughts-on-clojure-performance/</link><pubDate>Sat, 18 Feb 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-02-18-some-thoughts-on-clojure-performance/</guid><description>&lt;p&gt;&lt;em&gt;Edit&lt;/em&gt;: This post recently re-surfaced on hacker news and caused a bit of a stir, mainly because of a slightly sensational/misleading title (was &amp;ldquo;Why is Clojure so slow?&amp;rdquo;). I wrote this before &lt;a href="http://www.youtube.com/watch?v=I5iNUtrYQSM"&gt;Rich Hickey&amp;rsquo;s Clojure/Conj 2011 keynote&lt;/a&gt; was published, in which he talks about most of my concerns (and outlines possible solutions).&lt;/p&gt;
&lt;p&gt;Clojure is great in many ways, but one thing it can&amp;rsquo;t be accused of is being particularly fast. What I mean by fast here is the speed at which Clojure programs execute. This is a well-known issue in the Clojure community and has been discussed on the &lt;a href="http://groups.google.com/group/clojure"&gt;mailing list&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/2531616/why-is-the-clojure-hello-world-program-so-slow-compared-to-java-and-python"&gt;Stack Overflow&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Scheme as an external DSL in Clojure</title><link>http://martintrojer.github.io/post/2012-01-28-scheme-as-an-external-dsl-in-clojure/</link><pubDate>Sat, 28 Jan 2012 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2012-01-28-scheme-as-an-external-dsl-in-clojure/</guid><description>&lt;p&gt;This is a follow-up post to my previous &lt;a href="http://martintrojer.github.io/post/2011-11-29-scheme-as-an-embedded-dsl-in-clojure/"&gt;&amp;ldquo;Scheme in Clojure&amp;rdquo; post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This time we implement a Scheme interpreter as an external DSL. This means that we consider the DSL as completely foreign to the host language, so we need to write our own parser (or reader as it&amp;rsquo;s called in Clojure) and interpreter. I have to admit that this is a bit of an academic exercise because the internal DSL version I wrote about previously is both smaller (less code) and faster (as fast as any other Clojure code). However, this can serve as an example of how to write parsers in Clojure and it also highlights how elegant and succinct such a parser/interpreter can be. And of course, it&amp;rsquo;s pretty darn fun :-)&lt;/p&gt;</description></item><item><title>Asynchronous workflows in Clojure</title><link>http://martintrojer.github.io/post/2011-12-22-asynchronous-workflows-in-clojure/</link><pubDate>Thu, 22 Dec 2011 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2011-12-22-asynchronous-workflows-in-clojure/</guid><description>&lt;p&gt;Asynchronous workflows is a very powerful feature of F#, and recently I wanted to explore the state of the JVM and in particular Clojure when it comes to replicate the functionality. In this post I&amp;rsquo;ll share some of my findings and I&amp;rsquo;ll include some background material to explain the problems.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s start with an example of a webclient using &amp;ldquo;async&amp;rdquo; in F#.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fsharp" data-lang="fsharp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; download url &lt;span style="color:#f92672"&gt;=&lt;/span&gt; async &lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let&lt;/span&gt; request &lt;span style="color:#f92672"&gt;=&lt;/span&gt; HttpWebRequest.Create&lt;span style="color:#f92672"&gt;(&lt;/span&gt;Uri&lt;span style="color:#f92672"&gt;(&lt;/span&gt;url&lt;span style="color:#f92672"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let!&lt;/span&gt; response &lt;span style="color:#f92672"&gt;=&lt;/span&gt; request&lt;span style="color:#f92672"&gt;.&lt;/span&gt;AsyncGetResponse()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;use&lt;/span&gt; stream &lt;span style="color:#f92672"&gt;=&lt;/span&gt; response&lt;span style="color:#f92672"&gt;.&lt;/span&gt;GetResponseStream()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;let!&lt;/span&gt; res &lt;span style="color:#f92672"&gt;=&lt;/span&gt; asyncReadToEnd stream
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; res
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The magic here is that you can write continuation-style code in a sequential manner. This combines the scalability of asynchronous programs with the readability of sequential code. So, what lessons can we learn from this code and how would we do this with the JVM and Clojure? First of all, this is not the same as using futures over blocking calls;&lt;/p&gt;</description></item><item><title>Scheme as an embedded DSL in Clojure</title><link>http://martintrojer.github.io/post/2011-11-29-scheme-as-an-embedded-dsl-in-clojure/</link><pubDate>Tue, 29 Nov 2011 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2011-11-29-scheme-as-an-embedded-dsl-in-clojure/</guid><description>&lt;blockquote&gt;
&lt;p&gt;If you give someone Fortran, he has Fortran.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;If you give someone Lisp, he has any language he pleases.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;ndash; Guy Steele&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Replace Fortran with whatever language you are currently using, and the quote still holds true today. Lisp has been around for a long time, and it&amp;rsquo;s built-in flexibility is still unmatched by other languages. In this post we will look at key Lisp concepts such as code-is-data and powerful macro semantics.&lt;/p&gt;</description></item><item><title>Tail Calls in F#, Clojure and Scala</title><link>http://martintrojer.github.io/post/2011-11-20-tail-calls-in-f-clojure-and-scala/</link><pubDate>Sun, 20 Nov 2011 00:00:00 +0000</pubDate><guid>http://martintrojer.github.io/post/2011-11-20-tail-calls-in-f-clojure-and-scala/</guid><description>&lt;p&gt;I recently looked into Tail Call Optimisation/Elimination (TCO) and the implications for 3 modern languages, namely F#, Clojure and Scala. In this post I share my findings. If you&amp;rsquo;re new to the subject or just looking into some of these languages I hope this post can be of some use to you. I will mix code snippets in the 3 languages freely (and without warning! :)&lt;/p&gt;
&lt;p&gt;TCO is a well documented topic in books and articles about functional programming, and the TCO in .NET and the lack thereof in the JVM has been debated &amp;ldquo;to death&amp;rdquo; on various programmers&amp;rsquo; boards. I don&amp;rsquo;t intend to add any fuel to the fire here, rather some background and practical implications.&lt;/p&gt;</description></item></channel></rss>