<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Digital Digressions by Stuart Sierra</title>
	
	<link>http://stuartsierra.com</link>
	<description>From programming to everything else</description>
	<lastBuildDate>Tue, 03 Jan 2012 16:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/StuartSierra" /><feedburner:info uri="stuartsierra" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Clojure 2011 Year in Review</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/U3JOUjR6Ufw/clojure-2011-year-in-review</link>
		<comments>http://stuartsierra.com/2012/01/03/clojure-2011-year-in-review#comments</comments>
		<pubDate>Tue, 03 Jan 2012 13:00:15 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Clojure]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=607</guid>
		<description><![CDATA[A new year is upon us. Before the world ends, let&#8217;s take a look back at what 2011 meant for everybody&#8217;s favorite programming language: Clojure 1.3.0 was released, bringing better performance to numeric applications, reader syntax for record types, and &#8230; <a href="http://stuartsierra.com/2012/01/03/clojure-2011-year-in-review">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A new year is upon us. Before the world ends, let&#8217;s take a look back at what 2011 meant for everybody&#8217;s favorite programming language:
</p>
<ul>
<li>
<p><a href="https://groups.google.com/d/msg/clojure/w5Nmx5rPaQs/-Kl4dvGApP0J">Clojure 1.3.0 was released</a>, bringing better performance to numeric applications, reader syntax for record types, and <a href="https://github.com/clojure/clojure/blob/1.3.x/changes.txt">other enhancements</a>.</p>
</li>
<li>
<p><a href="http://clojure.com/blog/2011/07/22/introducing-clojurescript.html">ClojureScript was unveiled</a> to the world, leading to universal confusion about how to pronounce &#8220;Clojure&#8221; differently from &#8220;Closure.&#8221;</p>
</li>
<li>
<p>The <a href="http://clojure-conj.org/">second Clojure/conj</a> went off without a hitch but <a href="http://overtone.github.com/">plenty of bang</a>.</p>
</li>
<li>
<p><a href="http://clojure.com/blog/2011/12/05/lojic-part-one.html">Logic programming</a> burst into the mindspace of Clojure developers with <a href="http://clojure.com/blog/2011/12/08/lojic-part-two.html">core.logic</a>.</p>
</li>
<li>
<p><a href="http://dev.clojure.org/display/doc/Clojure+Contrib">Clojure-contrib was completely restructured</a> to support new libraries, a distributed development model, and an automated release process.</p>
</li>
<li>
<p><a href="https://groups.google.com/d/msg/clojure/QZGmfWFsgoo/XbqpUy5wuqYJ">ClojureCLR got a new home</a> and recognition as a Clojure sub-project.</p>
</li>
<li>
<p>David Liebke <a href="http://clojure.com/blog/2011/11/29/avout.html">introduced Avout</a>, an extension of Clojure&#8217;s software transactional memory model to distributed computing.</p>
</li>
<li>
<p>Clojure project management tools <a href="http://groups.google.com/group/leiningen/browse_thread/thread/5a79d02198a91b91">Leiningen and Cake</a> decided to bury the hatchet and join forces for the greater good.</p>
</li>
<li>
<p><a href="http://clojure.com/blog/">Clojure/core started blogging</a> more regularly.</p>
</li>
<li>
<p>Books! <a href="http://www.manning.com/fogus/">The Joy of Clojure</a> and <a href="http://www.manning.com/rathore/">Clojure in Action</a> (both from Manning) hit the bookshelves. The <a href="http://pragprog.com/book/shcloj2/programming-clojure">Second Edition of Programming Clojure</a> (Pragmatic) and <a href="http://shop.oreilly.com/product/0636920013754.do">Clojure Programming</a> (O&#8217;Reilly) went into early release.</p>
</li>
<li>
<p>PragPub magazine <a href="http://pragprog.com/magazines/2011-07/content">dedicated their July 2011 issue to Clojure</a>.</p>
</li>
<li>
<p>Chas Emerick released <a href="http://www.clojureatlas.com/">Clojure Atlas</a>, an interactive documentation system.</p>
</li>
<li>
<p>Clojure creator <a href="http://www.infoq.com/presentations/Simple-Made-Easy">Rich Hickey spoke at Strange Loop</a> and caused a minor tweet-storm.</p>
</li>
<li>
<p><a href="https://www.4clojure.com/">4Clojure</a> entered the world, giving thousands of programmers a new way to kill time and learn Clojure.</p>
</li>
</ul>
<p>
At this point, I&#8217;ve been typing and looking up links for an hour, so I&#8217;m calling it quits. Needless to say, this was a big year for Clojure, and I&#8217;m sure there&#8217;s a ton of stuff that I missed on this list. Regarding 2012, all I can say is, <i>You ain&#8217;t seen nothing yet</i>.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/U3JOUjR6Ufw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2012/01/03/clojure-2011-year-in-review/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2012/01/03/clojure-2011-year-in-review</feedburner:origLink></item>
		<item>
		<title>A Hacker’s Christmas Song</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/P_oG0D-pQaU/a-hackers-christmas-song</link>
		<comments>http://stuartsierra.com/2011/12/24/a-hackers-christmas-song#comments</comments>
		<pubDate>Sat, 24 Dec 2011 15:54:06 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=599</guid>
		<description><![CDATA[I&#8217;ll be home for Christmas To fix your old PC. Please have Coke and Mountain Dew And pizza there for me. Christmas Eve will find me In Windows Update screens, I&#8217;ll be done by New Year&#8217;s If only in my &#8230; <a href="http://stuartsierra.com/2011/12/24/a-hackers-christmas-song">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be home for Christmas<br />
To fix your old PC.<br />
Please have Coke and Mountain Dew<br />
And pizza there for me.</p>
<p>Christmas Eve will find me<br />
In Windows Update screens,<br />
I&#8217;ll be done by New Year&#8217;s<br />
If only in my dreams.</p>
<p>I&#8217;ll be home for Christmas<br />
Installing Google Chrome,<br />
Removing malware, cruft, and crud,<br />
And backing up your /home.</p>
<p>Christmas Eve will find me<br />
Swearing at the screen,<br />
Replacing it with Linux<br />
If only in my dreams.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/P_oG0D-pQaU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/12/24/a-hackers-christmas-song/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/12/24/a-hackers-christmas-song</feedburner:origLink></item>
		<item>
		<title>What Is a Program?</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/K6zN9Qvi2E4/what-is-a-program</link>
		<comments>http://stuartsierra.com/2011/12/19/what-is-a-program#comments</comments>
		<pubDate>Mon, 19 Dec 2011 13:45:08 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[metaprogramming]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=589</guid>
		<description><![CDATA[What is a program? Is it the source code that a programmer typed? The physical state of the machine on which it is run? Or something more abstract, like the data structures it creates? This is not a purely philosophical &#8230; <a href="http://stuartsierra.com/2011/12/19/what-is-a-program">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>What is a program? Is it the source code that a programmer typed? The physical state of the machine on which it is run? Or something more abstract, like the data structures it creates? This is not a purely philosophical question: it has consequences for how programming languages are designed, how development tools work, and what programmers do when we go to work every day.</p>
<p>How much information can we determine about a program <em>without</em> evaluating it? At the high end, we have the Halting Problem: for any Turing-complete programming language, we cannot determine if a given program written in that language will terminate. At the low end, consider an easier problem: can we determine the names of all of the invokable functions/procedures/methods in a given program? In a language in which functions are not first-class entities, such as C or Java, this is generally easy, because every function must have a specific lexical representation in source code. If we can parse the source code, we can find all the functions. At the other extreme, finding all function names in a language like Ruby is nearly impossible in the face of <code>method_missing</code>, <code>define_method</code>, and other &#8220;metaprogramming&#8221; tricks.</p>
<p>Again, these decisions have consequences. Ruby code is flexible and concise, but it&#8217;s hard to parse: <a href="https://github.com/ruby/ruby/blob/ruby_1_9_2/parse.y">ten thousand lines of YACC at last count</a>. I find that documentation generated from Ruby source code tends to be harder to read &mdash; and less useful &mdash; than JavaDoc. </p>
<p>Here&#8217;s another example: can I determine, without evaluating it, what other functions a given function calls? In Java this is easy. In C it&#8217;s much harder, because of the preprocessor. To build a complete call graph of a C function, we need to run the preprocessor first, in effect evaluating some of the code. In Ruby &mdash; Ha! Looking at a random piece of Ruby code, I sometimes have trouble distinguishing method calls from local variables. Again because of <code>method_missing</code>, I&#8217;m not sure it&#8217;s even possible to distinguish the two without evaluating the code.</p>
<p>I do not want to argue that <code>method_missing</code>, macros, and other metaprogramming tools in programming languages are bad. But they do make secondary tooling harder. The idea for this blog post came into my head after observing the following Twitter conversation:</p>
<blockquote>
<p><a href="https://twitter.com/#!/darevay/status/148235645083594753">Dave Ray</a>: &#8220;seesaw.core is 3500 lines of which probably 2500 are docstrings. I wonder if they could be externalized somehow&#8230;&#8221;</p>
<p><a href="https://twitter.com/#!/cemerick/status/148428056082649088">Chas Emerick</a>: &#8220;Put your docs in another file you load at the *end* of seesaw.core, w/ a bunch of <code>(alter-meta! #'f assoc :doc "docs")</code> exprs&#8221;</p>
<p><a href="https://twitter.com/#!/IORayne/status/148506007188946945">Anthony Grimes</a>: &#8220;I hate both of your guts for even thinking about doing this.&#8221;</p>
<p><a href="https://twitter.com/#!/cemerick/status/148519643101933568">Chas Emerick</a>: &#8220;Oh! [Anthony] is miffed b/c Marginalia doesn&#8217;t load namespaces it&#8217;s generating docs for. What was the rationale for that?&#8221;</p>
<p><a href="https://twitter.com/#!/fogus/status/148522300252237824">Michael Fogus</a>: &#8220;patches welcomed.&#8221;</p>
<p><a href="https://twitter.com/#!/cemerick/status/148522784451076098">Chas Emerick</a>: &#8220;Heh, sure. I&#8217;m just wondering if avoiding loading was intentional, i.e. in case someone has a (launch-missiles) top-level.&#8221;</p>
</blockquote>
<p>(As an aside, it&#8217;s hard to link to a Twitter conversation instead of individual tweets.)</p>
<p>Clojure &mdash; or any Lisp, really &mdash; exemplifies a tension between tools that operate on source code and tools that operate on the running state of a program. For any code-analysis task one might want to automate in Clojure, there are two possible approaches. One is to <code>read</code> the source as a sequence of data structures and analyze it. After all, in a Lisp, code is data. The other approach is to <code>eval</code> the source and analyze the state it generates.</p>
<p>For example, suppose I wanted to determine the names of all invokable functions in a Clojure program. I could write a program that scanned the source looking for forms beginning with <code>defn</code>, or I could evaluate the code and use introspection functions to search for all Vars in all namespaces whose values are functions. Which method is &#8220;correct&#8221; depends on the goal. </p>
<p>Michael Fogus wrote <a href="http://fogus.me/fun/marginalia/">Marginalia</a>, a documentation tool for Clojure which takes the first approach. Marginalia was inspired by Literate Programming, which advocates writing source code as a human-readable document, so the unevaluated &#8220;text&#8221; of the program is what it deals with. In contrast, Tom Faulhaber&#8217;s <a href="http://tomfaulhaber.github.com/autodoc/">Autodoc</a> for Clojure takes the second approach: loading code and then examining namespaces and Vars. Autodoc <em>has</em> to work this way to produce documentation for the core Clojure API: many functions in <code>core.clj</code> are defined before documentation strings are available, so their doc strings are loaded later from separate files. (As an alternative, those core functions could be rewritten in standard syntax after the language has been bootstrapped.)</p>
<p>One of the talking-point features of any Lisp is &#8220;all of the language, all of the time.&#8221; All features of the language are always available in any context: macros give access to the entire runtime of the language at compile time, and <code>eval</code> gives access to the entire compiler at runtime. These are a powerful tools for developers, but they make both the compiler and the runtime more complicated. ClojureScript, on the other hand, does not have <code>eval</code> and its macros are written in a different language (Clojure). These choices were deliberate because ClojureScript was designed to be compiled into compressed JavaScript to run on resource-constrained platforms, but I think it also made the ClojureScript compiler easier to write.</p>
<p>Chas&#8217;s last point about code at the top-level comes up often in discussions around Clojure tooling. The fact that we can write arbitrary code anywhere in a Clojure source file &mdash; <code>launch-missiles</code> being the popular example &mdash; means we can never be sure that evaluating a source file is free of side effects. But <em>not</em> evaluating the source means we can never be sure that we have an accurate model of what the code does. Welcome back to the Halting Problem.</p>
<p>Furthermore, maintaining all the metadata associated with a dynamic runtime &mdash; namespaces, Vars, doc strings, etc. &mdash; has measurable costs in performance and (especially) memory. If Clojure is ever to be successful on resource-constrained devices like phones, it will need the ability to produce compiled code that omits most or all of that metadata. At the same time, developers accustomed to the &#8220;creature comforts&#8221; of modern IDEs will continue to clamor for even more metadata. Fortunately, this isn&#8217;t a zero-sum game. ClojureScript proves that Clojure-the-language can work without some of those features, and there have been discussions around <a href="http://dev.clojure.org/display/design/Make+the+ClojureScript+analyzer+independently+callable+a+la+carte">making the ClojureScript analyzer more general</a> and implementing <a href="http://dev.clojure.org/display/design/Build+Profiles">targeted build profiles for Clojure</a>. But I don&#8217;t think we&#8217;ll ever have a perfect resolution of the conflict between tooling and optimization. Programs are ideas, and source code is only one representation among many. To understand a program, one needs to build a mental representation of how it operates. And to do that we&#8217;re stuck with the oldest tool we have, our brains.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/K6zN9Qvi2E4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/12/19/what-is-a-program/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/12/19/what-is-a-program</feedburner:origLink></item>
		<item>
		<title>JDK Version Survey Results</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/Xww4uEvC4uY/jdk-version-survey-results</link>
		<comments>http://stuartsierra.com/2011/11/04/jdk-version-survey-results#comments</comments>
		<pubDate>Fri, 04 Nov 2011 13:52:14 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=581</guid>
		<description><![CDATA[After a month and about 175 responses, here are the results of my JDK Version Usage Survey (now closed): Versions: Almost everyone uses 1.6. A few are still using 1.5, and a few are trying out 1.7. Only a handful &#8230; <a href="http://stuartsierra.com/2011/11/04/jdk-version-survey-results">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After a month and about 175 responses, here are the results of my JDK Version Usage Survey (now closed):</p>
<p><strong>Versions:</strong> Almost everyone uses 1.6. A few are still using 1.5, and a few are trying out 1.7. Only a handful are still on 1.4. Fortunately, no one is on a version older than 1.4.</p>
<p><a href="http://stuartsierra.com/wp-content/uploads/2011/11/2011-10-jdk-survey-versions.png"><img class="alignnone size-full wp-image-582" title="2011 JDK Version Survey: version results" src="http://stuartsierra.com/wp-content/uploads/2011/11/2011-10-jdk-survey-versions.png" alt="" width="651" height="243" /></a></p>
<p><strong>Reasons:</strong> These are more varied. The most common reason for not upgrading is lack of time, with &#8220;it just works&#8221; running a close second. A little less than half of respondents are limited by external forces: either operations/management or third-party dependencies.</p>
<p><a href="http://stuartsierra.com/wp-content/uploads/2011/11/2011-10-jdk-survey-reasons.png"><img src="http://stuartsierra.com/wp-content/uploads/2011/11/2011-10-jdk-survey-reasons.png" alt="" title="2011 JDK Versions Survey: reason responses" width="812" height="266" class="alignnone size-full wp-image-583" /></a></p>
<p>Not much came out in the comments. Banks and other large institutions seem to be the most resistant to upgrades, especially if they&#8217;ve been bitten by past JDK changes.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/Xww4uEvC4uY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/11/04/jdk-version-survey-results/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/11/04/jdk-version-survey-results</feedburner:origLink></item>
		<item>
		<title>JDK Version Survey</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/KzdziAfWg2U/jdk-version-survey</link>
		<comments>http://stuartsierra.com/2011/10/04/jdk-version-survey#comments</comments>
		<pubDate>Tue, 04 Oct 2011 12:52:05 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=575</guid>
		<description><![CDATA[The most recent JDK version poll I could find was from 2008 (thanks, Alex!) so here&#8217;s a new one. Loading&#8230;]]></description>
			<content:encoded><![CDATA[<p>The most recent JDK version poll I could find was <a href="http://java.dzone.com/news/jdk-version-poll-results">from 2008</a> (thanks, Alex!) so here&#8217;s a new one.</p>
<p><iframe src="https://docs.google.com/spreadsheet/embeddedform?formkey=dEU5a0d1VE52NFhOQTJUblFKUmVKeWc6MQ" width="760" height="870" frameborder="0" marginheight="0" marginwidth="0">Loading&#8230;</iframe></p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/KzdziAfWg2U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/10/04/jdk-version-survey/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/10/04/jdk-version-survey</feedburner:origLink></item>
		<item>
		<title>Design Philosophies of Developer Tools</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/FoqySOfivHo/design-philosophies-of-developer-tools</link>
		<comments>http://stuartsierra.com/2011/08/30/design-philosophies-of-developer-tools#comments</comments>
		<pubDate>Wed, 31 Aug 2011 00:55:15 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=565</guid>
		<description><![CDATA[I&#8217;ve been thinking about some of the tools that I use every day, and about the different design philosophies they reflect. Git First and foremost, Git. We use Git on every single project, internal and external. Git is a great &#8230; <a href="http://stuartsierra.com/2011/08/30/design-philosophies-of-developer-tools">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about some of the tools that I use every day, and about the different design philosophies they reflect.</p>
<h3>Git</h3>
<p>First and foremost, Git. <a href="http://thinkrelevance.com/">We</a> use Git on every single project, internal and external. Git is a great example of the Unix design philosophy: many small programs &mdash; 153 of them by my count &mdash; each of which does exactly one thing and does it well. But this is not &#8220;loose coupling.&#8221; The components of Git are tightly integrated: they all depend on the same <a href="http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html">repository structure</a> and file formats. </p>
<p>One of the nice things about Git is how its internals are both exposed for the world to see and thoroughly documented. We can easily write scripts to automate common tasks or create different workflows. With a bit more effort, we could even write new tools that integrate with the Git suite. These tools can do things that Git&#8217;s authors never intended, as long as they follow the documented repository structure. Git isn&#8217;t so much a version control system as the means to construct one.</p>
<p>Still, Git is one project with many components, not many separate projects. All 153 executables in Git are governed by a single release cycle, tested and known to work together. We never have to worry about incompatible versions of, say, <code>git-branch</code> and <code>git-merge</code> on the same machine. Older versions of Git can read repositories created with newer versions even if they don&#8217;t provide all the same features.</p>
<h3>Maven</h3>
<p>In stark contrast to Git, we have tools from the Java world like <a href="http://ant.apache.org/">Ant</a> and <a href="http://maven.apache.org/">Maven</a>. The <a href="http://blog.headius.com/2009/05/fork-and-exec-on-jvm-jruby-to-rescue.html">JVM cannot fork/exec</a>, so the many-small-programs design is a non-starter. Instead, the Java tools usually favor some sort of plug-in architecture, which is a great idea in theory but hard to get right in practice. </p>
<p>I&#8217;ve <a href="https://github.com/stuartsierra/new-clojure-maven-plugin">tried writing a Maven plugin</a>. Hacking up a one-off for a single project is not too difficult, but designing a general-purpose plugin that works everywhere is maddeningly complicated. Maven plugins are just Java code, so they can do whatever they want, but the APIs for interacting with the rest of the Maven system are woefully underdocumented. The <strong>contract</strong> of a Maven plugin, what it can and cannot do, is not well-defined. The internals of Maven itself are largely a black box. </p>
<p>The core Maven plug-ins have independent release cycles, so there is the possibility for unexpected incompatibilities, but I&#8217;ve never encountered such. On the whole, the Maven ecosystem is quite stable. The struggle comes once you venture outside the realm of what the standard plugins provide. Maven plugins are not designed to be composed, so adding new capabilities is rarely as simple as scripting plugins that already exist. You have to start from scratch every time.</p>
<h3>Ruby / Rubygems / RVM / Bundler</h3>
<p>Finally, we have tools from the Ruby world, the ever-changing cornucopia of Ruby implementations, libraries, and tools to manage it all. The problem with the Ruby tools is that they are both tightly-coupled and uncoordinated. Despite having separate tools for each task, each tool reaches into at least one of the others: Rubygems modifies the behavior of the Ruby interpreter, Bundler modifies the behavior of Rubygems, RVM modifies the behavior of the <em>shell</em>, and so on. Each one adds another layer of indirection, making debugging harder.</p>
<p>All of the Ruby development tools have independent release cycles, and they don&#8217;t seem to plan or coordinate with one another in advance of each release. Integration testing is left up to the users.</p>
<p>I admire the speed and eagerness with which the Ruby community produces new tools. But on almost every Ruby project I&#8217;ve worked on, we&#8217;ve spent hours or days sorting out incompatibilities among some combination of libraries, language implementations, and development tools.  Our internal mailing list is littered with advice like &#8220;Don&#8217;t use Bundler version X with RVM version Y.&#8221; The speed of development comes with its own cost.</p>
<h3>Thoughts</h3>
<p>So what do I take from all this? Just a few principles to keep in mind when writing software tools:</p>
<ol>
<li>Plan for integration</li>
<li>Rigorously specify the boundaries and extension points of your system</li>
<li>Do not depend on unspecified behavior</li>
</ol>
<p>And a couple of ideas if you&#8217;re starting a new project from scratch:</p>
<ol>
<li>The filesystem is the universal integration point</li>
<li>Fork/exec is the universal plugin architecture</li>
</ol>
<p><strong>Update 8/31:</strong> More comments at <a href="http://news.ycombinator.com/item?id=2943902">Hacker News</a>.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/FoqySOfivHo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/08/30/design-philosophies-of-developer-tools/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/08/30/design-philosophies-of-developer-tools</feedburner:origLink></item>
		<item>
		<title>The Naming of Namespaces</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/iwwS36YzFcU/clojure-namespaces</link>
		<comments>http://stuartsierra.com/2011/08/08/clojure-namespaces#comments</comments>
		<pubDate>Tue, 09 Aug 2011 01:43:58 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Clojure]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=550</guid>
		<description><![CDATA[From time to time I&#8217;m asked, &#8220;How do you organize namespaces in Clojure projects?&#8221; The question surprised me at first, because I hadn&#8217;t thought about it much. But then I was using Clojure back when the only way to load &#8230; <a href="http://stuartsierra.com/2011/08/08/clojure-namespaces">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>From time to time I&#8217;m asked, &#8220;How do you organize namespaces in Clojure projects?&#8221; The question surprised me at first, because I hadn&#8217;t thought about it much. But then I was using Clojure <a href="http://xkcd.com/378/">back when</a> the only way to load code was &#8220;load-file.&#8221;</p>
<p>Most programming languages, especially object-oriented languages, provide strong hints on how to structure your source files. Everything is a class, and (almost) every class is a file. In Clojure, everything (almost) is a function. Functions are much smaller units than classes. So how do we group them?</p>
<p>The important thing to remember about namespaces is that, from the compiler&#8217;s point of view, they don&#8217;t matter. Namespaces are a convenience for the programmer, to help you avoid name clashes without having to write longer names. There&#8217;s no reason why an entire application can&#8217;t be defined in a single namespace. Most of Clojure itself is defined in <a href="http://clojure.github.com/clojure/#clojure.core">one namespace</a> with over 500 symbols. (Common Lisp has <a href="http://www.lispworks.com/documentation/HyperSpec/Front/X_Symbol.htm">978 symbols</a> in a single namespace.)</p>
<p>You can think of namespaces as a tool to <strong>express something</strong> about your application. Here are some ideas to get you started:</p>
<ul>
<li>Group functions into namespaces based on <strong>type of data</strong> they manipulate. For example, functions to manipulate customer data go in the &#8220;customer&#8221; namespace. This technique is familiar from object-oriented languages, but it has the same limitations: where do you put functions concerning relationships among two or more types? The OO answer would be to make a new name for the relationship. This style leads to a proliferation of small namespaces, which can become a burden.</li>
<li>Divide a library into a <strong>public API</strong> namespace and a <strong>internal implementation</strong> namespace. Or define a <strong>high-level API</strong> for common cases and a <strong>low-level API</strong> for more advanced usage.</li>
<li>Divide an application into namespaces representing <strong>architectural layers</strong>. You can examine &#8220;ns&#8221; declarations to prove that each layer calls functions only from the layer below it.</li>
<li>Divide an application into namespaces representing <strong>functional modules</strong>, with well-defined contracts for communication between modules.</li>
<li>Try to separate <strong>decision-making</strong> code from the code that <strong>carries out</strong> those decisions. That is, keep your business logic purely functional and free of side-effects, so it is easy to test. You don&#8217;t necessarily have to put side-effect code in a separate namespace, but doing so may help keep it cleanly separated.</li>
</ul>
<p>With all these techniques, the point to remember is that namespaces are there to help you, not to get in your way. If you have a large namespace, you can still divide it up into multiple files.</p>
<p>The one hard-and-fast rule is that you cannot have a circular dependency between namespaces. That is, if namespace A needs to call functions defined in namespace B, then namespace B <strong>cannot</strong> call functions in namespace A. There is no workaround, it simply can&#8217;t be done. In practice, this is rarely a problem. If you encounter a situation where two namespaces are mutually dependent, it&#8217;s probably a sign that they should be merged into a single namespace.</p>
<p>In client projects at <a href="http://thinkrelevance.com/">Relevance</a> (home of <a href="http://clojure.com/">Clojure/core</a>) we often end up with one namespace for each aspect of an application — data access, UI, logging, and so on. Then there&#8217;s one &#8220;main&#8221; namespace that depends on all the others and ties it all together.</p>
<p><strong>Update 9/5/2011:</strong> Chris Houser wrote a nice answer on StackOverflow about <a href="http://stackoverflow.com/questions/4690758/splitting-a-clojure-namespace-over-multiple-files">how to split a Clojure namespace over several files</a>.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/iwwS36YzFcU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/08/08/clojure-namespaces/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/08/08/clojure-namespaces</feedburner:origLink></item>
		<item>
		<title>ClojureScript Launch, New York</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/MxvdCIB58Ok/clojurescript-launch-new-york</link>
		<comments>http://stuartsierra.com/2011/07/21/clojurescript-launch-new-york#comments</comments>
		<pubDate>Thu, 21 Jul 2011 21:04:31 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[ClojureScript]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=543</guid>
		<description><![CDATA[As you may have heard, last night we (Clojure/core) announced ClojureScript at the Clojure NYC Meetup. Rich Hickey gave a talk, which was streamed live over the web, while we monitored Twitter and IRC for feedback. The event was a &#8230; <a href="http://stuartsierra.com/2011/07/21/clojurescript-launch-new-york">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As you may have heard, last night we (<a title="Clojure/core: Clojure consulting services, support, and agile software development" href="http://clojure.com/">Clojure/core</a>) announced <a href="https://github.com/clojure/clojurescript">ClojureScript</a> at the <a href="http://www.meetup.com/Clojure-NYC/">Clojure NYC Meetup</a>. Rich Hickey gave a talk, which was streamed live over the web, while we monitored Twitter and IRC for feedback.</p>
<p>The event was a great success, with loads of excitement expressed by both the local New York crowd and the Internet at large.</p>
<div id="attachment_544" class="wp-caption alignnone" style="width: 310px"><a href="http://stuartsierra.com/wp-content/uploads/2011/07/2011-07-20-screenshot-during-clojurescript-talk.png"><img class="size-medium wp-image-544" title="2011-07-20-screenshot-during-clojurescript-talk" src="http://stuartsierra.com/wp-content/uploads/2011/07/2011-07-20-screenshot-during-clojurescript-talk-300x187.png" alt="Screenshot of IRC / Twitter during the ClojureScript announcement" width="300" height="187" /></a><p class="wp-caption-text">Screenshot of IRC / Twitter during the ClojureScript announcement</p></div>
<p>Video was also recorded, which will be posted soon.</p>
<p>Thanks to <a href="http://www.google.com/intl/ln/jobs/uslocations/new-york/index.html">Google New York</a> for hosting.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/MxvdCIB58Ok" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/07/21/clojurescript-launch-new-york/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/07/21/clojurescript-launch-new-york</feedburner:origLink></item>
		<item>
		<title>Vote for Clojure at JAX Innovation Awards!</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/8UiJFkhKHVk/vote-for-clojure-at-jax-innovation-awards</link>
		<comments>http://stuartsierra.com/2011/06/16/vote-for-clojure-at-jax-innovation-awards#comments</comments>
		<pubDate>Thu, 16 Jun 2011 12:55:29 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=538</guid>
		<description><![CDATA[Vote for Clojure as the Most Innovative Java Technology of 2011!]]></description>
			<content:encoded><![CDATA[<p><a href="http://vote.jax-awards.com/"><img src="http://stuartsierra.com/wp-content/uploads/2011/06/JAX_US_IA_Button_Vote_For_Us.png" alt="JAX Innovation Awards 2011: Vote for us" title="JAX_US_IA_Button_Vote_For_Us" width="401" height="263" class="alignnone size-full wp-image-539" /></a></p>
<p><a href="http://vote.jax-awards.com/">Vote for Clojure</a> as the Most Innovative Java Technology of 2011!</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/8UiJFkhKHVk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/06/16/vote-for-clojure-at-jax-innovation-awards/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/06/16/vote-for-clojure-at-jax-innovation-awards</feedburner:origLink></item>
		<item>
		<title>Dependency Management First-Aid Kit</title>
		<link>http://feedproxy.google.com/~r/StuartSierra/~3/yUzYhPeDokw/dependency-management</link>
		<comments>http://stuartsierra.com/2011/06/01/dependency-management#comments</comments>
		<pubDate>Wed, 01 Jun 2011 19:08:36 +0000</pubDate>
		<dc:creator>Stuart</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Leiningen]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://stuartsierra.com/?p=533</guid>
		<description><![CDATA[This article attempts to unravel some of the mysteries of dependency management with Maven and Maven-based tools. Help, something&#8217;s missing! Say you have a project named &#8220;my-new-project&#8221; which declares a dependency on version 3 of the &#8220;awesome-sauce&#8221; library by the &#8230; <a href="http://stuartsierra.com/2011/06/01/dependency-management">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This article attempts to unravel some of the mysteries of dependency management with <a href="http://maven.apache.org/">Maven</a> and Maven-based tools.</p>
<h3>Help, something&#8217;s missing!</h3>
<p>Say you have a project named &#8220;my-new-project&#8221; which declares a dependency on version 3 of the &#8220;awesome-sauce&#8221; library by the Example.com corporation. You add the dependency to your pom.xml, project.clj, or whatever configuration file your build tool uses. You take a deep breath and start a build. And it fails!</p>
<p>If you&#8217;re using Maven 2, you see something like this:</p>
<pre>[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) com.example:awesome-sauce:jar:3.0.0

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=com.example -DartifactId=awesome-sauce -Dversion=3.0.0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there:
      mvn deploy:deploy-file -DgroupId=com.example -DartifactId=awesome-sauce -Dversion=3.0.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
        1) my.group:my-new-project:jar:1.0.0-SNAPSHOT
        2) com.example:awesome-sauce:jar:3.0.0

----------
1 required artifact is missing.

for artifact:
  my.group:my-new-project:jar:1.0.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  clojars (http://clojars.org/repo/)</pre>
<p>Leiningen, which uses Maven 2 under the covers, produces similar output, but it mistakenly prints the current project name as <code>org.apache.maven:super-pom:jar:2.0</code>.</p>
<p>Maven 3 prints a less verbose (and less informative) error message, but the gist is the same.</p>
<h3>What happened?</h3>
<p>What is all this verbosity saying? Well, obviously, the build failed because something was missing. <em>What</em> was missing? Maven tells you:</p>
<pre>Missing:
----------
1) com.example:awesome-sauce:jar:3.0.0</pre>
<p>The JAR file for the project &#8220;awesome-sauce&#8221;, version 3.0.0, published in the &#8220;com.example&#8221; group, is missing. That just means Maven didn&#8217;t find it in any of the places it looked.</p>
<p>Where did it look? Maven tells you that too:</p>
<pre>from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  clojars (http://clojars.org/repo/)</pre>
<p>These are the public repositories where Maven searched for the file. Each repository has an ID (&#8220;central&#8221; and &#8220;clojars&#8221; in this case) and a URL. Both are specified in the configuration of:</p>
<ol>
<li>
<p>Your project, in pom.xml or project.clj</p>
</li>
<li>
<p>Your build tool&#8217;s global configuration file</p>
<ul>
<li>settings.xml for Maven</li>
<li>N/A for Leiningen</li>
</ul>
</li>
<li>
<p>Your build tool&#8217;s built-in defaults</p>
<ul>
<li>The <a href="http://repo1.maven.org/">Maven Central Repository</a> for almost any Maven-based tool</li>
<li><a href="http://clojars.org/">Clojars</a> for Leiningen</li>
</ul>
</li>
</ol>
<p>If you visit http://repo1.maven.org/maven2/com/example/awesome-sauce or http://clojars.org/repo/com/example/awesome-sauce in a browser you will see that those directories do not, in fact, exist.</p>
<p>Although it&#8217;s not listed, the first place Maven checks for a dependency is your <em>local</em> Maven repository. The local repository is just a big cache of everything Maven has downloaded in the past. It&#8217;s typically located at <code>$HOME/.m2/repository</code>.</p>
<h3>What to do next</h3>
<p>You have two options at this point:</p>
<ol>
<li>Find a public repository containing &#8220;awesome-sauce&#8221;</li>
<li>Install &#8220;awesome-sauce&#8221; in your local repository</li>
</ol>
<p>The first option is generally less work, and more repeatable if you ever build your project on another machine.</p>
<h3>Finding a repository</h3>
<p>Odds are, if the library you are looking for is free, open-source, and popular, it will already be in a public Maven repository somewhere. Start with the source: who released the library? Large organizations with a lot of open-source projects often host their own repositories, like <a href="http://code.google.com/p/google-maven-repository/">Google</a>  and <a href="http://repository.codehaus.org/">Codehaus</a>. Failing that, search engines such as <a href="http://mvnbrowser.com/">Mvnbrowser</a> may help you find it.</p>
<p>Once you&#8217;ve found a repository, you need to add it to your build. For example, to add the Codehaus repository to a Maven project, add these lines to pom.xml inside the <code>&lt;project&gt;</code> tag:</p>
<pre>&lt;repositories&gt;
  &lt;repository&gt;
    &lt;id&gt;codehaus&lt;/id&gt;
    &lt;name&gt;Codehaus&lt;/name&gt;
    &lt;url&gt;http://repository.codehaus.org/&lt;/url&gt;
  &lt;/repository&gt;
&lt;/repositories&gt;</pre>
<p>(You can pick your own <code>&lt;id&gt;</code> and <code>&lt;name&gt;</code>.)</p>
<p>For Leiningen, add the following lines inside the <code>(defproject&nbsp;...)</code> block:</p>
<pre>  :repositories {"codehaus" "http://repository.codehaus.org/"}</pre>
<h3>Installing locally</h3>
<p>If the library you want is not available in any public repository, you&#8217;re not stuck, you just have to do a bit more work. You need to get the JAR file for the library, either by downloading it manually or building from source. Then you need to install that JAR file in your local Maven repository. That&#8217;s easy, because Maven has already told you exactly how to do it:</p>
<pre>  Then, install it using the command:
      mvn install:install-file -DgroupId=com.example -DartifactId=awesome-sauce \
 -Dversion=3.0.0 -Dpackaging=jar -Dfile=/path/to/file</pre>
<p>Copy that command verbatim, changing only <code>/path/to/file</code> to the path to the library&#8217;s JAR file. Maven will copy the file to <code>$HOME/.m2/repository/com/example/awesome-sauce/3.0.0/awesome-sauce-3.0.0.jar</code>. The next time you build your project, Maven knows exactly where to find it.</p>
<h3>Installing remotely</h3>
<p>If you want others to be able to build your project without having to go through these manual steps, you need your own public Maven repository to which you can upload files. Hosting a Maven repository isn&#8217;t hard: <a href="http://stuartsierra.com/2009/09/08/run-your-own-maven-repository">all you need is a web server</a>.</p>
<p>If you work with a team, consider setting up a shared repository for everyone to use. A repository manager such as <a href="http://nexus.sonatype.org/">Nexus</a> can help you take care of user accounts and authentication.</p>
<p>If you publish open-source libraries, I strongly encourage you to get an account on <a href="http://nexus.sonatype.org/oss-repository-hosting.html">Sonatype OSS</a>, a free service provided by the makers of Nexus. Releasing your projects to Sonatype OSS gives them a path to get added to the Maven Central Repository. While the requirements for projects in Maven Central are more stringent than just tossing code into your own repository, it&#8217;s worth the effort. In Maven Central, your project will have greater visibility and will be easier for anyone in the world to use.</p>
<h3>But what if I don&#8217;t want that dependency?</h3>
<p>Maven dependencies are transitive: if your project depends on project X, which depends on projects Y and Z, then your build will try to download X, Y, and Z.</p>
<p>But sometimes projects declare dependencies that aren&#8217;t strictly necessary. Or they declare dependencies on something you want, but the wrong version. How can you avoid including those extra dependencies in your build?</p>
<p>Maven supports <em>dependency exclusions</em> for these cases. For example, suppose the &#8220;awesome-sauce&#8221; library declares a dependency on &#8220;com.example:stupidity:0.0.1&#8243;. You know that you don&#8217;t need &#8220;stupidity&#8221; in your project, so you want to prevent the build from including it.  In pom.xml, you write:</p>
<pre>&lt;dependencies&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;com.example&lt;/groupId&gt;
    &lt;artifactId&gt;awesome-sauce&lt;/artifactId&gt;
    &lt;version&gt;3.0.0&lt;/version&gt;
    &lt;exclusions&gt;
      &lt;exclusion&gt;
        &lt;groupId&gt;com.example&lt;/groupId&gt;
        &lt;artifactId&gt;stupidity&lt;/artifactId&gt;
      &lt;/exclusion&gt;
    &lt;/exclusions&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;</pre>
<p>Or in Leiningen&#8217;s project.clj, you write:</p>
<pre>  :dependencies [[com.example/awesome-sauce "3.0.0"
                  :exclusions [com.example/stupidity]]]</pre>
<p>Note that once you start using exclusions, you&#8217;re on your own. It&#8217;s up to you to make sure you still have the correct versions of all the libraries your project needs. </p>
<p>On rare occasions, a project&#8217;s dependencies cannot be resolved at all. In particular, if you need two different versions of the same library with the same class names but incompatible APIs, you&#8217;re pretty much stuck. Time to refactor, or investigate multiple-Classloader schemes like <a href="http://www.osgi.org/">OSGi</a>. But that&#8217;s a whole &#8216;nother story.</p>
<img src="http://feeds.feedburner.com/~r/StuartSierra/~4/yUzYhPeDokw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://stuartsierra.com/2011/06/01/dependency-management/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://stuartsierra.com/2011/06/01/dependency-management</feedburner:origLink></item>
	</channel>
</rss>

