[e-lang] choice of client-side for distributed application

Toby Murray toby.murray at dsto.defence.gov.au
Thu Jun 8 03:11:27 EDT 2006


John Carlson wrote:

>What I am trying to to do is to
>get someone to host a generic capability server that I can use as
>a database to support various applications.  
>  
>
I would suggest that you go download E and have a play with it. See what 
sorts of things it can do and whether it might suit your needs.
There has been a recent discussion on e-lang about hosting an E 
implementation on the web that would allow users to play with E from 
their web browser while also showing off its capacity to run 
untrustworthy code in a safe environment.
Other languages have similar sorts of on-line play environemtns designed 
to show themselves off to potential users.
You can also play with E by using the IRC bot on #erights on 
irc.freenode.net. Jump on there and type E code, prefixed with '?'.

>I do like the way that capabilities are passed around the network
>with web-calculus.   If E makes that invisible, maybe I should
>look at it more.   What is E's multiuser capability distribution system?
>  
>
I'm not sure I understnad the question. The word "multiuser" seems to 
indicate that you're thinking at a level of abstraction above that of 
E's model. E has no idea about "users" or "machines". E talks about 
"objects" hosted on "vats". For now, think of a "vat" as representing a 
single machine, although one machne can host multiple vats. From what I 
understand, a typical distributed E application (like your whiteboard) 
is implemented by a number of objects, each running on different vats, 
all talking to one another using method calls carried on capabilities 
(sometimes called references).

E has two sorts of inter-vat references. The first is a persistent 
reference (called a captp:// URL) that looks a lot like a YURL. The 
second is a non-persistent reference. These are opaque (in that the 
programmer is unaware of how they are implemented) and look like normal 
object references. Persistent references can't be invoked. You have to 
turn a persistent reference into a non-persistent reference before you 
can invoke methods on the object that the reference refers to.

Consider reading up on E. Particuarly Marc Stiegler's "E in a Walnut" 
http://www.skyhunter.com/marcs/ewalnut.html. Details of its 
implementation, philosophy and motivation appear in Mark Miller's PhD 
thesis "Towards Robust Composition" 
http://www.erights.org/talks/thesis/index.html. (which is a very 
enjoyable read, I found).

E has heaps of example code as well, which is a good help. I was able to 
knock up a distributed game in E using a Swing UI and a central server 
for maintaing game state within a couple days. I learnt a lot from 
looking at the "echat" application code that's distributed with E and 
googling bits of Walnut. Plus I'd already read the relevant papers for E 
that have been published over the last few years. Once you realise that 
you can write a capability-secure distributed application so quickly, E 
starts to look very cool. The fact that all you inter-machine comms is 
protected using strong self-authenticated crypto is hard not to like also.

I think you should be able to write a "server" for you whiteboard (that 
maintains a list lines that have been drawn on the board) quite quickly. 
You couuld probably even run this on the E IRC bot (unless it doesn't 
listen on port 3469 on the public net, which I suppose it might not). 
Then you could write a client that runs on you own machine and uses 
Swing for the UI. A good starting point might be Kevin Reid's Scribbler 
code that he posted a little while back.

>>/ #!/usr/bin/env rune
/>>/
/>>/ pragma.enable("easy-return")
/>>/ pragma.disable("explicit-result-guard")
/>>/
/>>/ # --- init
/>>/
/>>/ currentVat.morphInto("awt")
/>>/
/>>/ # --- definitions
/>>/
/>>/ def makeEPainter := <unsafe:com.zooko.tray.EPainter>
/>>/
/>>/ def catching(inner) {
/>>/   def catcher {
/>>/     match msg {
/>>/       try {
/>>/         E.callWithPair(inner, msg)
/>>/       } catch p {
/>>/         stderr.println(`$p${p.eStack()}`)
/>>/         null
/>>/       }
/>>/     }
/>>/   }
/>>/   return catcher
/>>/ }
/>>/
/>>/ def makeScribbleComponent(model) {
/>>/   var x := 0
/>>/   var y := 0
/>>/
/>>/   def scribbleC := makeEPainter(catching(def painter {
/>>/     to paintComponent(g) {
/>>/       for line :Tuple[int, int, int, int] in model {
/>>/         E.call(g, "drawLine", line)
/>>/       }
/>>/     }
/>>/   }))
/>>/
/>>/   scribbleC.addMouseListener(catching(def ml {
/>>/     to mousePressed(event) {
/>>/       x := event.getX()
/>>/       y := event.getY()
/>>/     }
/>>/     match _ {}
/>>/   }))
/>>/
/>>/   scribbleC.addMouseMotionListener(catching(def mml {
/>>/     to mouseDragged(event) {
/>>/       model.push([x, y,
/>>/                   x := event.getX(),
/>>/                   y := event.getY()])
/>>/       scribbleC.repaint()
/>>/     }
/>>/     match _ {}
/>>/   }))
/>>/   scribbleC.setPreferredSize(<awt:makeDimension>(300, 300))
/>>/   return scribbleC
/>>/ }
/>>/
/>>/ # --- application
/>>/
/>>/ def lines := [].diverge()
/>>/ def done
/>>/
/>>/ def frame := <unsafe:javax.swing.JFrame>("Scribble")
/>>/ frame.setContentPane(makeScribbleComponent(lines))
/>>/
/>>/ frame.addWindowListener(catching(def mainWindowListener {
/>>/   to windowClosing(event) :void {
/>>/     done__Resolver.resolve(null)
/>>/   }
/>>/   match _ {}
/>>/ }))
/>>/
/>>/ frame.setLocation(50, 50)
/>>/ frame.pack()
/>>/ frame.show()
/>>/
/>>/ interp.waitAtTop(done)

/

It's a standalone whiteboard but it wouldn't be all that difficult to 
have 'lines' as a remote object that all clients updated as they each drew.
In fact, the code probably wouldn't change at all, except that the app 
would start with a captp:// URL that it then converted to a remote 
reference to 'lines'. Also, the immediate sends to 'model' would have to 
be changed to eventual sends. (Sorry, the prevous sentence won't make 
much sense unless you've read up on E a bit).
The point being, I think you'd be pleasantly surprised at how quickly 
you could get your app up and running with E.

-- 
Toby Murray
Advanced Computer Capabilities Group
Information Networks Division
DSTO, Australia

IMPORTANT: This e-mail remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the
Crimes Act 1914. If you have received this e-mail in error, you are
requested to contact the sender and delete the e-mail.



More information about the e-lang mailing list