Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
/ protocall Public archive

protocall is an experimental programming language

License

Notifications You must be signed in to change notification settings

google/protocall

protocall is an experimental programming language. This is not an official Google product. The purpose of protocall is to explore a number of programming approaches with the goal of making distributed systems easier to develop.

Protocall adopts a number of philosophical principles:

  1. Simplicity, Flexibility, and Experimentation are the primary goals of protocall. Performance and security are (for now) non-goals.

  2. Protocall programs are expressed using Google Protocol Buffers. Entire programs, statements, identifiers, and types are all represented using a simple protocol buffer schema. Programs and all data can be serialized, deserialized, and manipulated using the protocol buffer API outside of the language.

  3. The protocall runtime is a simple VM that executes protocall protocol buffers.

  4. While simple, the language contains primitive types, arrays, structured types, variables, conditionals, loops and functions. Structured types in protocall can be any protocol buffer type. This includes the protocall protocol buffer schema, making programs that write programs (or modify themselves) trivial.

  5. Calls to remote services that speak protocol buffers over gRPC are especially simple: they look just like function calls that take Request arguments and return a Response. Similarly, implementing gRPC services that speak protocol buffers is also trivial.

  6. The language delegates nearly all additional functionality to external libraries- the standard library is a collection of external libraries, with a small syntactic sugar layer on top. Making calls to foreign functions is trivial.

  7. Because writing programs directly in protocol buffers is tedious, protocall provides an interpreter (with a REPL). The interpreted language, SeeThruP0, resembles Python and LISP and transliterates to protocall. Rather than attempting to make the protocall language include more features (such as syntactic sugar), users are encouraged to implement the language functionality at the interpreted level, and implement the runtime functionality as libraries in the protocall VM.

A simple SeeThruP0 session looks like this. Lines starting with "#" are commentary about what is happening. Lines starting with "> " are user commands. The interpreter prints the result of evaluating each line.

# Assign the integer value 5 to the identifier 'x'
> x = 5;
literal {
  integer {
    value: 5
  }
}

# Call the function "print_", with the value of the identifier 'x' in this scope
# bound to a local variable 'x' within the function.  The print_ function returns None.
> print_(x=x);
x: 5

None

The assignment statement above is expressed in protocall as:

statement {
  assignment {
    identifier {
      name: "x"
    }
    expression {
      atom {
        literal {
          integer {
            value: 5
          }
        }
      }
    }
  }
}

The print statement is expressed in protocall as:

statement {
  call {
    identifier {
      name: "print_"
    }
    argument {
      identifier {
        name: "x"
      }
      expression {
        atom {
          identifier {
            name: "x"
          }
        }
      }
    }
  }
}

A simple SeeThruP0 program with a loop.

{
  x=5;
  while (x > 0) {
    print_(x=x);
    x = x - 1;
  };
}

A simple program to compute Fibonacci numbers. This demonstates scoping, function definition and conditionals.

{
  define f {
    if (x == 0) {
      return 0;
    }
    elif (x == 1) {
      return 1;
    }
    else {
      a = f(x=x-2);
      b = f(x=x-1);
      return a+b;
    };
  };
  return f(x=5);
}

SeeThruP0 uses { and } for scoping- program, function and conditional body. Each scope induces a new local variable space. Arguments are passed to function by copy; use return values to communicate.

TODO(dek):

  • documentation
  • proto type/assignment support
  • better proto type support (various ints)
  • FFI support
  • RPC support
  • namespaces
  • interpreter multi-line support
  • imports of other files

About

protocall is an experimental programming language

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published