Piet (programming language)

from Wikipedia, the free encyclopedia
Piet program with edition "Piet"
Piet Mondrian's painting
"Hello World" program in Piet

Piet is an esoteric programming language in which the program code looks like an abstract picture. It was invented by David Morgan-Mar and named after Piet Mondrian , a pioneer of abstract art . The example program at the top right outputs the word "Piet". It is quite typical in its artificial appearance; Morgan-Mar had set himself the goal of approximating the appearance of common Mondrian pictures .

Like most other esoteric programming languages, Piet is of no immediate practical use, but is treated as an example of unusual language concepts in academic computer science training.

implementation

Technically, the program code must be in the form of an image file in GIF format. Piet is an interpreter language , that is, the Piet interpreter reads the content of the file (here an image file) with the source text bit by bit and interprets the information contained therein as program commands .

The smallest semantic unit in such an image file is a “code” ( composition of “ code ” and “ pixel ”), a - in the visual representation as an image - a square of n 2 pixels of the same color. This value n is passed to the Piet interpreter as a parameter and selected for the visual display of Piet programs so that a visually appealing (not too small) image results. In the examples on the right, n has the value 4 (above) or 11 (below).

The Piet programming language is based on stack operations. According to the specification, it is Turing-complete , since it allows values ​​of any size in the memory cells. However, if the maximum size of the values ​​of an implementation is finite, this implementation is not Turing-complete. The program sequence is controlled by two pointers which - interpreted visually - lead on a winding path through the image plane with the codes. Syntax elements are then for example

  • entering a black or white color field,
  • the number of codels in a contiguous color area,
  • the transition from one color to the next.

These (and other) language elements encode the typical stack operations such as push and pop as well as arithmetic operations and those for the input and output of characters.

Web links

Commons : Piet  - collection of images, videos and audio files

Individual evidence

  1. ^ DM's Esoteric Programming Languages. (English)
  2. ^ "Piet, a language for the eye" (lecture, University of Basel)  ( page no longer available , search in web archivesInfo: The link was automatically marked as defective. Please check the link according to the instructions and then remove this notice.@1@ 2Template: dead link / informatik.unibas.ch  
  3. Seminar "Esoteric Programming Languages" (University of Oldenburg)