April 09, 2003

So what is "Pure X" anyway?

Which is the question that's been wandering around behind the scenes. Posting the closure and continuation entries has lead me to a bunch of places on the web that I'd never have gone to otherwise (it's weird the places things get noted) and amongst the .NET folks there was some noting of "Well, what about S#"?

S# is a version of Smalltalk for .NET, by David Simmons of SmallScript fame.

Now, David's a darned smart guy, and he's done a lot of interesting stuff. I've heard him speak at a number of conferences, most recently at OOPSLA '02, where he talked about the stuff he's done to get smalltalk running on .NET. Which he's done. But...

Most of his talk was how he subverted .NET with add-on code to actually do what he wanted. The S# compiler doesn't generate code that will run on a stock .NET system--you have to have the add-on executable library pieces that he wrote to get around the limits of .NET's design (some of those limits were intentional, which is fine) and S# programs won't run as trusted code because they call out to DLLs outside the .NET core.

Basically, he cheated. Which is fine. I rather like cheating. But is it really pure .NET code?

The same is true of Java. If you use the Swing UI, is it pure Java? Swing sure as heck isn't written in Java. It's C.

And the same is true of Perl. DBI is terrifically cool, as a database interface, but does code that uses it count as pure perl? DBI, and the DBD drivers that connect to specific databases, is written in C.

Where do you draw the line? (Is it even a meaningful line to draw?) What' counts as pure? Is it pure if the only non-language code you execute is the VM? Is it OK if the only non-language code you execute ship with the language runtime? Is it OK if the only non-language code you execute is just written by someone else?

Does using SDBM_File (which ships with perl) still leave you with code that counts as pure perl? How about DBI, if you installed it from CPAN? What about using Inline::Python? Is it still pure perl if you're yanking in the damn python interpreter?

I dunno. I'm not sure I actually care, so much as care whether the code runs under certain circumstances. If it's a standalone "executable" for a VM, the question is more whether it works under a certain mode (trusted/untrusted) or across platforms (in which case embedding x86 code's an issue). But still... there's always that call, no matter how faint, for "pure X code!"

Oh, and for the record, since I mentioned his name, I do owe David an apology--I told him at LL1 that I didn't think that a portable, cross platform JIT was possible. He disagreed,and turns out he was right. Sorry, Dave. (so I suppose he might pull this one off, but it didn't sound that way at OOPSLA....)

Posted by Dan at April 9, 2003 04:17 PM | TrackBack (0)

Maybe you're thinking of AWT? Swing is indeed pure Java code. You can tell because you can install it on a Java 1.x JVM just by adding a .jar file.

And even if it weren't, I would still call a program using it "pure" Java because it's part of the Java platform, and is supposed to be there and perform the same on all platforms where Java works.

But, for example, I would say that Eclipse is NOT "pure" Java since it depends on SWT, which is custom native code.

Posted by: Steve Minutillo at April 9, 2003 04:46 PM

Nope, I'm thinking of Swing. Call me crazy, but I always call out to the system UI server/library/code to put bits up on the screen. (Yeah, I know, but I'm old-fashioned :) The JVM doesn't have, last I looked, generic callout facilities, which means that something has to be interfacing to the system. Might be that Swing is just living on top of AWT, which is fine--at least something useful'd be coming out of it.

The point is taken, and it actually makes things muddier, because what counts as a 'requirement for the platform' for something like perl, python, or ruby that isn't productized the same way that Java is?

Posted by: Dan at April 9, 2003 04:55 PM

By that logic, the set of "pure" programs would be very very small. Ultimately you'll have to call the system code to do just about anything more interesting that computing the Fibonacci sequence. (for example, just printing the sequence to STDOUT requires some system calls).

For Perl, or other scripting languages I'd call something "pure" if it runs on the "standard" installation + "standard" (core?) modules. This probably is not as well defined as I like to pretend it is, though.

Posted by: steve at April 9, 2003 05:05 PM

True enough, it is potentially very limiting, depending on the VM. (And in this case it'd the JVM) OTOH, I don't have a problem with not counting required libraries as tainting the "pure X"--certainly doesn't bother me to count an AWT-using program as pure Java if AWT's a required component. That's fine.

The question's more one in a larger context--does it count as "pure X" if you have to have a native library installed that provides functionality that the X runtime doesn't, or that actively subverts some of the X VM's facilities?

Posted by: Dan at April 9, 2003 05:53 PM

Hmm... I'll say if you need a native lib installed, it's not pure. But, if it subverts the VM in a way that will work across all implementations of that VM, then it's still pure.

Posted by: steve at April 9, 2003 06:04 PM

If you can subvert the VM without using outside code, it's not really subversion... :)

Posted by: Dan at April 9, 2003 07:23 PM

Actually, there is a Pure Perl DBI. It's included as part of the main distribution these days.


I think that there are also Pure Perl DBD's, too.

Just a small point. :-)


Posted by: Dominic Mitchell at April 10, 2003 07:54 AM