Introducing MAML: A Modest Proposal for HTML6

Update: Get involved on GitHub or Slack.

MAML is the Multipurpose Abstract Markup Language.  It is simple, easy-to-parse data format that is still sufficiently rich to simultaneously replace HTTP, HTML, JavaScript and CSS. As a declarative language MAML is not Turing complete, but is circuit universal (able to represent any Boolean circuit).  In fact, because is it is based on the Presburger arithmetic of finite bitfields – rather than the usual Peano axioms – it is simultaneously consistent and complete, avoiding both Gödel incompleteness and the halting problem.

 

The Universal Data Structure

The central insight of MAML is that all data structures – and most programming languages! – have the form (in pseudo-code):

construct:
    name1: metadata1;
    name2: metadata2;
    data1,
    data2,
    data3

This structure, which we call a frame, is used by, e.g.:

Frames act as a universal property list, incorporating aspects of both dictionaries and arrays. All values in MAML are frames, providing a uniform mechanism for iterating over and extracting both keyed metadata and positional data.

In addition, all frames are also:

  • Scoped: inheriting context from their parent construct
  • Callable: allowing dynamic evaluation in the context of an argument list
  • Composable: as both data-like keypaths and code-like expressions
  • Effect-typed: with strict rules limiting access, assignment, and mutation

MAML Syntax

MAML is unusual in that it has no keywords or special forms.  There are a few enough primitives that they can be uniquely identified by prefix sigils.  All functionality, including conditionals and iterators, are ordinary values defined in and inherited from the root Global Object Domain (G.O.D.).

Tokens

MAML uses a dot sigil (‘.’) to explicitly distinguishes between the name and value of a variable, unlike most languages which implicitly distinguish between the left and right sides of an assignment.

  • Values:  variable, CONSTANT
    • Numeric: 123, 0b11, 0x890abc, 0sBase64
    • Date: %2016-01-31%
  • Names: .variable, .CONSTANT
  • Controls: @error, @return, @exit, @etc.

Operators

Operators are just non-alphanumeric names. MAML provides a handful of pre-built operators in the G.O.D.:

  • if: ‘?’
  • else: ‘ :’
  • map: ‘&’
  • reduce: ‘|’
  • map_attributes: ‘&&’
  • reduce_attributes: ‘||’

There are no precedence rules. Expressions always evaluate left to right, though expressions without whitespace bind more tightly than those without.

Effect

  • Visibility: public, _protected, __private
  • Assignability: variable, CONSTANT
  • Mutability: .immutable, .mutable_
  • Mutating: non_mutating_method, mutating_method:

Terminals

  • Data (visible): ‘,’
  • Metadata (invisible): ‘;’
  • Whitespace: ‘ ‘
  • Newline ‘\n’

Note that tab and carriage return are invalid characters, though they may be valid inputs into text editors.

MAML requires 2-character indentation, and define a canonical format that all code must conform to.

Quotes

  • String: “Smart quotes”
  • Comment: #internal#, #end of line
  • Netstring: \length\binarydata

Traditional dumb quotes are invalid characters; text editors should use them to automatically insert the appropriate smart quote.  By using matched left and right quotes, this minimizes the need for escaping and allows one to easily comment out large sections of code.

Grouping

  • Unboxed (expression): (.meta 1; value)
  • Boxed (array): [.meta 1; v1, v2]
  • Lazy (closure): {.param 1; expression}

Note that unboxed expressions make it trivial to add metadata to a ‘bare’ value, such as  annotating a string for rich text.

Implementation

MAML is currently being implemented on GitHub using Typescript. We have also developed an Atom package for editing MAML files. The long-term goal is to implement MAML as a self-contained node.js package enabling  server- and client-side translation into HTML5, as both an interpreter and a compiler.

 

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: