Esoteric programming languages

Автор работы: Пользователь скрыл имя, 23 Октября 2013 в 21:25, реферат

Описание

An esoteric programming language (sometimes shortened to esolang) is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke. There is usually no intention of the language being adopted for mainstream programming, although some esoteric features such as visuospatial syntax have inspired practical applications in the arts. Such languages are often popular among hackers and hobbyists. This use of esoteric is meant to distinguish these languages from more popular programming languages.
Usability is rarely a high priority for such languages; often quite the opposite. The usual aim is to remove or replace conventional language features while still maintaining a language that is Turing-complete, or even one for which the computational class is unknown.

Работа состоит из  1 файл

Esoteric programming languages.docx

— 26.15 Кб (Скачать документ)

Lomonosov Moscow State University

Faculty of Computational Mathematics and Cybernetics

 

 

 

 

Esoteric programming languages.

 

 

 

 

 

 

 

 

    By IldarKhairullin

group №241

Moscow

2012

 

Esoteric programming languages.

Introduction

An esoteric programming language (sometimes shortened to esolang) is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke. There is usually no intention of the language being adopted for mainstream programming, although some esoteric features such as visuospatial syntax have inspired practical applications in the arts.  Such languages are often popular among hackers and hobbyists. This use of esoteric is meant to distinguish these languages from more popular programming languages.

Usability is rarely a high priority for such languages; often quite the opposite. The usual aim is to remove or replace conventional language features while still maintaining a language that is Turing-complete, or even one for which the computational class is unknown.

History

The earliest, and still the canonical example of an esoteric language was INTERCAL, designed in 1972 by Don Woods and James M. Lyon, with the stated intention of being unlike any other programming language the authors were familiar with.[2] It parodies elements of established programming languages of the day, such as Fortran, COBOL, and assembly language.

Early implementations of INTERCAL were tied to the IBM System/360 and an unidentified Atari computer (probably the Atari 2600) and have not survived. For many years INTERCAL was represented only by paper copies of the INTERCAL manual. The language's revival in 1990 as an implementation in C under Unix stimulated a wave of interest in the intentional design of esoteric computer languages.

In 1992, Wouter van Oortmerssen created FALSE, a small stack-oriented programming language, with syntax designed to make the code inherently obfuscated, confusing, and unreadable. It is also noteworthy for having a compiler of only 1024 bytes. This inspired Urban Müller to create an even smaller language, the now-famous brainfuck, which consists of only eight recognized characters. Along with Chris Pressey'sBefunge (like FALSE, but with a two-dimensional instruction pointer), brainfuck is now one of the most well-supported esoteric programming languages. These are canonical examples of minimal Turing tarpits and needlessly obfuscated language features; brainfuck'sminimality borders on elegant and pure language design; in fact it is related to the P′′ family of Turing machines.

Esoteric programming terms

Turing tarpit

A Turing tarpit is a Turing-complete programming language whose number of commands, operators, or equivalent objects is very small. These include brainfuck (8 commands, all with 0 operands), OISC (1 command, 3 operands), and Thue (1 command, 2 operands).

Turning tarpit

A turning tarpit is a Turing tarpit with a stateful encoding, i.e. a language in which commands are used to select from a finite range of operations and apply these operations to the current state of the program.[3] Examples include reMorse, Whirl and, arguably, INTERCAL.

Stateful encoding

A method of encoding programs, such that each substring of the encoding is an instruction to both:

Locate the next instruction in a list, and

Apply it to transform the current program state.

Note that a single instruction always includes two sequential phases: choosing an operation, and executing it. The list of operations may either be static – as in reMorse or THRAT - or dynamic - as in reMorse4ever.

Here is an example based on reMorse or THRAT:

Select Next Operation in list

Perform Operation

Language paradigm

The paradigm of a language can fall into a number of categories, and these categories are used to get a general understanding of the way that a specific language operates. These include imperative/despotic languages such as brainfuck, in which instructions describe how to change data; functional languages such as Unlambda, in which data and code are more or less interchangeable and execution is the repeated application of functions to the results of other functions; and rewriting languages such as Thue, in which transformation functions are applied to an initial state.

Funges

A funge is an esoteric programming language which models its programs as metric spaces with coordinate systems (often, but not necessarily, Cartesian) and which execute instructions located at points in their program space by moving an instruction pointer (a position vector which indicates the currently executing instruction) through that space. Different instructions determine the direction in which the instruction pointer moves, and consequently, the sequence of instructions that is executed.

The current official standard for the behaviour of these programming languages is the Funge-98 specification. This specification is a generalisation of the semantics of the Befunge programming language, which has a two-dimensional toroidal topology. Languages which adhere closely to this standard, such as Unefunge (one-dimensional) and Trefunge (three-dimensional), are sometimes called funges, while more "distant relatives" which differ in significant respects, such as Wierd, are referred to as fungeoids.

Nondeterministic language

For a deterministic language, if one is given the current state of a program, the next state can always be predicted. This is not true for a nondeterministic language. Most languages are deterministic, but some languages, such as Befunge, supply a built-in randomization instruction. Moreover, languages such as Java2K have only randomized instructions. Thus, getting even trivial programs to have a reliable output is often a monumental task.

Nondeterministic languages can be used to explore large search spaces, such as grammars, where exhaustive search is impractical. Random text generators such as the Dada Engine and rmutt are examples of this kind of nondeterminstic language.

More esoterically, nondeterministic algorithms have been employed in the theoretical investigation of hypercomputation.

BF

Brainfuck was invented by Urban Müller in 1993, in an attempt to make a language for which he could write the smallest possible compiler for the Amiga OS, version 2.0. He managed to write a 240-byte compiler. The language was inspired by False, which had a 1024-byte compiler. Müller chose to name the language brainfuck (with the initial letter in lower case, although it is now often capitalised).

It is not known to what extent Müller was aware of or influenced by Böhm's language P'' published in 1964, of which brainfuck can be considered a minor variation.

Brainfuck operates on an array of memory cells, also referred to as the tape, each initially set to zero. There is a pointer, initially pointing to the first memory cell. The commands are:

Command Description

  • > Move the pointer to the right
  • < Move the pointer to the left
  • + Increment the memory cell under the pointer
  • - Decrement the memory cell under the pointer
  • . Output the character signified by the cell at the pointer
  • , Input a character and store it in the cell at the pointer
  • [ Jump past the matching ] if the cell under the pointer is 0
  • ] Jump back to the matching [ if the cell under the pointer is nonzero

 

 

 

HQ9+

HQ9+ is a joke language with four instructions:

  • H: Print "hello, world"
  • Q: Print the program's source code
  • 9: Print the lyrics to "99 Bottles of Beer"
  • +: Increment the accumulator

Although the language is not of serious interest by itself, it can be useful to implement HQ9+ in a new esoteric programming language, since doing so proves that all the tasks above, except the quine, are possible. HQ9+ was created by Cliff L. Biffle.

 

Chef

Chef is a stack-based language where programs look like cooking recipes. Chef was designed by David Morgan-Mar in 2002. The design principles for Chef are:

  • Program recipes should not only generate valid output, but be easy to prepare and delicious.
  • Recipes may appeal to cooks with different budgets.
  • Recipes will be metric, but may use traditional cooking measures such as cups and tablespoons.

LOLCODE

LOLCODE is a general-purpose programming language being developed to resemble the kitty pidgin natlang of the lolcat phenomenon. It was created in 2007, one year after LOLCATS became an Internet meme.

  • HAI

 

  • BTW Comment
  • CAN HAZ STDIO?
  • VISIBLE [STRING]

 

  • COMPLAIN [STRING]

 

  • I HAZ A [VAR] ITZ [VALUE]

 

  • LOL [VAR] R [VALUE]

 

  • IZ [VAR] [OPERATOR] [VALUE]?

YARLY

...SOMECODE

KTHX

NOWAI

...SOMECODE

KTHX

  • IM IN YR LOOP

...SOMECODE

KTHX

IM OUTTA YR LOOP

 

 

 

  • KTHXBYE

 

  • In all LOLCODE programs, HAI introduces the program.
  • Introduces a comment.
  • Includes the library STDIO.
  • Prints STRING to the standard output stream.
  • Prints STRING to the standard error stream.
  • Declares a variable and assigns a value to it.
  • Another way of assigning a value to the variable.
  • An if statement (spec 1.0). OPERATOR can be BIGR THAN (>), SMALLR THAN (<) or LIEK (==).

 

 

 

 

  • Runs the same code in the "IM IN YR LOOP" code block until it goes to a "KTHX" instruction in the code block. An "IM IN YR LOOP" code block which never goes to a "KTHX" instruction causes an infinite loop.

 

KTHXBYE terminates the program. 
Internet community

There is a small but thriving community on the Internet of hobbyists who program in and design esoteric programming languages.

The esolang community is active sporadically, and topics of discussion range from debate as to whether a language is Turing-complete to how one would go about representing abstract and hard to visualise mathematical concepts in a programming environment. There is a mailing list, but it is nearly abandoned and most discussion happens on the wiki (see below) or on IRC.

Turing completeness is a favorite topic of discussion, since it is not immediately obvious whether or not a language is Turing complete, and it often takes rather large intuitive leaps to come to a solution. New languages with new features are always being created, so proof of Turing completeness is always a challenge.A related pursuit among programming language enthusiasts is the writing of obfuscated code.

 

References:

  1. McLean, A., Griffiths, D., Collins, N., and Wiggins, G. (2010). Visualisation of live code. In Electronic Visualisation and the Arts London 2010
  2. Alan Perlis, «Epigrams on Programming», SIGPLAN Notices Vol. 17, No. 9, September 1982, pages 7 — 13
  3. http://www.dangermouse.net/esoteric/chef.html
  4. http://lolcode.com/

Информация о работе Esoteric programming languages