<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>Feeding Baby Penguins.</title><generator>Tumblr (3.0; @johan-lindberg)</generator><link>http://cons.pulp.se/</link><item><title>Rethinking the MPS II compilation chain</title><description>&lt;p&gt;During summer I&amp;#8217;ve spent a lot of time looking at how &lt;a href="http://www.lambdassociates.org/"&gt;Qi&lt;/a&gt; compiles to Common Lisp.&lt;/p&gt;
&lt;p&gt;The thing is that I&amp;#8217;ve written the MPS II macros to expand into something that looks like it&amp;#8217;s been hand coded. That&amp;#8217;s been sort of a corner stone in the idea behind MPS and MPS II. The reason is because I wanted to allow easy inspection of the generated code to allow finding bugs and other irregularities easier.&lt;/p&gt;
&lt;p&gt;This &lt;a href="http://www.lambdassociates.org/studies/study10.htm"&gt;Qi code study&lt;/a&gt; however, changed everything. The generated code is butt ugly but fast as hell and more importantly, the &amp;#8220;pretty&amp;#8221; Common Lisp code is slow. Goto considered harmful? Sure. No problem, as long as it&amp;#8217;s fast.&lt;/p&gt;</description><link>http://cons.pulp.se/post/1216651929</link><guid>http://cons.pulp.se/post/1216651929</guid><pubDate>Thu, 30 Sep 2010 20:38:13 +0200</pubDate><category>MPS</category><category>common lisp</category><category>Qi</category></item><item><title>Obscure Programming Languages Exploration Group</title><description>&lt;p&gt;A couple of days ago &lt;a href="http://twitter.com/niclasnilsson/"&gt;@niclasnilsson&lt;/a&gt; and I &lt;a href="http://twitter.com/niclasnilsson/status/14419416732"&gt;started&lt;/a&gt; &lt;a href="http://twitter.com/rplaca/status/14421684961"&gt;talking&lt;/a&gt; &lt;a href="http://twitter.com/rplaca/status/14421770123"&gt;about&lt;/a&gt; &lt;a href="http://twitter.com/rplaca/status/14421800684"&gt;starting&lt;/a&gt; &lt;a href="http://twitter.com/niclasnilsson/status/14422876526"&gt;an&lt;/a&gt; &lt;em&gt;Obscure[1]  Programming Languages Exploration Group&lt;/em&gt; here in Gothenburg.  Earlier today we met for lunch together with &lt;a href="http://twitter.com/jorgen99"&gt;@jorgen99&lt;/a&gt; to discuss how to go  about it.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s nothing much &lt;em&gt;decided&lt;/em&gt; yet about form or  content but a few things are worth mentioning anyway. Mostly because I&amp;#8217;d  love to hear your thoughts on how to go about this.&lt;/p&gt;
&lt;p&gt;First of all,  we agreed on using &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; for all the code that we write.&lt;/p&gt;
&lt;p&gt;Secondly,  we will try to set up a number of problems that are large enough to  make a decent code base (we&amp;#8217;re thinking slightly larger than a typical &lt;a href="http://en.wikipedia.org/wiki/Code_Kata"&gt;code kata&lt;/a&gt;) but small  enough to be possible to solve alone in a few weeks time without &lt;a href="http://stallman.org/"&gt;super human&lt;/a&gt; powers.&lt;/p&gt;
&lt;p&gt;Last, but not least, most of the work will be done &lt;em&gt;homework-style&lt;/em&gt;,  meaning that we won&amp;#8217;t spend much time at the meetings actually writing  code. Instead we will focus on discussing differences and similarities  between solutions and languages.&lt;/p&gt;
&lt;p&gt;There are a few reasons,  hopes and assumptions behind these choices:&lt;/p&gt;
&lt;p&gt;It allows people to  join the fun from anywhere. All you need is a GitHub account and to  promise to &lt;strong&gt;&lt;em&gt;commit often&lt;/em&gt;&lt;/strong&gt; and to take &lt;em&gt;&lt;strong&gt;extra  special care&lt;/strong&gt;&lt;/em&gt; when writing your commit messages. We have  this idea that if we write really&lt;em&gt;, really&lt;/em&gt; detailed commit  messages describing not just &lt;em&gt;what&lt;/em&gt; has changed but also &lt;em&gt;why&lt;/em&gt; and &lt;em&gt;how you think&lt;/em&gt; about going about your solution, then going  through the commit log should be a decent substitute for attending a  meeting where that solution is presented.&lt;/p&gt;
&lt;p&gt;Also, since GitHub  allows comments on commits, the most interesting discussions about the  code won&amp;#8217;t necessarily happen at a meeting.&lt;/p&gt;
&lt;p&gt;And, if the author  doesn&amp;#8217;t understand your questions and suggestions or, if you feel that &lt;em&gt;code  speaks louder than words&lt;/em&gt;, you can fork the repository and  implement the solution that you think the author should have done in the  first place!&lt;/p&gt;
&lt;p&gt;Today we decided to meet again (the three of us) on  the 23rd of June and at that time have solutions to a &lt;a href="http://en.wikipedia.org/wiki/Reversi"&gt;Reversi&lt;/a&gt; problem (I&amp;#8217;ll  post details when I get them) in &lt;a href="http://en.wikipedia.org/wiki/Scala_%28programming_language%29"&gt;Scala&lt;/a&gt; (Jörgen), &lt;a href="http://en.wikipedia.org/wiki/Ioke_%28programming_language%29"&gt;Ioke&lt;/a&gt; (Niclas) and &lt;a href="http://en.wikipedia.org/wiki/Prolog_%28programming_language%29"&gt;Prolog&lt;/a&gt; (Johan).&lt;/p&gt;
&lt;p&gt;And that&amp;#8217;s about as far as we&amp;#8217;ve discussed things. So.  What&amp;#8217;s wrong with the above? What will so obviously not work? Which of  our assumptions and hopes are completely ridiculous? What else would it  take to make the above work for you?&lt;/p&gt;
&lt;p&gt;Comments, thoughts,  criticism, questions and suggestions welcome.&lt;/p&gt;
&lt;p&gt;[1] Obscure  might not be the most descriptive word for what we&amp;#8217;re looking for. We&amp;#8217;re  not that interested in languages &lt;em&gt;designed to be obscure&lt;/em&gt;,  rather languages that haven&amp;#8217;t gotten the attention they deserve for some  reason or other.&lt;/p&gt;</description><link>http://cons.pulp.se/post/638397667</link><guid>http://cons.pulp.se/post/638397667</guid><pubDate>Thu, 27 May 2010 21:52:53 +0200</pubDate><category>Programming</category></item><item><title>Finishing up MPS II</title><description>&lt;p&gt;Today I added the last of the missing functionality in &lt;a href="http://github.com/johanlindberg/minimal-production-system"&gt;MPS&lt;/a&gt;. With the last &lt;a href="http://github.com/johanlindberg/minimal-production-system/commit/edced67853f3480eda39f5c67e327c182b904621"&gt;commit&lt;/a&gt; I&amp;#8217;ve got 11 functions in the public API. They are (in alphabetical order): &lt;code&gt;agenda&lt;/code&gt;, &lt;code&gt;assert-facts&lt;/code&gt;, &lt;code&gt;clear&lt;/code&gt;, &lt;code&gt;deffacts&lt;/code&gt;, &lt;code&gt;defrule&lt;/code&gt;, &lt;code&gt;facts&lt;/code&gt;, &lt;code&gt;halt&lt;/code&gt;, &lt;code&gt;modify-fact&lt;/code&gt;, &lt;code&gt;reset&lt;/code&gt;, &lt;code&gt;retract-facts&lt;/code&gt; and &lt;code&gt;run&lt;/code&gt;. Some of these could have been left out and some should probably work differently from how I&amp;#8217;ve implemented them now but that&amp;#8217;s all details.&lt;/p&gt;
&lt;p&gt;All in all, I&amp;#8217;m very pleased with the result. The code base is smaller (roughly 500 LOC, almost half the size of MPS I) and a lot clearer and easier to read and understand. I&amp;#8217;m particularly pleased with a few of the public functions. Here&amp;#8217;s how the agenda function turned out:&lt;/p&gt;
&lt;script src="http://gist.github.com/409291.js?file=agenda.lisp"&gt;&lt;/script&gt;&lt;p&gt;If you know your way around production systems you&amp;#8217;ll hopefully agree with me that there&amp;#8217;s probably not a simpler description of the agenda functionality (using the conflict-resolution-strategy depth).&lt;/p&gt;
&lt;p&gt;The next couple of weeks I&amp;#8217;ll try to weed out as many bugs as I can by running a bunch of &lt;a href="http://github.com/johanlindberg/benchmarks"&gt;benchmarks&lt;/a&gt; (mostly Ms Manners) and I will hopefully come up with a way to add meta data (for example salience which I&amp;#8217;ve left out for now) to rules.&lt;/p&gt;</description><link>http://cons.pulp.se/post/619883439</link><guid>http://cons.pulp.se/post/619883439</guid><pubDate>Fri, 21 May 2010 21:32:26 +0200</pubDate><category>MPS</category><category>Common Lisp</category></item><item><title>Introducing slime-lispunit</title><description>&lt;p&gt;For a couple of weeks now I&amp;#8217;ve been playing around with &lt;a href="http://www.cliki.net/lisp-unit"&gt;Lisp-unit&lt;/a&gt; and &lt;a href="http://common-lisp.net/project/slime/"&gt;Slime&lt;/a&gt;. The idea is to provide some basic TDD support for Common Lisp programmers. The result is &lt;a href="http://github.com/johanlindberg/slime/blob/master/contrib/slime-lispunit.el"&gt;slime-lispunit.el&lt;/a&gt; and the code can be found on &lt;a href="http://github.com/johanlindberg/"&gt;GitHub&lt;/a&gt;. &lt;strike&gt;Unfortunately, at the moment, it requires &lt;a href="http://github.com/johanlindberg/lisp-unit"&gt;my fork of lisp-unit&lt;/a&gt; to work. I&amp;#8217;ll try to either have my changes merged with the original or modify slime-lispunit.el to work with the original.&lt;/strike&gt; I&amp;#8217;ll &lt;strike&gt;also&lt;/strike&gt; try to have slime-lispunit.el included in Slime as a contrib package.&lt;/p&gt;
&lt;p&gt;To use slime-lispunit you need to&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;install Lisp-unit. The easiest way is probably to git clone &lt;strike&gt;my&lt;/strike&gt; &lt;a href="http://repo.or.cz/w/lisp-unit.git"&gt;this&lt;/a&gt; repo and then use &lt;a href="http://common-lisp.net/project/asdf/"&gt;ASDF&lt;/a&gt; to have it loaded whenever you start Slime (./swank.lisp).&lt;/li&gt;
&lt;li&gt;copy the slime-lispunit.el file to the contrib folder of your Slime installation.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Once you&amp;#8217;ve got it properly set up you can use C-t C-a to run all tests in a package, C-t C-t to run specific tests in a package and C-t C-r to repeat the last test command without asking any questions.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s a screenshot of it &lt;a href="http://twitpic.com/1fq3ke"&gt;here&lt;/a&gt;, the code it shows is called the &lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz"&gt;FizzBuzz kata&lt;/a&gt; and is mainly used to introduce TDD concepts. I&amp;#8217;ve added it as a &lt;a href="http://gist.github.com/365626/"&gt;GitHub gist&lt;/a&gt; if anyone is interested in a simple example of how to use TDD to grow tests and code simultaneously.&lt;/p&gt;
&lt;p&gt;As always, feedback appreciated.&lt;/p&gt;
&lt;p&gt;[Update 2010-04-23] I&amp;#8217;ve updated slime-lispunit.el to work with the original version of lisp-unit.&lt;/p&gt;</description><link>http://cons.pulp.se/post/522988094</link><guid>http://cons.pulp.se/post/522988094</guid><pubDate>Thu, 15 Apr 2010 12:01:00 +0200</pubDate><category>slime</category><category>common lisp</category><category>TDD</category><category>Emacs</category></item><item><title>Ada Lovelace day</title><description>&lt;p&gt;Today is &lt;a href="http://findingada.com/"&gt;Ada Lovelace Day&lt;/a&gt;, a day to recognize women&amp;#8217;s contributions in technology and science. People &lt;a href="http://findingada.com/map/"&gt;around the world&lt;/a&gt; are contributing blog posts, videos, cartoons and podcasts to draw attention to women and the amazing work they do or have done.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m fortunate enough to know several talented women who work in IT and have had the pleasure to work with a few of them. But for today, I especially would like to mention &lt;a href="http://emilybache.blogspot.com/"&gt;Emily Bache&lt;/a&gt; (&lt;a href="http://www.twitter.com/emilybache"&gt;@emilybache&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Emily is the driving force behind several &lt;a href="http://codingdojo.org/"&gt;coding dojo&amp;#8217;s&lt;/a&gt; here in Gothenburg, Sweden. She&amp;#8217;s an amazing speaker and facilitator. As an avid defender of agile methods and test driven development, she&amp;#8217;s been pushing, pulling and motivating both herself and others to discuss and learn about what makes good code, and why.&lt;/p&gt;
&lt;p&gt;I am very thankful that Emily shares so much of both her time and knowledge with the rest of us. I, for one, am a better developer because of it.&lt;/p&gt;
&lt;p&gt;Thank you Emily and happy Ada Lovelace day!&lt;/p&gt;</description><link>http://cons.pulp.se/post/470772896</link><guid>http://cons.pulp.se/post/470772896</guid><pubDate>Wed, 24 Mar 2010 20:56:52 +0100</pubDate><category>Ada Lovelace Day</category></item><item><title>TDD and SLIME</title><description>&lt;p&gt;I&amp;#8217;ve finally gotten used to the rhythm of test-first development. It took me a while to get here, but now, I wouldn&amp;#8217;t dream of writing code without tests.&lt;/p&gt;
&lt;p&gt;Even though there are &lt;a href="http://www.cliki.net/test%20framework"&gt;plenty of test frameworks&lt;/a&gt; available for Common Lisp, no one has bothered connecting one with &lt;a href="http://common-lisp.net/project/slime/"&gt;SLIME&lt;/a&gt;. Personally, I find that very odd since unit tests are meant to be run often. The test suite should evolve at the same pace as the rest of the code base.&lt;/p&gt;
&lt;p&gt;For my code, I use &lt;a href="http://www.cliki.net/lisp-unit"&gt;Lisp-unit&lt;/a&gt; and since I don&amp;#8217;t want to have to switch back and forth between code buffers and the REPL just to invoke &lt;code&gt;(lisp-unit:run-all-tests &amp;lt;package&amp;gt;)&lt;/code&gt;. I decided to write some Emacs Lisp glue to bind the key sequence C-t C-a to lisp-unit&amp;#8217;s run-all-tests function. It&amp;#8217;s still very rough around the edges, but it works. You can find the code on &lt;a href="http://github.com/johanlindberg/slime/"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To install, place the file &lt;a href="http://github.com/johanlindberg/slime/blob/master/contrib/slime-lispunit.el"&gt;slime-lispunit.el&lt;/a&gt; in your slime/contrib/ directory and update your .emacs to include slime-lispunit in the call to slime-setup.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;[Update 2010-03-25]&lt;/strong&gt;&lt;/em&gt; I&amp;#8217;ve made some minor improvements of the code. Most importantly, pressing C-t C-a now behaves as if you&amp;#8217;ve typed &lt;code&gt;(lisp-unit:run-all-tests &amp;lt;package&amp;gt;)&lt;/code&gt; in the REPL.&lt;/p&gt;</description><link>http://cons.pulp.se/post/468541538</link><guid>http://cons.pulp.se/post/468541538</guid><pubDate>Tue, 23 Mar 2010 21:25:00 +0100</pubDate><category>TDD</category><category>Emacs</category><category>SLIME</category><category>Common Lisp</category></item><item><title>A walk through of the compilation process</title><description>&lt;p&gt;&lt;a href="http://github.com/johanlindberg/minimal-production-system"&gt;MPS II&lt;/a&gt; integrates seamlessly with the Common Lisp compilation chain. This means, among other things, that if your Lisp implementation produce compiled code; then your rules will be compiled as well.&lt;/p&gt;
&lt;p&gt;This integration is achieved using &lt;a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_defmac.htm"&gt;macros&lt;/a&gt;. Macros make it very easy to transform source code from one shape to another and it all happens before compilation time, so once all macros have been transformed the results are passed on to, and processed by, the compiler leaving us with a fairly efficient solution without having to write too much code.&lt;/p&gt;
&lt;p&gt;The individual steps in the chain of macro expansions can be seen by using the &lt;code&gt;macroexpand-1&lt;/code&gt; function. Below is the steps for the defrule example from my &lt;a href="http://cons.pulp.se/post/428854897/a-first-look-at-compiling-a-defrule"&gt;previous post&lt;/a&gt;. Please, ignore the obvious errors for now.&lt;/p&gt;
&lt;p&gt;&lt;small&gt;
&lt;script src="http://gist.github.com/323700.js"&gt;&lt;/script&gt;&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;Using macros to extend Lisp in this way is very common and there are numerous explanations and examples of the technique in several books on Lisp. For example, chapter 24 in &lt;a href="http://gigamonkeys.com/book/"&gt;Practical Common Lisp&lt;/a&gt; by Peter Seibel show how you can extend Common Lisp with functionality for parsing binary files. In chapter 15 of the book &lt;a href="http://paulgraham.com/acl.html"&gt;ANSI Common Lisp&lt;/a&gt;, Paul Graham show how you can add backwards chaining capabilities to Common Lisp with a few lines of code.&lt;/p&gt;
&lt;p&gt;Most of the MPS II compiler is written as macros. In fact, I&amp;#8217;m hoping that when I&amp;#8217;m done, all of it will have fit snugly within macros.&lt;/p&gt;</description><link>http://cons.pulp.se/post/430247100</link><guid>http://cons.pulp.se/post/430247100</guid><pubDate>Sat, 06 Mar 2010 15:01:00 +0100</pubDate><category>Compilation</category><category>Common Lisp</category><category>MPS</category><category>Rete Network</category></item><item><title>A first look at compiling a defrule</title><description>&lt;p&gt;Currently, the code in the &lt;a href="http://github.com/johanlindberg/minimal-production-system/tree/master/II/"&gt;MPS II git repository&lt;/a&gt;, is only capable of reading a defrule form and printing out the Common Lisp code it compiles into. There are several issues still to fix, but the overall structure of how a defrule is turned into Common Lisp code is there.&lt;/p&gt;
&lt;p&gt;&lt;small&gt;
&lt;script src="http://gist.github.com/323165.js"&gt;&lt;/script&gt;&lt;/small&gt;&lt;/p&gt;</description><link>http://cons.pulp.se/post/428854897</link><guid>http://cons.pulp.se/post/428854897</guid><pubDate>Fri, 05 Mar 2010 22:21:00 +0100</pubDate><category>MPS</category><category>Common Lisp</category><category>Compilation</category><category>Rete Network</category></item><item><title>Things to fix in MPS II</title><description>&lt;p&gt;Apart from some re-structuring and making the code more readable and easier to understand I also want to fix a few things that I&amp;#8217;ve left out in &lt;a href="http://github.com/johanlindberg/minimal-production-system"&gt;MPS&lt;/a&gt;. There are several things that are broken or missing, depending on how you choose to see it.&lt;/p&gt;
&lt;p&gt;Most notably the packaging is all wrong and the Not-CE (conditional element) can only handle one Pattern-CE. There are a couple of other minor things as well but currently I&amp;#8217;m trying to work out a good way of handling several Pattern-CEs in a Not-CE.&lt;/p&gt;
&lt;p&gt;My plan is to handle the &lt;i&gt;contents&lt;/i&gt; of a Not-CE as a separate subrule, with it&amp;#8217;s own &lt;a href="http://en.wikipedia.org/wiki/Rete_algorithm"&gt;Rete network&lt;/a&gt;. That&amp;#8217;s even fairly easy to accomplish by passing the contents to the &lt;code&gt;compile-LHS&lt;/code&gt; macro. I just need to figure out a way to yank out the Production node and replace it with a Not node to place in the network of the &lt;i&gt;original&lt;/i&gt; rule.&lt;/p&gt;
&lt;p&gt;Since MPS is relying on a mix of macro expansions and function calls to generate the Rete network there are a few timing issues that I need to sort out. But it&amp;#8217;s far from impossible. The embryo of the Not-CE compilation can be seen in the &lt;a href="http://github.com/johanlindberg/minimal-production-system/commit/cfd0b798bfdb6180c5aafa669d94c3f6f48d1ac0"&gt;Git repo&lt;/a&gt;.&lt;/p&gt;</description><link>http://cons.pulp.se/post/411648085</link><guid>http://cons.pulp.se/post/411648085</guid><pubDate>Thu, 25 Feb 2010 21:02:21 +0100</pubDate><category>Common Lisp</category><category>MPS</category></item><item><title>MPS II</title><description>&lt;p&gt;&lt;a href="http://github.com/johanlindberg/minimal-production-system"&gt;Minimal Production System (MPS)&lt;/a&gt; is an attempt to write a fully functional &lt;a href="http://clipsrules.sourceforge.net/"&gt;CLIPS&lt;/a&gt;-like &lt;a href="http://en.wikipedia.org/wiki/Production_system"&gt;Production system&lt;/a&gt; in less than 1000 lines of Common Lisp code. As of today (2010-02-23) &lt;a href="http://github.com/johanlindberg/minimal-production-system/blob/master/mps.lisp"&gt;mps.lisp&lt;/a&gt; consists of ~700 lines of code and works pretty well. It&amp;#8217;s not fast (compared to CLIPS) but it&amp;#8217;s not slow either (compared to &lt;a href="http://lisa.sourceforge.net/"&gt;Lisa&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;MPS II is (going to be) a cleaned up version of MPS. There are a number of improvements I&amp;#8217;d like to implement:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Clarify and simplify the code.&lt;/li&gt;
&lt;li&gt;Reduce the &lt;i&gt;core&lt;/i&gt; needed to run a rules-based program written in MPS.&lt;/li&gt;
&lt;li&gt;Add a possibility to use &lt;a href="http://en.wikipedia.org/wiki/CLOS"&gt;CLOS&lt;/a&gt; objects as facts.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;The work has begun. Follow my progress on &lt;a href="http://github.com/"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;</description><link>http://cons.pulp.se/post/407504798</link><guid>http://cons.pulp.se/post/407504798</guid><pubDate>Tue, 23 Feb 2010 21:36:34 +0100</pubDate><category>Common Lisp</category><category>MPS</category></item></channel></rss>

