"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Saturday, January 19, 2008

Premature Capitulation

The new thing is "gradual typing"...

I always like to know the origin of a name. In this case, gradual refers to the idea that in a gradually typed language, you can gradually add type annotations to what is otherwise a dynamically typed program.
Sounds like you need better tools (they pretty much stink for Python and Ruby, try Smalltalk or Lisp) and perhaps a better compiler (ditto). Doubtful you need "gradual typing".

Wednesday, January 16, 2008

More on "stable layers" regarding efficient dynamic languages

Another data point on the idea of languages implemented in layers, consider this... ("why you should care as a programmer about the study of programming languages")... (pdf)... Dan Friedman's talk at UNAM, Mexico, on April 27, 2001... quoting his student Jonathan Sobel:

“That was the amazing part: I had produced a program that I could not have written, and in any case would not have wanted to write.”
Sobel wrote a program in a simple, direct style using Scheme and then applied several transformations, from Scheme to Scheme, each a fairly simple transformation. The final transformation was ready to be translated into a C program using another simple transformation.

The efficient C program does not have to be maintained. Just the original, simple Scheme program. Probably programming in C itself (or Java or Scala) is a kind of premature optimization.

On the concept of a "stable layer"

Ola Bini writes about the concept of a "stable layer" for language implementations, especially (I gather) where the "stable layer" is underneath a "dynamic language" used by application programmers. I am using quotes because these terms do not have to my knowledge widely accepted, rigorous definitions. That's OK, coming to a common understanding of these terms is part of it.

I interpret his use of "stable layer" as perhaps an "implementation layer", what is used to implement the language one truly wants to use. Maybe they are the same language. If you want to program in Java or in Scala, then it would seem in these terms, the stable and the "top" (?) layer are one and the same.

CPython, CRuby, Jython, and JRuby have as "stable layers": C, C, Java, and Java, respectively. But this arrangement is not necessary for dynamic languages generally. My understanding is PyPy is implemented in Python and Rubinous is implemented in Ruby. (Excuse me if I messed that up a bit.)

As a couple of other data points on suitable languages for a "stable layer" consider the implementations of Squeak Smalltalk and Gambit Scheme. Both of these languages are implemented in subsets of themselves. Both of those subsets compile to C primarily to avoid implementing special translators for each instruction set architecture they run on.

Those subsets (of Smalltalk and Scheme) are essentially as efficient as C. But they are each "dynamic languages". And the stability of both implementations can be measured now in *decades*, regarding how long they've been around, used in "real" systems. Gambit in particular having very good performance because *any* application code can be compiled this way, and Squeak could take this same approach if desired.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.