Scope: A Web Programming Language To-Be

Spencer Lockhart
2 min readJul 29, 2018

--

Hi, I’m Spence and I’ve started an experiment I’d like to share with web developers.

Scope is a language under development for Web Application development. Scope is unique because:

  • It combines server-side and client-side code into a single code base.
  • It has a built-in XML type.
  • Automatic server-client 2-way socket bindings behind the scenes.
  • A scope type that can be a class, function, and/or a method.
  • Lispy: Everything is an expression or list of expressions; But like JavaScript, Scope looks more like C than Lisp.

What’s Scope look like?

Scope is released Open Source under the MIT license, and is available on NPM and GitHub.

The base language is pretty well done, but the libraries are hardly started. There’s no way (7/29/2018) to create a server or client yet, but a proposed way resembles this (which I posted earlier as a reply on reddit):

let server = httpServer((client: []) {
client.socket.on("buttonClick", {
client.find("#serverEmits").text("Message from Outer-space");
});
client.response.send(site);
});
let tellServer = (e: []) {
server.socket.emit("buttonClick");
};
let button = <button onClick=tellServer>
"Click me";
</button>;
let site =
<html>
<head>
<title>Example Site</title>;
</head>;
<body>
<div id="serverEmits"></div>;
button;
</body>;
</html>;

This would be a simple server that sends the XML-type value “site” to the client. When the button is clicked, the server receives a message for the “buttonClick” tag, and then sends a socket message back to the client that modifies an element with the ID “serverEmits”, causing a message to appear above the button that says “Message from Outer-space”.

The above code should make sense for traditional web developers. A proposed way to abstract I/O:

let server = httpServer((client: []) {
public message = "";
public repeatText = (data: "") {
message = data;
};
client.response.send(site);
});
let txt = <input type="text" bindIn=server.repeatText />;let site =
<html>
<head>
<title>Example Site</title>;
</head>;
<body>
<div bindOut=server.message"></div>;
txt;
</body>;
</html>;

Now it’s a bit different. When text input is changed, the server updates the `message` property. Because the div is bound to that same message property, whenever `message` is changed the client updates it’s inner-html with the value of server.message.

In Scope, the proposed client and server are two different things that communicate to each other- just like in web application development today. All Scope brings to the table is a very simple programming language where one designs the client and server in one program instead of two.

What else needs to be done?

  • Libraries are needed right away
  • A repository for public libraries, and a package manager
  • A test-case, tutorials/education materials, and better documentation
  • A community of supportive people like you!

--

--