<?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>Late Bound</title>
	<atom:link href="http://www.haltingproblem.net/weblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.haltingproblem.net/weblog</link>
	<description>Personal weblog of Roland Sadowski</description>
	<lastBuildDate>Mon, 03 Aug 2009 20:43:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>gen-struct: a Clojure macro for generating classes with mutable state</title>
		<link>http://www.haltingproblem.net/weblog/2009/08/03/making-clojure-a-bit-more-mutable/</link>
		<comments>http://www.haltingproblem.net/weblog/2009/08/03/making-clojure-a-bit-more-mutable/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 19:36:38 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=72</guid>
		<description><![CDATA[Sometimes the only way to get the desired performance is to shun
immutability.

In case of Clojure, that means using arrays or importing mutable
classes from an existing Java library - assuming the library already
has classes with properties/fields that fit our needs. Otherwise, we
have to write some Java code.

Dropping to another language for performance is pretty
disappointing. But sometimes [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes the only way to get the desired performance is to shun
immutability.</p>

<p>In case of Clojure, that means using arrays or importing mutable
classes from an existing Java library - assuming the library already
has classes with properties/fields that fit our needs. Otherwise, we
have to write some Java code.</p>

<p>Dropping to another language for performance is pretty
disappointing. But sometimes it&#8217;s the only sane choice. </p>

<p>I&#8217;ve created <a href="http://github.com/rosado/gen-struct/tree/clean">gen-struct</a> library to avoid some of those
situations. This simple macro, which in reality is a modified version
of the gen-class macro created by Rich Hickey, allows you to create
simple, mutable and immutable structures. You can customize only one
aspect of those classes: their fields. Here&#8217;s an example:</p>

<pre><code>(gen-struct
 :name my.test.struct
 :mutable-fields [[float x]
                  [float y]]
 :final-fields [[int timeout]
                [static int MAX_TIMEOUT :is 1000]
                [java.io.File input]])
</code></pre>

<p>gen-struct automatically generates a constructor which lets you
initialize all the final, non-static fields. In the above example,
single constructor accepting an <code>int</code> value and a <code>File</code> object would
be generated (you pass the arguments in order in which they were
declared in the macro).</p>

<p>gen-struct classes need to be compiled, just like with gen-class.</p>

<p>This is an ugly duckling, since it doesn&#8217;t allow for inheritance,
probably not everyone will be happy with no possibility of overriding <code>equals</code>, 
and static final fields can only be of primitive type. At least it doesn&#8217;t let you mix state and behavior in one entity.</p>

<p>My main motivation for creating it was that some of my experiments in
<a href="http://github.com/rosado/clj-processing/tree">clj-processing</a> needed a lot of mutation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2009/08/03/making-clojure-a-bit-more-mutable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Only one paragraph about Denmark</title>
		<link>http://www.haltingproblem.net/weblog/2009/02/15/only-one-paragraph-about-denmark/</link>
		<comments>http://www.haltingproblem.net/weblog/2009/02/15/only-one-paragraph-about-denmark/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 00:40:54 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/2009/02/15/only-one-paragraph-about-denmark/</guid>
		<description><![CDATA[I&#8217;ve been in Denmark for over a month and haven&#8217;t really seen much of it. I&#8217;m waiting for warmer weather. But the people are cool. Lots of different nationalities in the place I work in makes things even more interesting. 

I&#8217;m doing mostly .NET related stuff right now, I only have time for Clojure on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been in Denmark for over a month and haven&#8217;t really seen much of it. I&#8217;m waiting for warmer weather. But the people are cool. Lots of different nationalities in the place I work in makes things even more interesting. </p>

<p>I&#8217;m doing mostly .NET related stuff right now, I only have time for Clojure on weekends. I&#8217;m trying to get a feel for getting better performance out of Clojure code; yesterday I&#8217;ve dug up an old code sample, but now I see I was doing a bunch of subtle things wrong. Rewrite ahead! </p>

<p>Back in December I&#8217;ve begun to prototype a Swing app in Java (I needed auto-completion to get used to the giantic API). Right now I&#8217;m in the process of building it from scratch in Clojure. I want to see how far I can go without dropping down to Java, and how to combine Java and Clojure in one project effectively (mostly from the design perspective).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2009/02/15/only-one-paragraph-about-denmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clojure goodies</title>
		<link>http://www.haltingproblem.net/weblog/2008/11/25/clojure-goodies/</link>
		<comments>http://www.haltingproblem.net/weblog/2008/11/25/clojure-goodies/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 10:54:06 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=45</guid>
		<description><![CDATA[Processing + Clojure

Processing is a java library for doing visualizations and various
media related stuff. A while ago I did a Clojure wrapper for it. You
can get it from github: clj-processing. 

Cloak

A couple of months ago I saw examples of config files of ruby&#8217;s
rake. Rake is a build tool, like ant or msbuild, but unlike
those, it [...]]]></description>
			<content:encoded><![CDATA[<h4>Processing + Clojure</h4>

<p><a href="http://processing.org/">Processing</a> is a java library for doing visualizations and various
media related stuff. A while ago I did a Clojure wrapper for it. You
can get it from github: <a href="http://github.com/rosado/clj-processing/tree/master">clj-processing</a>. </p>

<h4>Cloak</h4>

<p>A couple of months ago I saw examples of config files of ruby&#8217;s
<a href="http://rake.rubyforge.org/">rake</a>. Rake is a build tool, like <code>ant</code> or <code>msbuild</code>, but unlike
those, it doesn&#8217;t involve editing XML files. And thanks to ruby&#8217;s
quite flexible syntax, the resulting configuration files don&#8217;t hurt
your eyes.</p>

<p>I don&#8217;t know ruby and didn&#8217;t really feel like learning it just for one
tool. Googling for something similar to rake in the python universe didn&#8217;t
yield any results.</p>

<p>Since I&#8217;m investing much time in Clojure lately, I decided that I
might as well write something useful in it. Hence <a href="http://github.com/rosado/cloak/tree">Cloak</a>, a
simplistic automation tool written in Clojure. It&#8217;s heavily inspired by
rake; I had rake&#8217;s docs opened most of the time when writing the app.</p>

<p>Here&#8217;s how to use it. You put a file named <code>CLOAK</code> in your project&#8217;s
directory, and in it you define tasks, like this:</p>

<pre>
(task :task-name [:other-task :another]
    (when (exists? "some.file")
        (rm  "some.file"))
    (sh "command arg1 arg2 arg3" :dofail))
</pre>

<p>Task name should be a keyword. To run it from the command line, type
<code>cloak task-name</code>, without the semicolon (assuming <code>cloak</code> is the name
of the shell script that launches cloak). Second argument to task is an
optional list of dependencies, which can be other tasks or files. For
example <code>[:compile "classes/my.lib"]</code>. To refer to a file, use it&#8217;s
file name. Apart from regular tasks, you can specify file tasks:</p>

<pre><code> (file "index.html" ["template.xml" "content/main.txt"]
       (sh "genhtml template.xml content/main.txt index.html"))
</code></pre>

<p><code>file</code> tasks differ from regular <code>tasks</code> in one detail: they compare
modification time of the target and all its dependencies. Task is
executed only if mtime of target &lt; mtime of source.</p>

<p>Cloak is not a replacement for <code>maven</code> or <code>ant</code>. It would take me ages
to reach the level of functionality of those tools. I just wanted
something simple, to automate the generation of my website (among
other things). So far, it&#8217;s still a work in progress but it&#8217;s usable enough for me to use it with my own projects.</p>

<h4>Utility Libs</h4>

<p>I&#8217;ve also put my <a href="https://github.com/rosado/libs4clj/tree">utility libs</a> on github. Cloak requires them (but has
them in in a jar, so no need to download them separately). There&#8217;s
some IO and math related stuff in there. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2008/11/25/clojure-goodies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autumn Update</title>
		<link>http://www.haltingproblem.net/weblog/2008/11/20/autumn-update/</link>
		<comments>http://www.haltingproblem.net/weblog/2008/11/20/autumn-update/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 22:23:13 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Journal]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=39</guid>
		<description><![CDATA[Since the end of the year is near, and because at the beginning of January
I&#8217;ll be pretty busy with other things (see below), I decided I&#8217;ll post
something while I still have spare time on my hands.

On a personal note, that was a good year (I finished school, among
other things). On the professional level, well, I [...]]]></description>
			<content:encoded><![CDATA[<p>Since the end of the year is near, and because at the beginning of January
I&#8217;ll be pretty busy with other things (see below), I decided I&#8217;ll post
something while I still have spare time on my hands.</p>

<p>On a personal note, that was a good year (I finished school, among
other things). On the professional level, well, I didn&#8217;t work
anywhere, was too busy with my thesis. But in September I started
sending out my CV and found something really nice. In Denmark.</p>

<p>I&#8217;m starting in January, that&#8217;s why I won&#8217;t have much time at the
beginning of next year for fancy retrospectives. I&#8217;ll spend 1+ year in
Denmark. I always wanted to live there, at least for a while. I mean,
they invented Lego, best toy <em>ever</em>.</p>

<p>But till then, I have lots of free time and so far I&#8217;m spending it
mostly on reading and programming. I&#8217;m gradually replacing Python with
<a href="http://www.clojure.org/">Clojure</a> as my weapon of choice and I&#8217;ll post something on that
topic shortly. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2008/11/20/autumn-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MathTalker Went Live</title>
		<link>http://www.haltingproblem.net/weblog/2008/08/31/mathtalker-went-live/</link>
		<comments>http://www.haltingproblem.net/weblog/2008/08/31/mathtalker-went-live/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 00:18:01 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mathtalker]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=35</guid>
		<description><![CDATA[On friday I uploaded the 1.0 version of MathTalker to
   Google&#8217;s servers. It&#8217;s a simple chat application which allows you to write
   mathematical formulas (using syntax similar to TeX). It was written in
   Python and runs on App Engine. 


MathTalker has pretty steep requirements for a web app: Firefox
 [...]]]></description>
			<content:encoded><![CDATA[<p>On friday I uploaded the 1.0 version of <a href="http://mathtalker.appspot.com">MathTalker</a> to
   Google&#8217;s servers. It&#8217;s a simple chat application which allows you to write
   mathematical formulas (using syntax similar to TeX). It was written in
   Python and runs on <a href="http://appengine.google.com">App Engine</a>. 
</p>

<p><em>MathTalker</em> has pretty steep requirements for a web app: Firefox
   browser and special math fonts (download links on <em>MathTalker</em>
   page). Displaying math formulas is possible thanks to <a href="http://asciimathml.sourceforge.net/">ASCIIMathML</a>
   library, which converts ASCII to MathML. I know about the plug-in that
   lets you render MathML in IE, but I decided to drop support for that
   browser after spending a couple of hours trying to make the UI work.
</p>

<h4>App Engine</h4>

<p>App Engine SDK comes with a little web framework and that&#8217;s what I
   used. You can also use <a href="http://www.djangoproject.com/">Django</a>, but I wanted to keep things
   simple. The built-in framework is nothing special, but it doesn&#8217;t get
   in your way. What requires more attention is Google&#8217;s Datastore -
   their distributed database. Honestly, I used only relational databases
   so far (oh, and flat files&#8230;), so I had to watch one or two talks
   from Google IO conference to get the idea.
</p>

<p>What pissed me off the most was lack of support for nested
   transactions and some bugs in existing transaction code. To run some
   piece of code, you have to pass a function to
   <code>db.run_in_transaction()</code>, but whenever I tried to make the code more
   generic (as in: not to write two almost identical functions) stuff
   exploded. It&#8217;s pretty bad, because creating an entity and updating a
   counter should be a single atomic action. But they aren&#8217;t, so you end
   up hoping for the best.
</p>

<h4>JavaScript</h4>

<p>Little bit of history: At first I hated it, then I really liked
   it. Now I&#8217;m just using it and ignoring its deficiencies. And regarding
   the period that I liked JS: it was the time that JS libraries were
   becoming really, really good, and I was just impressed (shocked, even)
   that it&#8217;s possible to build anything with it without cursing like mad.
</p>

<p>But even JS 1.7, which has generators and list comprehensions, is
   pretty verbose, and you can only take it so far as
   <a href="http://jquery.org">jQuery</a> - the best attempt for creating domain
   specific language in JavaScript. Great for traversing/manipulating
   DOM.
</p>

<p>Another thing: I used Emacs with <a href="http://code.google.com/p/js2-mode/">js2-mode</a>. The style of formating
   code encouraged (somewhat) by jQuery drives Emacs insane and beaks the
   indentation. At the beginning it bothered me, but then I stopped
   nesting function definitions and <code>js2-mode</code> let me do my work, and my
   code looked more readable. I don&#8217;t know if that was how <code>js2-mode</code>
   supposed to work or if it was just a bug, but it&#8217;s done more good than
   harm.
</p>

<h4>Blueprint</h4>

<p>I&#8217;ve also tried out <a href="http://blueprintcss.org/">Blueprint</a> CSS framework. I&#8217;ve used
   Yahoo&#8217;s CSS reset library before (and I don&#8217;t want to work without CSS
   reset <em>ever</em> again), but never Blueprint. It&#8217;s pretty good, but
   somehow feels not <em>clean</em> enough. I guess it provides to much defaults
   for my taste. But I&#8217;ll probably use it again someday.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2008/08/31/mathtalker-went-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functional</title>
		<link>http://www.haltingproblem.net/weblog/2008/07/20/functional/</link>
		<comments>http://www.haltingproblem.net/weblog/2008/07/20/functional/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 17:39:57 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=34</guid>
		<description><![CDATA[Recently I tried to rewrite a particular algorithm for generating 
   permutations in a functional manner. The original was written in C#, therefore 
   lots of mutable data structures etc. My first attempt at rewriting the code 
   in Clojure went something like this:




As you can see, I got [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I tried to rewrite a <a href="http://msdn.microsoft.com/en-us/library/aa302371.aspx">particular</a> algorithm for generating 
   permutations in a functional manner. The original was written in C#, therefore 
   lots of mutable data structures etc. My first attempt at rewriting the code 
   in <a href="http://www.clojure.org">Clojure</a> went something like this:
</p>

<p><a href="http://picasaweb.google.co.uk/szabla/ForMyBlog/photo#5225143462541658722"><img src="http://lh3.ggpht.com/szabla/SINwS5FACmI/AAAAAAAAAIU/dj1YvCFoJPI/s400/clj_fail.png" /></a></p>

<p>As you can see, I got lost halfway through. But this is what you get when you 
   try to write procedural/OO code in a functional language, using immutable 
   data structures. Usually the right way to get out of a mess like the one above 
   is to use <code>map</code> or its syntactic brother: list comprehension (Clojure&#8217;s <code>for</code> macro). 
</p>

<p>I ended up with a lazy list of permutations, where the laziness required 
   zero effort from me - got that for free from the language. 
</p>

<p>I&#8217;m still stumbling while writing programming in Clojure, but not in the 
   frustrating way like when I tried to write something of use in F#. 
   Probably getting to know Scheme beforehand helped a bit.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2008/07/20/functional/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m no longer a student.</title>
		<link>http://www.haltingproblem.net/weblog/2008/07/06/im-no-longer-a-student/</link>
		<comments>http://www.haltingproblem.net/weblog/2008/07/06/im-no-longer-a-student/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 09:24:31 +0000</pubDate>
		<dc:creator>roland</dc:creator>
				<category><![CDATA[Message]]></category>

		<guid isPermaLink="false">http://www.haltingproblem.net/weblog/?p=33</guid>
		<description><![CDATA[A little more than a week ago I defended my thesis and now have a Master&#8217;s degree in mathematics. The title of my thesis is &#34;Particular classes of functions holomorphic in the unit circle,&#34; topic related to the Bieberbach conjecture, for those more oriented in math. For the next month and then some, I&#8217;ll be [...]]]></description>
			<content:encoded><![CDATA[<p>A little more than a week ago I defended my thesis and now have a Master&#8217;s degree in mathematics. The title of my thesis is &quot;Particular classes of functions holomorphic in the unit circle,&quot; topic related to the Bieberbach conjecture, for those more oriented in math. For the next month and then some, I&#8217;ll be writing code and learning. I&#8217;d also like to finish <a href="http://en.wikipedia.org/wiki/Okami">Okami</a>. After that I&#8217;ll start looking for a job. 
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.haltingproblem.net/weblog/2008/07/06/im-no-longer-a-student/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
