Thursday, May 31, 2007

Scheme/Erlang interoperability - an idea

Would it be cool to be able to send and receive messages to an Erlang node from Scheme (or vice versa)?

For Java-based Scheme systems (Kawa, SISC), one could build something on top of jinterface. It is a high-level Java API for doing exactly that. With some macrology, it would not be too hard to come with something useful. For C based systems, there is erl_interface, though it's a much lower level API. But no real showstopper.

Of course, it would not be possible to send/receive objects other than lists, tuples, atom, numbers, i.e. the basic Erlang objects, but that could be a good starting point.

What do you think? Would that be useful?

Wednesday, May 30, 2007

Portable Termite

I heard, from trusted sources, that a portable implementation of Termite is underway. I won't give names, to protect the innocents, but trust me, we'll hear more about that this summer (or at the end of it).

This implementation will also support signed message passing. This means that a system will only be able to receive messages from trusted sources. THAT is interesting.

You'll be able to connect together different Scheme applications, developed using different Scheme systems. Will this be a way to re-unite the Scheme community?

What do you think? Is it a better approach than providing a common packaging infrastructure? I tend to believe it.

Tuesday, May 29, 2007

Tuple space implementation - The API

This article is the first in a series that will describe my implementation of a simple-minded tuple space in Termite Scheme and show how Scheme is well-suited (or not, we'll see) for this task.

In this article, I will present the main concepts of a tuple space, as well as the high-level API that will be used to interact with the tuple space.

Concepts

A tuple space is an associative, shared memory. There are basically three operations on tuple spaces: put, read, and get. The put operation, as its name implies, writes a new object (a tuple) in the tuple space. The read operation tries to retrieve a tuple from the tuple space that matches a given pattern (blocking if none exists), but leaves the object in the tuple space. The get operation is like the read operation, except that it removes the tuple from the tuple space.

One important point to note is that all tuples put in (or read from) the tuple space are identified by a tag. That's why the tuple space is an associative memory.

High-level API

My approach in designing a new library is usually to start from the perspective of the user of the library. In other words, I first try to write some test code that will use the library (akin to what we do in TDD). So what would those three primitives (put, read, get) would look like in Scheme?

The easiest one is put, of course. To put a tuple in the tuple space, it will be sufficient to have procedure tspace-put!:
(tspace-put! 'tag expr-1 expr-2 ... expr-n)


In the case of read and get, things are a little more complicated. First, most tuple space implementations (like Linda) allow variables to appear in the pattern. It would be nice to replicate that. In Linda (C), read would look like:
rd("tag", ?var1, ?var2);

This statement reads a tuple and also defines two variables, var1 and var2. In the subsequent expressions/statements, the variables var1 and var2 can be used. But in Scheme, even a macro cannot introduce a variable that would be accessible from subsequent expressions (unless it expands in set! expressions mutating already defined variables).
The Scheme way of doing things is to add extra expressions to the read/get form:
(tspace-read (tag var1 var2) 
expr-1
...
expr-n)

But then, the tspace-put! seems a little odd. It would be best to write:
(tspace-put! (tag expr-1 expr-2 ... expr-n))

This would be more consistent with the syntax of tspace-read and tspace-get.

Note that since tspace-put!, tspace-get, and tspace-read make no assumption at all on the representation of tuples. That's a good thing. And the sign of a good API.

The API is thus composed of three syntax forms:
(tspace-put! (tag expr-1 expr-2 ... expr-n))
(tspace-read (tag pat-1 pat-2 ... pat-n)
expr-1 ... expr-n)
(tspace-get (tag pat-1 pat-2 ... pat-n)
expr-1 ... expr-n)

where tag is a symbol, and pat-1 to pat-n are pattern elements, i.e. either a variable (symbol), or a constant (number, string, character, or quoted Scheme constant).

The other functions of the API are:
(tspace-connect node)
(tspace-disconnect)

to connect to a tuple space on node node and to disconnect from a tuple space.

What do you think? How can this API be improved?

Next steps

That's it for today. In the next article, I will show the implementation of the client API. This will involve some macrology and show the true power of Scheme in this respect.

Monday, May 28, 2007

Erlang Style Message Passing for SISC

Ben Simon has implemented Erlang Style Message Passing for SISC. The system has a number of limitations, of course. But that's a nice starting point.

Saturday, May 26, 2007

Startup culture in Montreal

A startup culture is developing rapidly in Montreal. I've been following some startup-related blogs for a few months now, and my conclusion is that something is cooking. Here are a few highlights:
  1. Many past and upcoming events;
  2. Local entrepreneurs meet regularly at the Montreal Tech Entrepreneurs Breakfast;
  3. Some well-known VC firms now have offices in Montreal (like Garage, Guy Kawasaki's capital fund);
  4. A new wiki on startups has been launched.

Combine this with the growing interest in dynamic, non-mainstream languages, as witnessed by the following facts:
  1. The Scheme User Group attracts about 20 people at each meeting, but I estimate to 35-40 the number of people who come to our meetings at least once a year;
  2. At our previous meeting (on Erlang), a lot of new faces show up at the MSLUG, and some of them mentioned they're working on new startup ideas;
  3. There is a good concentration of good Scheme developers who work on great, innovative tools: Gambit-C, Termite, JazzScheme, Snow.

Will Montreal become a small Silicon Valley?

Friday, May 25, 2007

Last night meeting

Here are a few pictures from the MSLUG's last night meeting.


Marc Feeley talks about Snow:


Part of the audience (we were about 20 Scheme enthusiasts):


We finished the night at the pub:
(I am the guy with the red shirt, at the right of the picture)


Here we see Marc Feeley, Danny Dubé (author of SILex), and Étienne Bergeron.

Wednesday, May 23, 2007

Scheme programmer wanted at GrammaTech

Here! Here!

Monday, May 21, 2007

JazzScheme on Gambit-C

Work has begun (or will begin shortly) on porting the JazzScheme platform to the Gambit-C Scheme system, which will speed up the porting of JazzScheme to Mac and Linux/X11.

Combine this effort with Termite and we'll soon have a formidable platform for developing Scheme-based distributed/concurrent applications.

Tuesday, May 08, 2007

Why Google ads

You may wonder why I added Google ads to this blog. Retiring from my day job is clearly not my goal. In the past month, I earned 1.12 dollars from Google AdSence! Since they send checks only when you reach 100$, this will be in 9 years at this pace...

No, the real reason is that Nü Echo will eventually launch a corporate blog on which I will collaborate on a regular basis, and I want to experiment with all the new technologies and tools that are used in the blogosphere. Google AdSense is one of them, as well as Google Analytics, Technorati, etc.

PLT Scheme Blog: Macros Matter

The guys from PLT-Scheme have launched a new blog. Their first post is about what distinguishes their work: Macros

Tuple spaces for Termite

A few weeks ago, Patrick Logan suggested, in a comment on a previous post, that a tuple space would be a nice addition to Termite.

In short, a tuple space is an associative, shared memory. There are basically three operations on tuple spaces: put, read, and get. The put operation, as its name implies, writes a new object (a tuple) in the tuple space. The read operation tries to retrieve a tuple from the tuple space that matches a given pattern (blocking if none exists), but leaves the object in the tuple space. The get operation is like the read operation, except that it removes the tuple from the tuple space.

These ideas have been introduced by David Gelernter in the Linda language. There are implementations of this idea in many languages.

A few days ago, I started working on a simple implementation of tuple spaces using Termite's concurrency/distribution primitives. It's not that difficult to come up with a very naïve implementation. But the devil is in the details. I will summarize the results of my experimentations here in the next weeks. Stay tuned!

Snow by example

At our next meeting of the Montreal Scheme/Lisp User Group, scheduled for May 24th, Marc Feeley (the author of Gambit-C), will talk about its new initiative, the Snow framework.