<?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>Drinkable Chicken &#187; liquid</title>
	<atom:link href="http://4.flowsnake.org/archives/tag/liquid/feed" rel="self" type="application/rss+xml" />
	<link>http://4.flowsnake.org</link>
	<description>A Pythoneer's adventures with Scheme, Clojure and a whole lot more. ^_^</description>
	<lastBuildDate>Sat, 10 Jul 2010 14:39:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Liquid progress report (or lack of it)</title>
		<link>http://4.flowsnake.org/archives/792</link>
		<comments>http://4.flowsnake.org/archives/792#comments</comments>
		<pubDate>Tue, 15 Sep 2009 20:28:52 +0000</pubDate>
		<dc:creator>Hans Nowak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[liquid]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://4.flowsnake.org/?p=792</guid>
		<description><![CDATA[As you might recall, Liquid is my attempt at writing a Lisp interpreter, with the purpose of exploring some ideas I have had for a while, and to eventually produce a system that can be used to write non-trivial programs. That last goal took a serious hit the other day, and I&#8217;ll have to go [...]]]></description>
			<content:encoded><![CDATA[<p>As you might recall, <a href="http://projects.flowsnake.org/liquid.html">Liquid</a> is my attempt at writing a Lisp interpreter, with the purpose of exploring some ideas I have had for a while, and to eventually produce a system that can be used to write non-trivial programs.</p>
<p>That last goal took a serious hit the other day, and I&#8217;ll have to go back to the drawing board. The core interpreter, as it stands, is simply too slow. I know, premature optimization is evil and all that, but if simple evaluations take several seconds, it&#8217;s probably time for a critical look at the design, at the very least.</p>
<p>For example, I had a <em>range</em> function, defined like this:</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">(define (range n)
  (define (range-aux n acc)
    (if (&lt;= n 0)
        acc
        (range-aux (- n 1) (pair (- n 1) acc))))
  (range-aux n ()))</pre>
<p>(A Scheme version would look much the same, except <em>pair</em> would be called <em>cons</em>, and the empty list would be written as <em>&#8216;()</em>. None of the more interesting features of Liquid are in this example.)</p>
<p><em>(range N)</em> produces a list of numbers from 0 to N, e.g. <em>(range 5)</em> gives <em>(0 1 2 3 4)</em>, etc. As it turned out, this function was horribly inefficient; <em>(range 10)</em> needed ~3000 <a href="http://4.flowsnake.org/archives/602">&#8220;evaluation steps&#8221;</a>, and <em>(range 1000)</em> took over 13 seconds to complete.</p>
<p>As it turned out, the major culprit was <em>&lt;=</em>. I foolishly figured I could implement <em>=</em> and <em>&lt;</em> as built-ins, and derive the other comparison operators from that. So <em>&lt;=</em> was defined as</p>
<pre>(define (&lt;= a b)
  (or (= a b) (&lt; a b)))</pre>
<p>This doesn&#8217;t look so bad, except that <em>or</em> is written in pure Liquid as well, and it&#8217;s pretty damn slow.</p>
<p>Rewriting <em>&lt;=</em> to make it a builtin was easy, and made <em>range</em> much faster. This didn&#8217;t solve the general problem though; one of the big ideas of Liquid is that you can write &#8220;syntax&#8221; like <em>or</em>, <em>and</em>, <em>case</em>, cond, <em>when</em>, <em>while</em>, etc, in Liquid itself, without using macros. (Not to mention, all kinds of other stuff.) While it does work, apparently it makes code unacceptably slow. :-(</p>
<p>The way an &#8220;evaluation step&#8221; currently handles code and figures out what to do next, is hairy, partially due to the way rest args and keyword args are handled. I am now thinking of doing a rewrite with a different way to handle delayed arguments. Hopefully that will be faster&#8230;</p>
<p>(The implementation language for this version is <a href="http://www.digitalmars.com/d/1.0/index.html">D</a>, by the way&#8230; so I was expecting more speed than with the Python prototype.)</p>
<p>(P.S. For whoever is interested, the current version of the interpreter can be found <a href="http://svn.flowsnake.org/liquid_d/trunk">here</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://4.flowsnake.org/archives/792/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wie C zegt, moet ook D zeggen</title>
		<link>http://4.flowsnake.org/archives/728</link>
		<comments>http://4.flowsnake.org/archives/728#comments</comments>
		<pubDate>Wed, 12 Aug 2009 22:59:09 +0000</pubDate>
		<dc:creator>Hans Nowak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[d]]></category>
		<category><![CDATA[liquid]]></category>

		<guid isPermaLink="false">http://4.flowsnake.org/?p=728</guid>
		<description><![CDATA[I am currently hacking on the latest incarnation of Liquid. This version is written in D. (I chose D for various reasons, over languages like Java, C#, OCaml and ActionScript&#8230; maybe someday I&#8217;ll write more about that. It&#8217;s not impossible that there will be another implementation in one of those languages, by the way. But [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently hacking on the latest incarnation of <a href="http://projects.flowsnake.org/liquid.html">Liquid</a>. This version is written in <a href="http://www.digitalmars.com/d/index.html">D</a>.</p>
<p>(I chose D for various reasons, over languages like Java, C#, OCaml and ActionScript&#8230; maybe someday I&#8217;ll write more about that. It&#8217;s not impossible that there will be another implementation in one of those languages, by the way. But for now, it&#8217;s D. <a href="http://www.digitalmars.com/d/1.0/index.html">D 1.0</a> to be precise, as I am developing it on an old iBook G3 that runs Tiger. Yes, not the most efficient of setups&#8230; but it&#8217;s fun! :-)</p>
<p>D is OK as far as statically typed languages go. It has a lot of improvements over C, but is less anal than Java, and less of a mess than C++. :-) It can be low-level if you wish (e.g. it has pointers much like C), but some of the features and library functions are pretty high-level, almost Python-like. It comes with a decent standard library, Unicode support, garbage collection, modules, dynamic arrays, real strings, a <em>foreach</em> loop and much more.</p>
<p>Of course, the static typing bites me every now and then&#8230; Often the error messages are actual bugs, but sometimes it&#8217;s just the type system being difficult.</p>
<p>I do hope that in the future, I will be able to link with some C libraries&#8230; maybe some GUI stuff. Right now everything is command line, which I wanted to avoid, but that&#8217;s how it goes. (An implementation in ActionScript would fix this, but it would lack a command line, and would likely be much slower.)</p>
<p>Anyway, I recommend D if you need to use a low-level language that isn&#8217;t too painful. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://4.flowsnake.org/archives/728/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The icicle melts</title>
		<link>http://4.flowsnake.org/archives/695</link>
		<comments>http://4.flowsnake.org/archives/695#comments</comments>
		<pubDate>Sun, 12 Jul 2009 06:59:50 +0000</pubDate>
		<dc:creator>Hans Nowak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[liquid]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://4.flowsnake.org/?p=695</guid>
		<description><![CDATA[For the past 2-3 months or so, I&#8217;ve been tinkering with a Lisp dialect called Liquid. Current prototype is in Python, but the idea is that I will eventually port this to a different platform; maybe the JVM, .NET, or Actionscript. (I should probably write a separate post discussing these choices.) The prototype works, to [...]]]></description>
			<content:encoded><![CDATA[<p>For the past 2-3 months or so, I&#8217;ve been tinkering with a Lisp dialect called <a href="http://projects.flowsnake.org/liquid.html">Liquid</a>. Current prototype is in Python, but the idea is that I will eventually port this to a different platform; maybe the JVM, .NET, or Actionscript. (I should probably write a separate post discussing these choices.)</p>
<p>The prototype works, to some extent, and can be played with, for those who like this kind of stuff. (Just run the <em>liquid</em> script to get a REPL&#8230; error handling etc isn&#8217;t too good, but this should be better in future versions.)</p>
<p>Constructive criticism and ideas welcome (but keep in mind that this is just a prototype and that I am not an old Lisp hand :-).</p>
]]></content:encoded>
			<wfw:commentRss>http://4.flowsnake.org/archives/695/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
