URLs as Pointers

One: Every once in a while I'll be re-entering some little piece of information, for instance, my name, address and telephone number, and I'll think, this should just be stored somewhere for me so I can use it like a variable. It should be available anywhere in any package I'm working in. In fact, in any language I'm working in. I should be able to update some resource with all my information and the places that depend on it should just update. If I change my email address, it should update on on my blog, on twitter, everywhere.

Two: Git and Github have changed the way software folks learn and work. Now if you need some functionality, you just pull and start using it. Code is a resource, and it can be executed, but it requires you to pull it down and run it. What if code could be executed in place on Github?

This is just for fun, so don't get out your red pens yet:

Imagine a programing language that didn't store your data in memory addresses when it ran, but it stored them at www urls, grabbing the source out of your source file and PUTting at your domain on the web. And when it dereferenced it, it just ran a GET on that url. If you PUT some executable code at a url, you would be able to POST to it with some data as args. And you could take that response and POST it somewhere else.

A session might look like this.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
> PUT /first-name
> Justin

> PUT /last-name
> Donato

> PUT /phone-number
> 718-555-5555

> PUT /email-address
> example@example.com

// At this point, imagine that post, get and put are functions in this language that make HTTP requests

> PUT /full-name
> get('first-name') get('last-name')

> PUT /business-card
> get('full-name')
> get('phone-number')
> get('email-address')

> GET /business-card

< Justin Donato
< 718-555-5555
< example@example.com

> GET /raw/business-card

< get('full-name')
< get('phone-number')
< get('email-address')

> PUT /posts
> []

> PUT /push
> function(l, atom) {
>     return l.push(atom)
> }

> POST /push
> get('posts')
> { title: "A Title, body: "Lorem ipsum" }

< [{ title: "A Title, body: "Lorem ipsum" }]

// Making HTTP requests by hand my be tiring. A 'compiler' could execute code like this:

put('/posts', post('/push', get('/posts'), {title: "Second post", ...}))
put('/posts', post('/push', get('/posts'), {title: "Third post", ...}))
put('/posts', post('/push', get('/posts'), {title: "Fourth post", ...}))

> PUT /head
> function(l, num) {
>     return l.slice(0, num)
> }

> POST /blog-index-ctx
post('/head', '/posts', 3)

> GET /blog-index-ctx
< [{title: "Second post", ...}, {title: "Third post", ...}, {title: "Fourth post", ...}]

> PUT /blog/template
> ... some template fn ...

> PUT /templatize
> function(tpl, ctx) {
>     return tpl(ctx)
> }

> PUT /blog
> post('/templatetize', get('/blog-index-ctx'))
> get('business-card')

> GET /blog

< A Title
< Lorem Ipsum

< Second Post
< ...

< Justin Donato
< 718-555-5555
< example@example.com

On top, we could build a syntax, and when I "run" a program, it PUTs and GETs all my functions and data and applies them with POSTs. I can create an entire web of functions and data and string them together with HTTP. You could use my functions and data. I could use yours.

1
2
3
4
PUT /fork
function(from, to) {
    put(to, get(from));
}

2013-08-10