Write-only language

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

In computer humor, a write-only language is a programming language with syntax (or semantics) sufficiently dense and bizarre that any routine of significant size is too difficult to understand by other programmers and cannot be safely edited.[1] Likewise, write-only code is source code so arcane, complex, or ill-structured that it cannot be reliably modified or even comprehended by anyone with the possible exception of the author.[1]

A more rarely used term is read-only language, which refers to systems with so many boundary conditions that the code can only be written through constant experimentation and not from first principles. The resulting code is perfectly readable by other programmers, but any attempt to duplicate it in another context will fail. The canonical example of a read-only language is AppleScript.[2]

Description

Write-only language is also referred to as line noise, suggesting that the code looks like spurious characters from signal noise in the communication line. In such a language it would be more difficult to read, understand, and modify existing source code than to start over and rewrite it from scratch.

Languages that are often derided as write-only include APL, DDT, older versions of BASIC, Perl,[3] Forth, TECO,[4] Mathematica and regular expression syntax used in various languages. Attributes that these languages have in common include a large set of operators and a syntax which encourages, or at least permits, the writing of very dense code. It is also a common feature of esoteric programming languages that strive to have obfuscated code, such as INTERCAL.

A classic example of a write-only program is Conway's Game of Life as written in APL2:[5]

⍎'⎕',∈N⍴⊂S←'←⎕←(3=T)∨M∧2=T←⊃+/(V⌽"⊂M),(V⊖"⊂M),(V,⌽V)⌽"(V,V ←1¯1)⊖"⊂M'

Read-only language

AppleScript has been described as a read-only language due to considerable implementation differences between different programs on the Macintosh platform. In theory, AppleScript is a simple language with considerable syntactic sugar that makes code easy to read and write. However, the core of the system, especially the system known as "chunking" and the objects it works on, has to be implemented within the third-party applications that support scripting. This support is not easy to add, and applications pick and chose which portions of the chunking system to implement. This leads to essentially random support within applications.

Programmers writing a script cannot determine in advance which features are supported and which are not. Instead, they must experiment to find a string of operations that will complete successfully. The resulting code is perfectly readable by other programmers, although the original meaning of the code might be lost. For instance, the code set the textStyle of characters 1 to 7 to bold is clear enough, but whereas the original intent of the code might have been to set the textStyle of the first word to bold, the word operator was not implemented in that application. Attempting to use the same or similar code with another application is almost sure to fail, as the set of supported features would be different. The working pattern can only be determined through further experimentation, and might look entirely different from the original solution.

Several other languages can be described as read-only, including COBOL.[6]

See also

References

<templatestyles src="Reflist/styles.css" />

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />
  1. 1.0 1.1 Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found.