What is One-Liner, Code Golf, Obfuscation Contest

By Xah Lee. Date: . Last updated: .

What is One-Liner, Code Golf, Code Obfuscation

One-liner evolved into code golf and code obfuscation.

One-Liner, Defined as Count of Character

Traditionally, one-liner is defied as being one single line, and typically within 80 characters.

This is suitable for perl.

An extended definition is, a contest of the shortest program, by character count. This constitutes code-golf.

This definition is suitable for procedural or imperative programing language, such as C.

One-liner for functional programing: one semantic unit of function call

A suitable definition for functional programing language is one single semantic unit of function call. That is, one nested call of a function, or one sequence of function chain, or mix of the above.

Why one-liner or code golf?

Creating the shortest program, requires significant mastery of the programing language, in particular programing language that involves lots ad hoc syntax and semantics, such as perl, C, C++, and even JavaScript.

Why one-liner for functional programing?

Writing a program that is a single nested or sequential function call tests your mastery of functional programing.

You need to master function taking function as argument, function return function, anonymous function, inline function application, recursion, function style loop, currying, pointless-style programing, and or combinator. Most are essential elements in functional programing.

History of One-Liner, and One-Liner in Functional Programing

xtodo work in progress

One-liner began with perl.

It's highly competitive to have the shortest program by char count, in particular for procedural languages.

It's also non-trivial to make things semantically one-line, for functional programing languages. For procedural languages semantically one-line is almost impossible (except perl). For functional programing language, it depends on the language.

Scheme lisp coding challenge. Code a given AdventOfCode 2002 puzzle in 1 single line of scheme lisp (or WolframLang, JavaScript). I can do it in livestream, i request $50 paypal to do it. 😄

Note: emacs lisp, common lisp, cannot do one-liner, nor python. but Scheme Lisp, Javascript, and Wolframlang can. I presume ocaml, julia, and maybe can, turn any arbitrary code into one semantically connected single line.

Here, oneliner, is defined by, literally one single connected sequence or nested function calls. (as opposed to, just compactify any lang source code by removing newline char with semicolon or such.)