项目作者: hoijui

项目描述 :
Escher: A language for programming in metaphors
高级语言: Go
项目地址: git://github.com/hoijui/escher.git
创建时间: 2020-04-27T05:51:27Z
项目社区:https://github.com/hoijui/escher

开源协议:Apache License 2.0

下载


Escher - A language for programming in pure metaphors

Build Status
Handbook Build Status
GoDoc
Go Report Card

NOTE\
Escher — in the original repository — is stagnant since 2015.\
The most recent version of the old project can be found in hoijuis old-history fork.\
This project however, is (more) alive!

See the projects website
for more info about the language.

Enclosed Enclosing
Escher code Escher Hand with Reflecting Sphere
Discrete Continuous

Escher is a programming language for everything.
It can naturally represent both process and data,
while being simpler than a calculator grammar.

Escher is a language for building intelligent real-time translations between the semantics of
different physical devices accessible through chains or networks of digital or electrical technologies.

In Escher, you can program from first- and third-person point-of-view at the same time;
just like Physics is particles and waves at the same time.

An early “proposal” for the design of Escher,
Escher: A black-and-white language for data and process representation,
might be an informative (but not necessary) read for the theoretically inclined.

Application domains

Anything that filters information from some input sources, in real-time,
and sends a transformed form to output devices.

  • Definition and generation of synthetic worlds governed by Physical laws,
    as in Augmented Reality and the Gaming Industry
  • General purpose concurrent and distributed programming,
    such as Internet services and cloud applications
  • Relational data representation, as in databases and CAD file formats
  • Real-time control loops, as in Robotics
  • Numerical and scientific computation pipelines

Computational Model

Attention: Non-Turing Mathematics ahead

The Escher abstraction of the world is NOT Turing-compatible:
From the point-of-view of an Escher program,
there is no input and output:
There are only emergences and disappearances of events.

Escher presents the world in a model called
Choiceless Computation.

Understanding the difference between Turing Machines and Choiceless Computation,
while not entirely necessary, sheds much light on the profound difference between
Escher and other languages.
The relevant publications are quoted in the bibliography at the end.

Choiceless Programming by example

The following puzzle demonstrates choiceless programming via a simple, relatable high-school
Math puzzle:


Four beer caps are placed on the corners of a square table with arbitrary orientations.
There is a robot on the table that acts upon three commands:

  1. flip a corner cap
  2. flip two diagonal caps
  3. flip two caps along a side

Upon action there is no guarantee as to which corner, diagonal
or side, respectively, the robot will choose to flip.

Devise a sequence of commands that forces the robot to turn all caps in a
configuration where they all have the same orientation.

Can you devise a sequence that ensures they all face up? Down?


This is a great introduction to the notion of choiceless programming.

Quick start

Escher is an interpreter comprising a singular executable binary.
It is written in Go,
and can be built for Linux, OSX and Windows.

Given that the Go Language compiler is installed,
you can build and install the circuit binary with one line:

  1. go get github.com/hoijui/escher/escher

Go to the Escher base directory and run one of the tutorials

  1. cd $GOPATH/src/github.com/hoijui/escher
  2. escher -src src/tutorial "*helloworld.escher"

Structure

Please refer to the projects website.

Syntax (files) and faculties (directories) structure

Escher programs are designated by a local root directory and all its descendants.
That directory is represented as the root in the faculty name-space
inside the Escher programming environment.

Escher compiles all files ending in .escher and attaches the resulting circuit designs
to the name-spaces corresponding to their directory parents.

To materialize (i.e. run) an Escher program, use the mandatory -x flag
to specify the path to the local source directory.

  1. escher -x tutorial/helloworld

Escher materializes the circuit design named main in the root source directory, e.g.

  1. // The main circuit is always the one materialized (executed).
  2. main {
  3. s @show
  4. s.Action = "¡Hello, world!"
  5. }

Recombining programs

To facilitate different embodiments (aka implementations) of gate functionalities,
Escher allows the mixing of two source hierarchies into a single execution.

For instance, the hierarchy acid/karajan contains circuit definitions
(in terms of gates or other circuits),
while the hierarchy tutorial/circuit/autorespawn contains a root main circuit.
To execute the latter, using the former as a “library” available in the visible name-space,
run for instance

  1. escher \
  2. -x tutorial/circuit/autorespawn \
  3. -y acid/karajan \
  4. -n ExecutionName \
  5. -s Server=Xa3242440007ad57b \
  6. -d 228.8.8.8:22

Auto-respawn tutorial

Basic gates

By default, the Escher environment provides a basic set of gates (a basis),
which enable a rich (infinite) language of possibilities in data manipulation.

Collectively, they are data (concept) and transformation (sentence) gates.

These gates are not part of Escher’s semantics.
They are merely an optional library — a playground for beginners.
Users can implement their own gates for data and transformation.

The basis reference below is nearly entirely visual.
You will notice that the visual language follows a prescribed format.

Data (Noun) gates

On blank slate, there is “nothing to do” — so to speak.
For this reason, we have a collection of gates which are effectively “springs” of objects.

Some produce integers, some floats, some complex numbers, some strings.
These are familiar types.

There is one gate that produces “trees”.
Trees are the basic type of “weavable” (or mutable) knowledge.
(In fact, the other types are not necessary, but we throw them in for convenience.)

In the illustration below, the syntax of the respective gate design is displayed
as their name (white on black).

Impression of the mind

Combinator (Manipulator) gates

Grammar manipulation gates

Arithmetic (Applying) gates

Arithmetic gates are a sufficient basis of operations that enables
algorithmic manipulation of the types string, int, float and complex.
TODO.

Tree of Knowledge and the Reason (Learning) Gate

You will notice, one of the basic data gates allows the creation of a struct-like object.
This is called a tree.
It is a novel data structure, described in detail in
“Extensible records with scoped labels” by Daan Leijen.

These data structures are “built out” and “trimmed down” using three elegant
reflection methods, described in the above publication.

Escher embodies all three in one gate,
whose main purpose is to manipulate the contents of trees.
This is the Reason Gate, illustrated below.

The following three illustrations show the same gate design,
but under different orientations of the event streams.
In all valid cases, the relationship between the valve values shown,
exemplifies the effect of the gate.

Generalization

Belief for the current state of the world,
combined with a new observation,
results in a theory.

Explanation

A theory of observations, which explains (includes) an observation at hand,
explains the observation only to a belief consisting of the theory without the observation.

Prediction

When a belief of the state of the world is combined with a theory that is bigger,
the conjectured difference must be found in a new observation.

Duality gates

Duality gates are the boundary between Escher semantics and the outside world.
They are the I/O with the outside.
Such gates affect some external technology when prompted through Escher in a certain way.
Alternatively, such gates might fire an Escher message on one of its valves,
in response to an asynchronous events occurring in an external technology.

Variation (Surprise) and Causation (Action) gates

See and Show

For instance, with the gates we’ve seen so far,
one might construct the following higher-level circuit abstraction for an I/O device,
which is controlled by a deferred logic:

I/O device

And the respective source code:

  1. io_device {
  2. // recalls
  3. in see
  4. out show
  5. swtch switch
  6. // matchings
  7. Logic = swtch.Socialize
  8. in.Sensation = swtch.Hear
  9. out.Action = swtch.Speak
  10. }

Introspective and extrospective gates

This special type of gates fulfills the complementary functions
of constructing new circuit designs “dynamically”
(akin to “reflection” in other languages),
and materializing (i.e. executing) these designs.

TODO

The Julia (Exploiting) Gate

TODO

The Escher (Einstein) Gate: Multiple foci over Space and Time

TODO

The future collapsed

TODO

Why you should be excited

It may seem that Escher is not more than a new semantic to do an old job.
But something nearly magical happens when transition to using the
Escher semantic—various compiler intelligence improvements that
used to be NP-hard become simple and tractable:

  • Users do not need to explicitly moduralize (sub-divide) their circuits.
    One could start designing a circuit wiring and the compiler will automatically
    find sub-patterns that are abstractable as circuits.
    Which includes non-obvious and/or recursive ones.

  • Code speed/space/etc optimizations reduce to a simple sub-graph replacement game,
    highly transparent to and customizable by the user.

Misc

A reference to the
initial
thoughts
that led to the invention of Escher.

To the original author,
Escher is a language for weaving dreams:

It makes imagination real.

Help make it tangible, so it can be shared.

Sponsors and credits

Bibliography

Additional, enlightening reading includes:

People working in this or unsuspectingly related areas: