[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how small is lightweight?



At 3:58 PM -0700 4/9/03, Steve Dekorte wrote:
>On Wednesday, April 9, 2003, at 03:14 PM, Christopher Dutchyn wrote:
>>I notice that you attempted to use the "minimal language" by excluding
>>libraries and extensions, but did you use the "minimal implementation" as
>>well?  I recall Gregor Kiczales' comment during the Vancouver Institute
>>talk, to the effect that "a complete implementation of PCL is less than
>>10KLOC, but an efficient implementation is more than 300KLOC".  Given wiggle
>>room of 1.5 orders of magnitude, all your examples may potentially be in the
>>same equivalence class by size.
>
>Hi Christopher,
>
>That's a good point. I'm more interested in a practical definition 
>than a theoretical one though. As in, can I download this language 
>from an official site and compile and do real work with it without 
>hassles on a small device with X(being small) amount of memory? I 
>choose lines of source because it's easy to measure and seems to be 
>a reasonable (though obviously not ideal) predictor of the answer to 
>that question.

The only problem with going with code size alone for a language is 
that, at some point, you end up with BF. As an example:

a BF interpreter signature by Eric Bock

/* Eric */main(s,i,j,k,c){char*p=malloc(s=1),*a=p+(*p=i=j=k=0)/* Bock */
;while(~(*a=getchar())&&(++a-p<s||(a=(p=realloc(p,s+s))+s)&&(s+=s))||(*a
=0));for(a=malloc(s=1),*a=0;(c=p[i])&&(c=='+'&&++a[j]||c=='-'&&--a[j]||c
=='>'&&(++j<s||(a=realloc(a,s+s))&&memset(a+s,0,s)&&(s+=s))||c=='<'&&j--
||c=='.'&&~putchar(a[j])||c==','&&~(a[j]=getchar()))|!strchr("><.,",c);i
++)while((c=='['&&!a[j]||c==']'&&a[j])&&(k+=(p[i]=='[')-(p[i]==']'))&&p[
i+=c/* Brainf*** */=='[']&&(/* worse than */i-=c==']'/* this sig! */));}

Or, if you're looking for a smaller, albeit somewhat more limited version:

A Bf interpreter signature

char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r;
r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c==
'+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(2,p,1),c-','||read(2,p,1));}

Dunno, but I think even RMS would be hard-pressed to wedge a Lisp 
implementation into three lines of C (or its equivalent) code...
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk