|
Namespaces, environments
Eric got me
interested in Plan
9, especially it's 9P protocol (see The use of name
spaces in Plan 9 and The organization
of networks in Plan 9).
The synopsis is that Plan 9 treats everything as either a file or a
collection of files. If you want a program (or script) to interface on
a network socket, rather then using calls like socket() and bind(),
you open files in directory specified by convention. This is really
interesting in that when you are creating a new programming language,
you only have to import the system calls for interacting with the file
system (~13 if i understand correctly), and your new language can
interact and control _any_ of the system devices, network, etc. 9P is
a simple protocol that implements these file system interfaces over a
simple channel. Plan 9 also has per process filesystem name spaces;
each process can mount/bind to change its view of the filesystem.
With a network channel and 9P it can mount a file system from another
computer. The remote computer's file system includes all of its device
files though, so if our process binds the portion of its file system
implementing networking, for example, our process has essentially
gained the ability to proxy through that computer. Since all system
interactions are done through the files system, with proper permissions
anything can be used remotely!
I've been thinking more about capability based languages and operating
systems. From my understanding, such a system can be built on scope: if
code only has access to what it has been given (which should be only
what it needs), and if there is no global/static state including library
calls granting it access to such, then it is secure.
Between Plan 9 and capabilities, namespaces are apparently quite an
important topic. So important that... why shouldn't they be first class?
Searchings doesn't turn up an overwhelming amount of material on first
class namespaces. First off, mit and umb schemes apparently have first class
name spaces. They have a 'make-environment' call, and an optional
argument to the eval function, specifying an environment. Not
real exciting.
On the other end of things, there's Symmetric Lisp, which completely
remolds lisp with first class namespaces. Interestingly, things
like structures, classes, modules or packages, closures, and even
streams can be modeled using these namespaces! The final surprise
is that they get parellelizable code for free! (see Environments
as first class objects and A programming
language supporting first-class parallel environments)
Finally, Erlang make concurrency
incredibly simple. They have a function like primitive that you wrap
your function call in. The primitive runs that function as a separate
process (possibly on a separate computer) and returns a handle which
can then be used to pass messages. It makes concurrent programming
incredibly simple.
Now, if i could only make a capability based language with first class
concurrent environments.
[2005.05.19 05:10] |
[articles/technical] |
#
|