Lecture
A tuple space is an implementation of the associative-memory paradigm for parallel/distributed computing. It provides a repository of tuples , which can be accessed concurrently. As an illustrative example, consider a group of processes that produce data, and a group of processes that consume that data. Producers place their data in the form of tuples in the space, and consumers then retrieve from the space the data matching a particular pattern. This is also known as the blackboard metaphor . A tuple space can be regarded as a form of distributed shared memory .
Tuple spaces formed the theoretical basis of the Linda language , developed by David Gelernter and Nicholas Carriero at Yale University in 1986.
Implementations of tuple spaces have also been developed for Java ( JavaSpaces ), Lisp , Lua , Prolog , Python , Ruby , Smalltalk , Tcl and the .NET Framework .

Object spaces are a paradigm for developing distributed computing applications. It is characterized by the existence of logical entities called object spaces . All participants of a distributed application share an object space . A service provider encapsulates a service as an object and places it in the object space . Clients of the service then query the object space , find out which object provides the required service, and get their request handled by that object.
The object-space paradigm as a computing concept was proposed in the 1980s by David Gelernter at Yale University . Gelernter developed a language called Linda to support the concept of global coordination of objects.
An object space can be regarded as a virtual store used by providers and consumers of network services, which are themselves abstracted as objects. Processes interact with each other using these shared objects, updating the objects' state as needed.
After an object is placed in the object space, it must be registered in that space's object directory . Any process can then identify the object in the object directory , using a search by properties, where the property defining the search criterion for the object is its name or another property that uniquely identifies it. If the required object is not yet present in the object space , the process can wait for it to be placed there .
Objects placed in the object space are passive, meaning their methods cannot be invoked while the objects are in the object space . Instead, the accessing process must retrieve the object from the object space into its local memory, use the service provided by the object, update the object's state, and place it back into the object space .
This paradigm inherently provides mutual exclusion . Since once an object has been accessed it must be removed from the object space and returned to it only after it is released. This means that no other process can access the object while it is being used by one process, which provides mutual exclusion.
JavaSpaces is a service specification that provides a mechanism for distributed exchange of objects and coordination (which may or may not be persistent) for Java objects . It is used to store the state of a distributed system and to implement distributed algorithms . In a JavaSpace all participants in the data exchange (nodes) interact and coordinate their actions by sharing state.
JavaSpaces can be used for scalability through parallel processing, as well as to provide reliable storage of objects via distributed replication, although it will not survive a complete power outage the way a hard disk will; many consider it reliable as long as the power supply is stable. Distribution can also be carried out to remote servers; however, this is rare, since JavaSpaces are usually used for low-latency, high-performance applications rather than for reliable object caching.
The most common software design pattern in JavaSpaces is the “master-worker” pattern. The master submits units of work into the “space”, and workers read, process, and write them back into the space. In a typical environment there are several “spaces”, several masters and many workers; workers are usually designed to be general-purpose, meaning they can take any unit of work from the space and process the task.
JavaSpaces is part of the Java Jini technology, which itself did not achieve commercial success. [ 1 ] Over the years the technology has found and retained new users, and some vendors offer products based on JavaSpaces. JavaSpaces remains a niche technology, used mainly in the financial sector and the telecommunications industry, where it continues to retain a devoted following. The announcement of Jini/JavaSpaces caused quite a stir, although Sun co-founder and Jini chief architect Bill Joy stated outright that this dream of distributed systems would represent a “ quantum leap in thinking ”. [ 2 ]
The following example demonstrates an application built using JavaSpaces. First, an object to be shared in the object space is created . In JavaSpace terminology, such an object is called an Entry . Here, Entry is used to encapsulate a service that returns the string "Hello World!" and tracks the number of times it has been used. The server providing this service creates an object space , or JavaSpace . The Entry is then written into the JavaSpace . The client reads the entry from the JavaSpace and calls its method to access the service, updating the usage counter in the process. The updated Entry is written back into the JavaSpace .
// An Entry class
public class SpaceEntry implements Entry {
public final String message = "Hello World!";
public Integer count = 0;
public String service() {
++count;
return message;
}
public String toString() {
return "Count: " + count;
}
}
// Hello World! server
public class Server {
public static void main(String[] args) throws Exception {
SpaceEntry entry = new SpaceEntry(); // Create the Entry object
JavaSpace space = (JavaSpace)space(); // Create an Object Space
// Register and write the Entry into the Space
space.write(entry, null, Lease.FOREVER);
// Pause for 10 seconds and then retrieve the Entry and check its state.
Thread.sleep(10 * 1000);
SpaceEntry e = space.read(entry, null, Long.MAX_VALUE);
System.out.println(e);
}
}
// Client
public class Client {
public static void main(String[] args) throws Exception {
JavaSpace space = (JavaSpace) space();
SpaceEntry e = space.take(new SpaceEntry(), null, Long.MAX_VALUE);
System.out.println(e.service());
space.write(e, null, Lease.FOREVER);
}
}
A tuple space really does resemble all of the following at once:
But there are important differences.
1. There is “data in storage”
("enemy", "orc", 100)
2. There is a “query”
("enemy", ?, ?)
This is reminiscent of SQL:
SELECT * FROM enemies WHERE type = 'orc';
A tuple space resembles:
Because:
1. In a database, programmers do a “query and get a copy”
SELECT → the data stays in the table
2. In a Tuple Space you “take and remove” (with in)
in(("enemy", ?, ?)) → the data disappears from the space
That is, this is more like:
“took a task from the shared pool”
In a database:
table enemies(id INT, type TEXT, hp INT)
In a tuple space:
you can put anything:
("enemy", 10)
("chat", "hi")
(42, true, "abc")
There is no strict structure.
Database:
Tuple space:
A very precise analogy
A tuple space is:
“a database + a task queue + pattern search + the ability to take data away for good”
| Property | Database | Cache | Tuple space |
|---|---|---|---|
| SQL queries | + | sometimes | - |
| strict schema | + | sometimes | - |
| pattern search |
partially / depends on the specific implementation |
- | + |
| removal on read | - | - | + (in) |
| distributedness |
partially / depends on the specific implementation |
partially / depends on the specific implementation |
+ by design |
| asynchrony of processes |
partially / depends on the specific implementation |
partially / depends on the specific implementation |
foundational |
Thus
Database = a table with data
Cache = a fast dictionary
Tuple space = “a shared table where physical tasks lie, and anyone can pick up the one that suits them”
Comments