<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>EclipseSource Blog &#187; Manuel Woelker</title>
	<atom:link href="http://eclipsesource.com/blogs/author/manuel/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsesource.com/blogs</link>
	<description>Eclipse Equinox OSGi</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:54:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Persistent Trees in git, Clojure and CouchDB</title>
		<link>http://eclipsesource.com/blogs/2009/12/13/persistent-trees-in-git-clojure-and-couchdb-data-structure-convergence/</link>
		<comments>http://eclipsesource.com/blogs/2009/12/13/persistent-trees-in-git-clojure-and-couchdb-data-structure-convergence/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 16:33:35 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3606</guid>
		<description><![CDATA[This is a tale of three images. I found these images while investigating the internals of several different applications. There are some really neat software projects emerging at the moment, and as a developer I always find it interesting to take a look at the implementation details, because there is often a lot to be [...]]]></description>
			<content:encoded><![CDATA[<p>This is a tale of three images. I found these images while investigating the internals of several different applications. There are some really neat software projects emerging at the moment, and as a developer I always find it interesting to take a look at the implementation details, because there is often a lot to be learned. It&#8217;s not always something you might need right now, but maybe a few years down the line you may be confronted with a similar problem. Plus &#8211; in my opinion &#8211; knowing a bit about the internals of a program helps reasoning about its behaviour.</p>
<h3>Exhibit A: git repositories</h3>
<p><img class="aligncenter size-full wp-image-3633" title="git-trees" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/12/git-trees.png" alt="git trees Persistent Trees in git, Clojure and CouchDB" width="640" height="480" /></p>
<p>Let&#8217;s start with the first image. This one is taken from <a href="http://www.gitcasts.com/git-talk">Scott Chacon&#8217;s talk &#8220;Getting Git&#8221;</a>. (Actually I had to mix slides 138 and 142 together to better fit the blog format.) I&#8217;ll try not to go to much into the details of <a href="http://git-scm.com/">git</a> here, listen to the talk instead of you want to know more. The thing I <em>do</em> want to talk about though is git&#8217;s tree structures.  These tree structures describe the project contents (both directory and file) for one specific commit. These trees are completely immutable (this is ensured by SHA-1 hashes). A new commit creates what amounts to a completely new tree. But usually the changes in each commit are only a fraction of the whole tree. Since a lot of the sub-trees of the original tree have not changed (and are immutable), these can be safely recycled. Only files and folders that have changed need to be added. Note that this means parent nodes of changed nodes have to be created as well, recursively up to the tree root. But even though the tree itself is new (as evidenced by the new root) the additional space requirements are quite low, on the order of approximately O(log n). This makes for extremely compact repository format, and an astonishingly simple one.<br />
Another thing I want to point out that the only element that needs to be mutated is the reference to the root of the tree, everything else is immutable.</p>
<h3>Exhibit B: Clojure&#8217;s persistent data structures</h3>
<p><img class="aligncenter size-full wp-image-3631" title="clojure-trees" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/12/clojure-trees.png" alt="clojure trees Persistent Trees in git, Clojure and CouchDB" width="640" height="342" /></p>
<p>Next up is a picture lifted from <a href="http://blip.tv/file/812787">Rich Hickey&#8217;s &#8220;Clojure Concurrency&#8221; talk</a>. If you are interested in figuring out ways to deal with the impending multi-core age, I highly recommend you take a look at this talk. The concepts and techniques are not exclusive to <a href="http://clojure.org/">Clojure</a>, so even if you are not into Lisp&#8217;s you might want to watch it.</p>
<p>The way clojure deals with concurrency (in a nutshell) is that every core data structure (list, trees, hash maps, etc) is immutable. This has one big perceived drawback: Immutable data structures incur a huge overhead because of all the copying involved in creating new instances. But this is only a problem if the immutability is implemented naively. Analysis shows that usually only a part of a data structure is actually modified at any given time. This again allows recycling large parts of the the &#8220;old&#8221; data structure and only creating part of it new, and just pointing to the bits of the old structure that have not changed. As these are immutable as well, it is completely safe to do so. In the picture the two green boxes are the root nodes of two data structures sharing large parts of their trees.</p>
<p>Since a program that only deals with static, immutable data is pretty boring, there are mechanisms for introducing changes in a program. These mechanisms are called references, and these <em>do</em> mutate. But the runtime ensures that these changes happen in a controlled and well behaved manner, e.g. in the form of Software Transactional Memory (STM) or agents. But everything else is essentially immutable. Note that this has the neat side effect that reading process are inherently thread-safe since nothing can suddenly change while you are looking at it, i.e. no more ConcurrentModificationExceptions.</p>
<h3>Exhibit C: CouchDB&#8217;s append-only file format</h3>
<p><img class="aligncenter size-full wp-image-3632" title="couchdb-trees" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/12/couchdb-trees.png" alt="couchdb trees Persistent Trees in git, Clojure and CouchDB" width="400" height="212" /></p>
<p>The third picture is from a <a href="http://horicky.blogspot.com/2009/11/nosql-patterns.html">blog post by Ricky Ho titled &#8220;NoSQL patterns&#8221;</a>. <a href="http://couchdb.apache.org/">CouchDB</a> has made quite a few waves recently, so I wanted to see what makes it tick under the hood. In keeping with the Erlang philosophy of robustness and failure tolerance, couchdb uses an append-only file format. This means that all data written is not modified any further and there is thus little chance for corruption. CouchDB uses a <a href="http://en.wikipedia.org/wiki/B%2B_tree">B+ Tree</a> to index its entries, so again we have a tree structure. And because the tree entries live inside an append only file, these trees are immutable as well. When making a change to the database, the new data is written along with all changes to nodes in the B+ Tree. Since the B+ Tree is very flat, that means even for databases with millions of entries the number of updated tree nodes is fairly small. The most recent root of the index tree can always be found at the very end of the file, and thus the database file is read from the end backwards. If any kind of failure occurs while writing changes, the software can see that the last entry is corrupt and can seek further back until it finds a &#8220;good&#8221; entry and proceed from there. Another interesting benefit is that reading processes don&#8217;t block writing processes and vice versa. A reading process can just find the latest root and then work from there. Because all references go backward in the file, and everything is immutable there is no contention. Meanwhile a writing process can happily append at the end of the file without disrupting any readers.</p>
<h4>Further exhibits</h4>
<p>There are probably more examples of this pattern to be found. The oldest reference I could find is &#8220;<a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.8933">The Design and Implementation of a Log-Structured File System</a>&#8221; written by Mendel Rosenblum and John K. Ousterhout in 1991. The most recent file system effort seems to be <a href="http://www.nilfs.org">NILFS</a>. The flash-based SSDs that are currently entering the market are also rumored to use <a href="http://lwn.net/Articles/353411/">something along these lines internally</a>. I also suspect that a few of the traditional DBMS might use similar data structures under the hood</p>
<h3>Shared characteristics</h3>
<p>Although all the applications do very different things and come from completely different backgrounds, they share a common data structure underneath. Unfortunately I have not been able to find a well published moniker for this pattern. If anyone does, please let me know.</p>
<p><strong>Update: </strong>As FuncFan pointed out in the comments the moniker I was looking for was &#8220;<a href="http://en.wikipedia.org/wiki/Purely_functional#Trees">Purely functional trees</a>&#8220;. Thanks for the quick reply!</p>
<h4>Immutable, recycling trees</h4>
<p>All three systems have these immutable trees in some way way or form that allow sharing structure. In git these are tree objects, in Clojure they are called persistent data structures, and in CouchDB they are part of the internal index tree.</p>
<h4>Mutable references</h4>
<p>To allow for changes in an otherwise immutable world, all systems allow for mutable reference constructs. All change is encapsulated in these references, which are called exactly that in both git and Clojure. In CouchDB the story is a little different. Here the &#8220;reference&#8221; to the latest tree is simply the end of the database file</p>
<h3>More common ground</h3>
<p>Apart from these &#8220;primary&#8221; characteristics there are other shared features among these three systems, that are a direct result of the underlying data structure.</p>
<h4>Garbage collection</h4>
<p>Because data may be shared between data structures, it is often not safe to delete all children when a root node is no longer needed. Instead a garbage collection mechanism is needed to free unused structures. Git does have a special command that does exactly that, Clojure uses the Garbage Collection in the JVM implicitly, and CouchDB offers a compact operation, which removes old versions and tree indices.</p>
<h4>Versioning</h4>
<p>Because no structure is changed, it is trivially easy to keep old versions around, and since a lot of data is shared it is usually fairly cheap in terms of memory to do so. Versioning is the primary application of git, so no big surprises on that end. In Clojure it is also fairly easy to add versioning for things like an &#8220;undo&#8221; buffer: Just keep a list of the old objects around. CouchDB also offers some lightweight versioning out-of-box, but it is mostly used for replication. But it should be fairly simple to add more sophisticated versioning features.</p>
<h4>Concurrency Safety</h4>
<p>The immutability properties of all three system make reasoning about concurrent changes and processes a lot simpler. Reading is trivial because all that is read is set in stone, so to speak. Writing is made easier by the fact that there is only a single point &#8211; the reference &#8211; that is modified to effect a specific change. This critical point can then be guarded with traditional synchronization primitives, without having to worry about the rest of the data structure.</p>
<h3>Conclusion</h3>
<p>I have to admit I found it a bit eerie seeing a single pattern pop up in so many different places. It may be just an idea whose time has come (similar to Garbage Collection a few years back). Or it may be just that now we simply have enough memory and computing resources at our disposal, which allows us to never have to delete something from the record, but instead only add incrementally. And oftentimes the <a href="http://en.wikipedia.org/wiki/Dendrochronology">history of data is just as interesting as the data itself</a>. The benefits of immutability may also be a good way to tame the concurrency beast in the years to come.</p>
<p>I hope you enjoyed this comparative trip into the internals of these software systems. Again, check out the two talks and the blog post, they are well worth the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/12/13/persistent-trees-in-git-clojure-and-couchdb-data-structure-convergence/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Using JUnit&#8217;s &#8220;Assume&#8221; for faster tests</title>
		<link>http://eclipsesource.com/blogs/2009/10/07/using-junits-assume-for-faster-tests/</link>
		<comments>http://eclipsesource.com/blogs/2009/10/07/using-junits-assume-for-faster-tests/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 14:34:24 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[assume]]></category>
		<category><![CDATA[assumptions]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[pde build]]></category>
		<category><![CDATA[pde test]]></category>
		<category><![CDATA[preconditions]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3163</guid>
		<description><![CDATA[I wanted to share something I learned today about JUnit. Some of you may know this, but it was news to me. My triggering problem was that I was writing some unit-tests which required OSGi to be started up. All my other tests were plain (i.e. non-OSGi) tests. Since I didn&#8217;t want to suffer from [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to share something I learned today about JUnit. Some of you may know this, but it was news to me.</p>
<p>My triggering problem was that I was writing some unit-tests which required OSGi to be started up. All my other tests were plain (i.e. non-OSGi) tests. Since I didn&#8217;t want to suffer from the startup delay every time I ran the unit tests, I thought about &#8220;ignoring&#8221; these OSGi dependent tests based on whether I was running plain tests or PDE tests. A bit of googling turned up an interesting feature of JUnit (since 4.4): <a href="http://junit.sourceforge.net/doc/ReleaseNotes4.4.html#assumptions">Assumptions</a>. Assumptions are defined in the <a href="http://junit.org/apidocs/org/junit/Assume.html">Assume</a> class and are basically the exact opposite of JUnit assertions: If an assumption fails, the test automatically passes. This keeps tests from failing when certain preconditions have not been met. Ideally these would be marked as &#8220;ignored&#8221; or &#8220;skipped&#8221; but still better than nothing (maybe someone with commit rights to the TestRunner could make this happen).</p>
<p>This neat feature allows us to do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  @Before
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Assume.<span style="color: #006633;">assumeTrue</span><span style="color: #009900;">&#40;</span> <span style="color: #003399;">Activator</span>.<span style="color: #006633;">isOsgiRunning</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now the tests will only be executed if they are running in an OSGi environment.</p>
<p>If you put this in an abstract base class that all PDE Tests inherit, these will be ignored when running in &#8220;plain&#8221; mode, for even quicker test runs. In that case be sure to name your <code>@Before</code> method in a unique way so it does not get overridden (and thus nullified) by subclasses.</p>
<p>These assumptions might also be useful for tests known to fail on particular platforms, JREs, runtime environments etc. Another neat addition to my toolbox. The bit of hair in this soup is that JUnit 4 support in Eclipse is a bit lacking, especially when it comes to the PDE build. Some of this is detailed in <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=153429">Bug #153429</a> which hopefully will be fixed in 3.6. (Hint: Vote!)</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/10/07/using-junits-assume-for-faster-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Executable WARs with Jetty</title>
		<link>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/</link>
		<comments>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 08:24:55 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[servlet container]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3134</guid>
		<description><![CDATA[Today I want to talk about one of the younger members in the Eclipse family: Jetty. It is great to have such an interesting project on board and it is yet another example of how Eclipse has become more than just an IDE. What I wanted to with jetty was to create an executable, standalone [...]]]></description>
			<content:encoded><![CDATA[<p>Today I want to talk about one of the younger members in the Eclipse family: <a href="http://www.eclipse.org/jetty/">Jetty</a>. It is great to have such an interesting project on board and it is yet another example of how Eclipse has become more than just an IDE.</p>
<p>What I wanted to with jetty was to create an executable, standalone and self-contained WAR. I first encountered this concept in <a href="https://hudson.dev.java.net/">Hudson</a>. The hudson.war contains an embedded <a href="http://winstone.sourceforge.net/">Winstone servlet container</a>, which makes it possible to run the application by executing</p>
<pre>java -jar hudson.war</pre>
<p>This makes test driving the application really simple. The idea was to do the same with Jetty. Embedding the Jetty runtime in the war proved to be the easy part, as it was just a matter of declaring the jetty dependencies in the maven pom.xml.</p>
<p>The tricky part was telling jetty where to find the war-file to serve. My first try was to hardcode the filename, but that left a foul aftertaste. Finding a solution took quite some time, which is why I am posting this for future reference. This is the Main-Class used to bootstrap Jetty (adapted from the Wicket quickstart archetype):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Connector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Server</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.bio.SocketConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.webapp.WebAppContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Start <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    Server server <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Server<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    SocketConnector connector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SocketConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Set some timeout options to make debugging easier.</span>
    connector.<span style="color: #006633;">setMaxIdleTime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    connector.<span style="color: #006633;">setSoLingerTime</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    connector.<span style="color: #006633;">setPort</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server.<span style="color: #006633;">setConnectors</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Connector<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> connector <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    WebAppContext context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebAppContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setServer</span><span style="color: #009900;">&#40;</span>server<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setContextPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">ProtectionDomain</span> protectionDomain <span style="color: #339933;">=</span> Start.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getProtectionDomain</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">URL</span> location <span style="color: #339933;">=</span> protectionDomain.<span style="color: #006633;">getCodeSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getLocation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setWar</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">toExternalForm</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    server.<span style="color: #006633;">addHandler</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      server.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">in</span>.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      server.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      server.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The interesting bit is the <code>getProtectionDomain()/getCodeSource()</code> part, which tells us the location of the war-file. That&#8217;s all there is to it. Presto, executable web-application powered by Jetty in jar.</p>
<p><em>Edit:</em> Added the import statements as per Tim&#8217;s suggestion.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>The Future of Eclipse PDE builds</title>
		<link>http://eclipsesource.com/blogs/2009/09/22/the-future-of-pde-builds/</link>
		<comments>http://eclipsesource.com/blogs/2009/09/22/the-future-of-pde-builds/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 08:36:44 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[b3]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[pde build]]></category>
		<category><![CDATA[tycho]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3081</guid>
		<description><![CDATA[Eclipse has earned a reputation of being one of the best IDEs in existence. While it has become a lot more than that in many ways, its roots and its focus have always been the user facing aspects. That is probably the reasons why certain other aspects like the PDE build have been a bit [...]]]></description>
			<content:encoded><![CDATA[<p>Eclipse has earned a reputation of being one of the best IDEs in existence. While it has become a <a href="http://wiki.eclipse.org/index.php/Rich_Client_Platform">lot</a> <a href="http://www.eclipse.org/jetty/">more</a> <a href="http://www.eclipse.org/eclipselink/">than</a> <a href="http://wiki.eclipse.org/Equinox">that</a> in <a href="http://www.eclipse.org/riena/">many</a> <a href="http://www.eclipse.org/higgins/">ways</a>, its roots and its focus have always been the user facing aspects. That is probably the reasons why certain other aspects like the PDE build have been a bit neglected for quite a while. Between the ugly map files, the dependence on a target platform and its <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=153429">disability to run JUnit 4 tests</a> it feels like there is quite some room for improvement.<br />
I appreciate all the effort that went into the current state of the PDE Build, and there is quite a lot that it offers: Checking of OSGI access rules, validation of extension and extensions points, multi-platform builds, generation of p2 metadata for update sites among other things. I want to take a look at some of the recent and ongoing developments that build upon that legacy.</p>
<h4>b3</h4>
<p>The <a href="http://wiki.eclipse.org/PDE/Incubator/b3/Proposal">b3 project</a> is currently in incubation at eclipse.org. Its goal is basically to be to the PDE build what p2 was to the update manager: A revised, more powerful version of one of the main components of the Eclipse Platform. But while p2 was more or less a complete rewrite, the key with b3 idea is to build upon the exisiting technologies like the PDE build core, Buckminster, EMF and P2. Important key aspects are extensibility and customizability. as well as interoperability with other build tools such as ant and maven.</p>
<p>It is refreshing to see the build process getting more attention as of late, and that the Eclipse community itself is <a href="http://intellectualcramps.blogspot.com/2009/09/builds-we-make-them-complicated.html">stepping up to the task</a> of making sure that Eclipse based applications are built in a simple, repeatable and reproducible manner.</p>
<h4>Tycho</h4>
<p>While Eclipse is certainly one of the defacto industry standards, another one is maven. Just as Eclipse is more than an IDE, maven is more than a build tool. The <a href="http://docs.codehaus.org/display/M2ECLIPSE/Tycho+project+overview">Tycho project</a> is the maven implementation for building Eclipse plugins. While there are currently maven plugins out there capable of building &#8220;plain&#8221; OSGi bundles, Eclipse plugins are quite a lot more involved. Since both the maven pom.xml and the OSGi manifest include dependency information, there is a bit of redundancy here. The idea is here to have one of these be the &#8220;master&#8221; version, and then synthesize the other one from that. This means that projects can either be &#8220;pom-first&#8221; or &#8220;manifest-first&#8221; depending on the sepcific requirements and project setup.</p>
<p>There a certainly some roadblocks in the way. For example, both OSGi and maven have a concept of versions that is important for resolving dependencies. And while their format is superficially the same, their notion of version ordering is subtly but definitely incompatible. This can lead to all kinds of havoc.</p>
<p>Hopefully issues like these will be resolved sooner rather than later. Eclipse is not an island. Many applications based on Eclipse RCP are actual rich <em>clients,</em> which means they are connected to a server. These server components are usually more traditional &#8220;read: non-OSGI&#8221; Java applications, and thus tend to be built by a maven setup. In cases like these it would be desirable to have client and server share the same build infrastructure. This would be a huge boon to many real-life projects out there.</p>
<h4>Better builds</h4>
<p>Both these projects show an encouraging amount of progress, and I am convinced that these efforts will go a long way in making the Eclipse and the Java Platform an even better combination. While I think friendly competition is a good thing, competitive cooperation can be even better. Maybe these two projects have slightly different goals and will fill slightly different niches in the future. But I believe there is a lot of common ground, and I hope there is some healthy cross-pollination between these two projects, if not more. Both teams have a quite a background in their respective areas, and thus could bring a lot to the table.</p>
<p>I for one am looking forward to see these two project bear fruit, making the Eclipse build process a lot less painful and a lot more powerful.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/09/22/the-future-of-pde-builds/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Maven in Eclipse</title>
		<link>http://eclipsesource.com/blogs/2009/09/17/maven-in-eclipse-a-powerful-combo/</link>
		<comments>http://eclipsesource.com/blogs/2009/09/17/maven-in-eclipse-a-powerful-combo/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 08:00:15 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[IAM]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[Q4E]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2963</guid>
		<description><![CDATA[In the past I have said some unkind words about about maven&#8217;s pom.xml format. My aversion to xml heavy configuration has drawn me to more lightweight approaches to build systems, like gradle for example. At the same I was intrigued: If a tool like maven is seeing such a widespread use despite its cumbersome format, [...]]]></description>
			<content:encoded><![CDATA[<p>In the past I have said some <a href="http://eclipsesource.com/blogs/2009/08/10/xml-still-no-silver-bullet/">unkind words about about maven&#8217;s pom.xml format</a>. My aversion to xml heavy configuration has drawn me to more lightweight approaches to build systems, like <a href="http://www.gradle.org/">gradle</a> for example. At the same I was intrigued: If a tool like <a href="http://maven.apache.org/">maven</a> is seeing such a widespread use despite its cumbersome format, there must something to make up for it. My curiosity finally got the better of me and I decided to give it a shot. I figured there might be some tooling available to help ease the pain.</p>
<p>And lo and behold, there&#8217;s not one but two eclipse projects for integrating maven. One is the<a href="http://www.eclipse.org/iam/"> IAM project</a> (formerly known as Q4E) and the second is <a href="http://m2eclipse.sonatype.org/">m2eclipse</a>. In that regard it&#8217;s a bit like subversive/subclipse but hopefully without all that licensing nonsense. But it is usually  good to have some choice &#8211; and competition of course. To get a clearer picture I decided to give both plugins a try.</p>
<h4>IAM</h4>
<p>I started with IAM. Setting up my sample project was a snap, and the maven integration immediately started downloading dependencies and adding them to the project classpath. Maven repositories can also hold source jars, making development and debugging much easier. The pom editor seems to cover all options and is looking quite solid. I was more interested in the core feature set, so I didn&#8217;t check out any advanced options.</p>
<h4>m2eclipse</h4>
<p>Next up I tested m2eclipse, which offers basically the same core feature set. Dependencies are automatically downloaded and added to the project classpath. The pom editor covered the same functionality as IAM&#8217;s, but I personally liked the the looks and layout better in m2eclipse. One really nice feature is code completion for dependencies.</p>
<div id="attachment_2999" class="wp-caption aligncenter" style="width: 369px"><img class="size-full wp-image-2999" title="I am too lazy to type..." src="http://eclipsesource.com/blogs/wp-content/uploads/2009/09/maven.png" alt="maven Maven in Eclipse" width="359" height="178" /><p class="wp-caption-text">Code completion - rocks!</p></div>
<p>I know I am spoiled eclipse developer, and <a href="http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/">I expect my IDE to finish my thoughts for me</a>. But it gets even better: There is also a quickfix (Ctrl+1) for unresolved imports. Talk about convenience!</p>
<div id="attachment_3000" class="wp-caption aligncenter" style="width: 669px"><img class="size-full wp-image-3000" title="Do what I mean" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/09/maven2.png" alt="maven2 Maven in Eclipse" width="659" height="226" /><p class="wp-caption-text">Quickfix to the rescue!</p></div>
<p>It&#8217;s good to see that there at least two very viable options when it comes to developing maven  projects in eclipse. Kudos to both the IAM and the m2eclipse team for the fantastic work.</p>
<h4>The Price of Modularity</h4>
<p>To me, one of the greatest strengths of the Java Platform has been its rich ecosystem. There are so many java libraries and frameworks out there, that when developing for the Java platform you almost never have to start from scratch. Most of the time it&#8217;s finding the right libraries, writing a little adapter code and the core business logic. No need for reinventing wheels. This truly is modular and reusable software development, and one of the main reasons why the Java platform is so competitive.</p>
<p>But this modularity does come at a price known as dependency hell. Any non-trivial project has a dozens of dependencies. Even your basic run-of-the mill webapp requires a web framework, logging, OR mapper, JDBC drivers, etc. Add in all the indirect dependencies and you are looking at quite a lot of libraries. This is why strong dependency management is such a compelling argument for build systems like maven.</p>
<p>But there is another issue apart from painfully assembled builds: Jumpstarting new developers. Especially for open source projects it is quite a turnoff for a potential contributor to look at the long list of requirements and dependencies needed to get to the point where the code even compiles cleanly. This is where strong dependency management comes to the rescue. Sure, maven may download two and a half internets on the first compile, but when its done you have everything ready to start working.</p>
<h4>&#8220;apt-get for Java&#8221;</h4>
<p>Due to popularity and pervasiveness of maven, there are plugins for integrating almost all imaginable build tools. For most of projects maven provides everything needed right out of the box: unni testing, coverage, javadoc, pmd, you name it. Combined with <a href="https://hudson.dev.java.net/">hudson</a> this makes it ridiculously easy to get a continuous integration server running literally within minutes.</p>
<p>It is good to see that automatic dependency management is making such inroads in different areas of computing. Apt-get and maven, and even p2 have helped a lot to make the dependency hell a little more bearable.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/09/17/maven-in-eclipse-a-powerful-combo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Type Inference at Design Time via Eclipse</title>
		<link>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/</link>
		<comments>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 16:52:11 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[implicit typing]]></category>
		<category><![CDATA[jdt]]></category>
		<category><![CDATA[type inference]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2112</guid>
		<description><![CDATA[Dynamically typed programming languages have become more popular over the recent years. Dynamic typing makes certain tasks a lot easier, however, I will not go into a full discussion of dynamic versus static typed languages (I&#8217;m saving that discussion for later). Instead, I want to take a look at one of the cool ideas in [...]]]></description>
			<content:encoded><![CDATA[<p>Dynamically typed programming languages have become more popular over the recent years. Dynamic typing makes certain tasks a lot easier, however, I will not go into a full discussion of <em>dynamic versus static</em> typed languages (I&#8217;m saving that discussion for later). Instead, I want to take a look at one of the cool ideas in dynamic language design and demonstrate how Eclipse can somewhat emulate it.</p>
<p>By definition, dynamic languages have no concept of variable types. This means there is no need for a type declaration&#8230; so for example, in Python or Ruby you can just write:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">randomNumber=<span style="color: #ff4500;">4</span></pre></div></div>

<p>Some statically typed languages also allow the type declaration of variables to be omitted. But since the language is statically typed, where the does the variable type come from? A reasonably smart compiler can <em>infer</em> the type of a variable by looking at how the variable is used. Haskell and Scala are two examples of such languages that allow <em>implicit typing</em> and then determine the types through <em>compile time <a href="http://en.wikipedia.org/wiki/Type_inference">type inference</a></em>. This allows you to write the following scala code:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">var</span> randomNumber<span style="color: #000080;">=</span><span style="color: #0000ff; font-weight: bold;">new</span> BigDecimal<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">4</span><span style="color: #F78811;">&#41;</span></pre></div></div>

<p>The type of <code>randomNumber</code> is <code>java.math.BigDecimal</code>. This avoids having to type <code>BigDecimal</code> twice&#8230; once for the variable type declaration and once for the constructor. Since Eclipse has a full blown Java compiler under the hood (a fairly smart one), it allows you to do almost the same. You can basically omit the type declaration altogether, and when Eclipse complains just, hit <em>Ctrl+1</em> and select the appropriate option. The official name for that shortcut is <strong>Quickfix</strong>, but I like to think of as: &#8220;Dear Eclipse, I&#8217;m just too lazy, <a href="http://en.wikipedia.org/wiki/DWIM">why don&#8217;t you fix it for me</a>?&#8221;</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2009/08/design-time-type-inference.png"><img class="alignnone size-medium wp-image-2710" title="Eclipse design time type inference" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/08/design-time-type-inference-300x108.png" alt="design time type inference 300x108 Type Inference at Design Time via Eclipse" width="300" height="108" /></a></p>
<p>I don&#8217;t know whether this quickfix was created with this usage pattern in mind, but I find myself using this quite often. A close relative is the <strong>Extract variable</strong> refactoring which also does design time type inference. Another refactoring where type inference comes into play is <strong>Generalize declared type</strong>, which lets you reduce the specificness of a variable type to its lowest common denominator.</p>
<p>I am sure there are a number of similar refactorings and quick fixes. These powerful features demonstrate how a smart IDE can make working with a statically typed language much easier, while still reaping the benefits of static type checks.</p>
<p>What are your favorite type inference shortcuts?</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/08/17/eclipse-type-inference-at-design-time/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Beyond XML: The Future of Extensible Metaformats</title>
		<link>http://eclipsesource.com/blogs/2009/08/11/beyond-xml-the-future-of-extensible-metaformats/</link>
		<comments>http://eclipsesource.com/blogs/2009/08/11/beyond-xml-the-future-of-extensible-metaformats/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 15:56:09 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[gant]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2666</guid>
		<description><![CDATA[Yesterday I discussed some of the issues with XML. Today I'll be taking a look at three of the potential alternatives that may improve on the current situation.]]></description>
			<content:encoded><![CDATA[<p>Yesterday I discussed <a title="XML: Still No Silver Bullet" href="http://eclipsesource.com/blogs/2009/08/10/xml-still-no-silver-bullet/">some of the issues with XML</a>. Today I&#8217;ll be taking a look at three of the potential alternatives that may improve on the current situation.</p>
<h4>YAML</h4>
<p><a title="The Official YAML Website" href="http://www.yaml.org/">YAML Ain&#8217;t Markup Language</a>. To quote the <a title="YAML Ain’t Markup Language (YAML™) Version 1.2 " href="http://www.yaml.org/spec/1.2/spec.html">spec</a>, it is a &#8220;human-friendly, cross language, Unicode based data serialization         language&#8221;. While mainly designed with so-called agile languages in mind, it can also be used with more traditional languages. The format is more data-centric than document-driven. Even so, one of its primary design goals is good readability. It was heavily influenced by <a title="Internet Message Format" href="http://www.rfc-editor.org/rfc/rfc2822.txt">RFC 2822 (Internet Message Format)</a>. That means it looks a lot like mail headers. It features built-in support for lists, hashes (i.e. dictionaries or<strong> </strong>associative array), and common data types. It also allows elements to have multiple parents, which also allows cross-references. There are some more minor features that make working with the format easier. Here&#8217;s a small example of a YAML document lifted from the spec:</p>
<pre>invoice: 34843
date   : 2001-01-23
bill-to: &amp;id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.</pre>
<p>While YAML seems like a solid solution with implementations written for many languages, there are some issues, like the surprising lack of momentum in the software development community and the controversial use of significant whitespace.</p>
<h4>JSON</h4>
<p>The <a title="The JSON Website" href="http://www.json.org/">JavaScript Object Notation</a> is basically a subset of JavaScript used to statically describe data. With the release of YAML 1.2 it is also a subset of YAML, which means every JSON document is a YAML file. Its focus is primarily simplicity and readability. While it is trivial to parse JSON in a JavaScript environment, its simplicity makes it also quite easy parse in other languages. Parsers for most popular modern development platforms exist. Being so easily accessible in browsers has earned it quite some support and momentum in modern web development, already often completely replacing XML in the AJAX stack. Here&#8217;s a small snippet lifted from the JSON Wikipedia page:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
     <span style="color: #3366CC;">&quot;firstName&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;John&quot;</span><span style="color: #339933;">,</span>
     <span style="color: #3366CC;">&quot;lastName&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Smith&quot;</span><span style="color: #339933;">,</span>
     <span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #3366CC;">&quot;streetAddress&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;21 2nd Street&quot;</span><span style="color: #339933;">,</span>
         <span style="color: #3366CC;">&quot;city&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;New York&quot;</span><span style="color: #339933;">,</span>
         <span style="color: #3366CC;">&quot;state&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;NY&quot;</span><span style="color: #339933;">,</span>
         <span style="color: #3366CC;">&quot;postalCode&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">10021</span>
     <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
     <span style="color: #3366CC;">&quot;phoneNumbers&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #3366CC;">&quot;home&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;212 555-1234&quot;</span><span style="color: #339933;">,</span>
         <span style="color: #3366CC;">&quot;fax&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;646 555-4567&quot;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>JSON is currently quite popular, though it may in certain cases be hampered by its simpleness. Maybe YAML forward compatibility can provide an convenient upgrade path, should a more sophisiticated format be necessary.</p>
<h4>Groovy</h4>
<p>Most of you may know <a title="The Groovy Website" href="http://groovy.codehaus.org/">Groovy</a> as a JVM scripting language. I have also already blogged about <a title="Groovy, Eclipse Commands and Expressions" href="http://eclipsesource.com/blogs/2009/07/14/groovy-expressions-proof-of-concept/">using Groovy to replace especially painful parts of XML</a>.</p>
<p>Groovy features a MarkupBuilder that let&#8217;s you create what is basically an XML DOM tree in memory using a slightly more fluent syntax. Have a look:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">  car<span style="color: #66cc66;">&#40;</span>name:<span style="color: #ff0000;">'HSV Maloo'</span>, make:<span style="color: #ff0000;">'Holden'</span>, year:<span style="color: #cc66cc;">2006</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    country<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Australia'</span><span style="color: #66cc66;">&#41;</span>
    record<span style="color: #66cc66;">&#40;</span>type:<span style="color: #ff0000;">'speed'</span>, <span style="color: #ff0000;">'Production Pickup Truck with speed of 271kph'</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Some might consider this just syntactic sugar but it really goes a long way.</p>
<p>But I think Groovy can also be used as a first class configuration language. There are already several projects out there that use groovy scripts for tasks that have traditionally been in the firm grip of XML. One such example is <a title="The gant website" href="http://gant.codehaus.org/">gant</a>, which is basically just a thin wrapper to write ant files. Of course nowadays, everyone is using maven instead, but there&#8217;s also a neat tool for that: <a title="The Gradle website" href="http://www.gradle.org/">Gradle</a> is build system configured using a Groovy <a title="Domain-specific language" href="http://en.wikipedia.org/wiki/Domain-specific_language">DSL</a>, while employing Apache ivy and maven under the hood. Take a look at this example from the official gradle documentation:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">usePlugin <span style="color: #ff0000;">'java'</span>
&nbsp;
sourceCompatibility <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1.5</span>
version <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'1.0'</span>
manifest.<span style="color: #006600;">mainAttributes</span><span style="color: #66cc66;">&#40;</span>
    <span style="color: #ff0000;">'Implementation-Title'</span>: <span style="color: #ff0000;">'Gradle Quickstart'</span>,
    <span style="color: #ff0000;">'Implementation-Version'</span>: version
<span style="color: #66cc66;">&#41;</span>
&nbsp;
repositories <span style="color: #66cc66;">&#123;</span>
    mavenCentral<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
dependencies <span style="color: #66cc66;">&#123;</span>
    compile group: <span style="color: #ff0000;">'commons-collections'</span>, name: <span style="color: #ff0000;">'commons-collections'</span>, version: <span style="color: #ff0000;">'3.2'</span>
    testCompile group: <span style="color: #ff0000;">'junit'</span>, name: <span style="color: #ff0000;">'junit'</span>, version: <span style="color: #ff0000;">'4.+'</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
test <span style="color: #66cc66;">&#123;</span>
    options.<span style="color: #006600;">systemProperties</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'property'</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'value'</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
uploadArchives <span style="color: #66cc66;">&#123;</span>
    repositories <span style="color: #66cc66;">&#123;</span>
       flatDir<span style="color: #66cc66;">&#40;</span>dirs: file<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'repos'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>A lot easier on the eyes, while still providing interoperability with &#8220;legacy&#8221; systems like maven.</p>
<p>The power and expressiveness of groovy make it really easy to create domain-specific languages like these. Such a special purpose language might not always be desirable, especially when interoperability is a key concern. But for certain applications these DSLs might be a better solution than any general purpose format.</p>
<p>On the whole, these are interesting times we live in and I&#8217;m curious to see what the future holds in store. As I said before, XML is probably gonna be here for quite a while, but there are some compelling alternatives out there. What are your thoughts on the legacy of XML?</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/08/11/beyond-xml-the-future-of-extensible-metaformats/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>XML: Still No Silver Bullet</title>
		<link>http://eclipsesource.com/blogs/2009/08/10/xml-still-no-silver-bullet/</link>
		<comments>http://eclipsesource.com/blogs/2009/08/10/xml-still-no-silver-bullet/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 10:57:14 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2644</guid>
		<description><![CDATA[The XML format has done a lot in the last decade to reduce some of the pains of legacy formats and to encourage application interoperability. Having a common syntax makes the development process a lot easier. But I still feel that there are some severe shortcomings when it comes to the general format itself andand the concrete implementation of xml dialects that I want to discuss in this blog post.]]></description>
			<content:encoded><![CDATA[<p>The XML format has done a lot in the last decade to reduce some of the pains of legacy formats and to encourage application interoperability. Having a standardized syntax and object model makes the development process a lot easier. But I still feel that there are some severe shortcomings when it comes to the general format itself and and the concrete implementation of XML dialects that I want to discuss in this blog post.</p>
<h4>XML is a <em>markup</em> language</h4>
<p>As the name <em>Extensible Markup Language</em> implies, the language is first and foremost a markup language. That means that the language annotates a body of text. So if you were to strip out all the markup from an XML document, it should still end up with legible and comprehensible. This is certainly true for (X)HTML and DocBook. It might be slightly harder to read and understand, but all the crucial information is right there in plain text. The markup just adds semantic or presentational meta-information, e.g. which bits of text are headers or quotes.</p>
<p>In many cases XML is <em>misused</em> as a general data format. This often means that there is no actual text (character data) whatsoever in the resulting files. Then why use a markup-language in the first place? The<em> </em>Eclipse <em>plugin.xml</em> format for example is a markup only format (save some extension points schemas).</p>
<h4>Attribute and Element Dichotomy</h4>
<p>Another gripe with XML is when to use attributes vs. elements. There are at least three options that at first glance seem equally plausible. For example:</p>
<p>Name as PCDATA</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
ACME Inc.
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/customer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Name as extra element, PCDATA</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ACME Inc.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/customer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Name as attribute</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ACME Inc.&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>I have seen these three styles mixed within the same document for almost exactly the same fields. Should a general purpose data interchange format really be that hard to get right, or at least consistent?</p>
<h4>Awkward mapping of common constructs</h4>
<p>Because xml implicitly is a tree structure, all structures involving cyclic references or <strong>multiple cross-references</strong> in general are not easily mapped to an XML compatible form. Object-oriented models can often contain back-references, or reference a single object from different places in the object graph. Although there is some support for such constructs in the form of ID/IDREF attributes, this is neither supported by all parsers nor even publicly widespread information.</p>
<p>Another common data type that is painful to describe in XML is the <strong>associative map</strong>. An example from the Eclipse<em> plugin.xml</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;aboutImage&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;eclipse_lg.gif&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Compare that to a simple properties file format:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">aboutImage=eclipse_lg.gif</pre></div></div>

<p>The third type of commonly found data that is hard to put into XML is <strong>relational data</strong>. That kind of data is traditionally found in RDBMS, CSV files and unfortunately spreadsheets. While it is fairly trivial to create a corresponding xml format, the result is often needlessly verbose and repetitive, since all elements usually have the same attributes.</p>
<h4>Readability</h4>
<p>By far the biggest gripe I have with xml on a day to day basis is that it is really hard to parse for me as a human. Between the angle brackets bunched up against the element names, the endless repetition and escaped entities it seems like this format was not really designed with a legibility in mind. Another reason could be related to my first point: In regular markup languages the tags only contribute a relatively small percentage of the overall content. The majority is plain text, so the tags are few and far between. In markup-only languages however, there&#8217;s a much higher density of markup elements. In my opinion this redundant repetition lowers the signal to noise ratio significantly, making these documents much harder to read.</p>
<p>These are the main problems that I currently see with XML. I concede that the common, extensible meta format was a huge step forward, and that for some problem domains it is a pretty good fit. I also realize that XML is gonna be here for quite a while, but I think it&#8217;s time to stop resting on these laurels and see how we can address these problems in the future.</p>
<p>Tomorrow I&#8217;ll be looking at the some of the alternatives that might be potential successors to XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/08/10/xml-still-no-silver-bullet/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Why is that button gray?</title>
		<link>http://eclipsesource.com/blogs/2009/08/06/ui-design-why-is-that-button-gray/</link>
		<comments>http://eclipsesource.com/blogs/2009/08/06/ui-design-why-is-that-button-gray/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 13:50:57 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disabled]]></category>
		<category><![CDATA[swt]]></category>
		<category><![CDATA[tooltip]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2626</guid>
		<description><![CDATA[There is a user interface design issue that has been bugging me for quite some time, but I haven't been able to put my finger on it until recently: Disabled interaction elements, most often in the form of grayed out buttons and menu entries. The visual cue here is that the action is not available at the moment. While that information is quite convenient, it raises the obvious question of: "<strong><em>Why</em> is that action not available?</strong>"]]></description>
			<content:encoded><![CDATA[<p>There is a user interface design issue that has been bugging me for quite some time, but I haven&#8217;t been able to put my finger on it until recently. How do you best represent disabled interaction elements (most often in the form of grayed out buttons and menu entries)? The visual cue here is that the action is not available at the moment. While that information is quite convenient, it raises the obvious question of: </p>
<blockquote><p>Why is that action not available?</p></blockquote>
<p>Often the answer might be obvious to the experienced user but this isn&#8217;t good for novices. </p>
<p>What about new or inexperienced users? Can&#8217;t we ease the learning curve a little and help users get to grips with the desired functionality? This might help avoid statements like&#8230;</p>
<blockquote><p>&#8220;Oh wow, so that&#8217;s what that button does. I never used it because it was always disabled.&#8221;</p></blockquote>
<p>In many cases there might only be a single reason why the action is unavailable. That means if the button is gray it is fairly simple to figure out what is amiss. But in non-trivial applications there may be a whole host of reasons why an action can not be performed. Typical reasons include:</p>
<ul>
<li>technical reasons: e.g. a &#8220;delete&#8221; action can not be performed if nothing is selected</li>
<li>infrastructure reasons: e.g. a required service is unavailable</li>
<li>operational reasons: e.g. user has insufficient privileges, or  the action can only be performed during business hours</li>
<li>business domain reasons: e.g. certain preconditions have not been met, or the action is incompatible with another action that has already been performed</li>
</ul>
<p>That last reason can really be a big can of worms&#8230; because at least in my experience &#8220;businessy&#8221; applications have a propensity for growing complex rule sets that have to be modeled in software. That may even leave domain experts guessing why the button &#8220;re-evaluate taco consumption rates&#8221; is grayed out.</p>
<p>So is there way to deal with that problem in a more sophisticated and helpful manner? </p>
<p>Here is an idea how the information could be presented in a natural and obvious way.</p>
<div id="attachment_2627" class="wp-caption aligncenter" style="width: 710px"><img class="size-full wp-image-2627" title="Tooltip for disabled elements" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/08/disabled_tooltip.png" alt="disabled tooltip Why is that button gray?" width="700" height="250" /><p class="wp-caption-text">Tooltip for disabled elements - Answering the question</p></div>
<p>We&#8217;re doing nothing mind-boggling here but it gets the message across. On the implementation side of things, I could imagine something analogous to JFace style validators to attach to the button so that the appropriate message can be created on the fly. This might make for a cleaner technical design because different concerns of when to disable the button can be decoupled. One big drawback of this approach is that disabled (Windows) buttons don&#8217;t seem to show their tool tips. It may be possible to work around this problem with some SWT-fu though.</p>
<p>A more radical approach to the whole dilemma is the standpoint that disabled user interface elements are <em>design smells</em> that should be avoided completely. Applications should be designed in a way to support the necessary work flows and guide the user along logical steps&#8230; instead of doing trial and error and guesswork.</p>
<p>After all, trial and error and guesswork should be a domain reserved for point-and-click adventures.</p>
<p>So have you run into this issue as well? What were your experiences or solutions?</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/08/06/ui-design-why-is-that-button-gray/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Groovy, Eclipse Commands and Expressions</title>
		<link>http://eclipsesource.com/blogs/2009/07/14/groovy-expressions-proof-of-concept/</link>
		<comments>http://eclipsesource.com/blogs/2009/07/14/groovy-expressions-proof-of-concept/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 14:34:40 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=2445</guid>
		<description><![CDATA[There has to be a better way to describe command expressions than xml.]]></description>
			<content:encoded><![CDATA[<p>During my last project I had the dubious joy to work with a boatload of command framework expressions (<code>activeWhen</code>, <code>enabledWhen</code>). I appreciate the need for such a framework&#8230; don&#8217;t go through the overhead of loading all the classes for dozens of plugins to determine which commands are available&#8230; and instead use a lightweight alternative inside the plugin.xml file. This neatly sidesteps all the osgi class loading runtime overhead, making the eclipse experience fast and snappy. And I have to admit I am a sucker for speed. So I am on board with the concept but how things work in practice aren&#8217;t optimal in my opinion.</p>
<p>I&#8217;m not a big fan of XML in general and the idea of writing code in XML gives me the <em>shivers</em>. I have written enough XSLT to know pain&#8230; in copious amounts. We already have a long-established notation for formal expressions: programming languages. There is a very good reason Java&#8217;s syntax (or that of any other popular programming language) looks nothing like XML.</p>
<p>One argument that proponents of XML often make is that you usually shouldn&#8217;t have to look at XML at all. Well, I think they are wrong. The XML leaks through the cracks way too often. As a developer I am probably more exposed to that than the average user but nevertheless I still have to put up with it. Sometimes there may be a layer of GUI eye candy in between, but for something as specific as an expression editor&#8230; the standard extension editor just doesn&#8217;t cut it for me.</p>
<p>With a quick look at the following image: Tell me when the expression is true. Oh right, you can&#8217;t &#8211; the expression is distributed over several tree nodes.</p>
<div id="attachment_2452" class="wp-caption aligncenter" style="width: 674px"><img class="size-full wp-image-2452" title="Classic expressions" src="http://eclipsesource.com/blogs/wp-content/uploads/2009/07/groovy_exp_001.png" alt="groovy exp 001 Groovy, Eclipse Commands and Expressions" width="664" height="618" /><p class="wp-caption-text">Classic expressions</p></div>
<p>Now let&#8217;s look at the XML. Only slightly better, but at least you can see everything at once. Still clocking in at 6 elements, the signal to noise ratio is abysmally low.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handler</span></span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;groovy.expressions.handlers.SampleClassicHandler&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">commandId</span>=<span style="color: #ff0000;">&quot;groovy.expressions.commands.sampleCommand&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabledWhen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;or<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;with</span> <span style="color: #000066;">variable</span>=<span style="color: #ff0000;">&quot;activePartId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;not<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;equals</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;groovy.expressions.navigationView&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/not<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/with<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;with</span> <span style="color: #000066;">variable</span>=<span style="color: #ff0000;">&quot;selection&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;count</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/with<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/or<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabledWhen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To put my <span style="text-decoration: line-through;">money</span> code where my mouth is&#8230; so I tried to implement a more elegant solution to the problem. Note though that this is just a proof of concept hacked together in my spare time. I wanted to integrate a scripting language with the command framework so that expressions could be written as small snippets of code. The ecosystem of scripting languages is quite prolific at the moment, so there is a lot of choice. But choice is good right? I settled for Groovy since I had done some embedding experiments with it before. But I am convinced that other scripting languages would work just as well.</p>
<p>Hooking up the groovy runtime was a snap, adding another expression type (creatively named &#8220;groovy&#8221;) was easy as well. I found out before long that I had to specify which command variables to use. The first reason for that was that I had to bind these command variables to groovy variables &#8211; although this could also have been achieved with some propertyMissing trickery. The more compelling reason was that the command framework had to known when to re-evaluate the expression, i.e. when relevant variables had changed. The resulting expression now looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;handler</span></span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;groovy.expressions.handlers.SampleGroovyHandler&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">commandId</span>=<span style="color: #ff0000;">&quot;groovy.expressions.commands.sampleCommandGroovy&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;enabledWhen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groovy</span> <span style="color: #000066;">using</span>=<span style="color: #ff0000;">&quot;selection,activePartId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	activePartId != &quot;groovy.expressions.navigationView&quot; || selection.size() == 2
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groovy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/enabledWhen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Quite a bit more readable, eh? Notice the &#8220;using&#8221; attribute specifying the used variables mentioned above. It might even be possible to compute these variables by traversing the syntax tree of the expression. This feature is offered by some scripting engines and would mean we could completely drop the &#8220;using&#8221; attribute. The rest is just plain groovy code, and I&#8217;m sure most of you will have no problem understanding an expression like that.</p>
<p>Next I want to discuss some of the caveats and advantages of this approach.</p>
<h4>Caveats:</h4>
<p><strong>Needs a scripting engine</strong><br />
As far as I know, Java 1.6 ships with a Rhino interpreter so that could be an option for the future. Other small scripting engines (e.g. BeanShell) could be integrated as well. That is unless the big bad licensing monster rears its ugly head.</p>
<p><strong>Might need standardization</strong><br />
As mentioned above there is a whole plethora of scripting languages available right now on the JVM, so choosing &#8220;the one&#8221; might be a problem. Another option of course would be to delegate to <a href="http://jcp.org/en/jsr/detail?id=223">JSR 223</a> and let the user decide.</p>
<p><strong>Yet another language?</strong><br />
There might some developer resistance concerning yet another language to learn. While this is certainly a concern, some scripting options are very close Java (Groovy and particularly BeanShell come to mind). I would argue that the current XML expression language is &#8220;yet another language&#8221; to learn as well &#8211; and a cumbersome and ill-specified one at that.</p>
<h4>Advantages:</h4>
<p><strong>Legible expressions</strong><br />
As mentioned above, the expression is much easier to parse for developers. The machine doesn&#8217;t care either way, but software should not only be list of machine-operable instructions but also as a means of documentation and communication. The current implementation falls way short in that regard.</p>
<p><strong>Debuggable</strong><br />
Ever tried to debug a highly nested XML expression? Not fun, let me tell you. With &#8220;scripted&#8221; expressions in the worst case you can pepper your code with println statements. In the best case you can set breakpoints on your expression code editor. The latter would probably be quite a bit of work but I don&#8217;t think it is totally infeasible.</p>
<p><strong>More powerful</strong><br />
I haven&#8217;t looked into it too deeply but the current expression engine is probably a <a href="http://en.wikipedia.org/wiki/Turing_tarpit">turing tarpit</a> eager for prey. A &#8220;proper&#8221; scripting language would gives us a well understood, turing-complete way to describe complex expressions. It would also make it easier to factor common functionality into shared functions in order to reduce coupling and repetition.</p>
<p><strong>Improved Testability</strong><br />
A scripting environment might also make it easier to write and execute unit tests on the expression to verify its correctness. While this also possible with the current expression engine, it is quite a bit of work to get up and running. With scripted expressions one could fairly easily set up the variables and run a minimal execution wrapper around the expression code to test its behaviour in a classical JUnit test.</p>
<p>I put up the code on the github <a href="http://github.com/manuel-woelker/groovy_expressions/tree/master">here</a>. Basically the application is your vanilla RCP Mail example. The meat of the code is in <a href="http://github.com/manuel-woelker/groovy_expressions/blob/f63276ac8be38be812fcbb28c880f0708bd3e6de/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/GroovyExpression.java"><code>org.eclipse.core.internal.expressions.GroovyExpression</code></a>. Apart from the mucking in the expression engine, the only thing I did was add two commands and handlers with the same activeWhen semantics, but once described as classic XML and once expressed as Groovy code. Have a look, I&#8217;m looking forward to your comments and critique.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/07/14/groovy-expressions-proof-of-concept/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

