Code golf

from Wikipedia, the free encyclopedia

Codegolf is a recreational programming competition in which participants try to implement a particular algorithm with as little source code as possible. Codegolf is not to be confused with so-called "sizecoding", which is about creating the smallest possible executable binary files . Sometimes code golf is also called "script golf" or, especially in English, is linked to the programming language to be used (such as " pearl golf" in English ).

history

The length of the shortest possible program to generate a specific output (in a specific programming language) is called Kolmogorov Complexity , named after Andrey Kolmogorov because of his mathematical work on this topic in 1963. Often, code golf is more about a general input to be achieved. Output transformation rather than simply achieving a specific output without prior input.

The term "Codegolf" was probably used for the first time in 1999 in connection with the Perl programming language; and initially stayed in this environment because of the spread of the language with RSA encryption . Similar informal competitions were already known among APL hackers. Today the term is used independently of the programming language, which in some cases has even led to the emergence of languages ​​only for code golf competitions. The systematic use of such short source texts is referred to in practice as "Spartan programming".

The background to the designation "code golf" is the endeavor in golf to achieve the lowest possible number of points, in contrast to the goal of a high number of points in other sports.

Types of code golf

Many code golf assignments do not require a specific programming language. Most of the time, however, restrictions are put in place, such as using specific code golf dialects like REBMU (a dialect of the REBOL language ) or time limits to make the task more interesting and challenging.

Special code golf languages

Several new programming languages ​​have been developed for explicit use in code golf. The best known among them are GolfScript and Flogscript. Both are Turing-complete and offer extensive possibilities for expressing complex processes in a few characters of source code. The downside of these languages ​​is the poor low readability, which makes them impossible for practical use; they are therefore often called " esoteric programming languages ". Other examples are the languages Pyth and CJam .

An example in GolfScript that prints the first fifty digits of Pi :

;''
6666,-2%{2+.2/@*\/10.3??2*+}*
`50<~\;
 -> 3141592653589793238462643383279502884197169399375

Competitions

The following competitions allow several programming languages: Anarchy Golf , JAGC , Shortening Codes , Code Golf & Coding Challenges , CodinGam , Code Golf . The 4clojure.com competition only allows Clojure , VimGolf only allows Vim .

See also

Web links

Individual evidence

  1. ^ Greg Bacon: Re: Incrementing a value in a slice. May 28, 1999, accessed July 12, 2011 .
  2. Adam Back: RSA in 5 lines of pearl . Retrieved January 10, 2011.
  3. ^ Spartan Programming , Jeff Atwood , Coding Horror , July 8, 2008
  4. REBMU: Code Golf Save for Humans
  5. list of specific Code Golf Languages: List of dedicated golfing languages on the esowiki .
  6. ^ Anarchy Golf .
  7. ^ Just Another Golf Coding .,
  8. Shortening codes .
  9. 4clojure League . Retrieved July 24, 2011: "While the primary purpose of 4clojure.com is to teach Clojure" by doing ", you may also choose to compete for the shortest solution. This is affectionately known as code golf: the lower your score the better, get it? If you choose to participate, we'll score your correct solutions based on the number of non-whitespace characters (and some more metrics in the future). "