Talk:One-liner program

July 2019
That C program won't compile under gcc, main is int not void. You don't need the return explicity specified, so I propose to just delete the "void"? 84.93.243.76 20:47, 22 July 2005 (UTC)

Some of the programs are not one-liners, but rather multi-liners crammed on "one" line by removing newlines. The standard for lines are the 80 and 132 characters per line offered by terminals. I suggest to remove those longer than 132 characters and give better examples for true one-liners. -- JS
 * With 8-bit home computers, a one-liner was whatever fit in one BASIC line, typically around 255 characters. Since they often had 40 column or fewer displays, limiting to one line would remove an entire genre. --scruss (talk) 16:43, 13 July 2019 (UTC)

Not an Expression
The term "one liner" should only apply to something that when expressed on one line and the return is hit, then a meaningful answer is returned. It gets murky when you include expressions. Bare expressions are only one-liners when they are typed into what would be an interpreter for the language of the expression.

Usually when talking of one-liners we mean one liners typed into a command line shell such as bash, sh, csh, tcsh, cmd.exe etc. Not a Python shell or other programming language shell (as opposed to the command-line shells built primarily to start programs written in other languages).

One liners should then include the invocation of a specific compiler or interpreter together with the source to run and should give the required result after hitting return on that single line.

It would be wrong to state the following for example as an AWK one-liner: NR == 10 The proper statement would be something like: awk 'NR == 10' path_to_some_text_file Similarly the perl equivalent below relies on showing the options to the perl invocation which are instrumental in making the command work: perl -n -e '($.==10) and print' text_file

Even though Python is my main programming language, the Python examples are very misleading because
 * 1) They fail to state that they must be executed from the Python shell (which is marginal as they don't work from a command shell)
 * 2) They require input data that is not shown so do nothing if typed in as the first expressions of the python shell.
 * 3) Python is not a particularly good language for writing proper one-liners in.

I think the main explanation needs changing and the Python examples removed. --Paddy (talk) 12:58, 11 December 2008 (UTC)
 * Paddy you are wrong, the AWK examples were taken from the AWK book, They are in a section called examples of one-liners or something alike, They are called one-liners because are written in one-line pattern-action parts. You need to understand the AWK strcucture to see why. The volunteer who wrote that section omitted the explanation. — Preceding unsigned comment added by 2806:106E:B:DCE2:B91C:FFCC:4813:8157 (talk) 08:27, 15 October 2021 (UTC)

x-liner program
Can someone point out the significance of one-liner programs? Else two-liner program and any other x-liner program articles could qualify for article existence. --Abdull (talk) 00:06, 6 October 2010 (UTC)


 * one-liner is a wrong term, one-liners (plural) refer to one-line programs. In its origin programs written composing Unix filters with pipes, also called stream processing. One-line programs are not necessary one line long, just very short.
 * Because AWK is rich enough to write programs as done with general purpose programming languages, the term one-line program is used to refer to programs written in the AWK style, one line per pattern, in contrast to those written in AWK using the conventional structured programming style. By extension this term is also used in other languages.
 * The title should be changed either to "one-line programs" or "one-liners". A programmer skilled to write elegant one-line programs,may be called a one-liner, the person not the program. Is just basic grammar. — Preceding unsigned comment added by 2806:106E:B:DCE2:B91C:FFCC:4813:8157 (talk) 13:49, 14 October 2021 (UTC)

I agree. "one-liner program" is inadequate as an encyclopedic heading. It does rather imply a whole family of "x-liner programs" Something like "Single line editors" or "single line processors" would be better. Some authority please chime in! Janopus (talk) 17:54, 17 June 2011 (UTC)


 * A one liner refers to the amount of processing one can do succinctly, as well as the ease of solving common problems. It can be used as an "acid test" for the utility of a scripting language or of how expressive a language is; or as simple code golf. If you program at the command-line prompt, especially in a Unix type environment then creating one-liners can be a very useful skill. Conversely, if you stick within GUI environments then you may never come across the need to develop a one-liner.
 * A one-liner is a very common term that is in regular use. Changing the page title makes no sense - it would be the equivalent of changing some page that refers to, for example, a dirt-biker racing phrase just because I don't know what the common phrase means as I don't dirt-bike. --Paddy (talk) 05:59, 21 June 2011 (UTC)

BASIC
I can't believe that this article has been around so long without any mention of the rich tradition of one-liners in BASIC. I shall see what I can do to remedy this --scruss (talk) 00:48, 3 July 2018 (UTC)

Information copied from https://wiki.tcl-lang.org/
I just reverted an edit that was a verbatim copy of text from https://wiki.tcl-lang.org/revision/gold?V=748 (archive.org).

This web site is licensed under the Tcl/Tk Licensing Terms which say The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions..

I'm not sure Wikipedia can comply with the "copyright notices are retained in all copies" since anyone can edit. I'll ask for advice on one of the Wikipedia: forums related to copyrights and licensing.

In any case, here is a copy of the license:

Tcl/Tk Licensing Terms

The following terms apply to the all versions of the core Tcl/Tk releases, the Tcl/Tk browser plug-in version 2.0, and TclBlend and Jacl version 1.0. Please note that the TclPro tools are under a different license agreement. This agreement is part of the standard Tcl/Tk distribution as the file named "license.terms".

Tcl/Tk License Terms

This software is copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files.

The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.

IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

GOVERNMENT USE: If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are acquiring the software on behalf of the Department of Defense, the software shall be classified as "Commercial Computer Software" and the Government shall have only "Restricted Rights" as defined in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license.

This is the main Tcl Developer Xchange site, www.tcl-lang.org.

davidwr/ (talk)/(contribs)  22:43, 26 September 2020 (UTC)


 * I have opened a discussion at Wikipedia talk:Copyrights. Please participate.  The outcome will determine if material from https://wiki.tcl-lang.org can stay on this page.  davidwr/  (talk)/(contribs)  23:02, 26 September 2020 (UTC)


 * Followup: The good news is that it appears that the Wikipedia editor and the editor of the page at wiki.tcl-lang.org appear to be collaborating. This revision of this article from September 18 was copied in part to this revision of the page on tcl-lang.org on September 19.


 * My hope is that the person managing the page at wiki.tcl-lang.org will explicitly release the material that was put on that web site first under a Wikipedia-compatible license. That will make the copyright issue "go away."  davidwr/  (talk)/(contribs)  23:15, 26 September 2020 (UTC)

"one-liner" is wrong, "one-line" programs belong to the "one-liners" category of programs
The title is wrong, a very short single line program is called one-line the set of one-line programs is called the one-liners, it is wrong to call a single program one-liner. This is how the term is used in the cited AWK book. Here the context:

An essential philosophy of the original Unix design is "small is beautiful". Instead of writing programs (or commands) with lots of options, they preferred to write special purpose languages that do one thing but do it well. Those languages formed part of the Unix programming environment. After Unix pipes. invented/discovered by Douglas McIlroy, they became an essential feature of Unix.

The pipe mechanism is a way to interconnect programs in a cooperating by providing the output produced by one program as the input of a consumer program. Abstractly, pipes are a kind of file, which is used as the standard output by the producer and as the standard input by the consumer. Both programs run at the same time, the pipe works as a kind of buffer, a lines queue which are written by the producer and read by the consumer. The data flowing through pipes are called streams.

This mechanism is best used by interconnecting very simple programs written in specialized languages like AWK, sed, grep, wc, etc., short enough that the text is often passed as a parameter. For example, the Unix shell command: counts the files with either the "catalog" or "collection" string with any lower upper case combination. The same one-line program written in an imperative general purpose programming language would have a structure similar to this pseudocode:

By the time when Unix was written, many business applications was done by COBOL batch processing. COBOL is a very very very, verbose language, it was impressive to see how many of those programs, mainly those generating reports, could be replaced by one-line programs.

Please rename the article to one-line programs (programmers jargon)
The AWK section was taken from the cited AWK book, in that chapter says that one can write conventional programs in AWK, but the aim of AWK is to write one-line programs. AWK programs have a pattern-action structure, the short programs with simple actions are called one-liners in that book, because one can write a program like this: the AWK collection of programs written with one or several pattern-action (a very simple one) are called one-liners in that book, because they are built with one or several one-line pattern-action lines. In other texts the authors use one-line programs (see The Unix Programming Environment). I tried to fix the article, but was an unsuccessful effort. I simply how to do it, the changes were reverted before I finished, and I did not find how to change the title.

I do not support the idea to erase this article, because I have seen the term one-liner is used by extension to programs written in Python with lines analogous to one-line programs. Also books promising to teach programmers to became one-liners (programmers who write one-line based code).

Neither I know how to classify this article, once edited, in the programmers jargon category.

The article is also wrong considering obfuscated programs one-liners, obfuscated code is never one-line because the goal to write one-line programs in the Unix philosophy, is a way to write neat programs, not illegible ones. Got it?

I am not going to waste more time with this article, is up to other skilled volunteers to fix it. I gave up! sorry!