Skip to content

Design Philosophy

The Problem with Traditional Code Mobility

Modern distributed systems require seamless code mobility—the ability to send executable code across network boundaries, store it in databases, and reconstruct it in different runtime environments. Traditional approaches face fundamental challenges:

1. Serialization Complexity

Most languages require complex serialization frameworks (e.g., pickle, protobuf) that are brittle, version-dependent, and often insecure.

2. Runtime Dependencies

Serialized code often depends on specific runtime versions, libraries, or execution contexts that may not be available on the receiving end.

3. Security Vulnerabilities

Deserializing code can execute arbitrary instructions, creating significant attack vectors.

4. Platform Lock-in

Serialization formats are often language-specific, preventing cross-platform code sharing.

The JSL Solution

JSL solves these problems by making JSON the native representation for both data and code. This design enables powerful properties for network-native programming. The core language is purely functional and safe, while interactions with the host system are reified as data and controlled through a programmable, capability-based environment model.

Theoretical Foundations

Homoiconicity

Like classic Lisps, JSL is homoiconic, meaning code and data share the same representation. However, instead of S-expressions, JSL uses JSON—a universally supported and standardized format.

Key Benefits:

  • No Parsing Ambiguity: JSON has a precise, standardized grammar.
  • Universal Tooling: Every major language and platform can handle JSON.
  • Network Transparency: Valid JSON travels safely across all network protocols.
  • Human Readability: Code can be inspected and modified with standard text tools.

Verifiable, Serializable State

Handling closures (functions that capture their lexical environment) is a primary challenge in code mobility. JSL solves this with a content-addressable storage model that elegantly handles circular references and makes program state verifiable, efficient, and safely serializable.

  • Content-Addressable Objects: Every complex object (closure or environment) is identified by a unique hash of its contents. Objects are stored in a hash table and referenced by their content hashes, naturally handling circular references.
  • Serializable Closures: A closure is serialized as a JSON object containing its parameters, body, and a reference to its captured environment. The environment reference uses the content-addressable format {"__ref__": "hash"}.
  • Efficient Sharing: Identical objects share the same hash, avoiding duplication and creating an efficient storage model for complex object graphs.
  • Format Versioning: The serialized payload includes __cas_version__ to enable format evolution while maintaining backward compatibility.

This architecture ensures that a serialized JSL program can handle arbitrarily complex object relationships while remaining a verifiable, self-contained unit of computation.

Wire-Format Transparency

Every JSL value can be serialized to JSON and reconstructed identically in any compliant runtime. This enables:

  • Database Storage: Store executable code with ACID properties.
  • HTTP Transmission: Send functions using standard web infrastructure.
  • Cross-Language Interoperability: Leverage JSON's universal support.
  • Audit Trails: Create reproducible records of code execution.
  • Version Control: Use standard JSON diff/merge tools to manage code.

Practical Applications

1. Distributed Computing

Send computations to where data resides, rather than moving data.

["lambda", ["data"], 
  ["filter", 
    ["lambda", ["record"], ["=", ["get", "record", "status"], "active"]], 
    "data"]]

2. Edge Computing

Deploy and update logic on edge devices dynamically.

["lambda", ["sensor_reading"],
  ["if", [">", "sensor_reading", 75],
    ["send-alert", "High temperature detected"],
    ["log", "Normal reading:", "sensor_reading"]]]

3. Database Functions

Store and execute business logic directly in databases.

["lambda", ["user_id", "new_status"],
  ["host", "db/update", "users", 
    {"id": "user_id"}, 
    {"$set": {"status": "new_status"}}]]

SICP-Inspired Design

JSL follows the elegant principles outlined in "Structure and Interpretation of Computer Programs":

  • Simplicity: Everything is built from a small set of primitives (atoms, lists, functions).
  • Composability: Complex operations are created by combining simple ones.
  • Abstraction: Higher-level concepts are built on lower-level foundations.
  • Uniformity: A consistent evaluation model applies throughout the language.
  • Extensibility: New capabilities are added through composition, not special cases.

This approach creates a language that is both theoretically elegant and practically useful for distributed computing.