<?xml version="1.0" encoding = "utf-8" ?>
<rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  <channel rdf:about="http://www.xoltar.org/rss.xml">
    <title>Xoltar</title>
    <description>
      Software development news and opinions
    </description>
    <link>http://www.xoltar.org</link>

    <image rdf:resource="http://www.xoltar.org/images/logo88x33.gif"/>

    <items>
      <rdf:Seq id="itemseq">
      <li rdf:resource="http://www.xoltar.org/2005/sep/28/lambda-the-ultimate-killfile.html">
</li><li rdf:resource="http://www.xoltar.org/2005/sep/06/ftplets.html">
</li><li rdf:resource="http://www.xoltar.org/2005/aug/31/dynamic-haskell.html">
</li><li rdf:resource="http://www.xoltar.org/2005/aug/03/settling-down.html">
</li><li rdf:resource="http://www.xoltar.org/2005/jul/25/factor.html">
</li><li rdf:resource="http://www.xoltar.org/2005/may/11/arsmathematica.html">
</li><li rdf:resource="http://www.xoltar.org/2005/may/06/haskell-sequence.html">
</li><li rdf:resource="http://www.xoltar.org/2005/may/04/cabal.html">
</li><li rdf:resource="http://www.xoltar.org/2005/apr/21/desert-spring-time.html">
</li><li rdf:resource="http://www.xoltar.org/2005/mar/23/math-learning.html">
</li><li rdf:resource="http://www.xoltar.org/2005/mar/17/plnews.html">
</li><li rdf:resource="http://www.xoltar.org/2005/mar/17/python-reduce.html">
</li><li rdf:resource="http://www.xoltar.org/2005/mar/17/higher-order-perl.html">
</li><li rdf:resource="http://www.xoltar.org/2005/mar/09/nice-version-0.9.10.html">
</li><li rdf:resource="http://www.xoltar.org/2005/jan/20/darcs-infected.html">
</li><li rdf:resource="http://www.xoltar.org/2005/jan/18/seaside-site.html">
</li><li rdf:resource="http://www.xoltar.org/2005/jan/12/firestarter.html">
</li><li rdf:resource="http://www.xoltar.org/2005/jan/04/object-oriented-haskell.html">
</li><li rdf:resource="http://www.xoltar.org/2004/dec/30/linux-conversion.html">
</li><li rdf:resource="http://www.xoltar.org/2004/nov/23/roundy-interview.html">
</li><li rdf:resource="http://www.xoltar.org/2004/oct/07/alt-jre-nice.html">
</li><li rdf:resource="http://www.xoltar.org/2004/oct/06/haskell-perf.html">
</li><li rdf:resource="http://www.xoltar.org/2004/sep/22/rss-adjustment.html">
</li><li rdf:resource="http://www.xoltar.org/2004/sep/22/nice-version-0.9.9.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/17/slice-of-nice.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/17/stop-nullpointers.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/17/courtesy-of-nice.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/12/more-quizzes.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/09/nice-groovy-2.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/07/nice-groovy.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/05/jedit-nice-mode.html">
</li><li rdf:resource="http://www.xoltar.org/2004/aug/04/editor-progress.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/20/dos-attack.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/19/partial-continuations.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/19/java-continuations.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/19/epigram.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/15/boo.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/12/andre-pang-comments.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jul/09/nice-database-api.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jun/30/nice-version-0.9.8.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jun/21/lambda-has-moved.html">
</li><li rdf:resource="http://www.xoltar.org/2004/may/04/tbray-python.html">
</li><li rdf:resource="http://www.xoltar.org/2004/apr/27/icfp-2004-announcemnt.html">
</li><li rdf:resource="http://www.xoltar.org/2004/apr/16/which-os-are-you.html">
</li><li rdf:resource="http://www.xoltar.org/2004/mar/29/nice-type-inference.html">
</li><li rdf:resource="http://www.xoltar.org/2004/feb/28/bonniot-blog.html">
</li><li rdf:resource="http://www.xoltar.org/2004/feb/09/ideal-source-control.html">
</li><li rdf:resource="http://www.xoltar.org/2004/feb/6/darcs.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/29/patrick-syntax.news.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/26/nice-generator.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/22/nice-safety.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/21/nice-logging.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/20/scala.html">
</li><li rdf:resource="http://www.xoltar.org/2004/jan/16/lexifi.html">
</li><li rdf:resource="http://www.xoltar.org/2003/dec/16/two-new-books.html">
</li><li rdf:resource="http://www.xoltar.org/2003/dec/04/site-facelift.html">
</li><li rdf:resource="http://www.xoltar.org/2003/dec/04/impotence-of-functional.html">
</li><li rdf:resource="http://www.xoltar.org/2003/dec/04/nice-reflection.html">
</li><li rdf:resource="http://www.xoltar.org/2003/oct/09/blogdom2.html">
</li><li rdf:resource="http://www.xoltar.org/2003/sep/09/haskellLoops.html">
</li><li rdf:resource="http://www.xoltar.org/2003/sep/01/favicon.html">
</li><li rdf:resource="http://www.xoltar.org/2003/aug/13/templateHaskellTupleSample.html">
</li><li rdf:resource="http://www.xoltar.org/2003/aug/12/monadTutorial.html">
</li><li rdf:resource="http://www.xoltar.org/2003/aug/06/picoThreadsJava.html">
</li><li rdf:resource="http://www.xoltar.org/2003/aug/04/rhinoCC.html">
</li><li rdf:resource="http://www.xoltar.org/2003/aug/04/haskellConcise.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jul/29/blogdom.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jul/23/twoHaskellGUIs.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jul/14/reflectionsOSCon2003.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jul/10/oscon2003.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jun/25/partialModule.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jun/16/modernStatic.html">
</li><li rdf:resource="http://www.xoltar.org/2003/jan/15/backToNice.html">
</li><li rdf:resource="http://www.xoltar.org/2002/oct/17/haskellCSV.html">
</li><li rdf:resource="http://www.xoltar.org/2002/sep/29/skinningHaskell.html">
</li></rdf:Seq>
    </items>

  </channel>

  <image rdf:about="http://www.xoltar.org/images/logo88x33.gif">
    <title>Xoltar</title>
    <url>http://www.xoltar.org/images/logo88x33.gif</url>
    <link>http://www.xoltar.org</link>
  </image>

<item rdf:about="http://www.xoltar.org/2005/sep/28/lambda-the-ultimate-killfile.html"><title>Lambda the Ultimate Killfile
</title><link>http://www.xoltar.org/2005/sep/28/lambda-the-ultimate-killfile.html
</link>
<description>

&lt;p&gt;

&lt;a href=&quot;http://www.lambda-the-ultimate.org&quot;&gt;Lambda the Ultimate&lt;/a&gt; is an outstanding programming languages

weblog that I read frequently. Lately, though, the signal-to-noise ratio has been dropping, and I've felt the need for a way

to eliminate some of the chaff. So, I created &lt;a href=&quot;http://www.xoltar.org/tools/greasemonkey/lambda-the-ultimate-killfile.user.js&quot;&gt;Lambda the Ultimate Killfile&lt;/a&gt;,

which is a &lt;a href=&quot;http://greasemonkey.mozdev.org/&quot;&gt;Greasemonkey&lt;/a&gt; script that prunes out entries

from people whose comments you'd rather not read. Simply install, then use Greasemonkey's &quot;Manage User Scripts&quot; 

dialog to edit the script. Add the names of the users you don't want to see to the &quot;users&quot; array,

and you're off and running.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/sep/06/ftplets.html"><title>Using the FTP protocol for more than serving files
</title><link>http://www.xoltar.org/2005/sep/06/ftplets.html
</link>
<description>

&lt;p&gt;

Old protocol, &lt;a href=&quot;http://www.cincomsmalltalk.com/userblogs/avi/blogView?showComments=true&amp;entry=3303394043&quot;&gt;new uses&lt;/a&gt;. Very cool.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/aug/31/dynamic-haskell.html"><title>Dynamic Applications From the Ground Up
</title><link>http://www.xoltar.org/2005/aug/31/dynamic-haskell.html
</link>
<description>

&lt;p&gt;

&lt;a href=&quot;http://www.cse.unsw.edu.au/~dons/papers/SC05.html&quot;&gt;This paper&lt;/a&gt; describes an application architecture using &lt;a href=&quot;http://www.cse.unsw.edu.au/~dons/hs-plugins/paper/&quot;&gt;hs-plugins&lt;/a&gt; which enables Haskell programs to dynamically load and reload modules. Hs-plugins also provides &quot;eval&quot; functionality. The resulting architecture allows for hot-swapping modules in a running program without any loss of data or state.

&lt;/p&gt;

&lt;p&gt;

The authors describe using this plugin-based architecture to implement a &lt;a href=&quot;http://www.cse.unsw.edu.au/~dons/yi.html&quot;&gt;text editor&lt;/a&gt; and an IRC robot. Each program only has a statically compiled core of around 100 lines of code; everything else is dynamically loaded. Of course, this is still Haskell - even though you're loading things dynamically, you still get the same type checking at module load time that you would get if you compiled it statically. Really outstanding work. 

&lt;/p&gt;

&lt;p&gt;

I especially liked this quote:

&lt;blockquote&gt;

At this point, Haskell offers significant advantage over languages

which encourage the use of global state. Unrestricted use

of global state leads to a multitude of values scattered throughout

the program; hence, bookkeeping of such a dispersed state becomes

difficult and potentially infeasible. Hot swapping is only practical if

the application already has disciplined use of global state as is the

case by default in Haskell programs. Without restricted state, runtime

system or operating system support seems necessary to deal

with the state problem.

&lt;/blockquote&gt;

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/aug/03/settling-down.html"><title>Settling down and choosing a language
</title><link>http://www.xoltar.org/2005/aug/03/settling-down.html
</link>
<description>

&lt;p&gt;

I've been interested in programming languages for a long time now, and it's been good for me. I've learned a lot of new ideas, broadened my horizons. However, I've noticed I don't seem to write much software for myself anymore, only what I'm paid to write at work. Whenever I spend my own time on computers, it's always reading some academic paper or book, never actually writing programs. I used to write software on my own time, for fun. I enjoyed that, and I think I'd like to do some more of it. The problem is, after you've been exposed to so many languages, how do you pick one and really dig into it?

&lt;/p&gt;

&lt;p&gt;

After thinking about it for some time, I've decided to settle down and focus all my spare computing time on a single language: &lt;a href=&quot;http://www.haskell.org&quot;&gt;Haskell&lt;/a&gt;. I'm not saying it's the end-all-be-all of languages; it's got some warts. It's hard to find good documentation, though that's getting better. It's hard to do dynamic things - reflection, plugins, etc., though that's getting better, too. The thing is, I've noticed that the code I write in Haskell is usually more elegant than the code I write in other languages, and since this is my time, I can choose what's important. Crisp, elegant code is important to me.

&lt;/p&gt;

&lt;p&gt;

So I'm going to give it a go. It doesn't mean I won't be keeping an eye on a dozen or so of my other interesting languages, but from a distance - as a spectator. It does mean I'm going to start writing code again, and that feels good.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/jul/25/factor.html"><title>Factor
</title><link>http://www.xoltar.org/2005/jul/25/factor.html
</link>
<description>

&lt;p&gt;

I'm surprised to see I've never mentioned &lt;a href=&quot;http://factor.sourceforge.net&quot;&gt;Factor&lt;/a&gt; here before. It's a concatenative (i.e., Forth-like) language with strong influences from Joy. It's also progressing by leaps and bounds. They just released version 0.76, which supports an interactive tutorial that's quite impressive for such a young language. Install is dirt simple, and so far works fine on Windows. Very cool.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/may/11/arsmathematica.html"><title>New math site: Arsmathematica.net
</title><link>http://www.xoltar.org/2005/may/11/arsmathematica.html
</link>
<description>

&lt;p&gt;

Just yesterday, &lt;a href=&quot;http://www.arsmathematica.net/&quot;&gt;arsmathematica.net&lt;/a&gt;, a new website that aims to be like Lambda the Ultimate for mathematics was launched:



&lt;blockquote&gt;

This site is dedicated to the mathematical arts: mathematics itself, and its many children. Mathematics, even the most abstruse, is now pervasive throughout physics, computer science, economics, and other fields. We explore these topics, in lieu of doing our jobs or conversing with our loved ones.

&lt;/blockquote&gt;

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/may/06/haskell-sequence.html"><title>Haskell-related blog
</title><link>http://www.xoltar.org/2005/may/06/haskell-sequence.html
</link>
<description>

&lt;p&gt;

Recently noticed a Haskell related blog: &lt;a href=&quot;http://sequence.complete.org/&quot;&gt;The Haskell Sequence&lt;/a&gt;

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/may/04/cabal.html"><title>Cabal build system works well!
</title><link>http://www.xoltar.org/2005/may/04/cabal.html
</link>
<description>

&lt;p&gt;

There's a common standard for packaging Haskell libraries now, called &lt;a href=&quot;http://www.haskell.org/cabal/&quot;&gt;Cabal&lt;/a&gt; (Common Architecture for Building Applications and Libraries). Basically, the application/library designer creates a simpe project specification that says which modules are to be provided, what executables to create, etc., and puts that together with a little Haskell code that just calls into the Cabal library to do the heavy lifting. Then you, the user, just unpack the tarball, do:

&lt;/p&gt;

&lt;pre&gt;

ghc -package Cabal Setup.lhs -o setup

setup configure

setup build

setup install

&lt;/pre&gt;

&lt;p&gt;

Voila, the package is installed. This is &lt;em&gt;really&lt;/em&gt; nice, since people in Haskell-land have sometimes been a little too Unix-centric, so their packages wouldn't build on my Windows box. However, every Cabalized package I've installed so far has gone smoothly. &lt;strong&gt;If you develop a Haskell package or application, PLEASE package it with Cabal!&lt;/strong&gt; Windows users (and probably everyone else for that matter) thank you!

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2005/apr/21/desert-spring-time.html"><title>Desert Spring-Time
</title><link>http://www.xoltar.org/2005/apr/21/desert-spring-time.html
</link>
<description>      

&lt;p&gt;

&lt;a href=&quot;http://dst.purevoid.org/&quot;&gt;Desert Spring-Time&lt;/a&gt; is a project to create an &lt;a href=&quot;http://caml.inria.fr/&quot;&gt;Objective Caml&lt;/a&gt;-based operating system. Looks like very early days, but they're already getting started on basic GUI stuff. See also &lt;a href=&quot;http://www.cse.ogi.edu/~hallgren/House/&quot;&gt;House&lt;a/&gt;, a similar project for &lt;a href=&quot;http://www.haskell.org/ghc&quot;&gt;GHC Haskell&lt;/a&gt; which is a bit further along.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2005/mar/23/math-learning.html"><title>Reading Math
</title><link>http://www.xoltar.org/2005/mar/23/math-learning.html
</link>
<description>      

&lt;p&gt;

&lt;a href=&quot;http://patricklogan.blogspot.com/2005/03/math.html&quot;&gt;Patrick points out&lt;/a&gt; an interesting &lt;a href=&quot;http://www.paulgraham.com/undergrad2.html&quot;&gt;snippet on Paul Graham's site&lt;/a&gt;:

&lt;blockquote&gt;

I found, when I was studying mathematics, that 2 things were true: (1) the teacher was not too good and (2) the book was not too good. So I would always buy a half-dozen books on the topic and try to get the full picture by reading the same sections in each book. The combination helped me understand much more than the sum of the content. Also, I was never opposed to reading something as much as 10 times until I squeezed everything out of it.

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

I've also had this problem. I've also done a lot of math reading on my own time, and the biggest single thing I can recommend for reading math books is this: Force yourself to read every single line carefully. Some more than once. I always want to read math like I read other books, that is, very quickly. Math is more dense. Don't worry, you're not wasting time, you're not worse at math than you are at other things. It's just more information in less space. Take your time.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2005/mar/17/plnews.html"><title>PLNews
</title><link>http://www.xoltar.org/2005/mar/17/plnews.html
</link>
<description>      



&lt;p&gt;

Thanks to a &lt;a href=&quot;http://lambda-the-ultimate.org/node/view/587&quot;&gt;reference on Lambda the Ultimate&lt;/a&gt;, I just discovered a blog called &lt;a href=&quot;http://tacojuice.org/plnews/&quot;&gt;PLNews&lt;/a&gt;, which seems to focus on release announcements and things of that nature. Might make a nice complement to Lambda, which mostly tries to avoid announcements about specific products. 

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2005/mar/17/python-reduce.html"><title>Python to lose reduce()
</title><link>http://www.xoltar.org/2005/mar/17/python-reduce.html
</link>
<description>      



&lt;p&gt;On the other hand, functional programming isn't getting a warm reception from Guido: &lt;a href=&quot;http://www.artima.com/weblogs/viewpost.jsp?thread=98196&quot;&gt;Guido says&lt;/a&gt; that Python can do without map, filter, and reduce. He argues that removing map and filter is &quot;uncontroversial&quot;, and that reduce is just too complicated:

&lt;blockquote&gt;

So now reduce(). This is actually the one I've always hated most, because, apart from a few examples involving + or *, almost every time I see a reduce() call with a non-trivial function argument, I need to grab pen and paper to diagram what's actually being fed into that function before I understand what the reduce() is supposed to do. So in my mind, the applicability of reduce() is pretty much limited to associative operators, and in all other cases it's better to write out the accumulation loop explicitly.

&lt;/blockquote&gt;

&lt;/p&gt;



&lt;p&gt;

Then he goes on to explain that we can have sum(), product() and similar functions to handle the common cases. I don't mind having sum and product, but really, is that all that reduce is for? I understand what he's saying about complexity - I remember when I first learned how to use reduce(), and it was hard. I also remember learning standard procedural programming idioms (like &lt;tt&gt;for&lt;/tt&gt; loops), and that was hard too, but worth learning nonetheless. Just because it takes practice to use a tool, doesn't mean the tool isn't valuable. 

&lt;/p&gt;

&lt;p&gt;

One of the things that's most valuable about functional programming is the ability to encapsulate patterns. Reduce() isn't just a function that does something useful, it encapsulates a pattern, just like &lt;tt&gt;for&lt;/tt&gt; loops encapsulate a common pattern of &lt;tt&gt;if&lt;/tt&gt;s and &lt;tt&gt;goto&lt;/tt&gt;s.

&lt;/p&gt;

&lt;p&gt;

A lot of the motivation for throwing out map, filter, and reduce seems to come from the fact that Python has ugly lambdas:

&lt;blockquote&gt;

Why drop lambda? Most Python users are unfamiliar with Lisp or Scheme, so the name is confusing; also, there is a widespread misunderstanding that lambda can do things that a nested function can't -- I still recall Laura Creighton's Aha!-erlebnis after I showed her there was no difference! Even with a better name, I think having the two choices side-by-side just requires programmers to think about making a choice that's irrelevant for their program; not having the choice streamlines the thought process. Also, once map(), filter() and reduce() are gone, there aren't a whole lot of places where you really need to write very short local functions; Tkinter callbacks come to mind, but I find that more often than not the callbacks should be methods of some state-carrying object anyway (the exception being toy programs).

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

I'm not sure what to say about this. Python's lambdas are ugly. None of its built-in datastructures are written in a functional style, nor are most of its basic constructs expressions. This means you're severely limited in what you can write in a Python lambda, and even if you could use statements in a lambda, the indentation-based syntax looks pretty ugly when you try to use a block of statements in the middle of a function call. Maybe Guido's right, and functional programming doesn't belong in Python. Of course, that would imply that functional programmers don't belong in Python, either... I hear Perl's more receptive these days, and you won't find Ruby or Smalltalk giving up blocks/lambdas anytime soon. Or heck, try a real functional language like Haskell, Ocaml, Dylan, Nice, Scheme, or what have you. Even C++ is getting &lt;a href=&quot;http://www.boost.org/doc/html/lambda.html&quot;&gt;more functional&lt;/a&gt; these days. Too bad to see Python going backwards.

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2005/mar/17/higher-order-perl.html"><title>Higher Order Perl
</title><link>http://www.xoltar.org/2005/mar/17/higher-order-perl.html
</link>
<description>      



&lt;p&gt;Via the ll1-discuss list, &lt;a href=&quot;http://perl.plover.com/hop/&quot;&gt;Higher Order Perl&lt;/a&gt;, a book on functional programming with Perl. Seems like functional programming is starting to make real inroads with the mainstream crowd these days. Here's what Damian Conway, famous Perl-person has to say:



&lt;blockquote&gt;

&quot;As a programmer, your bookshelf is probably overflowing with books that did nothing to change the way you program. . . or think about programming.



You're going to need a completely different shelf for this book.



While discussing caching techniques in Chapter 3, Mark Jason Dominus points out how a large enough increase in power can change the fundamental way you think about a technology. And that's precisely what this entire book does for Perl.



It raids the deepest vaults and highest towers of Computer Science, and transforms the many arcane treasures it finds---recursion, iterators, filters, memoization, partitioning, numerical methods, higher-order functions, currying, cutsorting, grammar-based parsing, lazy evaluation, and constraint programming---into powerful and practical tools for real-world programming tasks: file system interactions, HTML processing, database access, web spidering, typesetting, mail processing, home finance, text outlining, and diagram generation.



Along the way it also scatters smaller (but equally invaluable) gems, like the elegant explanation of the difference between 'scope' and 'duration' in Chapter 3, or the careful exploration of how best to return error flags in Chapter 4. It even has practical tips for Perl evangelists.



Dominus presents even the most complex ideas in simple, comprehensible ways, but never compromises on the precision and attention to detail for which he is so widely and justly admired.



His writing is---as always---lucid, eloquent, witty, and compelling.



Aptly named, this truly is a Perl book of a higher order, and essential reading for every serious Perl programmer.&quot;

&lt;/blockquote&gt;

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2005/mar/09/nice-version-0.9.10.html"><title>Nice 0.9.10 Released
</title><link>http://www.xoltar.org/2005/mar/09/nice-version-0.9.10.html
</link>
<description>

&lt;p&gt;

A few days late, but...

&lt;/p&gt;

&lt;p&gt;

&lt;pre&gt;

This long awaited release adds many improvements to the possible interactions

with Java libraries and tools. It improves some error messages, and fixes a

large number of bugs.

&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

&lt;pre&gt;

Thanks to the hard work of Luc Perrin and Arjan Boeijink, an important part of

the Nice compiler has been converted from Java to Nice itself!

&lt;/pre&gt;

&lt;/p&gt;

&lt;pre&gt;

Changes:

  * Better error messages for wrong constructor calls and method

    implementations with wrong parameter names.

  * Default value of fields can be overriden in subclasses. For instance:

      class A {

        int x = 1;

      }

      class B extends A {

        override x = 5;

      }

    This also works for final fields.

  * Imported methods can be generalized. That is, it is possible to

    define a new method which is more general than an existing one,

    and the existing method will be recognized as a special case of the

    general one. For instance, consider:



      abstract interface Addable&lt;T&gt; { void add(T item); }

      interface java.util.Collection implements Addable;



    Method java.util.Collection.add() is recognized as implementing

    the new add method, which makes Collection a valid Addable class.

  * Java methods and fields with parametric types are given a type with

    UnknownTypes as type parameters instead of being ignored.

  * Number of errors and warning are printed to the console.

  * Improved source information for debuggers.

  * Generated classes are smaller, thanks to smaller debugging information.

  * Niceunit now reports test failures with the source file and line number

    information for the failed assertion.

  * Native compilation with gcj is twice faster.

  * Bug fixes (disallowed redefinition of parameters, execution order of

    initializers in super classes, visibility checking of java classes,

    cyclic custom constructors, methods and fields in classes with less type

    parameters, 'this' in custom constructors, comparison of possibly null

    values with primitive values, ... )

&lt;/pre&gt;
</description></item><item rdf:about="http://www.xoltar.org/2005/jan/20/darcs-infected.html"><title>Darcs infected
</title><link>http://www.xoltar.org/2005/jan/20/darcs-infected.html
</link>
<description>      

&lt;p&gt;

Just like &lt;a href=&quot;http://junit.sourceforge.net&quot;&gt;JUnit&lt;/a&gt; makes people &lt;a href=&quot;http://junit.sourceforge.net/doc/testinfected/testing.htm&quot;&gt;&quot;test infected&quot;&lt;/a&gt;, &lt;a href=&quot;http://www.abridgegame.org/darcs/&quot;&gt;darcs&lt;/a&gt; is getting me &quot;version control infected.&quot; I'm using darcs for every little throwaway script I write now. Code a little, test a little, &lt;tt&gt;darcs record&lt;/tt&gt;. It's dirt simple to use, and since there's no administration because there's no &quot;central repository&quot;, you can create a new repository for any little thing you want to work on.

&lt;/p&gt;

&lt;p&gt;Darcs doesn't slow you down, and you'll be glad to have all the flexibility of being able to review (or revert to) older versions of your code. If you're doing something a little more complicated, that's even better. You can do branching, share patches with other people (maybe you want to work on something with a couple of other people, but can't or don't want to make a branch on the &quot;official&quot; project version control system). It's just cool. &lt;/p&gt;



&lt;p&gt;You may want to use it even though you already have another system. Make little, fine-grained patches with darcs, and when you've got everything finalized, go ahead and check in your changes to the Official Repository using your Offically Approved Version Control System. It's nice to have a little more flexibility for your own workspace.

&lt;/p&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2005/jan/18/seaside-site.html"><title>Seaside gets a new website
</title><link>http://www.xoltar.org/2005/jan/18/seaside-site.html
</link>
<description>      

&lt;p&gt;

The Seaside web application framework for Smalltalk, noted for its powerful use of continuations, has a &lt;a href=&quot;http://www.seaside.st/&quot;&gt;new community website&lt;/a&gt;. Seaside is definitely on my list of things to learn more about when I have some free time.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2005/jan/12/firestarter.html"><title>Solved: personal firewall
</title><link>http://www.xoltar.org/2005/jan/12/firestarter.html
</link>
<description>      

&lt;p&gt;

Many thanks to Alex Drahon for pointing out &lt;a href=&quot;http://www.fs-security.com/&quot;&gt;Firestarter&lt;/a&gt; as a replacement for ZoneAlarm on Ubuntu Linux. It's already in the Hoary universe repository, so &lt;code&gt;sudo apt-get install firestarter&lt;/code&gt; solves the problem nicely.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2005/jan/04/object-oriented-haskell.html"><title>Haskell's overlooked object system
</title><link>http://www.xoltar.org/2005/jan/04/object-oriented-haskell.html
</link>
<description>      

&lt;p&gt;

I finally got around to reading &lt;a href=&quot;http://www.cwi.nl/~ralf/OOHaskell/&quot;&gt;this paper&lt;/a&gt; by Oleg Kiselyov, Ralf Laemmel, and Kean Schupke. Basically, they've explained how to add object orientation to &lt;a href=&quot;http://www.haskell.org&quot;&gt;Haskell&lt;/a&gt; without changing the language at all - it turns out all the necessary features are already present in the language, but nobody noticed this before. It's fascinating reading. By the end of the paper, they've put together an object system that's a slight improvement on Ocaml's object system (and therefore a significant improvement over Java/C#/C++). There's real code too, check it out. Of course, some of the stuff they do would go down a little bit nicer with some syntactic sugar, but it's surprisingly palatable in the raw.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/dec/30/linux-conversion.html"><title>Living with Linux
</title><link>http://www.xoltar.org/2004/dec/30/linux-conversion.html
</link>
<description>

&lt;p&gt;

I recently decided to take the plunge and see whether Linux would work for me. I picked &lt;a href=&quot;http://www.ubuntulinux.org&quot;&gt;Ubuntu Linux&lt;/a&gt;, because I'd heard good things about the Ubuntu install and user experience, and I've always used Red Hat before so I wanted to see what life was like with &lt;a href=&quot;http://www.debian.org&quot;&gt;Debian&lt;/a&gt;'s vaunted packaging system. So, I backed up my important data, and installed.

&lt;/p&gt;

&lt;p&gt;

To win this challenge, Linux needed to be able to completely replace my Windows 2000 setup. So I didn't even bother setting up a dual-boot configuration, I just wiped the whole hard disk and gave it all to Ubuntu.

&lt;/p&gt;

&lt;p&gt;The results have been, unsurprisingly, mixed. The installation went smoothly. I've been 100% satisfied with the aforementioned Debian packaging system. The desktop is pleasing, the fonts don't suck like they used to on other Linux installs I've tried, and by and large all my allegedly cross-platform applications (Firefox, IDEA, etc.) were able to make the transition, and I have a working system. It may be my imagination, but it &lt;em&gt;seems&lt;/em&gt; marginally faster than Windows 2000 also. I also was shocked and amazed to discover a very useable Windows Terminal Server client was included, which makes my life a lot easier.

&lt;/p&gt;

&lt;p&gt;There are some things I had a lot of trouble with, though, and I'm going to post them here in case some other unfortunate soul is out there scouring the net looking for solutions to problems that no one else seems to have.

&lt;/p&gt;

&lt;h3&gt;Microsoft VPN&lt;/h3&gt;

&lt;p&gt;

It turns out that it's actually pretty easy to set up a VPN to a Microsoft VPN server. First, ignore all the HOWTOs and documentation that you find when you do a Google search for &quot;linux VPN setup&quot; or somesuch. That is all for non-Microsoft VPNs, and will only confuse you. What you want is &lt;a href=&quot;http://pptpclient.sourceforge.net/&quot;&gt;pptp&lt;/a&gt;. Unless you want to do more reading than I did, you'll probably want the GUI for it as well. You can get these with apt-get or synaptic, you need pptp and pptp-config. Setting up your pptp configuration is straightforward. However, beware the GUI, it's very nonstandard and you may accidentally lose your configuration a few times before you figure out how to save it.

&lt;/p&gt;

&lt;h3&gt;External serial mouse&lt;/h3&gt;

&lt;p&gt;Ubuntu didn't detect my external serial mouse during the install, though to be fair I'm not entirely sure it was plugged in at the time - it didn't occur to me that this would take special planning. It does. However, I've learned that &lt;tt&gt;xf86cfg&lt;/tt&gt; is your friend in this case. It's a little graphical depiction of your X setup, and you can use this to add a second mouse with little trouble. Hints: The right-click menu (which you need to use to configure the mouse once you've added it to your setup) requires you to &lt;em&gt;hold&lt;/em&gt; the right button while you make your choice. Once you've configured the mouse, you need to &lt;tt&gt;enable&lt;/tt&gt; it, that will draw the little connecting line like you see for the other devices. Finally, ctrl-alt-backspace to restart X. After that your mouse should work.

&lt;/p&gt;

&lt;h3&gt;The LCD/CRT switch&lt;/h3&gt;

&lt;p&gt;This one was tricky. Hitting Fn-F3 on my laptop switched the display from the builtin LCD to the external CRT when I was using windows. Under Ubuntu, its only function was to lock the system so badly I had to pull the power. I searched and searched, and found nothing useful. Eventually, I decided to switch to the as-yet-unfinished HoaryHedgehog release of Ubuntu to see if that would help. It did help; after the upgrade I could use the LCR/CRT switch and it would actually do something. It would switch to the CRT and display lots of colorful garbage there. More investigation reveals that X isn't capable of switching monitors midstream. If you're going to switch, either do the switch before X starts, or ctrl-alt-backspace it and switch before gdm comes back up. Then it will work fine.

&lt;/p&gt;

&lt;h3&gt;Migrating Thunderbird mail&lt;/h3&gt;

&lt;p&gt;

I hoped this would be as simple as copying the profiles folder from my Windows install to the .thunderbird folder in my home directory. Alas, not quite. It wasn't too bad, though. The trick is, you're going to have to set up a new Thunderbird profile, add in all your accounts, and then copy the mail and address book individually. If you try to copy the whole profile &lt;i&gt;en masse&lt;/i&gt;, Thunderbird dies whenever it launches a sub-window (e.g., the email composer window, or the preferences window).

&lt;/p&gt;

&lt;h3&gt;Wireless PCMCIA card&lt;/h3&gt;

&lt;p&gt;Plugging in my wireless card accomplished exactly nothing. I took a guess and opened up a terminal window, did &lt;tt&gt;sudo dhclient&lt;/tt&gt;, and voila, the network was working. How I happened to know there was a progam called dhclient and what it did I don't remember now....

&lt;/p&gt;

&lt;h3&gt;Printing to Windows printers&lt;/h3&gt;

&lt;p&gt;This is a nightmare, still ongoing. The printers dialog (known to the cognoscenti as gnome-cups-manager, I eventually discovered) &lt;em&gt;seems&lt;/em&gt; to provide an easy way to set up printing to a remote Windows printer. It certainly worked just fine for a locally connected printer. For a networked Windows printer, it's a nightmare. It happilly takes your input and reports no errors, but then it turns out that it's garbled your username and password.&lt;/p&gt;

&lt;p&gt;I eventually found out that gnome-cups-manager works with the CUPS daemon, which is configured via /etc/cups/printers.conf. It would have been helpful to have &lt;em&gt;some&lt;/em&gt; kind of help to that effect in the gnome-cups-manager applet itself, but oh well. Reading through that file, I figured out what the problem was: the special characters in my password weren't being escaped, and so the parsing of the Samba URL for the printer was messed up. Even entering in the data by hand in the /etc/cups/printers.conf file doesn't seem to have helped, though. By the way, you'll have to kill and restart &lt;tt&gt;cupsd&lt;/tt&gt; after you make changes to printers.conf if you want to see your changes in the gnome-cups-manager.

&lt;/p&gt;

&lt;h3&gt;Sound&lt;/h3&gt;

&lt;p&gt;I have none. Not sure why yet. I'll add an update if I ever get around to figuring this out. &lt;b&gt;Update (03 JAN 2005):&lt;/b&gt; I didn't have sound under Warty. After upgrading to Hoary, my volume control applet crashed when I used it, so I assumed sound still wasn't working. But now, it does, at least for the Flash plugin. Haven't heard any system sounds yet, but at least the volume control applet works today.&lt;/p&gt;

&lt;h3&gt;Personal firewall&lt;/h3&gt;

&lt;p&gt;I used ZoneAlarm under Windows, can't seem to find anything that simple for Linux. From casual Googling, it seems as if the approved way to set up your firewall has changed with each kernel release lately. I don't know which one is the latest, or how to set it up. If you know a simple solution, by all means let me know and I'll post it here with credits.

&lt;b&gt;Update (12 JAN 2005):&lt;/b&gt; Alex Drahon &lt;a href=&quot;http://www.xoltar.org/2005/jan/12/firestarter.html&quot;&gt;solved the problem&lt;/a&gt; nicely.

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2004/nov/23/roundy-interview.html"><title>Interview with David Roundy, creator of Darcs
</title><link>http://www.xoltar.org/2004/nov/23/roundy-interview.html
</link>
<description>      

&lt;p&gt;

Sorry for the long gap between postings, folks. It's been busy. I just came across this &lt;a href=&quot;http://www.osdir.com/Article2571.phtml&quot;&gt;interview with David Roundy&lt;/a&gt;, the creator of &lt;a href=&quot;http://www.darcs.net/&quot;&gt;darcs&lt;/a&gt;, a revision control system written in &lt;a href=&quot;http://www.haskell.org&quot;&gt;Haskell&lt;/a&gt;. I've written about darcs &lt;a href=&quot;http://www.xoltar.org/2004/feb/6/darcs.html&quot;&gt;before&lt;/a&gt;, and I definitely think it's work a look. One of my favorite quotes from the interview:

&lt;/p&gt;

&lt;p&gt;

&lt;blockquote&gt;

One danger that is often mentioned is that of a lack of contributors due to the rarity of Haskell programmers. I've been surprised by the number and quality of contributors darcs has had. There seem to be quite a few people out there just looking for somewhere to use Haskell! :) And in fact, there have also been developers who learned Haskell expressly for the purpose of contributing to darcs. It's such a pleasant language to work with that I think it's more of a draw to developers than a put-off.

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

I hope the success of darcs encourages more people to try out Haskell and other functional languages.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/oct/07/alt-jre-nice.html"><title>Nice appears in the alt.lang.jre series
</title><link>http://www.xoltar.org/2004/oct/07/alt-jre-nice.html
</link>
<description>

&lt;p&gt;

Andrew Glover has written a &lt;a href=&quot;http://www-106.ibm.com/developerworks/library/j-alj10064.html&quot;&gt;great new introduction to Nice&lt;/a&gt; over at IBM developerWorks. Check it out!

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/oct/06/haskell-perf.html"><title>Haskell Performance
</title><link>http://www.xoltar.org/2004/oct/06/haskell-perf.html
</link>
<description>      

&lt;p&gt;

Over at &lt;a href=&quot;http://www.algorithm.com.au/mt/&quot;&gt;/\lgorithm.com.au&lt;/a&gt;, there's a nice piece on the 

&lt;a href=&quot;http://www.algorithm.com.au/mt/haskell/haskells_performance.html#000155&quot;&gt;difficulties of 

getting good performance&lt;/a&gt; out of &lt;a href=&quot;http://www.haskell.org&quot;&gt;Haskell&lt;/a&gt;. It's not that it can't be

done, it's just that it takes a lot of expertise, which is a shame. What's the best way to fix it? Some

simple syntax changes might be a good start, as the article suggests.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/sep/22/rss-adjustment.html"><title>Changes to RSS feed
</title><link>http://www.xoltar.org/2004/sep/22/rss-adjustment.html
</link>
<description>      

&lt;p&gt;

I've changed the code that builds the RSS file for this site. Now it includes only the 10 most recent items (just like the home page does), and only the first paragraph of each, which should cut bandwidth usage considerably.

&lt;/p&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2004/sep/22/nice-version-0.9.9.html"><title>Nice Programming Language 0.9.9 released
</title><link>http://www.xoltar.org/2004/sep/22/nice-version-0.9.9.html
</link>
<description>      

&lt;p&gt;

Version 0.9.9 of the &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice Programming Language&lt;/a&gt; compiler is now available. You can download it &lt;a href=&quot;http://nice.sourceforge.net/install.html&quot;&gt;from this page&lt;/a&gt;. Changes in this version include:

&lt;/p&gt;

&lt;pre&gt;

* Assertions about the type of variables are used by the typechecker, so that

    casts are not necessary. For instance:



      Object o = ...;

      // We happen to know by design than the object must be a string

      assert o instanceof String;

      // Here o can be used as a string without cast



    The same construct can be used with '!= null' tests.

  * java.lang.Class is now parameterized by the type it represents.

    In particular, newInstance is now declared in nice.lang with



      &lt;T&gt; T newInstance(Class&lt;T&gt;);



    This make it possible to write type-safe code that uses reflexion,

    in particular when using class literals.

  * Subclasses can have less type parameters than their parent by fixing

    the value of the others. For instance:



      class BitField implements List&lt;boolean&gt; { ... }



  * Improved speed of coverage tests for some methods.

  * Much improved nicedoc tool.

  * Removed the '--strict' compiler option.

  * Underscores are allowed and ignored in literal numbers. example:

      long x = 1_000_123_000_456;

  * The indexing operator supports multiple arguments now. For instance

    'a[x,y]' is syntactic sugar for 'a.get(x,y)'.

  * Lists now support a wide array of slicing and indexing

    operations. There is a new bit of syntax, '@', which indicates

    the index of the last item in a list, which can be used for working

    with indexes relative to the end of the list, instead of the beginning.



    For instance, given a list of ints from 0 to 6 called

    'intList':

	intList[@] is 6,

	intList[@-1] is 5,

	intList[1..2] is the list [1,2].

	intList[1..@-1] is a list of all but the first and last

		elements of ints, i.e., [1,2,3,4,5]

	intList[1..] is a list of all but the first element of intList

	intList[..] is a complete copy of intList

	intList[..@-1] is a list of all but the last element of intList

	intList[int i =&gt; i % 2 == 0] is a list of all the even ints

		in intList: [0,2,4,6]

	Several more options are available, an update to the manual will

	reflect this.

&lt;/pre&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2004/aug/17/slice-of-nice.html"><title>A slice of Nice
</title><link>http://www.xoltar.org/2004/aug/17/slice-of-nice.html
</link>
<description>

&lt;p&gt;I've just committed slice support and a few other new features to the Nice CVS repository, and I'd like to know what people think about them. Any suggestions for improvement would be welcome.&lt;/p&gt;

&lt;p&gt;

In Nice, as in some other languages, it's possible to override the behavior of the [] operator. I've done this for lists, so that the [] operator now supports a number of new options, including slicing, filtering, and indexing relative to the end of the list, instead of the front.&lt;/p&gt;



&lt;p&gt;

First, we introduce a new symbol, &quot;@&quot;, which means, &quot;the last index in the list&quot;. Sometimes I think of it as &quot;-0&quot;. So, given a list of ints from 0 to 6 called 'intList':

&lt;/p&gt;

&lt;pre&gt;

   intList[@] is 6,

   intList[@-1] is 5

&lt;/pre&gt;

&lt;p&gt;

Makes sense? This has the desirable property of making indexing reflective: 1 is the second element from the front, @-1 is the second element from the back.

&lt;/p&gt;

&lt;pre&gt;

from the front:     0    1    2    3    4    5



(or: )              0   0+1  0+2  0+3  0+4  0+5



                  [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;]



from the back:     @-5  @-4  @-3  @-2  @-1   @

&lt;/pre&gt;



&lt;p&gt;Next, we add slicing, using the range operator we've had for a while now (and even in the manual, in the section on extended for loops).&lt;/p&gt;

&lt;pre&gt;

   intList[1..2] is the list [1,2].

   intList[1..@-1] is a list of all but the first and last

       elements of ints, i.e., [1,2,3,4,5]

   intList[1..] is a list of all but the first element of intList

   intList[..] is a complete copy of intList

   intList[..@-1] is a list of all but the last element of intList

   intList[@-2..@-1] is the third-from-last and second-from-last: [4,5]

&lt;/pre&gt;

&lt;p&gt;

Notice that Nice's range is an &lt;em&gt;inclusive&lt;/em&gt; range, as opposed to Python's half-open range. So where Python would write:

&lt;/p&gt;

&lt;pre&gt;

   intList[1:-1]

&lt;/pre&gt;

&lt;p&gt;

(where -1 represents the last item in the list) to mean all but the first and last items of the list, we write

&lt;/p&gt;

&lt;pre&gt;

   intList[1..@-1]

&lt;/pre&gt;

&lt;p&gt;

for the same thing. @ means the last item in the list, minus one makes it the second to the last item in the list, and &quot;..&quot; is the inclusive range operator which takes everything from index 1 to index @-1, including the end points.

&lt;/p&gt;

&lt;p&gt;

There are also some more unusual variants, such as filtering:

&lt;/p&gt;

&lt;pre&gt;

   intList[int i =&gt; i % 2 == 0] is a list of all the even ints in intList, i.e.: [0,2,4,6]

&lt;/pre&gt;

&lt;p&gt;

Picking out a sequence of arbitrary indices:

&lt;p&gt;

&lt;pre&gt;

   intList[[2,3,0,1, @]] is [2,3,0,1,6]

&lt;/pre&gt;



&lt;p&gt;Assigning to a filter:&lt;/p&gt;

&lt;pre&gt;

   intList[int i =&gt; i % 2 == 0] = 27 makes intList into: [27, 1, 27, 3, 27, 5, 27]

&lt;/pre&gt;

&lt;p&gt;

Assigning to arbitrary indices:

&lt;/p&gt;

&lt;pre&gt;

   intList[[0,2] = -3 makes intList into: [-3, 1, -3, 3, 4, 5, 6]

&lt;/pre&gt;



&lt;p&gt;

Assigning to a slice:

&lt;/p&gt;

&lt;pre&gt;

   intList[3..] = 9 makes intList into: [0,1,2, 9, 9, 9, 9]

   intList[3..] = [5,4,3,2] makes intList into: [0,1,2,5,4,3,2]

&lt;/pre&gt;



&lt;p&gt;

Removing a slice:

&lt;/p&gt;

&lt;pre&gt;

   intList.removeAt(3..) makes intList into: [0,1,2]

&lt;/pre&gt;



&lt;p&gt;

We've also debated adding support for a half-open range as &quot;..!&quot;, e.g., 1..!4 to mean the same as 1..3, on the theory that the half-open range can be useful too in certain circumstances. Does this come up often enough to merit it? I'm not interested in adding &quot;...&quot; for this, as I would never be able to keep the meanings of &quot;..&quot; and &quot;...&quot; straight.

&lt;/p&gt;



&lt;p&gt;

So what do you think of these new features? Good? Bad? Ugly? Let me know.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2004/aug/17/stop-nullpointers.html"><title>A plan for NullPointerExceptions
</title><link>http://www.xoltar.org/2004/aug/17/stop-nullpointers.html
</link>
<description>

&lt;p&gt;&lt;a href=&quot;http://www.almaer.com/blog/archives/000400.html&quot;&gt;Dion&lt;/a&gt; reports on &lt;a href=&quot;http://weblogs.asp.net/ericgu/archive/2004/08/17/215779.aspx&quot;&gt;Eric Gunnerson's&lt;/a&gt; receipt of an email posing the problem:

&lt;/p&gt;

&lt;blockquote&gt;

When I'm writing code, I often come across a situation where my code throws an exception because another component called with a null parameter. I'd like a way to prevent that from happening.

&lt;/blockquote&gt;



&lt;p&gt;Apparently, all sorts of weird and wonderful solutions have been proposed. Dion just wants careful error reporting, and that's fine. How about plan B?

&lt;/p&gt;

&lt;h3&gt;Plan B&lt;/h3&gt;

&lt;p&gt;

Use a language like &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt;, which &lt;a href=&quot;http://nice.sourceforge.net/safety.html#id2433011&quot;&gt;prevents NullPointerExceptions altogether&lt;/a&gt;. I'd love to have a .Net backend for Nice, so if C# people have a burning desire to solve the NullPointer problem, we'd welcome their help with porting Nice to run on .Net.

&lt;/p&gt;





</description></item><item rdf:about="http://www.xoltar.org/2004/aug/17/courtesy-of-nice.html"><title>Courtesy Implementation in Nice
</title><link>http://www.xoltar.org/2004/aug/17/courtesy-of-nice.html
</link>
<description>

&lt;p&gt;

Martin Fowler &lt;a href=&quot;http://www.martinfowler.com/bliki/CourtesyImplementation.html&quot;&gt;is talking about &quot;courtesy implementations&quot;&lt;/a&gt;, which of course is all very sensible. Working with a language with first-class multi-methods makes this even more painless. Here's Fowler's example in &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt;:



&lt;pre&gt;

interface Node {}



class Box implements Node {

	List&lt;Node&gt; children = new ArrayList();

	void `&lt;&lt;` (Node argNode) { children.add(argNode); }	

}



class Elephant implements Node {}



int num_elephants(Node n);



num_elephants(Elephant e) = 1;

num_elephants(Box b) {

	var result = 0;

	for (node: b.children) {

		result += node.num_elephants();

	}

	return result;

}



&lt;/pre&gt;

&lt;p&gt;

Things to notice about this code:

&lt;ul&gt;

	&lt;li&gt;Despite being code for a statically typed language, it's about the same size as Martin's Ruby code, maybe even a little shorter.&lt;/li&gt;

        &lt;li&gt;If you create a new class which implements &lt;code&gt;Node&lt;/code&gt;, the compiler will complain if you don't also provide a new implementation of &lt;code&gt;num_elephants&lt;/code&gt; to go with it, just like an abstract method in Java.&lt;/li&gt;

	&lt;li&gt;Nice syntax accepts method definitions and overrides within class bodies, but they're still multi-methods, just as if they were defined outside the class. Whatever you're more comfortable with is fine.&lt;/li&gt;

	&lt;li&gt;Because classes don't &lt;em&gt;contain&lt;/em&gt; methods, &quot;adding a method to a base class&quot; is as trivial as defining any other kind of method. You want to define new methods on Object, or String? Go right ahead, nothing's stopping you.&lt;/li&gt;

	&lt;li&gt;Everybody brings up the &quot;but what if I have a list of arbitrary objects&quot; question for statically typed languages, so I'll also mention this alternative definition of &lt;code&gt;num_elephants&lt;/code&gt;:

	&lt;pre&gt;

	int num_elephants(Object o) = 0;

	num_elephants(Elephant e) = // Same as original

	num_elephants(Box b) = //Same as original

	&lt;/pre&gt;

	This would let you find the number of elephants in &lt;em&gt;anything&lt;/em&gt;. Things that you haven't specialized the method for simply get a default of 0. So, &lt;code&gt;&quot;foo&quot;.num_elephants()&lt;/code&gt; would return 0. Things that care, can give better results. Things that don't, don't break.

	&lt;/li&gt;

	&lt;li&gt;Nice has some great power tools from the world of functional programming. Here's a shorter way of implementing &lt;code&gt;num_elephants&lt;/code&gt; for the &lt;code&gt;Box&lt;/code&gt; class:

	&lt;pre&gt;

	num_elephants(Box b) = b.children.map(num_elephants).foldLeft(

		(int i, int j) =&gt; i + j);

	&lt;/pre&gt;

	&lt;/li&gt;

	&lt;li&gt;

	I didn't have to declare &lt;code&gt;num_elephants&lt;/code&gt; when I declared Node, I did it later, and that's fine. I could have done it in another file or package, too.

	&lt;/li&gt;

&lt;/ul&gt;

&lt;/p&gt;



&lt;p&gt;

Nice takes this even further, though. You can override a method for a &lt;em&gt;particular object&lt;/em&gt;. Smalltalk, Ruby, Python all do this, too. But your garden variety statically typed languages don't let you play this game. Let's go ahead and allow strings to count as elephants, too:

&lt;pre&gt;

	num_elephants(String s) = s.indexOf(&quot;Elephant&quot;) &gt; -1 ? 1 : 0

&lt;/pre&gt;

but let's make a special exception:

&lt;pre&gt;

	num_elephants(&quot;SpecialElephant&quot;) = 5;

&lt;/pre&gt;



Methods are so convenient, Nice doesn't even have (or need) a &lt;code&gt;switch&lt;/code&gt; statement. Think about it.

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2004/aug/12/more-quizzes.html"><title>More personality quizzes
</title><link>http://www.xoltar.org/2004/aug/12/more-quizzes.html
</link>
<description>      

&lt;p&gt;

More quizzes.

&lt;a href=&quot;http://patricklogan.blogspot.com/2004/08/not-what-water.html&quot;&gt;via Patrick, again.&lt;/a&gt;

&lt;/p&gt;

&lt;img src=&quot;http://www.xoltar.org/images/mRNA.jpg&quot; border=&quot;0&quot; alt=&quot;mRNA&quot;&gt;&lt;br&gt;You are mRNA. You're brilliant, full of important,&lt;br&gt;interesting information and you're a great&lt;br&gt;friend to the people you care about. You may&lt;br&gt;have sides to you that no one understands. But&lt;br&gt;while you understand more than most people,&lt;br&gt;you're only half-there most of the time.

&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://quizilla.com/users/Sc0tty/quizzes/Which%20Biological%20Molecule%20Are%20You%3F/&quot;&gt; &lt;font size=&quot;-1&quot;&gt;Which Biological Molecule Are You?&lt;/font&gt;&lt;/a&gt;&lt;BR&gt; &lt;font size=&quot;-3&quot;&gt;brought to you by &lt;a href=&quot;http://quizilla.com&quot;&gt;Quizilla&lt;/a&gt;&lt;/font&gt;



&lt;table align=&quot;center&quot; width=&quot;250&quot;&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;

	&lt;div style=&quot;font-size:18px;font-family:Verdana&quot;&gt;

		&lt;b&gt;I AM 38% HIPPIE!&lt;/b&gt;

    &lt;/div&gt;

    &lt;a href=&quot;http://www.fuali.com/test.aspx?id=116&quot;&gt;

    	&lt;img src=&quot;http://www.xoltar.org/images/38-percent-hippie.gif&quot; alt=&quot;38% HIPPIE&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

    	&lt;div style=&quot;font-size:10px;font-family:Verdana&quot;&gt;

    	I need to step away from the tie-dye.  

    	I smell too good to be a hippie and my dad is probably a cop.  

    	Being a hippie is not a fashion craze, man.  

    	It was a way of life, in the 60's, man.

    	&lt;/div&gt;

    	&lt;div style=&quot;font-size:12px;font-family:Verdana&quot;&gt;

    	&lt;a href=&quot;http://www.fuali.com/test.aspx?id=116&quot;&gt;Take the HIPPIE test at Fuali.com&lt;/a&gt;

    	&lt;/div&gt;

    	&lt;/td&gt;

    	&lt;/tr&gt;

    	&lt;/table&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/aug/09/nice-groovy-2.html"><title>Groovy features in Nice, part 2
</title><link>http://www.xoltar.org/2004/aug/09/nice-groovy-2.html
</link>
<description>

&lt;p&gt;

In my &lt;a href=&quot;http://www.xoltar.org/2004/aug/07/nice-groovy.html&quot;&gt;last post&lt;/a&gt; 

I started comparing &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt; 

and &lt;a href=&quot;http://groovy.codehaus.org/&quot;&gt;Groovy&lt;/a&gt; on the basis of Groovy's

features as explained on the Groovy homepage. I did this not to denigrate the

fine work the Groovy folks have done, but to point out capabilities of Nice that

have perhaps not been publicized very well. Here's Part 2.

&lt;/p&gt;

&lt;p&gt;

I should mention that some of the features I mention here (namely list slicing

and using &lt;code&gt;someList[someFunction]&lt;/code&gt; to mean 

&lt;code&gt;someList.filter(function)&lt;/code&gt;) are not

yet available for release, but they're hardly deep magic, either. For instance, 

here's the implementation of the filter syntax above:

&lt;/p&gt;

&lt;pre&gt;

&lt;T&gt; List&lt;T&gt; get(List&lt;T&gt; list, T-&gt;boolean function) = 

	list.filter(function);

&lt;/pre&gt;

&lt;p&gt;Anyway, I'm not going to mention anything that isn't already working on my

machine, all of which will be available by or before version 1.0.&lt;/p&gt;



&lt;h3&gt;&lt;a href=&quot;http://wiki.codehaus.org/groovy/SyntaxForTuplesListsMaps&quot;&gt;

	Native Syntax for Lists and Maps&lt;/a&gt;&lt;/h3&gt;

Groovy

&lt;pre&gt;

myTuple = 1, 2, 3;

print myTuple[2];



anotherTuple = (1, (2, 3), 4);

print anotherTuple[2:3];



list = { 1, 2, 3 };

list.add(4);

print list[2:4];



block = { print 'hello'; };

block.call();



block = { x : print x; }

block.call('hello');



list = [ 'a', 'b', 'c' ];

list.each { i : print i; }



map = [ 1 : 'bob', 2 : 'james' ];

print map[1];

map[4] = 'jon';

&lt;/pre&gt;



Nice

&lt;pre&gt;

let myTuple = (1, 2, 3);

let (a0, a1, a2) = myTuple;

println(a2);



let anotherTuple = (1, (2, 3), 4);

let (b0, b1, b2) = anotherTuple;

println(b1, b2);



let list = [ 1, 2, 3 ];

list.add(4);

println(list[2..3]);



let block = () =&gt; { println(&quot;hello&quot;); };

block();



let list = [ 'a', 'b', 'c' ];

list.foreach(int i =&gt; println(i); }

// or, equivalently:

list.foreach(println);

// or, again:

for(i:list) { println(i); }



let map = [(1,&quot;bob&quot;), (2,&quot;james&quot;)].listToMap();

println(map[1]);

map[4] = &quot;jon&quot;;

&lt;/pre&gt;



&lt;h3&gt;&lt;a href=&quot;http://groovy.codehaus.org/sql.html&quot;&gt;Groovy SQL&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;

Groovy has some handy syntax for SQL. It's the same handy syntax it uses for

other things. Nice is in the same boat. I've not yet had reason to write

a database library for Nice, but let's just write a quick sketch here and

see how it goes. Of course, we could just use JDBC as-is, but we can do

much better.

&lt;/p&gt;



&lt;pre&gt;&lt;span class=&quot;com&quot;&gt;package nice.sql;

&lt;/span&gt;&lt;span class=&quot;key&quot;&gt;import &lt;/span&gt;nice.functional;

&lt;span class=&quot;key&quot;&gt;import &lt;/span&gt;java.sql.*;



&lt;span class=&quot;typ&quot;&gt;Connection &lt;/span&gt;connect&lt;span class=&quot;sym&quot;&gt;() { &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;throw new &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&amp;quot;Not implemented&amp;quot;&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;)&lt;/span&gt;; &lt;span class=&quot;sym&quot;&gt;}



&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Generic query. Not sure what this ought to look like, but this will work

&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//for our examples here.

&lt;/span&gt;var ?&lt;span class=&quot;typ&quot;&gt;Connection &lt;/span&gt;conn = null;

&lt;span class=&quot;typ&quot;&gt;Iterator&lt;/span&gt;&amp;lt;&lt;span class=&quot;typ&quot;&gt;ResultSet&lt;/span&gt;&amp;gt; query&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;String &lt;/span&gt;sqlQuery, ?&lt;span class=&quot;typ&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;typ&quot;&gt;Object&lt;/span&gt;&amp;gt; binders = null&lt;span class=&quot;sym&quot;&gt;) {

    &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;conn == null&lt;span class=&quot;sym&quot;&gt;) {

        &lt;/span&gt;conn = connect&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

    &lt;span class=&quot;sym&quot;&gt;}

    &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;let &lt;/span&gt;c = conn;

    &lt;span class=&quot;key&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;c != null&lt;span class=&quot;sym&quot;&gt;) {

    &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;let &lt;/span&gt;stmt = c.createStatement&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

    &lt;span class=&quot;key&quot;&gt;try &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;{

        &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;binders != null&lt;span class=&quot;sym&quot;&gt;) {

            &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Replace all the ? chars with our given binders.

&lt;/span&gt;            &lt;span class=&quot;key&quot;&gt;let &lt;/span&gt;tokens = binders.map&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;sql&lt;span class=&quot;sym&quot;&gt;)&lt;/span&gt;.iterator&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

            &lt;span class=&quot;key&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;sqlQuery.indexOf&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&amp;quot;?&amp;quot;&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;) &lt;/span&gt;&amp;gt; &lt;span class=&quot;num&quot;&gt;-1 &lt;/span&gt;&amp;amp;&amp;amp; tokens.hasNext&lt;span class=&quot;sym&quot;&gt;())

                &lt;/span&gt;sqlQuery = sqlQuery.replace&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;'?'&lt;/span&gt;, tokens.next&lt;span class=&quot;sym&quot;&gt;())&lt;/span&gt;;

                &lt;span class=&quot;sym&quot;&gt;}

            &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;return &lt;/span&gt;iterator&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;stmt.executeQuery&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;sqlQuery&lt;span class=&quot;sym&quot;&gt;))&lt;/span&gt;;

    &lt;span class=&quot;sym&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;finally &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;{

       &lt;/span&gt;stmt.close&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

    &lt;span class=&quot;sym&quot;&gt;}

   }

   &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;throw new &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&amp;quot;Couldn't connect&amp;quot;&lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;)&lt;/span&gt;;

&lt;span class=&quot;sym&quot;&gt;}



&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Wrap up ResultSets as Iterators, so we can use all the built-in

&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//methods for iterators that Nice already supports.

&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Iterator&lt;/span&gt;&amp;lt;&lt;span class=&quot;typ&quot;&gt;ResultSet&lt;/span&gt;&amp;gt; iterator&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ResultSet &lt;/span&gt;res&lt;span class=&quot;sym&quot;&gt;) {

    &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;return &lt;/span&gt;iterator&lt;span class=&quot;sym&quot;&gt;(() &lt;/span&gt;=&amp;gt; &lt;span class=&quot;sym&quot;&gt;{

    &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;res.next&lt;span class=&quot;sym&quot;&gt;())

        &lt;/span&gt;&lt;span class=&quot;key&quot;&gt;return &lt;/span&gt;res;

    &lt;span class=&quot;key&quot;&gt;return &lt;/span&gt;stop&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

    &lt;span class=&quot;sym&quot;&gt;})&lt;/span&gt;;

&lt;span class=&quot;sym&quot;&gt;}



&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Support [] operator for indexes, dynamic typing here!

&lt;/span&gt;&amp;lt;T&amp;gt; T get&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ResultSet &lt;/span&gt;r, &lt;span class=&quot;key&quot;&gt;int &lt;/span&gt;i&lt;span class=&quot;sym&quot;&gt;) &lt;/span&gt;= cast&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;r.get&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;sym&quot;&gt;))&lt;/span&gt;;



&lt;span class=&quot;com&quot;&gt;//Support [] operator for column names, dynamic typing here!

&lt;/span&gt;&amp;lt;T&amp;gt; T get&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ResultSet &lt;/span&gt;r, &lt;span class=&quot;typ&quot;&gt;String &lt;/span&gt;col&lt;span class=&quot;sym&quot;&gt;) &lt;/span&gt;= cast&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;r.get&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;col&lt;span class=&quot;sym&quot;&gt;))&lt;/span&gt;;



&lt;span class=&quot;com&quot;&gt;//Handy SQL formatting

&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;String &lt;/span&gt;sql&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;?&lt;span class=&quot;typ&quot;&gt;Object &lt;/span&gt;obj&lt;span class=&quot;sym&quot;&gt;) &lt;/span&gt;= obj == null ? &lt;span class=&quot;str&quot;&gt;&amp;quot;null&amp;quot;&lt;/span&gt; : obj.toString&lt;span class=&quot;sym&quot;&gt;()&lt;/span&gt;;

sql&lt;span class=&quot;sym&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;String &lt;/span&gt;s&lt;span class=&quot;sym&quot;&gt;) &lt;/span&gt;= &lt;span class=&quot;str&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt; + s + &lt;span class=&quot;str&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;;

&lt;span class=&quot;com&quot;&gt;//Need one for dates...

&lt;/span&gt;



&lt;/pre&gt;

&lt;p&gt;One interesting thing to notice here is how well Nice handles dynamic typing 

when that's what's really necessary. See the implementation for the &lt;code&gt;get&lt;/code&gt;

method? The &lt;code&gt;&amp;lt;T&amp;gt;&lt;/code&gt; bit at the front introduces a type variable,

exactly the same sort of type variable we use for writing things like &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt;.

Notice however, that though the function returns type T, there are no Ts in the

arguments to the method, nor any other constraints on T. That means, T can be

&lt;em&gt;any type at all&lt;/em&gt;. Voila, dynamic typing. You promise the compiler you

know the type you're expecting, and you get a runtime exception if you get it

wrong, same as if you used casting or a dynamically typed language. You don't have 

to use a cast each time you call it, though, which is a lot nicer than Java's 

approach.

&lt;/p&gt;

&lt;p&gt;

Because we're implementing a simple database library for freestyle data access,

we don't have types available for the tables we're working with. If we did,

we could talk about how to build a statically typed interface to the database.

&lt;/p&gt;

&lt;p&gt;Now, let's compare: &lt;/p&gt;



Groovy

&lt;pre&gt;

import groovy.sql.Sql

import groovy.sql.TestHelper



foo = 'cheese'

sql = TestHelper.makeSql()



sql.eachRow(&quot;select * from FOOD where type=${foo}&quot;) { 

    println &quot;Gromit likes ${it.name}&quot; 

}&lt;/pre&gt;



Nice

&lt;pre&gt;

import nice.sql;



void main(String[] args) {

	let foo = &quot;cheese&quot;;

	for(r : query(&quot;select * from FOOD where type = ?&quot;, [foo])) {

		println(&quot;Gromit likes &quot; r[&quot;name&quot;]);

	}

}

&lt;/pre&gt;



Groovy

&lt;pre&gt;

import groovy.sql.Sql

import groovy.sql.TestHelper



foo = 'cheese'

sql = TestHelper.makeSql()



answer = 0

sql.eachRow(&quot;select count(*) from FOOD where type=${foo}&quot;) { row |

	answer = row[0]

}

assert answer &gt; 0

&lt;/pre&gt;



Nice

&lt;pre&gt;

import nice.sql;



void main(String[] args) {

	let foo = 'cheese'

	int answer;

	for(row : query(&quot;select count(*) from FOOD where type= ?&quot;, [foo]))

		answer = row[0];

	assert answer &gt; 0;

}

&lt;/pre&gt;



Groovy

&lt;pre&gt;

import groovy.sql.Sql

import groovy.sql.TestHelper



sql = TestHelper.makeSql()



food = sql.dataSet('FOOD')

cheese = food.findAll { it.type == 'cheese' }

cheese.each { println &quot;Eat ${it.name}&quot; }

&lt;/pre&gt;



Nice

&lt;pre&gt;

import nice.sql;



void main(String[] args) {

	let food = query(&quot;FOOD&quot;);

	let cheese = food[ResultSet r =&gt; r[&quot;type&quot;] == &quot;cheese&quot;];

	for(r:cheese)

		println(&quot;Eat &quot; r[&quot;name&quot;]);

}

&lt;/pre&gt;



&lt;p&gt;

More later.

&lt;/p&gt;





</description></item><item rdf:about="http://www.xoltar.org/2004/aug/07/nice-groovy.html"><title>Groovy features in Nice
</title><link>http://www.xoltar.org/2004/aug/07/nice-groovy.html
</link>
<description>

&lt;p&gt;

Over on &lt;a href=&quot;http://www.lambda-the-ultimate.org&quot;&gt;Lambda&lt;/a&gt;, Mario B. 

&lt;a href=&quot;http://lambda-the-ultimate.org/node/view/100#comment-1126&quot;&gt;made a 

comment&lt;/a&gt; to the effect that in comparing Nice and Groovy, he thought that 

Groovy had more features. I don't mean any disrespect to the Groovy folks, but

I think Nice supports most of the features on &lt;a href=&quot;http://groovy.codehaus.org/&quot;&gt;

the Groovy homepage&lt;/a&gt; at least as well as 

Groovy. Here's my proof.

&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;http://groovy.codehaus.org/markup.html&quot;&gt;Groovy Markup&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;

Here's what Groovy looks like building a XML document or something else with

a tree structure:

&lt;/p&gt;

&lt;pre&gt;

someBuilder = new NodeBuilder()



someBuilder.people(kind:'folks', groovy:true) {

  person(x:123,  name:'James', cheese:'edam') {

    project(name:'groovy')

    project(name:'geronimo')

  }

  person(x:234,  name:'bob', cheese:'cheddar') {

    project(name:'groovy')

    project(name:'drools')

  }

}

&lt;/pre&gt;



&lt;p&gt;

The critical features here are syntactic. You have to be able to support keyword

arguments, and you have to support trailing block closures. The rest is library

work. Nice has both these features. I can demonstrate the library support if

anybody's interested, but I'll skip it here for the time being.

&lt;/p&gt;



&lt;a href=&quot;http://groovy.codehaus.org/GPath&quot;&gt;&lt;h2&gt;Path expression language&lt;/h2&gt;&lt;/a&gt;

&lt;p&gt;

This is a convenient way of dealing with complicated object structures. The 

syntax will look a little bit different with Nice, but it's equally convenient.

Some examples:

&lt;/p&gt;

Groovy

&lt;pre&gt;

if (customer.orders.any { it.amount &gt; 1000 &amp;&amp; 

	it.product.type == &quot;cheese&quot;} ) {

  doSomething();

}

&lt;/pre&gt;



Nice

&lt;pre&gt;

if (customers.orders.any(Order ord =&gt; ord.amount &gt; 1000 &amp;&amp; 

	ord.product.type == &quot;cheese&quot;)) {

  doSomething();

}

&lt;/pre&gt;



&lt;p&gt;

Note that the only difference is the need to specify a name for the 

argument (&quot;ord&quot;), as opposed to always having to use a special name (&quot;it&quot;)[&lt;a href=&quot;#correction1&quot;&gt;1&lt;/a&gt;]. 

Don't be dismayed by the need to declare a type for ord (&quot;Order&quot;), Nice does

type inference almost everywhere else, and I'm hoping Daniel will implement it

for anonymous methods like these before the 1.0 release. Then it will be possible

to omit it and still have type safety:

&lt;/p&gt;

Nice (future)

&lt;pre&gt;

if (customers.orders.any(ord =&gt; ord.amount &gt; 1000 &amp;&amp; 

	ord.product.type == &quot;cheese&quot;)) {

  doSomething();

}

&lt;/pre&gt;



Groovy

&lt;pre&gt;

if (customers.any { it.location.code == &quot;UK&quot; &amp;&amp; 

	it.orders.any { it.amount &gt; 1000 &amp;&amp; 

		it.product.type == &quot;cheese&quot;}} ) {

  doSomething();

}

&lt;/pre&gt;



Nice

&lt;pre&gt;

if (customers.any(Customer c =&gt; c.location.code == &quot;UK&quot; &amp;&amp; 

	c.orders.any(Order o =&gt; o.amount &gt; 1000 &amp;&amp;

		o.product.type == &quot;cheese&quot;)) ) {

  doSomething();

}

&lt;/pre&gt;

&lt;p&gt;

In this example, being able to choose a name other than &quot;it&quot; improves readability, I think.

&lt;/p&gt;



Groovy

&lt;pre&gt;

for (order in customers.findAll { it.location.code == &quot;UK&quot; }.orders) {

  println(&quot;order ${order.id} has value ${order.value}&quot;);

}

&lt;/pre&gt;



Nice

&lt;pre&gt;

for (order : customers[

	Customer it =&gt; it.location.code == &quot;UK&quot;].map(orders).concat) {

  println(&quot;order &quot; order.id &quot; has value &quot; order.value);

}

&lt;/pre&gt;



&lt;h3&gt;&lt;a href=&quot;http://groovy.codehaus.org/operators.html&quot;&gt;Operator Overloading&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;

Groovy lets you overload the builtin operators. This means that it translates

&lt;code&gt;a + b&lt;/code&gt; into &lt;code&gt;a.plus(b)&lt;/code&gt;, so that you can define your own

&lt;code&gt;plus()&lt;/code&gt; method. This is a useful feature, but it is limited in that

the type of the first object in the expression determines which plus method will

be called! This means that &lt;code&gt;a + b&lt;/code&gt; may not be the same as &lt;code&gt;b + a&lt;/code&gt;, 

if a and b both define &lt;code&gt;plus()&lt;/code&gt; methods. Nice doesn't have this limitation,

since it is based on multiple dispatch. This means that the most applicable method

for a given call is chosen based on the types of &lt;em&gt;all&lt;/em&gt; the arguments involved.

Nice's syntax for this is more self-explanatory as well since it uses the operator

symbol directly.

&lt;p&gt;

Groovy

&lt;pre&gt;

class MyClass {

  /*..*/

  MyClass plus(MyClass other) { /*..*/ }

}

&lt;/pre&gt;

Nice

&lt;pre&gt;

class MyClass { /*..*/ }

MyClass `+` (MyClass lhs, MyClass rhs) { /*.. */ }

&lt;/pre&gt;



&lt;h3&gt;&lt;a href=&quot;http://groovy.codehaus.org/closures.html&quot;&gt;Closures&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;First class methods you can pass around, not related to any particular class.

Nice is an object/functional language, with first class multi-methods and anonymous methods.

Syntax differs, of course, but both are equally convenient.

&lt;/p&gt;

&lt;h3&gt;Polymorphic iteration and autoboxing&lt;/h3&gt;

&lt;p&gt;

Nice supports autoboxing sanely. Better than even Java 1.5 does. 

See &lt;a href=&quot;http://www.jroller.com/page/dbr/20040312#autoboxing_and_nullpointerexceptions_in_java&quot;&gt;

Daniel's article&lt;/a&gt; for details. Not sure what &quot;polymorphic iteration&quot; means, 

so that will have to wait for later.

&lt;/p&gt;



&lt;p&gt;

Well, that's enough for one day. More later.

&lt;/p&gt;

&lt;a name=&quot;correction1&quot;/&gt; &lt;p&gt;

[&lt;b&gt;Update:&lt;/b&gt; Jeremy Rayner pointed out that you can use a different name in Groovy, like this: 

&lt;pre&gt;

if (customers.any { c | c.location.code == &quot;UK&quot; &amp;&amp; 

	c.orders.any { o | o.amount &gt; 1000 &amp;&amp; 

		o.product.type == &quot;cheese&quot;}} ) {

  doSomething();

}&lt;/pre&gt;

]&lt;/p&gt;
</description></item><item rdf:about="http://www.xoltar.org/2004/aug/05/jedit-nice-mode.html"><title>Nice programming language mode for JEdit
</title><link>http://www.xoltar.org/2004/aug/05/jedit-nice-mode.html
</link>
<description>      

&lt;p&gt;

I played around with &lt;a href=&quot;http://www.jedit.org&quot;&gt;JEdit&lt;/a&gt; a bit last night, 

and liked what I saw. It's fast,

the documentation is helpful, and it was pretty easy to get started writing

a &lt;a href=&quot;http://www.xoltar.org/tools/nice.xml&quot;&gt;syntax highlighting mode for Nice&lt;/a&gt;. 

I'm not sure I'm going to be able to use the builtin parsing options to actually do the 

highlighting of types and type constraints the way I'd ideally like to, but it 

looks pretty good already. To install, just save the file at the link above to 

your JEdit modes folder, and add these lines to your &quot;catalog&quot; file in the same folder:

&lt;/p&gt;

&lt;pre&gt;

&amp;lt;MODE NAME=&quot;nice&quot;		FILE=&quot;nice.xml&quot;

				FILE_NAME_GLOB=&quot;*.nice&quot; /&amp;gt;

&lt;/pre&gt;

&lt;p&gt;

I supposed I'll need to talk to the JEdit people now about getting it into the

standard distribution.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2004/aug/04/editor-progress.html"><title>Narrowing down editor choices
</title><link>http://www.xoltar.org/2004/aug/04/editor-progress.html
</link>
<description>      

&lt;p&gt;

I'm just back from vacation and feeling rejuvenated, so I think it's time to make some progress on an old issue - text editors. I've been able to narrow the field down a bit. Remember, my criteria (from my &lt;a href=&quot;http://www.xoltar.org/tools/editors.html&quot;&gt;editor page&lt;/a&gt;) were:

&lt;ul&gt;

	&lt;li&gt;Graphical, but doesn't require me to use the mouse&lt;/li&gt;

	&lt;li&gt;Fast&lt;/li&gt;

	&lt;li&gt;Cross-platform, to include Windows and Linux at a minimum&lt;/li&gt;

	&lt;li&gt;Extensible, using a real language. Python, Scheme, or Haskell would be fine&lt;/li&gt;

	&lt;li&gt;Supports syntax coloring, macros, smart indent, code folding&lt;/li&gt;

	&lt;li&gt;Works (or can be taught to work) with any programming language&lt;/li&gt;

	&lt;li&gt;Supports Unicode, or at least UTF-8&lt;/li&gt;

	&lt;li&gt;Completely customizable, menus- and key- wise&lt;/li&gt;

&lt;/ul&gt;

&lt;/p&gt;



&lt;p&gt;

Some of them have changed a bit over time. For instance, I now think that dynamic typing is a dead end, so Scheme and Python are not acceptable extension languages for me anymore. Also, I've decided that I'm okay with using a Java-based editor so long as it's fast enough (and some of them are, now). Since I'm now looking at JVM-based editors, that means I can write plugins and extensions in &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt;, which to my eye is the finest programming language currently available for the Java virtual machine. 

&lt;/p&gt;

&lt;p&gt;

So at the moment, my two favorite contenders are &lt;a href=&quot;http://www.eclipse.org/&quot;&gt;Eclipse&lt;/a&gt; and &lt;a href=&quot;http://www.jedit.org/&quot;&gt;JEdit&lt;/a&gt; (thanks to Mark Evans for suggesting the latter). I'll be looking into both in more detail now, to try to figure out which one suits me best. If anyone has other ideas (other than Emacs or Vim, I've tried those) about good editors which meet the criteria above (whether or not they're written for the JVM), let me know. Thanks!

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/20/dos-attack.html"><title>Denial of Service
</title><link>http://www.xoltar.org/2004/jul/20/dos-attack.html
</link>
<description>      

&lt;p&gt;

You probably won't get to read this until after it's over, but the reason you haven't been able to connect to this site is because my web hosting provider has been under a denial of service attack since the 19th of July. Sorry for the inconvenience.

&lt;/p&gt;

&lt;p&gt;

&lt;b&gt;Update: (21 JUL 2004 14:14)&lt;/b&gt; Whew! I can finally see my site again! I think the attack is actually going on, the provider had to move all the websites to a different server.

&lt;/p&gt;	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/19/partial-continuations.html"><title>Partial continuations
</title><link>http://www.xoltar.org/2004/jul/19/partial-continuations.html
</link>
<description>      

&lt;p&gt;

First-class continuations are fun, but sometimes they're more power than you really want. Chris Double has &lt;a href=&quot;http://www.double.co.nz/scheme/partial-continuations/partial-continuations.html&quot;&gt;written an article&lt;/a&gt; which explains the use of &lt;em&gt;partial&lt;/em&gt; continuations, with examples in Scheme.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/19/java-continuations.html"><title>Continuations in Java
</title><link>http://www.xoltar.org/2004/jul/19/java-continuations.html
</link>
<description>      

&lt;p&gt;

In case you haven't heard it elsewhere, there's a plan afoot to &lt;a href=&quot;http://vafer.org/blog/tcurdt/archives/000109.html&quot;&gt;add continuations to Java&lt;/a&gt; via the JSR process. &lt;a href=&quot;http://kasparov.skife.org/blog/src/java/cont-jsr.html&quot;&gt;here's a little blurb about it&lt;/a&gt;, and there's also a &lt;a href=&quot;http://docs.codehaus.org/display/continuation/Home&quot;&gt;Wiki&lt;/a&gt; for discussing continuations and the JSR process. They've already &lt;a href=&quot;http://docs.codehaus.org/display/continuation/Related+Projects&quot;&gt;got links&lt;/a&gt; to &lt;a href=&quot;http://www.beta4.com/seaside2/&quot;&gt;Seaside&lt;/a&gt; and Chris Double's &lt;a href=&quot;http://www.double.co.nz/scheme/modal-web-server.html&quot;&gt;modal web server example&lt;/a&gt;, so they're on the right track.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/19/epigram.html"><title>Epigram - a new language with dependent typing
</title><link>http://www.xoltar.org/2004/jul/19/epigram.html
</link>
<description>      

&lt;p&gt;

Via &lt;a href=&quot;http://lambda-the-ultimate.org/node/view/115&quot;&gt;Lambda the Ultimate&lt;/a&gt;, I just discoved &lt;a href=&quot;http://www.dur.ac.uk/CARG/epigram/&quot;&gt;Epigram&lt;/a&gt;, a Haskell-like language with dependent types. There's a well-written tutorial &lt;a href=&quot;http://www.dur.ac.uk/CARG/epigram/epigram-afpnotes.pdf&quot;&gt;here&lt;/a&gt; which will help explain what dependent types are good for. 

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/15/boo.html"><title>Boo - a new .Net language
</title><link>http://www.xoltar.org/2004/jul/15/boo.html
</link>
<description>      

&lt;p&gt;

Via &lt;a href=&quot;http://patricklogan.blogspot.com/2004/07/boo-hoo.html&quot;&gt;Patrick&lt;/a&gt; I just discovered a new language for the .Net CLR, called &lt;a href=&quot;http://boo.codehaus.org/&quot;&gt;Boo&lt;/a&gt;. Pythonic syntax, object oriented static typing with type inference, and macros. Looks interesting.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/12/andre-pang-comments.html"><title>André Pang comments on &quot;Modern Static Typing: Less Code, Better Code&quot;
</title><link>http://www.xoltar.org/2004/jul/12/andre-pang-comments.html
</link>
<description>      

&lt;p&gt;

André Pang has &lt;a href=&quot;http://www.algorithm.com.au/mt/archives/programming_languages/me_on_xoltar_on_static_typing.html#000109&quot;&gt;made some comments&lt;/a&gt; on my article &lt;a href=&quot;http://www.xoltar.org/misc/static_typing_eckel.html&quot;&gt;&lt;em&gt;Modern&lt;/em&gt; Static Typing: Less Code, Better Code&lt;/a&gt;, which was a rebuttal of Bruce Eckel's &lt;a href=&quot;http://mindview.net/WebLog/log-0025&quot;&gt;Strong Typing vs. Strong Testing&lt;/a&gt;.

&lt;/p&gt;

&lt;p&gt;

André's comments are very welcome, and make good reading. Of course I have some comments on the comments as well!

&lt;/p&gt;

&lt;p&gt;

&lt;blockquote&gt;

While it's possible to have such name clashes with different semantics, in reality I don't think it's a big problem: certainly one not worth spending a few paragraphs on in an article

&lt;/blockquote&gt;

I agree it probably doesn't happen all that often. On the other hand, isn't it better to be sure the right method always gets called, especially if the cost is low?

&lt;blockquote&gt;

It is very cool to program in a language which enables you to separate the code you write, from declaring how that code is used as part of your whole system design.

&lt;/blockquote&gt;

Yes, very cool indeed! I recently noticed &lt;a href=&quot;http://nice.sourceforge.net/cgi-bin/twiki/view/Doc/AspectOrientedMultiMethodExample&quot;&gt;an example by Isaac Gouy&lt;/a&gt; on the &lt;a href=&quot;http://nice.sourceforge.net/cgi-bin/twiki/view/Doc/WebHome&quot;&gt;Nice wiki&lt;/a&gt; which shows this off nicely. It shows how Nice can easily handle things that Aspect Oriented languages do (at least in some cases) by rewriting an example from the article &lt;a href=&quot;http://www-106.ibm.com/developerworks/library/j-aopsc/&quot;&gt;AOP banishes the tight-coupling blues&lt;/a&gt; in Nice.

&lt;blockquote&gt;

Haskell, which enables you to declare a type class to capture common functionality provided by different functions... This is the same idea as Nice's separation of code declaration vs interface declaration, though type classes are a far more powerful and generic concept.

&lt;/blockquote&gt;

I agree the features are very similar, but I'm not sure type classes are any more powerful and generic. I'll have to look into that in more detail before replying in full. 

&lt;blockquote&gt;

Objective-C's categories, which enable you to add new methods to existing classes. You don't like it how the NSFileHandle class doesn't have a method to create a new temporary file and return you a file descriptor for it? No problem, just add your own method to do that to the class no subclassing necessary. Categories are possibly the greatest thing I miss about Objective-C when I use any other language (Haskell included: it would be really cool to be able to extend type classes by adding new methods to them!).

&lt;/blockquote&gt;

This is a feature of most multi-method languages, Nice included. You can add any method to any class or interface at any time, even builtin classes like String. This is different from Haskell (or Java or C++, etc.). The key to understanding this is to stop thinking that classes &lt;em&gt;contain&lt;/em&gt; methods. In Nice, methods are free-standing objects in their own right. Interfaces are essentially just names, and each class is essentially just a name plus a structure. Create a new method which takes a certain interface as one of its parameters, omit the implementation, and you've just created a new constraint on the interface - anything that implements that interface must also be accompanied by an implementation of the new method. Or you can provide a default implementation (just like in Haskell type classes) and let people extend it as necessary. This is sufficiently different from the usual way of looking at things that I'm thinking of writing an article on the subject to explain it in more detail, with examples.

&lt;Blockquote&gt;

He remarks right at the end of his article that &quot;We need both strong testing and strong typing&quot; - I think he means static typing, not strong typing, considering that was what his entire article was about

&lt;/blockquote&gt;

Yes indeed! I was of course talking about static typing, I just phrased it that way to underscore the false dichotomy in the title of Bruce's article. Factual accuracy would probably have been a better choice. :-)



&lt;/p&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2004/jul/09/nice-database-api.html"><title>Thoughts on a Nice database API
</title><link>http://www.xoltar.org/2004/jul/09/nice-database-api.html
</link>
<description>      

&lt;p&gt;

Over at &lt;a href=&quot;http://www.lambda-the-ultimate.org&quot;&gt;Lambda&lt;/a&gt;, there's a &lt;a href=&quot;http://lambda-the-ultimate.org/node/view/76&quot;&gt;discussion&lt;/a&gt; going on about database abstraction layers. This is something that I think about from time to time, and lately I've been wondering what sort of database API we should have for &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt;.

&lt;/p&gt;



&lt;p&gt;

It seems to me there are (at least) two major design decisions to consider. First, how will one express queries, and second, what facilities does one want to provide for converting query results into objects and back. Both of these are very tricky indeed.

&lt;/p&gt;

&lt;h3&gt;Query Language&lt;/h3&gt;

&lt;p&gt;

Obviously, embedded SQL is a choice that's available. It has the advantage of simplicity of implementation, and people who know SQL will of course be able to use it immediately. I'd really like to be able to statically check the SQL against a database, so that means we have to make changes to the parser like SQLJ. 

&lt;/p&gt;

&lt;p&gt;

There are problems with SQL, though. For one thing, no two database vendors seem to deal with it the same way. So already we need some kind of abstraction layer, some sort of &quot;generic&quot; SQL that can be translated into vendor-specific SQL. Lots of systems for Java do this kind of thing already (though they are often hard to use, dynamically type checked, or both), and &lt;a href=&quot;http://schematics.sourceforge.net/schemeql.html&quot;&gt;SchemeQL&lt;/a&gt; and &lt;a href=&quot;http://haskelldb.sourceforge.net/&quot;&gt;HaskellDB&lt;/a&gt; may provide some inspiration.

&lt;/p&gt;

&lt;p&gt;There are also simple but important issues like naming to consider: I'd like to be able to write code that works with names like &quot;Employee_Manager&quot;, even though the database table's actual name might be &quot;emp_mgr&quot;, or even &quot;emp_mgr_join_table_23&quot;. So some sort of mapping facility is necessary, too. We haven't even gotten to the impedance mismatch headache yet, and already our work is cut out for us.

&lt;/p&gt;

&lt;p&gt;

Ideally, I'd like to have a facility that's more expressive than SQL. If the query/update that I've expressed turned out to be too complicated for a single SQL statements, then it would get translated into multiple SQL queries, or a stored procedure, or whatever is most appropriate (and efficient) for the target DBMS.

&lt;/p&gt;

&lt;h3&gt;Object Mapping&lt;/h3&gt;

&lt;p&gt;

First question is, do we even need one? When one has an object mapping, one tends to want to deal with objects exclusively, to forget there is a relational database out there at all. This can lead to problems such as out-of-date cached copies of objects, especially if the database has triggers which modify the data after the program has committed its transaction. Some Java tools try to address this problem by re-querying the objects that have just been committed, but this is a performance problem, because in many cases the objects won't actually be used again.

&lt;/p&gt;

&lt;p&gt;

Many times classes are designed to hold all the data that are relevant to a given concept. So an Employee will have a GivenName, a FamilyName, a TaxID, a Salary, one or more Managers, a HireDate, etc. However, in some cases we wish to deal with large numbers of Employees, and we don't actually need to use all these fields. Perhaps we only want to give pay raises based on their HireDate anniversary, so we don't actually need the names, tax ID, and so on. With an object mapping, you tend to get them anyway, which is wasteful of resources. Some systems let you specify that you only want certain attributes retrieved, and the rest are left as null (or zero or false, if they're primitives), but that means you have to remember that the Employee object is not &lt;em&gt;really&lt;/em&gt; an Employee object, and you had better not let references to it escape into parts of the program that expect fully loaded Employees, or you'll get lots of errors that don't make any sense. This problem is even more unacceptable in Nice, because the type system prevents undeclared null values, and so getting a NullPointerException is rare event indeed, usually stemming from imported Java code. So partial objects whose attributes are set to null if they're not loaded are really a nasty way of lying to the compiler. There has to be a better way. 

&lt;/p&gt;

&lt;p&gt;

An object mapping also encourages you (well, maybe not &lt;em&gt;you&lt;/em&gt;, but what about your most junior team member?) to implement &quot;give a 5% raise to each employee whose hire anniversary is today&quot; as (roughly):

&lt;pre&gt;

ObjectResultSet emps = connection.executeQuery(&quot;select * from emp&quot;);

while(emps.next()) {

	Employee emp = emps.get();

	if (isHireAnniversary(emp))

	   emp.setSalary(emp.getSalary() + emp.getSalary() * 0.05);

}

commit();

&lt;/pre&gt;

which is going to cause every employee in the database to be loaded into memory, which will either require a huge amount of memory, or else keep the garbage collector quite busy, depending on whether the implementation holds extra references to the queried objects or not. Even more importantly, it will require a huge amount of I/O. A better solution would be to implement isHireAnniversary at the database level, and offload that calculation onto the DBMS. A goal that would be really useful to achieve would be to have the code for running it in the application and the code for running it in the database look the same, so you could just say &quot;run this transaction here&quot; or &quot;run this transaction on the database server.&quot; Hey, I didn't say it would necessarily be easy!

&lt;/p&gt;

&lt;p&gt;

Another argument against an object mapping in Nice is that Nice already supports tuples! In Nice, the example above could be rewritten without objects like this:

&lt;pre&gt;

Iterator&lt;(int, Date, BigDecimal)&gt; emps = 

	connection.executeQuery(&quot;select id, hiredate, salary from emp&quot;);

for((id, hire, salary):emps) {

	if (isHireAnniversary(hire))

	   connection.update(&quot;update emp set salary = &quot; +

	   	salary + salary * 0.05 + &quot; where id = &quot; + id ); 

}

commit();

&lt;/pre&gt;

Of course, this trades better performance for more complicated code - you can't just call &quot;setSalary&quot;, you have to write an update statement. It also doesn't solve the I/O problem, but it does reduce it - we're not bringing back any fields that we won't even use anymore.

&lt;/p&gt;

&lt;p&gt;

One last gripe about object mappings: If you load an Employee, and then call &quot;emp.getManager().getDepartment().getDepartmentManager().getManager()&quot;, this will actually result in no less than four sequential trips to the database to load the next object in the chain. Argh!

&lt;/p&gt;

&lt;p&gt;

More ruminations next time, perhaps... Anyone have any good ideas they'd like to share?

&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2004/jun/30/nice-version-0.9.8.html"><title>Nice Programming Language 0.9.8 released
</title><link>http://www.xoltar.org/2004/jun/30/nice-version-0.9.8.html
</link>
<description>      

&lt;p&gt;

Version 0.9.8 of the &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice Programming Language&lt;/a&gt; compiler is now available. You can download it &lt;a href=&quot;http://nice.sourceforge.net/install.html&quot;&gt;from this page&lt;/a&gt;. Changes in this version include:

&lt;/p&gt;

&lt;pre&gt;

* Nice methods are now compiled inside classes whenever possible. This does

  not make any difference for Nice programs, but simplifies integration with

  Java tools and usage of Nice code from Java sources.

* Is is now possible to make a class of an imported package implement

  an interface defined in the current package, with:

    class some.pkg.ClassName implements MyInterface;

* Type parameters can always be qualified with nullness markers '?' and '!'.

  For instance, a class declaration can be

    class OptionalRef&lt;T&gt;

    {

      // The value might be null

      ?T value;

    }

* Allow calls to Java methods defined in a Java class that implements

  several Java interfaces declaring that same method, like

  java.io.ObjectOutputStream.flush()

* Reduced compilation time (about 20%) and memory consumption.

* Smaller generated bytecode.

* Fixed native compilation using gcj. It used to block when gcj produced

  too much output.

&lt;/pre&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2004/jun/21/lambda-has-moved.html"><title>Lambda the Ultimate has moved
</title><link>http://www.xoltar.org/2004/jun/21/lambda-has-moved.html
</link>
<description>      

&lt;p&gt;

&lt;a href=&quot;http://www.lambda-the-ultimate.org&quot;&gt;Lambda the Ultimate&lt;/a&gt;, the premier (IMHO) programming languages weblog, has moved from its former, horribly slow home. The new site is very responsive, a big step up.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/may/04/tbray-python.html"><title>How dynamic typing will save the world (not).
</title><link>http://www.xoltar.org/2004/may/04/tbray-python.html
</link>
<description>      

&lt;p&gt;

Tim Bray &lt;a href=&quot;http://www.tbray.org/ongoing/When/200x/2004/05/03/Pedroni&quot;&gt;waxes euphoric over Jython&lt;/a&gt;, and makes some broad generalizations about dynamic languages:

&lt;blockquote&gt;

If I had to cram it into one sentence: it's faster to write software in dynamic languages, and the (real) benefits you get from an anally type-sensitive compiler can be had more cheaply with modern testing disciplines.

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

Of course, I have to disagree with Tim here, you can't get &lt;em&gt;all&lt;/em&gt; the benefits of static type checking with modern testing disciplines. I've &lt;a href=&quot;http://www.xoltar.org/misc/static_typing_eckel.html&quot;&gt;written about this misconception&lt;/a&gt; before, back when &lt;a href=&quot;http://mindview.net/WebLog/log-0025&quot;&gt;Bruce Eckel wrote about it&lt;/a&gt;, and that refutation still stands.

&lt;/p&gt;

&lt;p&gt;My guess is Tim's also comparing &lt;em&gt;modern&lt;/em&gt; testing versus &lt;em&gt;ancient&lt;/em&gt; static type checkers. Hey, Tim - have you seen what advanced statically typed languages are doing with the JVM? How about &lt;a href=&quot;http://nice.sf.net&quot;&gt;Nice&lt;/a&gt;, or &lt;a href=&quot;http://scala.epfl.ch/&quot;&gt;Scala&lt;/a&gt;? They're both leaps and bounds ahead of vanilla Java, and definitely worth checking out.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/apr/27/icfp-2004-announcemnt.html"><title>The Seventh ICFP Programming Contest
</title><link>http://www.xoltar.org/2004/apr/27/icfp-2004-announcemnt.html
</link>
<description>      

&lt;p&gt;

&lt;a href=&quot;http://www.cis.upenn.edu/proj/plclub/contest/&quot;&gt;The Seventh ICFP Programming Contest&lt;/a&gt; has just been announced:

&lt;blockquote&gt;

Is your favorite programming language the best? Does it lead to better and faster programs? Does it make programs easy to write and modify? Are you and your friends the best programmers in the world?



Then prove it!



All programmers are invited to enter the contest, either individually or in teams. The contest offers  direct, head-to-head comparison of language technology and programming skill. We have a range of prizes including unlimited bragging rights for the winners. The prizes will be awarded at ICFP 2004 in Snowbird, Utah this September.

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

These are always a lot of fun. Choose your language, assemble your team, and get ready! The contest runs from June 4th to June 7th. And remember:



&lt;blockquote&gt;

The programming contest is being conducted by ICFP, which has a desire to promote functional languages. However, rather than debate the definition of a &quot;functional programming language,&quot; we will accept submissions implemented using &lt;i&gt;any language whatsoever.&lt;/i&gt;

&lt;/blockquote&gt;

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/apr/16/which-os-are-you.html"><title>It's all clear to me now.
</title><link>http://www.xoltar.org/2004/apr/16/which-os-are-you.html
</link>
<description>      

&lt;p&gt;

Via &lt;a href=&quot;http://patricklogan.blogspot.com/2004_04_11_patricklogan_archive.html#108196206599484357&quot;&gt;Patrick&lt;/a&gt; I found this quiz that tells you what OS best represents your personality.&lt;br/&gt;



&lt;a href=&quot;http://bbspot.com/News/2003/01/os_quiz.php&quot;&gt;&lt;img

src=&quot;http://www.xoltar.org/images/slackware.jpg&quot; width=&quot;300&quot; height=&quot;90&quot;

border=&quot;0&quot; alt=&quot;You are Slackware Linux. You are the brightest among your peers, but are often mistaken as insane.  Your elegant solutions to problems often take a little longer, but require much less effort to complete.&quot;&gt;&lt;br&gt;Which OS are You?&lt;/a&gt;



&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/mar/29/nice-type-inference.html"><title>Type Inference in Nice
</title><link>http://www.xoltar.org/2004/mar/29/nice-type-inference.html
</link>
<description>      

&lt;p&gt;

In the &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice&lt;/a&gt; CVS repository, Daniel's putting the finishing touches on a great

new feature: &lt;strong&gt;polymorphic type inference&lt;/strong&gt;.

&lt;/p&gt;

&lt;p&gt;

For a long time now, it's been possible to omit type declarations for monomorphic types (that is, types that aren't parameterized - like &lt;code&gt;String&lt;/code&gt;, or &lt;code&gt;int&lt;/code&gt;, but not &lt;code&gt;ArrayList&lt;/code&gt;). So you could do things like this:

&lt;pre&gt;

let name = &quot;Nice&quot;;

let version = 0.97;

&lt;/pre&gt;

and it would be just as if you had typed:

&lt;pre&gt;

let String name = &quot;Nice&quot;;

let float version = 0.97;

&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

Now, though, Nice supports &lt;em&gt;polymorphic&lt;/em&gt; type inference, which means that Nice can almost always figure out the right types for your variables, even the parameterized ones, without any help from the programmer:

&lt;pre&gt;

let list = new ArrayList();

list.add(&quot;A&quot;);

list.add(2); //Compile error!

&lt;/pre&gt;

The compiler can tell from the fact we added a string to the list, that the list can only contain strings. When we later try to add a number, we get a compile-time error. All without writing a single type declaration. This is a feature normally found in functional languages like &lt;a href=&quot;http://www.haskell.org&quot;&gt;Haskell&lt;/a&gt;, not often (ever?) in object oriented languages for the JVM.

&lt;/p&gt;



	



</description></item><item rdf:about="http://www.xoltar.org/2004/feb/28/bonniot-blog.html"><title>Creator of the Nice Programming Language gets a blog
</title><link>http://www.xoltar.org/2004/feb/28/bonniot-blog.html
</link>
<description>      

&lt;p&gt;

Daniel Bonniot, creator of the &lt;a href=&quot;http://nice.sourceforge.net&quot;&gt;Nice programming language&lt;/a&gt; has just started a new blog using the &lt;a href=&quot;http://www.jroller.com&quot;&gt;JRoller&lt;/a&gt; blog service. Head over to &lt;a href=&quot;http://www.jroller.com/page/dbr&quot;&gt;Daniel's blog&lt;/a&gt; and check it out. He's already got some interesting content there.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/feb/09/ideal-source-control.html"><title>An Ideal Source Code Management System
</title><link>http://www.xoltar.org/2004/feb/09/ideal-source-control.html
</link>
<description>      

&lt;p&gt;

I posted the notice about &lt;a href=&quot;http://abridgegame.org/darcs/&quot;&gt;darcs&lt;a/&gt; &lt;a href=&quot;http://lambda.weblogs.com/discuss/msgReader$11054?mode=topic&quot;&gt;over at Lambda the Ultimate&lt;/a&gt;, and it's turned into an interesting discussion of how source code management could change to deal with code a little bit higher level than it does now. Darcs takes some steps in that direction, but we can do more.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/feb/6/darcs.html"><title>darcs - a thoughtful replacement for CVS
</title><link>http://www.xoltar.org/2004/feb/6/darcs.html
</link>
<description>      

&lt;p&gt;

I thought I'd point out David Roundy's &lt;a href=&quot;http://www.abridgegame.org/darcs&quot;&gt;darcs&lt;/a&gt; (David's Advanced Revision Control System). It's basically a CVS replacement, written in Haskell, but the interesting thing about it is the &lt;a href=&quot;http://www.abridgegame.org/darcs/manual/node7.html&quot;&gt;theory of patches&lt;/a&gt; that David created. The blurb on that bit is below.

&lt;/p&gt;

&lt;p&gt;

One of the things that interested me was the token-rename patch. It's a patch that says something like 'change all the names &quot;Foo&quot; to &quot;Bar&quot; in this section of code', so the patch includes semantic information, not just a textual diff.

&lt;/p&gt;

&lt;p&gt;

I've been using automatic refactoring with IntelliJ IDEA for a while now, so the first thing that struck me was that revision control systems of the future might in fact deal more with refactorings than with diffs. I can imagine a patch like &quot;Perform Extract Method on method Foo from line 12 to 30, and rename the new 'bar' paramter to 'baz'.&quot; Food for thought.

&lt;/p&gt;



&lt;blockquote&gt;

Theory of patches

The development of a simplified theory of patches is what originally motivated me to create darcs. This patch formalism means that darcs patches have a set of properties, which make possible manipulations that couldn't be done in other revision control systems. First, every patch is invertible. Secondly, sequential patches (i.e. patches that are created in sequence, one after the other) can be reordered, although this reordering can fail, which means the second patch is dependent on the first. Thirdly, patches which are in parallel (i.e. both patches were created by modifying identical trees) can be merged, and the result of a set of merges is independent of the order in which the merges are performed. This last property is critical to darcs' philosophy, as it means that a particular version of a source tree is fully defined by the list of patches that are in it. i.e. there is no issue regarding the order in which merges are performed. For a more thorough discussion of darcs' theory of patches, see Appendix A.

&lt;/blockquote&gt;
</description></item><item rdf:about="http://www.xoltar.org/2004/jan/29/patrick-syntax.news.html"><title>Macro envy
</title><link>http://www.xoltar.org/2004/jan/29/patrick-syntax.news.html
</link>
<description>      

&lt;p&gt;

Patrick Logan &lt;a href=&quot;http://patricklogan.blogspot.com/2004_01_25_patricklogan_archive.html#107535307749574598&quot;&gt;writes&lt;/a&gt;:

	&lt;blockquote&gt;

I can only whine a bit in response to &lt;a href=&quot;http://blogs.msdn.com/ericgu/archive/2004/01/28/63957.aspx&quot;&gt;this desire to create new flow of control sytax&lt;/a&gt;.

&lt;br/&gt;

Yesterday I posted a new way to &lt;a href=&quot;http://patricklogan.blogspot.com/2004_01_25_patricklogan_archive.html#107526896309998964&quot;&gt;define functions and their tests contiguously&lt;/a&gt; using a new syntax in Scheme. It took about 10 minutes and less than 10 lines of code.

&lt;br/&gt;

Likewise in Lisp as well as Smalltalk defining new control structures is childs play, mainly because the control structures in those languages are defined using the very same mechanisms that are available to you, the dear programmer.

&lt;br/&gt;

Yes, I know, I am a loser to even bring this up.

       &lt;br&gt;&lt;br&gt;

	&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

Not a loser at all, Patrick! People need to be reminded of the power that macros (and first-class functions/blocks/etc.) bring to the table. I'm keeping my eye on &lt;a href=&quot;http://www.haskell.org/th&quot;&gt;Template Haskell&lt;/a&gt; and &lt;a href=&quot;http://www.cs.rice.edu/~taha/MetaOCaml/&quot;&gt;MetaOCaml&lt;/a&gt; (in addition to &lt;a href=&quot;http://www.plt-scheme.org&quot;&gt;PLT Scheme&lt;/a&gt;, of course). I think a macro/multi-staging facility is extremely important, and I'd love to add one into Nice when I have the time.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jan/26/nice-generator.html"><title>Nice generator library in CVS
</title><link>http://www.xoltar.org/2004/jan/26/nice-generator.html
</link>
<description>      

&lt;p&gt;

Just committed a new package into the Nice standard library: nice.functional. Currently it contains all sorts of methods for working with iterators and generators. All the same methods are defined for each, but the two styles reflect some of the philosophical leanings of Java and Nice.

&lt;/p&gt;

&lt;p&gt;

I use the word &quot;iterator&quot; to refer to &lt;code&gt;java.util.Iterator&lt;/code&gt;s, which can be seamlessly used in Nice without any special effort. I use &quot;generator&quot; to refer to a more functional version of iterators. A generator is simply a method that takes no arguments, and returns a new element each time it is called. When it has no more elements to yield, it calls &lt;code&gt;stop()&lt;/code&gt;. Here's a simple example:

&lt;pre&gt;

/**

 * A generator which yields natural numbers.

 */

()-&gt;int naturals() 

{

  var int num = 1;

  return (()=&gt;num++);

}

&lt;/pre&gt; 

&lt;/p&gt;

&lt;p&gt;

This method returns a generator which will yield consecutive integers starting with 1 and continuing forever (well, until &lt;code&gt;int&lt;/code&gt; wraps). The new generator library will let you do some interesting things with this generator:

&lt;pre&gt;

//return only odd numbers

let odds = naturals().filter(int n =&gt; n % 2 != 0);



//Add the first 10 numbers togther:

let sum = naturals().take(10).fold(0, (int acc, int n)=&gt; acc + n);



//Generate consecutively numbered filenames:

let fileNameGenerator = naturals().map(

	int n =&gt; &quot;backup_&quot; + n + &quot;.zip&quot;);



&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

One of the really nice things about generators, other than their general convenience, is that they let you deal easily with potentially infinite sequences of elements, and actually build only those elements you actually use. Lazy languages like Haskell make this their default mode of operation. That's not Nice's style, but it's a great tool to have available when you need it.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jan/22/nice-safety.html"><title>Type safety in Nice
</title><link>http://www.xoltar.org/2004/jan/22/nice-safety.html
</link>
<description>      

&lt;p&gt;

&lt;i&gt;Why programs written in Nice have less bugs&lt;/i&gt;

&lt;/br&gt;

Daniel Bonniot, the creator of the Nice language, wrote an &lt;a href=&quot;http://nice.sourceforge.net/safety.html&quot;&gt;overview of some of the safety properties of Nice&lt;/a&gt;. It's a good introduction to some of the problems that Nice and other languages with stronger-than-average type systems can solve.

&lt;/p&gt;
</description></item><item rdf:about="http://www.xoltar.org/2004/jan/21/nice-logging.html"><title>Better logging - how Nice!
</title><link>http://www.xoltar.org/2004/jan/21/nice-logging.html
</link>
<description>      

&lt;p&gt;

One of the things that often drives people crazy in Java is the question of logging. Java has great logging toolkits such as Log4J, the Apache Commons Logging framework, and others. However, there's a very basic problem with the language, which no mere library can circumvent: You want to put interesting things into the log messages, but you don't want to pay for them when you're not actually logging. With Java, your only choice is to wrap the logging code in &lt;code&gt;if&lt;/code&gt; statements, thus:

&lt;pre&gt;

if (DEBUG) {

	logger.debug(&quot;This manager has &quot; + 

		manager.getEmployees().size() + 

		&quot; employees&quot;);

}

&lt;/pre&gt;

&lt;/p&gt;

	

&lt;p&gt;

Of course, you could always skip the &lt;code&gt;if (DEBUG)&lt;/code&gt; protection, and many times that works. The people who design these systems try very hard to minimize the performance overhead of calling &lt;code&gt;debug&lt;/code&gt; when nothing's interested in collecting debug information. But that doesn't solve a more important problem. Sometimes, the arguments to the logging method (&quot;This manager..&quot;, above) are &lt;em&gt;expensive&lt;/em&gt; to evaluate, and without that &lt;code&gt;if&lt;/code&gt; statement, the arguments to the logging method always get evaluated, whether or not they get used. If, for instance, manager.getEmployees() involves a call to the database that wouldn't otherwise be needed, it's a big problem.

&lt;/p&gt;

&lt;p&gt;

&lt;a href=&quot;http://nice.sf.net&quot;&gt;The Nice programming language&lt;/a&gt; solves this problem neatly, with a clean syntax for anonymous methods which aren't associated with any particular class. So we change our API to allow us to pass a method instead of the actual string. Then, the logging function can decide whether to call the method and produce the needed string, or not. Here's how a rough first pass might look:

&lt;pre&gt;

logger.debug(DEBUG,

	()=&gt; &quot;This manager has &quot; + 

		manager.getEmployees().size() + 

		&quot; employees&quot;);

&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

The notation &lt;code&gt;()=&gt;...&lt;/code&gt; introduces an anonymous method which takes no arguments, and returns the value of the expression (...). This neatly solves our main problem of delaying evaluation of our string, while not introducing as much clutter as the &lt;code&gt;if&lt;/code&gt; statement did.

&lt;/p&gt;

&lt;p&gt;

Nice will let us make this even more ergonomic. First, let's make an obvious guess: 90% of the time, if we want debug information, we'll have the logging system configured for it. So we'll make the test condition that determines whether to evaluate the string or not be based on the logging system. We'll use Nice's default parameters to make this guess implicit, we can always change it at the call site if we need to. Here's what our implementation looks like so far, using Apache Commons Logging.

&lt;pre&gt;

void debug(Log logger, 

	  void-&amp;gt;String message,

	  &lt;b&gt;boolean when = logger.isDebugEnabled()&lt;/b&gt;)

{

  if (when) {

      info(logger, message());

  }

}



&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

All of the Apache Commons Logging methods also have overloaded versions which take throwables. We've got default parameters, so we'll just go ahead and accommodate that in the same method definition:

&lt;pre&gt;

void debug(Log logger, 

	  void-&amp;gt;String message,

	  &lt;b&gt;?Throwable err = null,&lt;/b&gt;

	  boolean when = logger.isDebugEnabled())

{

  if (when) {

      info(logger, message(), &lt;b&gt;err&lt;/b&gt;);

  }

}



&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

Finally, Nice allows an alternate syntax for parameters which are zero-argument methods - you simply make a block after the call, and write the code for the method in that block. So, our final, streamlined call looks like this:

&lt;pre&gt;

logger.debug() {

	return &quot;This manager has &quot; + 

		manager.getEmployees().size() + 

		&quot; employees&quot;;

}

&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

Problem solved! And we can do variations:

&lt;pre&gt;

logger.debug(&lt;b&gt;when: isTuesday()&lt;/b&gt;) {

	return &quot;This manager has &quot; + 

		manager.getEmployees().size() + 

		&quot; employees&quot;;

}

try {

	//...

} catch (Exception e) {

	logger.debug(&lt;b&gt;when: isTuesday()&lt;/b&gt;, &lt;b&gt;err: e&lt;/b&gt;) {

		return &quot;This manager has &quot; + 

			manager.getEmployees().size() + 

			&quot; employees&quot;;

	}

}

&lt;/pre&gt;



Much &lt;a href=&quot;http://nice.sf.net&quot;&gt;Nice&lt;/a&gt;r! A complete wrapper for the Apache Commons Logging library which uses this approach is available &lt;a href=&quot;http://www.xoltar.org/languages/nice/log.nice&quot;&gt;here&lt;/a&gt;.

&lt;/p&gt;
</description></item><item rdf:about="http://www.xoltar.org/2004/jan/20/scala.html"><title>The Scala Language
</title><link>http://www.xoltar.org/2004/jan/20/scala.html
</link>
<description>      

&lt;p&gt;

The programming language &lt;a href=&quot;http://scala.epfl.ch&quot;&gt;Scala&lt;/a&gt; has been released. It's an object-functional language which runs on the JVM and is compatible with Java. I haven't had time to try it yet, but here's the text of the announcement from xml-dev:

&lt;blockquote&gt;

We'd like to announce availability of the first implementation of the Scala programming language. Scala smoothly integrates object-oriented and functional programming. It is designed to express common programming patterns in a concise, elegant, and type-safe way. Scala introduces several innovative language constructs. For instance:

&lt;ul&gt;

&lt;li&gt;Abstract types and mixin composition unify ideas from object and module systems.&lt;/li&gt;



&lt;li&gt;Pattern matching over class hierarchies unifies functional and object-oriented data access. It greatly simplifies the processing of XML trees.&lt;/li&gt;



&lt;li&gt;A flexible syntax and type system enables the construction of advanced libraries and new domain specific languages.&lt;/li&gt;

&lt;/ul&gt;

At the same time, Scala is compatible with Java. Java libraries and frameworks can be used without glue code or additional declarations.



The current implementation of Scala runs on Java VM. It requires JDK 1.4 and can run on Windows, MacOS, Linux, Solaris, and most other operating systems. A .net version of Scala is currently under development.



For further information and downloads, please visit:



http://scala.epfl.ch 

&lt;/blockquote&gt;

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2004/jan/16/lexifi.html"><title>Financial contracts - commercial software in Caml
</title><link>http://www.xoltar.org/2004/jan/16/lexifi.html
</link>
<description>

&lt;p&gt;

Thanks to Oliver Lefevre's &lt;a href=&quot;http://lambda.weblogs.com/discuss/msgReader$10657?mode=day&quot;&gt;post on Lambda the Ultimate&lt;/a&gt;, we now know that a company called &lt;a href=&quot;http://www.lexifi.com&quot;&gt;LexiFi&lt;/a&gt; has written a product that evaluates and manages financial contracts, along the lines of &lt;a href=&quot;http://research.microsoft.com/Users/simonpj/Papers/financial-contracts/contracts-icfp.htm&quot;&gt;this paper by Simon Peyton-Jones&lt;/a&gt;. The product is implemented in &lt;a href=&quot;http://www.ocaml.org&quot;&gt;the functional language Caml&lt;/a&gt;. One more example of functional languages in the real world.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2003/dec/16/two-new-books.html"><title>Two interesting new books on computer science
</title><link>http://www.xoltar.org/2003/dec/16/two-new-books.html
</link>
<description>



&lt;p&gt; 

There are a couple of interesting books that have been released (relatively) recently. Peter van Roy, of &lt;a href=&quot;http://www.mozart-oz.org&quot;&gt;Oz language&lt;/a&gt; fame, and Seif Haridi have written a book called &lt;a href=&quot;http://www.info.ucl.ac.be/people/PVR/book.html&quot;&gt;Concepts, Techniques, and Models of Computer Programming&lt;/a&gt;. It's a general-purpose introduction to computer science and programming languages. It emphasizes a &quot;kernel language&quot; approach, where a wide range of programming language features are built up from a small set of carefully chosen primitives. The book also examines different programming language paradigms (functional, object oriented, logic, concurrent) and shows how they can be integrated.

&lt;/p&gt;

&lt;p&gt;

Shriram Krishnamurthi has just this morning released a PDF version of his textbook, &lt;a href= &quot;http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/&quot;&gt;Programming Languages: Application and Interpretation&lt;/a&gt;. I haven't read it yet, but the book has already been used at Brown as the textbook for a programming languages course, and Shriram is a smart guy with interesting things to say about programming languages, so check it out.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2003/dec/04/site-facelift.html"><title>Site upgrade for Mozilla users
</title><link>http://www.xoltar.org/2003/dec/04/site-facelift.html
</link>
<description>



&lt;p&gt; 

I've upgraded the site slightly, changed some of the colors, added drop shadows to the news items, etc. All well and good. Except it didn't work at all under Internet Explorer. So I had to make it all conditionally included to keep from warping IE's little non-standards-compliant brain. I'd love to support both equally, but I'm not a CSS whiz and I don't have the time. 

&lt;/p&gt;

&lt;p&gt;

If you have a Mozilla-based browser, and you have Javascript enabled, you get the new look. Otherwise, no changes.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2003/dec/04/impotence-of-functional.html"><title>Context, metadata, and zip()
</title><link>http://www.xoltar.org/2003/dec/04/impotence-of-functional.html
</link>
<description>



&lt;p&gt; 

Sjoerd Visscher &lt;a href=&quot;http://w3future.com/weblog/2003/11/11.xml#theImpotenceOfFunctionalProgramming&quot;&gt;writes&lt;/a&gt;:&lt;br/&gt;

[referring back to another article on the importance of context]

&lt;blockquote&gt;

I completely agree. In fact, it's exactly the issue I have with functional programming. Take for example the function zip (or zip3, zip4, exponential ugh-ness), a very popular function in f.e. Haskell. Firstly, if you have two lists, with values that go pairwise together, those values shouldn't have been apart in the first place. Secondly, what you end up with is a list of tuples. Values in a tuple always have more context than just being together. All this information is lost.

&lt;/blockquote&gt;

&lt;/p&gt;

&lt;p&gt;

It seems to me that zip provides a useful service. How is

&lt;pre&gt;

listOfTuples = zip(listOne, listTwo)

&lt;/pre&gt;

worse than this:

&lt;pre&gt;

listOfTuples = []

for i in range(min(len(listOne), len(listTwo))):

	listOfTuples.append(listOne[i], listTwo[i])

&lt;/pre&gt;



If this is going to be an argument against allowing anonymous tuples in a language, fine. I don't see what this has to do with functional languages or &lt;code&gt;zip()&lt;/code&gt;, though.

&lt;/p&gt;

&lt;p&gt;

&lt;blockquote&gt;

That this issue is completely lost on the functional programming world is very apparent from the research.

&lt;/blockquote&gt;

They're mostly focussing on structural typing, so this makes sense. 

&lt;/p&gt; 

&lt;p&gt;

&lt;blockquote&gt;

The holy grail seems to be a generic map on any data structure. But in practice any data structure more complex than a list, is bound to have some meta data. A generic map would map a function over the data and the meta data at the same time. That's almost never usefull. Obviously this encourages the use of a separate data structure for meta data, pulling that data out of context.

&lt;/blockquote&gt;

I don't think I follow this at all. Maybe examples would help.

&lt;/p&gt;

&lt;p&gt;

&lt;blockquote&gt;

XML has already a nice solution for this. XPath is a very simple syntax for building generators. Esp. the axes (ancestor::*,following-sibling::* etc.) are a nice way of iterating over XML in a specific way/direction. That way it's easy to map a function over a specific part of the data structure.

&lt;/blockquote&gt;

I'm still not getting it. What is it about functional programming that discourages traversing a data structure in a specific way or direction? I'm mostly confused here. Maybe Sjoerd will write some more (with examples :-), to explain what functional programming has to do with this. Is the argument just &quot;it's bad to use anonymous tuples instead of creating named classes/records/whatever?&quot;

&lt;/p&gt;

&lt;p&gt;

&lt;b&gt;Update:&lt;/b&gt; Sjoerd &lt;a href=&quot;http://w3future.com/weblog/2003/12/15.xml#providingContextInProgrammingpart1&quot;&gt;clarifies&lt;/a&gt;.

&lt;/p&gt;







</description></item><item rdf:about="http://www.xoltar.org/2003/dec/04/nice-reflection.html"><title>Smooth dynamic typing in Nice
</title><link>http://www.xoltar.org/2003/dec/04/nice-reflection.html
</link>
<description>



      

&lt;p&gt;In a &lt;a href=&quot;http://lambda.weblogs.com/discuss/msgReader$10211?mode=day&quot;&gt;post on Lambda The Ultimate&lt;/a&gt;, I mentioned Nice's capabilities for smoothly integrating static and dynamic typing. These are new, and not widely publicized, so I thought people might be interested. I wrote another example for the Nice discussion forum &lt;a href=&quot;http://sourceforge.net/forum/message.php?msg_id=2230259&quot;&gt;here&lt;a/&gt; (the thread starts &lt;a href=&quot;http://sourceforge.net/forum/forum.php?thread_id=948473&amp;forum_id=40268&quot;&gt;here&lt;/a&gt;).	

&lt;/p&gt;

	





</description></item><item rdf:about="http://www.xoltar.org/2003/oct/09/blogdom2.html"><title>Inching Toward Blogdom (again)
</title><link>http://www.xoltar.org/2003/oct/09/blogdom2.html
</link>
<description>

     &lt;p&gt;

	Well, I've finally found a news aggregator to use for the time being.

	It's &lt;a href=&quot;http://www.aggreg8.net&quot;&gt;Aggreg8&lt;/a&gt;, a Mozilla extension,

	which plugs nicely into my Mozilla Firebird so I don't have to have

	yet another tool running. 

     &lt;/p&gt;

     &lt;p&gt;

	This caused me to notice that Xoltar.org's newsfeed doesn't include

	the actual content of the articles in the feed, while other sites do.

	So I've fixed that now, enjoy.

     &lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2003/sep/09/haskellLoops.html"><title>Loops in Haskell
</title><link>http://www.xoltar.org/2003/sep/09/haskellLoops.html
</link>
<description>      

&lt;p&gt;

I noticed in &lt;a href=&quot;http://blogs.gotdotnet.com/emeijer/PermaLink.aspx/eb37226d-25d9-4a3c-bfe8-f26a1137ebc6&quot;&gt;Erik Meijer's blog&lt;/a&gt; a link to a &lt;a href = &quot;http://www.artima.com/weblogs/viewpost.jsp?forum=106&amp;thread=4550&quot;&gt;post Guido van Rossum made a few months back&lt;/a&gt; in which he asserted that looping was a higher level, more intuitive concept than recursion, and that Haskell was doomed to remain an academic language because it lacks looping constructs. 

&lt;/p&gt;



&lt;p&gt;

Well, if that's all that's missing, I'm here to help.

&lt;/p&gt;

&lt;p&gt;

&lt;pre&gt;

import Data.IORef



-- Define 'foreach'

foreach = flip mapM_



-- Define 'while'

while test action = do

  val &lt;- test

  if val then do {action;while test action}

         else return ()



-- Some helpers for use with 'while':

incr ref = modifyIORef ref (+1)

test ref f = do { val &lt;- readIORef ref; return (f val) }



-- Exercise them. Equivalent Python code:

-- for x in range(1,11): 

--     print x

-- i = 0

-- while i &lt; 5:

--     print &quot;Still running&quot;

--     i += 1



main = do

  foreach [1..10] print

  ref &lt;- newIORef 0

  while (test ref (&lt; 5))

        (do 

	  print &quot;Still running!&quot;

          incr ref)

&lt;/pre&gt;

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2003/sep/01/favicon.html"><title>Send a programmer to do a graphic artist's job...
</title><link>http://www.xoltar.org/2003/sep/01/favicon.html
</link>
<description>      

&lt;p&gt;

I belatedly noticed that I've never created the 88x33 pixel logo that's supposed to be used in news aggregators. I probably never noticed because I don't use one yet myself... Does anyone want to recommend a favorite? So, the icon is in place now. While I was at it, I made a favicon for the site, and added a gif version of the logo because it looked weird in IE. Blech.

&lt;/p&gt;

	



</description></item><item rdf:about="http://www.xoltar.org/2003/aug/13/templateHaskellTupleSample.html"><title>Template Haskell Example
</title><link>http://www.xoltar.org/2003/aug/13/templateHaskellTupleSample.html
</link>
<description>

&lt;p&gt;

&lt;a href=&quot;http://www.haskell.org/th/&quot;&gt;Template Haskell&lt;/a&gt; is a sophisticated 

macro system for Haskell. It is included with &lt;a href=&quot;http://www.haskell.org/ghc/&quot;&gt;GHC&lt;/a&gt; 6.0 and above. One of the first uses people are finding for Template Haskell is the ability to capture patterns that were previously beyond the scope of Haskell's type system. 

&lt;/p&gt;

&lt;p&gt;

One of the convenient things we do in Python (for instance) is to unpack

a list into a tuple like this:

&lt;pre&gt;

(foo, bar, baz) = list_of_stuff

&lt;/pre&gt;

now this, while convenient, is a mess from a typing standpoint, and 

Haskell's type system won't let you do it. But you could imagine writing

&lt;pre&gt;

let (foo, bar, baz) = (list_of_stuff !! 0, list_of_stuff !! 1, list_of_stuff !! 2)

&lt;/pre&gt;

to do the same thing, and that would work fine. With Template Haskell,

you can automate this sort of thing:

&lt;pre&gt;

let (foo, bar, baz) = $(tuple 3) list_of_stuff

&lt;/pre&gt;

Pretty cool.

&lt;/p&gt;

&lt;p&gt;

Here's the code for the tuple function:

&lt;pre&gt;

tuple :: Int -&gt; ExpQ

tuple n = [|\list -&gt; $(tup (exprs [|list|])) |]

  where

    exprs list = [infixE (Just (list))

		         (var &quot;!!&quot;)

		         (Just (lit (Integer (toInteger num))))

		    | num &lt;- [0..(n - 1)]]



&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;

More information:

&lt;ul&gt;

  &lt;li&gt;&lt;a href=&quot;http://www.haskell.org/th/&quot;&gt;Template Haskell home page&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href=&quot;http://www.haskell.org/hawiki/TemplateHaskell&quot;&gt;TH page on the Hakell Wiki&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href=&quot;http://www.haskell.org/mailman/listinfo/template-haskell&quot;&gt;TH mailing list&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;/p&gt;





</description></item><item rdf:about="http://www.xoltar.org/2003/aug/12/monadTutorial.html"><title>A Most Excellent Monad Tutorial
</title><link>http://www.xoltar.org/2003/aug/12/monadTutorial.html
</link>
<description>

&lt;p&gt;

Jeff Newbern has just released &lt;a href=&quot;http://www.nomaware.com/monads/html/&quot;&gt;an excellent tutorial on monads&lt;/a&gt; 

in Haskell. I've just read it and I have to say that I wish I'd had this when I was starting out in Haskell. 

It covers how to make monads, how to use them, a lengthy section on the monads that are already in

the standard library, and how to combine monads with monad transformers.

&lt;/p&gt;

&lt;p&gt;

The chapter on monad transformers was especially nice because (as far as I know) it's the only one of its kind.

If you're into Haskell but you've never quite gotten the hang of monads, this is for you.

&lt;/p&gt;

&lt;p&gt;

&lt;b&gt;Update:&lt;/b&gt; The link above seems to be dead now. I found at least one copy elsewhere on the net, try &lt;a href=&quot;http://www.lifl.fr/~boulet/formation/CALP/man/monads/html/&quot;&gt;here&lt;/a&gt; instead.

&lt;/p&gt;
</description></item><item rdf:about="http://www.xoltar.org/2003/aug/06/picoThreadsJava.html"><title>Picothreads - lightweight threading for Java
</title><link>http://www.xoltar.org/2003/aug/06/picoThreadsJava.html
</link>
<description>

&lt;p&gt;

In &lt;a href=&quot;http://www.xcf.berkeley.edu/~jmacd/cs262.pdf&quot;&gt;this paper&lt;/a&gt;, 

Andrew Begel, Josh MacDonald, and Michael Shilman present a program transformation for Java that produces a program which uses cooperative, user-level, lightweight threading instead of Java's usual heavyweight native threads. Generally Java programs can't have the massive concurrency that, say, Erlang can, because the memory (and task-switching) overhead of native threads is too great. These folks are hoping to fix that. I've only skimmed the paper so far, but I have to say this is my favorite quote so far:

&lt;/p&gt;

	



&lt;blockquote&gt;

We were unable to find a Java implementation fast enough to properly exercise our web crawler. Current implementations leave it CPU-bound, regardless of the threading model. Perhaps a better test would be to have many threads read files over the network without parsing them.

&lt;/blockquote&gt;
</description></item><item rdf:about="http://www.xoltar.org/2003/aug/04/rhinoCC.html"><title>Rhino gets continuations
</title><link>http://www.xoltar.org/2003/aug/04/rhinoCC.html
</link>
<description>



The folks at the Apache Cocoon project have &lt;a href=&quot;http://wiki.cocoondev.org/Wiki.jsp?page=RhinoWithContinuations&quot;&gt;re-worked the Rhino Javascript interpreter&lt;/a&gt; to include tail-call elimination and first-class continuations, best known from Scheme. Nifty. 
</description></item><item rdf:about="http://www.xoltar.org/2003/aug/04/haskellConcise.html"><title>Haskell even more concise than Python...
</title><link>http://www.xoltar.org/2003/aug/04/haskellConcise.html
</link>
<description>

&lt;p&gt;

My minimal blogging tool is currently written in Python, mostly because when I wrote it, I couldn't find an FTP client library for Haskell. Just for kicks, I decided to rewrite it into Haskell anyway, just to see how different the code would look. It turned out the Haskell version is noticeably shorter. This is interesting because when I've done microbenchmarks like those at &lt;a href=&quot;http://www.bagley.org/~doug/shootout/&quot;&gt;The Great Computer Language Shootout&lt;/a&gt;, they've always ended up about the same line count as their Python equivalents. In this project, it seems the slight differences are adding up. I've not finished yet, so I'll let you know how it comes out in the end, but so far I'm seeing that every function definition is a few lines shorter in the Haskell version, which leaves the totals at 416 LOC for the Python version and 353 for the Haskell version.

&lt;/p&gt;

&lt;p&gt;

They say that the productivity of programmers is constant in terms of lines per day, regardless of the language used. Does that mean we should all be using &lt;a href=&quot;http://www.kx.com/a/k/readme.txt&quot;&gt;the K language&lt;/a&gt;? At what point does concise expression conflict with readability? I think Haskell and Python are both doing fine, but can we get any more concise without making a mess? Anybody using K, J, or similarly terse languages out there care to comment? 	

&lt;/p&gt;

 
</description></item><item rdf:about="http://www.xoltar.org/2003/jul/29/blogdom.html"><title>Inching Toward Blogdom
</title><link>http://www.xoltar.org/2003/jul/29/blogdom.html
</link>
<description>

     &lt;p&gt;

     I'm slowly moving from manually maintaining this site to publishing with a weblogging

     tool I've cobbled together to serve my minimal needs. Today is the first time I'm publishing

     with an automated tool, to which I've added support for permalinks, archiving of old articles,

     and an RSS feed.

     &lt;/p&gt;

     &lt;p&gt;

     Most of the ideas in &lt;a href=&quot;http://mpt.phrasewise.com/2003/05/02#a507&quot;&gt;mpt's Ultimate Weblogging System&lt;/a&gt;

     sound pretty reasonable, so I'm using them as a rough guide. I'm using an ID for each article

     (which I make up), that appears as the ID of the &amp;lt;div&amp;gt; of the news article. To find an old article, you

     need the date, and the ID. So, for instance this item would be accessible as 

     &lt;a href=&quot;http://www.xoltar.org/2003/jul/29/blogdom.html&quot;&gt;http://www.xoltar.org/2003/jul/29/blogdom.html&lt;/a&gt;

     &lt;/p&gt;

     &lt;p&gt;

     Eventually I'll get around to building summaries by year, month, and category.

     &lt;/p&gt;

     &lt;p&gt;

     &lt;b&gt;Update:&lt;/b&gt; Added automated pinging of weblogs.com when the site is updated.

	&lt;br/&gt;

     &lt;b&gt;Update 2:&lt;/b&gt; Now my publishing tool works with news entries in a nice rfc2822 format. Aaah.

     &lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2003/jul/23/twoHaskellGUIs.html"><title>Two new GUI toolkits for Haskell
</title><link>http://www.xoltar.org/2003/jul/23/twoHaskellGUIs.html
</link>
<description>



&lt;p&gt; 

  In the past couple of days, two new, cross-platform GUI toolkits for Haskell have been announced: &lt;a href=&quot;http://wxhaskell.sourceforge.net&quot;&gt;wxHaskell&lt;/a&gt; and &lt;a href=&quot;http://htoolkit.sourceforge.net&quot;&gt;HToolkit&lt;/a&gt;. The wxHaskell toolkit is a Haskellized wrapper around the wxWindows cross-platform C++ GUI library, while HToolkit attempts to build a small common library of C code that will work with GTK or Windows, and then builds a Haskell layer on top of that.

&lt;/p&gt;

&lt;p&gt;

I haven't had a chance to play with HToolkit yet, but wxHaskell was really nice to work with. I sure do appreciate having decent Haskell GUI libraries (though still missing important things like grid controls) that will work on Windows. Next on my wish list: Oracle &amp; MSSQL interfaces, and getting sockets to work right with threads on Windows.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2003/jul/14/reflectionsOSCon2003.html"><title>Reflections on O'Reilly OSCon 2003
</title><link>http://www.xoltar.org/2003/jul/14/reflectionsOSCon2003.html
</link>
<description>

&lt;p&gt; 

Well, the second two days were better than the first. I learned to avoid the keynotes entirely, and I picked better sessions to attend. Interestingly, the most memorable ones were mostly social, not technical - discussions on geek volunteerism, and on what sorts of social contracts we should have for web services. There was also a very interesting presentation from someone (I missed his name) from a large financial firm explaining the sorts of software his company needs to run its business. I may focus on that one in particular in a few days.&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2003/jul/10/oscon2003.html"><title>O'Reilly OSCon 2003
</title><link>http://www.xoltar.org/2003/jul/10/oscon2003.html
</link>
<description>

&lt;p&gt; 

I'm at the O'Reilly Open Source convention this week, and I'm surprised to say I'm really unimpressed so far. I've been two only two other conventions before, one very large (JavaOne) and one smaller than this (the International Python Conference). Both conferences had a lot of energy that this one is missing. There were product announcements, interesting talks on new projects and technologies, it seemed like things were really happening. 

&lt;/p&gt;



&lt;p&gt;

Here, it seems there's nothing new under the sun. The talks have largely been uninspired and uninteresting, including today's keynotes. I did go to one talk on Tomcat clustering that had good information, and the one on the Jakarta commons was also decent. That was it for yesterday, hopefully today will be better.

&lt;/p&gt;

&lt;p&gt; This is also a conference that's clearly on a budget. Breaks consist of coffee only (no bagels, juice, fruit, anything like that), no breakfast, no lunch (except for the bag lunch yesterday provided by Microsoft). Even the vendors have stopped giving things away - t-shirts are $10 and up, and O'Reilly is trying to sell the leftover t-shirts and bags from previous years' conferences.

&lt;/p&gt;

&lt;p&gt;

One other thing: some of these rooms are &lt;em&gt;really&lt;/em&gt; small for the number of people attending. I'm writing this right now instead of attending a session because both of the sessions I was interested in this hour are overflowing into the hallway.

&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2003/jun/25/partialModule.html"><title>Partial application/curry module for Python
</title><link>http://www.xoltar.org/2003/jun/25/partialModule.html
</link>
<description>

&lt;p&gt;

By request, I'm releasing a draft of my partial.py module 

(as mentioned on my &lt;a href = &quot;http://www.xoltar.org/languages/python.html&quot;&gt;Python page&lt;/a&gt;), 

which does things like this:

&lt;pre&gt;

&gt;&gt;&gt; from partial import _

&gt;&gt;&gt; addWorld = _ + &quot; world!&quot;

&gt;&gt;&gt; addWorld(&quot;Hello,&quot;)

&quot;Hello, world&quot;



&gt;&gt;&gt; mapcall(_.upper, [&quot;list&quot;, &quot;of&quot;, &quot;strings&quot;])

[&quot;LIST&quot;, &quot;OF&quot;, &quot;STRINGS&quot;]

&lt;/pre&gt;



This is a work in progress, use at your own risk. I do not expect the interface to change at all but it

is not widely tested and there may very well be bugs. The module depends on updated

versions of other modules in the &lt;a href=&quot;http://www.sf.net/projects/xoltar-toolkit&quot;&gt;Xoltar Toolkit&lt;/a&gt;, 

so I'm releasing updated versions of them as well. I'm not making a Sourceforge release

because I haven't had time to do the sort of testing I'd like to do before making a release. At least

this way, you can try them out. If you find bugs, please report them and I'll fix them (though sometimes slowly).

Here's the documentation:

&lt;pre&gt;

    Void objects are stand-ins, blanks, or holes in an expression,

    which can later be filled in. For example:



    v = Void()



    add_one = v + 1



    Now add_one is a function which takes one argument, and returns the

    argument plus one. This module exports &quot;_&quot;, a single underscore, as

    an instance of Void, because it is suggestive of a blank or missing

    piece. Here are some more examples:



    import sys

    from operator import add



    adder = add(1,_)

    assert map(adder, range(3)) == [1,2,3]



    assert (_ + 5)(5) == 10

    assert (5 + _)(5) == 10

    assert (5 * _)(5) == 25

    assert (_ * 5)(5) == 25

    assert ((5 + _) * 5)(3) == 40, ((5 + _) * 5)(3)

    assert ((5 + _) * _)(3)(5) == 40

    assert ((5 + _) * _)(3, 5) == 40



    lst = []

    (_.append)(lst)(5)

    assert lst == [5], lst



    unsplit = [&quot;foo&quot;, &quot;ba ba&quot;, &quot;baz&quot;]

    postsplit = [[&quot;foo&quot;], [&quot;ba&quot;, &quot;ba&quot;], [&quot;baz&quot;]]



    assert mapcall(_.split, unsplit) == postsplit

    assert mapcall(None, map(_.split, unsplit)) == postsplit

    assert mapcall(_.split, unsplit, 'o') == [['f','',''], ['ba ba'], ['baz']]

    assert map(_ + 5, [1,2,3]) == [6,7,8]

    assert map(_['key'], [{'key':5}]) == [5]

    assert map(_[0], [(1,2,3),(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;), (10, 20, 30)]) == [1, &quot;a&quot;, 10]

    assert map(_[1:3], [(1,2,3),(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;), (10, 20, 30)]) == [(2,3), (&quot;b&quot;, &quot;c&quot;), (20, 30)]



    if sys.version_info[0] &gt; 2 or sys.version_info[1] &gt; 2:

        revtest = map(_[3:0:-1], [(1,2,3),(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;), (10, 20, 30)])

        assert revtest == [(3,2), (&quot;c&quot;, &quot;b&quot;), (30, 20)], revtest

    assert len(((_ + 2) * &quot;foo&quot;)(3)) == 15

    &lt;/pre&gt;

&lt;/p&gt;

&lt;b&gt;Download: &lt;/b&gt;

&lt;a href=&quot;http://www.xoltar.org/languages/python/partial.py&quot;&gt;partial.py&lt;/a&gt;

&lt;a href=&quot;http://www.xoltar.org/languages/python/functional.py&quot;&gt;funtional.py&lt;/a&gt;

&lt;a href=&quot;http://www.xoltar.org/languages/python/datastruct.py&quot;&gt;datastruct.py&lt;/a&gt;

</description></item><item rdf:about="http://www.xoltar.org/2003/jun/16/modernStatic.html"><title>&lt;em&gt;Modern&lt;/em&gt; Static Typing: Less Code, Better Code&lt;/h3&gt; &lt;center&gt;(or: How Java/C++/C# Ruin Static Typing for the Rest of Us)&lt;/center&gt;
</title><link>http://www.xoltar.org/2003/jun/16/modernStatic.html
</link>
<description>

&lt;p&gt;

In a recent piece called &lt;a href = &quot;http://mindview.net/WebLog/log-0025&quot;&gt;Strong Typing vs. Strong Testing&lt;/a&gt;, noted programmer and author Bruce Eckel makes an argument that dynamically typed languages such as &lt;a href=&quot;http://www.python.org&quot;&gt;Python&lt;/a&gt; are superior to statically typed languages such as Java and C++. I've done quite a bit of Python and Java programming, and even a little C++, so I can appreciate his position, but I think the conclusion goes too far. Whether Python is more productive than C++ or Java is one thing, whether static typing in general should be abandoned is quite another.

&lt;/p&gt;

&lt;a href=&quot;http://www.xoltar.org/misc/static_typing_eckel.html&quot;&gt;More...&lt;/a&gt;

&lt;p&gt;

&lt;b&gt;Update (12 JUL 2004):&lt;/b&gt; &lt;a href=&quot;http://www.xoltar.org/2004/jul/12/andre-pang-comments.html&quot;&gt;André Pang comments on the article&lt;/a&gt;.



&lt;/p&gt;

</description></item><item rdf:about="http://www.xoltar.org/2003/jan/15/backToNice.html"><title>Back to Nice
</title><link>http://www.xoltar.org/2003/jan/15/backToNice.html
</link>
<description>

      

&lt;p&gt; 	I've always been impressed with &lt;a href=&quot;http://nice.sf.net&quot;&gt;Nice&lt;/a&gt;,

an advanced object/functional language for the Java VM, 	and recently

I've been lucky enough to get to work with it again. Daniel Bonniot's

been busy improving his creation while 	I've been away. The main

improvements are the addition of Design By Contract, and big

improvements 	in the Java integration department. Nice now uses standard

Java collections without requiring 	import or modification, but you

still get Nice's much stronger type system. It also has a host of great

features 	like multi-methods, anonymous functions, default arguments,

etc. 	&lt;/p&gt;

	

&lt;p&gt; 	One of the things that's really cool about Nice is that it's based

on strong principles 	of type safety that improve the stability of the

code, but even though you get &lt;em&gt;more&lt;/em&gt; than Java 	offers, it takes &lt;em&gt;less&lt;/em&gt;

work to do it. There are a number of Java extensions which 	support

parametric polymorphism (aka &quot;generics&quot;) as Nice does, but Nice does a

lot more - look at the 	Nice solution for avoiding NullPointerExceptions

for example. Nice (unlike Java) makes a distinction between 	a type

that may be null, and one that may not be. So, if you want to allow

null Strings, you write ?String for the type. 	If you don't, you just

write String. You can't pass a ?String where a String is expected,

unless you 	can prove it's not null. How do you do that? With some

absurdly convenient Nice magic: 	&lt;/p&gt;

&lt;code&gt; &lt;/code&gt;

&lt;pre&gt;	void foo(String arg) {...}&lt;br&gt;	&lt;br&gt;	void bar(?String arg) {&lt;br&gt;		if (arg != null) {&lt;br&gt;			//Here Nice knows arg is not null, so it can &lt;br&gt;			// be passed to a method which takes a String!&lt;br&gt;			foo(arg);	&lt;br&gt;		} &lt;br&gt;		foo(arg); //Here arg may or may not be null, &lt;br&gt;			  //so Nice gives a compile error.&lt;br&gt;	}&lt;br&gt;&lt;/pre&gt;

	

&lt;p&gt; 	All of this means you never have to check that all your arguments

aren't null again, unless 	you actually want to allow nulls. 	&lt;/p&gt;



</description></item><item rdf:about="http://www.xoltar.org/2002/oct/17/haskellCSV.html"><title>A Haskell CSV parser
</title><link>http://www.xoltar.org/2002/oct/17/haskellCSV.html
</link>
<description>

&lt;p&gt;

Just added an example of Haskell in action - a comma separated value

(CSV) parser. Reads in a file and produces a list of lists of strings.

Supports embedded newlines, commas and quotes. Short and sweet. Here's

the &lt;a href=&quot;http://www.xoltar.org/languages/haskell/CSV.hs&quot;&gt;code&lt;/a&gt;. 

&lt;/p&gt;

&lt;p&gt;

&lt;b&gt;Update:&lt;/b&gt; Fixed the link to the CSV module, which was broken in the permalink version of this news item.

&lt;/p&gt;





</description></item><item rdf:about="http://www.xoltar.org/2002/sep/29/skinningHaskell.html"><title>Skinning Haskell
</title><link>http://www.xoltar.org/2002/sep/29/skinningHaskell.html
</link>
<description>      

&lt;p&gt;

One of the nicest things about Haskell is how much you can customize it

to suit your tastes.  For instance, maybe you've been using Python for a

while now and you've admired its uniform  notation for accessing

elements of all manners of sequences and mappings. When you switch  to

Java, it's likely to drive you crazy that you can't foo[0] an ArrayList,

only a plain old  array. You think &quot;Gee, foo.get(i) and foo[i] are

basically the same concept, it's a shame I have  to write it two

different ways&quot;. With Haskell, you can have all the type safety (and

much more)  that Java offers, with the uniform notation that Python

offers. &lt;a href=&quot;http://www.xoltar.org/languages/haskell/skinning_haskell.html&quot;&gt;More...&lt;/a&gt; 

&lt;/p&gt;

&lt;p&gt;

&lt;b&gt;Update:&lt;/b&gt; Fixed broken link in the permalink version of this story.

&lt;/p&gt;

     

</description></item></rdf:RDF>