A presentation by Robin Upton ( ) latest version at Attribution – NonCommercial - ShareAlike FF 404 : Decentralised F 2 F Programming in 4 Minutes Decentralised Programming v1.0
(1)Decentralised Programming. WWW as Distributed Programming C C C C C C C S distributed.net = Distributed, Centralised Calculations are performed by many CPUs, but directed by a single authority. Friend2Friend.net = Distributed, Decentralised Each computers in F2F network has unique local data & instructions. None has special privilege. F F F F F F F Distributed programs may still be centrally controlled.
Sites: code data code data code data code data WWW as Distributed Programming Clients Send Data Websites have unique instructions and data stores... Clients send data to one site at a time Clients:
Clients Send Data. Servers Return Data Users input data through browsers and pass it to websites: decentralization
Servers Return Data Code ≠ Data Websites receive data, carry out instructions, return data to clients
Code ≠ Data 'Code' = XML = 'Data' function f2fError($text, $nodename='error') { // Example of usual source code $err= new DOMDocument(); $errnode=$err->createElementNS(nsF2F, $nodename, $text); $err->appendChild($errnode); return $err; } to be processed by trusted code. Untrusted data is dynamically input... Most programming languages cannot treat data as code.
'Code' = XML = 'Data' (2) How to Program F2F In F2F, programs, instructions and data share a common format: XML F2F data streams can embed instructions, allowing for rich interaction. i.e. Sites can dynamically script other sites. F2F service, coded in XML arbitrary XML...
(2)How to Program F2F. Hello World Service F2F servers are XML virtual machines. Input, output & internal workings are XML. Although required, the namespace is omitted for brevity from this point on. All instructions to F2F servers take the form: etc.
XML Stylesheet Language Transformations v is a 1999 W3C recommendation!... is a programming language expressed in XML.... transforms one XML document into another.... ‘side-effect free’, so cannot write files/send messages/ etc.
Hello-World Service. Processing Service Requests We start by requesting the service: So this is implemented by the XSL template at hello.xslt The F2F server finds the matching service definition: Unique identifier Location on disk
Passing Arguments The XSL transforms it to an Output Document: The itself is the script’s Input Document: Hello World! Processing Service Requests Hello World!
Passing Arguments Nested Servicereqs Many languages pass a comma separated list of input parameters to a function: function browse($uri, $width, $height) {...instructions here, in which $uri, $width and $height are replaced at run time by the values of the arguments given... } browse(“ 130, 500) <!-- Transform here, which operates on the whole XML document --!> F2F passes an XML document:
Nested Servicereqs. Processing Directives browse(“ getwidth(), getheight()) By default, F2F starts with the deepest : Evaluation is usually from inside out: <!-- Transform here, which gets the width. --!> <!-- Transform here, which gets the height. --!> <!-- Transform here, which operates on the whole XML document --!>
Tree-shaped Pipelines Nested items results in pipelining XML: Nested Servicereqs = Pipelined XML The interior outputs XML......which is fed into the exterior... XSL ex.1 XSL ex.2 XML pipelining is taking the input from one transform and feeding it into another:
Core Services The model allows trees of transforms. Tree-shaped Pipelines XSL 2B XSL 3 3b 3a XSL 2A 3c 2b XSL 1A XSL 1B 1a 2a22a1 1b
Saving Instructions About 80 hardcoded (non-XSLT) services extend the possibilities. e.g: Core Services Send/Receive Read/Write XML data Read/Write the F2F Server Read/Write Files to disk
F2F scripts use XSLT, extended with about 100 extra core functions. Nested items pipeline XML data & instructions. F2F servers are general purpose XML virtual machines. F2F servers are designed to form decentralised networks....