{"id":13550813,"url":"https://github.com/hoijui/escher","last_synced_at":"2025-04-10T00:44:09.023Z","repository":{"id":57554769,"uuid":"259218277","full_name":"hoijui/escher","owner":"hoijui","description":"Escher: A language for programming in metaphors","archived":false,"fork":false,"pushed_at":"2021-10-29T05:43:00.000Z","size":3114,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T00:44:04.723Z","etag":null,"topics":["flow-based-programming","graph-based-programming","programming-language"],"latest_commit_sha":null,"homepage":"https://hoijui.github.io/escher/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoijui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-27T05:51:27.000Z","updated_at":"2023-07-04T09:16:09.000Z","dependencies_parsed_at":"2022-09-26T18:51:27.197Z","dependency_job_id":null,"html_url":"https://github.com/hoijui/escher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoijui%2Fescher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoijui%2Fescher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoijui%2Fescher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoijui%2Fescher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoijui","download_url":"https://codeload.github.com/hoijui/escher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137998,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flow-based-programming","graph-based-programming","programming-language"],"created_at":"2024-08-01T12:01:37.941Z","updated_at":"2025-04-10T00:44:09.003Z","avatar_url":"https://github.com/hoijui.png","language":"Go","funding_links":[],"categories":["Go","others"],"sub_categories":[],"readme":"# [Escher - A language for programming in pure metaphors](https://hoijui.github.io/escher/)\n\n[![Build Status](https://github.com/hoijui/escher/workflows/Build%20\u0026%20Test/badge.svg)](https://github.com/hoijui/escher/actions?query=workflow%3A%22Build+%26+Test%22)\n[![Handbook Build Status](https://github.com/hoijui/escher/workflows/Deploy%20Pages/badge.svg)](https://github.com/hoijui/escher/actions?query=workflow%3A%22Deploy+Pages%22)\n[![GoDoc](https://godoc.org/github.com/hoijui/escher?status.png)](https://godoc.org/github.com/hoijui/escher)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hoijui/escher)](https://goreportcard.com/report/github.com/hoijui/escher)\n\n\u003e ___NOTE___\\\n\u003e _Escher -- in [the original repository](https://github.com/gocircuit/escher) -- is stagnant since 2015._\\\n\u003e The most recent version of the old project can be found in [hoijuis old-history fork](https://github.com/hoijui/escher-old-history).\\\n\u003e This project however, is (more) alive!\n\nSee [the projects website](https://hoijui.github.io/escher/)\nfor more info about the language.\n\nEnclosed | Enclosing\n--- | ---\n![Escher code](misc/img/main.svg) | ![Escher Hand with Reflecting Sphere](https://upload.wikimedia.org/wikipedia/en/6/66/Hand_with_Reflecting_Sphere.jpg) \nDiscrete | Continuous\n\nEscher is a programming language for everything.\nIt can naturally represent both process and data,\nwhile being simpler than a calculator grammar.\n\nEscher is a language for building intelligent real-time translations between the semantics of\ndifferent physical devices accessible through chains or networks of digital or electrical technologies.\n\nIn Escher, you can program from first- and third-person point-of-view at the same time;\njust like Physics is particles and waves at the same time.\n\nAn early \"proposal\" for the design of Escher,\n[Escher: A black-and-white language for data and process representation](http://www.maymounkov.org/memex/abstract),\nmight be an informative (but not necessary) read for the theoretically inclined.\n\n## Application domains\n\nAnything that filters information from some input sources, in real-time,\nand sends a transformed form to output devices.\n\n* Definition and generation of _synthetic worlds_ governed by Physical laws,\n  as in Augmented Reality and the Gaming Industry\n* _General purpose concurrent and distributed programming_,\n  such as Internet services and cloud applications\n* _Relational data representation_, as in databases and CAD file formats\n* _Real-time control loops_, as in Robotics\n* Numerical and scientific computation pipelines\n* ...\n\n## Computational Model\n\n___Attention:___ _Non-Turing Mathematics ahead_\n\nThe Escher abstraction of the world is NOT Turing-compatible:\nFrom the point-of-view of an Escher program,\nthere is no input and output:\nThere are only emergences and disappearances of events.\n\nEscher presents the world in a model called\n[Choiceless Computation](http://arxiv.org/pdf/math/9705225.pdf).\n\nUnderstanding the difference between _Turing Machines_ and _Choiceless Computation_,\nwhile not entirely necessary, sheds much light on the profound difference between\nEscher and other languages.\nThe relevant publications are quoted in the [bibliography](#bibliography) at the end.\n\n### Choiceless Programming by example\n\nThe following puzzle demonstrates choiceless programming via a simple, relatable high-school\nMath puzzle:\n\n---\n\nFour beer caps are placed on the corners of a square table with arbitrary orientations.\nThere is a robot on the table that acts upon three commands:\n\n1. flip a corner cap\n2. flip two diagonal caps\n3. flip two caps along a side\n\nUpon action there is no guarantee as to which corner, diagonal\nor side, respectively, the robot will choose to flip.\n\nDevise a sequence of commands that forces the robot to turn all caps in a\nconfiguration where they all have the same orientation.\n\nCan you devise a sequence that ensures they all face up? Down?\n\n---\n\nThis is a great introduction to the notion of choiceless programming.\n\n## Quick start\n\nEscher is an interpreter comprising a singular executable binary.\nIt is written in [Go](http://golang.org),\nand can be built for Linux, OSX and Windows.\n\nGiven that the [Go Language compiler is installed](http://golang.org/doc/install),\nyou can build and install the circuit binary with one line:\n\n```bash\ngo get github.com/hoijui/escher/escher\n```\n\nGo to the Escher base directory and run one of the tutorials\n\n```bash\ncd $GOPATH/src/github.com/hoijui/escher\nescher -src src/tutorial \"*helloworld.escher\"\n```\n\n## Structure\n\nPlease refer to [the projects website](https://hoijui.github.io/escher/).\n\n## Syntax (files) and faculties (directories) structure\n\nEscher programs are designated by a local root directory and all its descendants.\nThat directory is represented as the root in the faculty name-space\ninside the Escher programming environment.\n\nEscher compiles all files ending in `.escher` and attaches the resulting circuit designs\nto the name-spaces corresponding to their directory parents.\n\nTo materialize (i.e. run) an Escher program, use the mandatory `-x` flag\nto specify the path to the local source directory.\n\n```bash\nescher -x tutorial/helloworld\n```\n\nEscher materializes the circuit design named `main` in the root source directory, e.g.\n\n```escher\n// The main circuit is always the one materialized (executed).\nmain {\n\ts @show\n\ts.Action = \"¡Hello, world!\"\n}\n```\n\n### Recombining programs\n\nTo facilitate different embodiments (aka implementations) of gate functionalities,\nEscher allows the mixing of two source hierarchies into a single execution.\n\nFor instance, the hierarchy `acid/karajan` contains circuit definitions\n(in terms of gates or other circuits),\nwhile the hierarchy `tutorial/circuit/autorespawn` contains a root `main` circuit.\nTo execute the latter, using the former as a \"library\" available in the visible name-space,\nrun for instance\n\n```bash\nescher \\\n\t-x tutorial/circuit/autorespawn \\\n\t-y acid/karajan \\\n\t-n ExecutionName \\\n\t-s Server=Xa3242440007ad57b \\\n\t-d 228.8.8.8:22\n```\n\n![Auto-respawn tutorial](misc/img/proc1.svg)\n\n## Basic gates\n\nBy default, the Escher environment provides a basic set of gates (a basis),\nwhich enable a rich (infinite) language of possibilities in data manipulation.\n\nCollectively, they are data (concept) and transformation (sentence) gates.\n\nThese gates are not part of Escher's semantics.\nThey are merely an optional library — a playground for beginners.\nUsers can implement their own gates for data and transformation.\n\nThe basis reference below is nearly entirely visual.\nYou will notice that the visual language follows a prescribed format.\n\n### Data (Noun) gates\n\nOn blank slate, there is \"nothing to do\" -- so to speak.\nFor this reason, we have a collection of gates which are effectively \"springs\" of objects.\n\nSome produce integers, some floats, some complex numbers, some strings.\nThese are familiar types.\n\nThere is one gate that produces \"trees\".\nTrees are the basic type of \"weavable\" (or mutable) knowledge.\n(In fact, the other types are not necessary, but we throw them in for convenience.)\n\nIn the illustration below, the syntax of the respective gate design is displayed\nas their name (white on black).\n\n![Impression of the mind](misc/img/impress.svg)\n\n### Combinator (Manipulator) gates\n\n![Grammar manipulation gates](misc/img/combine.svg)\n\n### Arithmetic (Applying) gates\n\nArithmetic gates are a sufficient basis of operations that enables\nalgorithmic manipulation of the types string, int, float and complex.\n_TODO_.\n\n### Tree of Knowledge and the Reason (Learning) Gate\n\nYou will notice, one of the basic data gates allows the creation of a struct-like object.\nThis is called a _tree_.\nIt is a novel data structure, described in detail in\n[\"Extensible records with scoped labels\" by Daan Leijen](http://research.microsoft.com/pubs/65409/scopedlabels.pdf).\n\nThese data structures are \"built out\" and \"trimmed down\" using three elegant\nreflection methods, described in the above publication.\n\nEscher embodies all three in one gate,\nwhose main purpose is to manipulate the contents of trees.\nThis is the _Reason Gate_, illustrated below.\n\nThe following three illustrations show the same gate design,\nbut under different orientations of the event streams.\nIn all valid cases, the relationship between the valve values shown,\nexemplifies the effect of the gate.\n\n![Generalization](misc/img/generalization.svg)\n\n\u003e Belief for the current state of the world,\n  combined with a new observation,\n  results in a theory.\n\n![Explanation](misc/img/explanation.svg)\n\n\u003e A theory of observations, which explains (includes) an observation at hand,\n  explains the observation only to a belief consisting of the theory without the observation.\n\n![Prediction](misc/img/prediction.svg)\n\n\u003e When a belief of the state of the world is combined with a theory that is bigger,\n  the conjectured difference must be found in a new observation.\n\n## Duality gates\n\nDuality gates are the boundary between Escher semantics and the outside world.\nThey are the I/O with the outside.\nSuch gates affect some external technology when prompted through Escher in a certain way.\nAlternatively, such gates might fire an Escher message on one of its valves,\nin response to an asynchronous events occurring in an external technology.\n\n### Variation (Surprise) and Causation (Action) gates\n\n![See and Show](misc/img/seeshow.svg)\n\nFor instance, with the gates we've seen so far,\none might construct the following higher-level circuit abstraction for an I/O device,\nwhich is controlled by a deferred logic:\n\n![I/O device](misc/img/io.svg)\n\nAnd the respective source code:\n\n```escher\nio_device {\n\t// recalls\n\tin see\n\tout show\n\tswtch switch\n\t// matchings\n\tLogic = swtch.Socialize\n\tin.Sensation = swtch.Hear\n\tout.Action = swtch.Speak\n}\n```\n\n## Introspective and extrospective gates\n\nThis special type of gates fulfills the complementary functions\nof constructing new circuit designs \"dynamically\"\n(akin to \"reflection\" in other languages),\nand materializing (i.e. executing) these designs.\n\n_TODO_\n\n### The Julia (Exploiting) Gate\n\n_TODO_\n\n### The Escher (Einstein) Gate: Multiple foci over Space and Time\n\n_TODO_\n\n## The future collapsed\n\n_TODO_\n\n## Why you should be excited\n\nIt may seem that Escher is not more than a new semantic to do an old job.\nBut something nearly magical happens when transition to using the\nEscher semantic—various compiler intelligence improvements that\nused to be NP-hard become simple and tractable:\n\n* Users do not need to explicitly moduralize (sub-divide) their circuits.\n  One could start designing a circuit wiring and the compiler will automatically\n  find sub-patterns that are abstractable as circuits.\n  Which includes non-obvious and/or recursive ones.\n\n* Code speed/space/etc optimizations reduce to a simple sub-graph replacement game,\n  highly transparent to and customizable by the user.\n\n## Misc\n\nA reference to the\n[initial](http://www.maymounkov.org/chomsky-valiant-algorithmic-mirror)\n[thoughts](http://www.maymounkov.org/puzzle-test-turing-test)\nthat led to the invention of Escher.\n\nTo the original author,\nEscher is a language for weaving dreams:\n\nIt makes imagination real.\n\nHelp make it tangible, so it can be shared.\n\n## Sponsors and credits\n\n* [DARPA XDATA](http://www.darpa.mil/Our_Work/I2O/Programs/XDATA.aspx)\n  initiative under the program management of\n  [Dr. Christopher White](http://www.darpa.mil/Our_Work/I2O/Personnel/Dr_Christopher_White.aspx), 2013–2014\n* [Data Tactics Corp](http://www.data-tactics.com/), 2013–2014\n* [L3](http://www.l-3com.com/), 2014\n\n## Bibliography\n\n* [Choiceless Polynomial Time](http://arxiv.org/pdf/math/9705225.pdf),\n  [Andreas Blass](http://www.math.lsa.umich.edu/~ablass/),\n  [Yuri Gurevich](http://research.microsoft.com/en-us/um/people/gurevich/) and\n  [Saharon Shelah](http://shelah.logic.at/), published by Shelah Office\n  on [arXiv](http://arxiv.org/abs/math/9705225), 1997\n\n* [Choiceless Polynomial Time Logic: Inability to Express](http://link.springer.com/chapter/10.1007%2F3-540-44622-2_6),\n  [Saharon Shelah](http://shelah.logic.at/), Springer Lecture Notes in Computer Science, Volume 1862, 2000, pp. 72-125\n\n* [Circuits of the Mind](http://www.amazon.com/Circuits-Mind-Leslie-G-Valiant/dp/0195126688), Leslie Valiant, 2000\n* [Probably Approximately Correct, 53589083](http://www.probablyapproximatelycorrect.com/), Leslie Valiant, 2013\n\nAdditional, enlightening reading includes:\n\n* [Ancient Evenings](http://en.wikipedia.org/wiki/Ancient_Evenings), Norman Mailer, 1983\n* [Yoga Philosophy of Patañjali](http://www.amazon.com/Yoga-Philosophy-Patanjali-Translation-Annotations/dp/0873957296),\n  State University of New York Press, 1984\n* [Samskrta-Subodhini: A Sanskrit Primer](http://www.amazon.com/Samskrta-Subodhini-Sanskrit-Primer-Michigan-Southeast/dp/089148079X),\n  Michigan Papers on South and Southeast Asia, Book 47, 1999\n\nPeople working in this or unsuspectingly related areas:\n\n* [Steven Witten](http://acko.net/about/) and [Kyle McDonald](http://kylemcdonald.net/) for heroic\n  attempts at fluidity in digital art.\n\n* [Bret Victor](http://worrydream.com/#!2/LadderOfAbstraction) for the insight that inventing a\n  good user interface and reverse-engineering the mind is one and the same thing.\n\n* [Noam Chomsky](https://www.youtube.com/watch?v=bfSyWRvoYfw) for suggesting\n  that discrepancies in language vs action are a window into the producing device, as well as\n  the circularity of the meaning of languages.\n\n* [John Conway](http://en.wikipedia.org/wiki/John_Horton_Conway)\n  for the [Symmetries of Things](http://www.amazon.com/The-Symmetries-Things-John-Conway/dp/1568812205).\n\n* [Daniel Spielman](http://www.cs.yale.edu/homes/spielman/precon/precon.html)\n  for the insight that general linear systems will never be invertible in linear time,\n  because there are no naturally linguistically-posable problems that can result in such matrices.\n  As well as the insight that even circular objects (like general undirected graphs)\n  have to be intellectually broken down to \"simple\" trees (via the notion of “distribution of trees”)\n  in order to enable a thinking process:\n  Thereby motivting the \"tree of knowledge\" data representation.\n\n* [Madhu Sudan](http://people.csail.mit.edu/madhu/) and\n  [Irit Dinur](http://www.wisdom.weizmann.ac.il/~dinuri/) for\n  [Probabilistically-checkable Proofs](http://www.ams.org/journals/bull/2007-44-01/S0273-0979-06-01143-8/home.html) and\n  [Universal Semantic Communication](http://people.csail.mit.edu/madhu/talks/2008/Semantic-TRDDC.pdf).\n\n* [Steven Pinker](http://stevenpinker.com/) and\n  [The Stuff of Thought](http://www.amazon.com/The-Stuff-Thought-Language-Window/dp/0143114247).\n\n* [Steven Boyd](http://web.stanford.edu/~boyd/)\n  for pointing attention to the relationship between convex optimization\n  [CVX](https://class.stanford.edu/courses/Engineering/CVX101/Winter2014/about)\n  and language.\n\n* [Leslie Valiant](http://people.seas.harvard.edu/~valiant/) for\n  [Circuits of the Mind](http://www.amazon.com/Circuits-Mind-Leslie-G-Valiant/dp/0195126688) and\n  [Probably Approximately Correct](http://www.probablyapproximatelycorrect.com/),\n  as well as for inspiring a spirit of thought outside of my profession (Theoretical Computer Science).\n\n* [Saharon Shelah](http://shelah.logic.at) for the notion of\n  [Choiceless Computation](http://link.springer.com/chapter/10.1007%2F3-540-44622-2_6).\n\n* [William Thurston](http://en.wikipedia.org/wiki/William_Thurston) for the\n  [Geometry and Topology of Three-manifolds](http://library.msri.org/books/gt3m/).\n\n* [Ken Thompson](http://en.wikipedia.org/wiki/Ken_Thompson) and\n  [Rob Pike](http://en.wikipedia.org/wiki/Rob_Pike)\n  for their pioneering work in programming languages that enabled the idea and later,\n  via the [Go Language](http://golang.org), the realization of Escher.\n\n* [Ken Stephenson](http://www.math.utk.edu/~kens/) and his work on\n  [Circle Packings](http://www.amazon.com/Introduction-Circle-Packing-Discrete-Functions/dp/0521823560)\n\n* [The Clay Institute](http://www.claymath.org)\n  for the insight that reducing the count of open problems\n  and the theoretical unification of logical theories (reducing the count of axioms)\n  are one and the same thing.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoijui%2Fescher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoijui%2Fescher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoijui%2Fescher/lists"}