Remarks: One-Liners
From Maze
(Difference between revisions)
(Added APL info at beginning) | |||
| Line 1: | Line 1: | ||
| − | In the early 1980s, magazines published one-line programs to fascinate and intrigue home computer users and to teach them how to write software. In the Commodore-specific magazine ''RUN,'' they appeared in a section near the front of the magazine entitled "Magic," which contained "Hints and tricks that will let you perform computing wizardy." Some of their one-liners and tips were clearly for amusement, having at best an educational purpose. Some were practical programming aids. Many were quite expressive and produced interesting visual effects. | + | While the one-liner became known as a type of BASIC program, the form predated home computing, the exchange of BASIC code in magazines, and even the BASIC programming language itself. Concise programs known as "one-liners" were written at least as early as the beginning of the 1960s, and the language that was most famous for writing such programs was APL, designed by Kenneth Iverson using special (non-ASCII) notation. APL was first described in the 1957 book ''A Programming Language'' and was first implemented at IBM beginning in 1960. |
| − | Take for example, this one-liner from the April 1985 ''RUN'' (p. 8): | + | In APL, there is no limit on the length of a line; anything that a programmer can express as a single statement counts. A report showings that "all 'practically' computable functions" can be written as APL one-liners (Lipton & Snyder 2), so perhaps one-liners should not be impressive, but programmers have nevertheless found them to be so. APL one-liners have been published that solve the problem of placing N queens on a NxN chessboard (Selfridge 243) and that completely encode John Conway's Game of Life (McDonnell 6). The final Game of Life APL function presented is only nine tokens long. While not everyone involved with computing shared these programmers' enthusiasm for one-liners, or for APL, the exchange and academic publication of APL one-liners does demonstrate that this form of program was not only popular among amateurs or those new to computing. |
| + | |||
| + | In the early 1980s, magazines published one-line programs, sometimes regularly, to fascinate and intrigue home computer users and to help them explore programming. In the Commodore-specific magazine ''RUN,'' they appeared in a section near the front of the magazine entitled "Magic," which contained "Hints and tricks that will let you perform computing wizardy." Some of their one-liners and tips were clearly for amusement, having at best an educational purpose. Some were practical programming aids. Many were quite expressive and produced interesting visual effects. | ||
| + | |||
| + | This note, with a one-liner, appeared in the April 1985 ''RUN'' (p. 8): | ||
<blockquote>Sent in from a user named Larson E. Rapp: "When he's not looking, run this on a friend's VIC or C-64. Then get him to type a line or two, and watch the fun as he scrambles for his warranty."</blockquote> | <blockquote>Sent in from a user named Larson E. Rapp: "When he's not looking, run this on a friend's VIC or C-64. Then get him to type a line or two, and watch the fun as he scrambles for his warranty."</blockquote> | ||
| Line 13: | Line 17: | ||
Only the most utilitarian of one-liners were compatible across BASIC machines like the Commodore, Apple and Atari home computers and the original Dartmouth BASIC compiler. There were numerous of versions of BASIC, and some included commands such as PLOT and SOUND to facilitate making graphics and music. Of course, a one-liner using such a BASIC could take advantage of these special commands. | Only the most utilitarian of one-liners were compatible across BASIC machines like the Commodore, Apple and Atari home computers and the original Dartmouth BASIC compiler. There were numerous of versions of BASIC, and some included commands such as PLOT and SOUND to facilitate making graphics and music. Of course, a one-liner using such a BASIC could take advantage of these special commands. | ||
| − | The Apple 2 with its BASIC commands for high- and low- resolution graphics enjoyed a rich culture of one-line programming as well as other variations in form such as "two-step" programs. "Two steps" were two lines long instead of one. That change in practice made them harder to memorize but more complex in their presentation. BASIC implementations with multimedia commands access their platform hardware often lead to more impressive one-liners which were not possible on the Commodore computers due to their relatively sparse operating system implementation, which may have been related to Commodore's earlier simple calculator products (Bagnall ??). | + | The Apple 2 with its BASIC commands for high- and low- resolution graphics enjoyed a rich culture of one-line programming as well as other variations in form such as "two-step" programs. "Two steps" were two lines long instead of one. That change in practice made them harder to memorize but more complex in their presentation. BASIC implementations with multimedia commands access their platform hardware often lead to more impressive one-liners which were not possible on the Commodore computers. |
| − | There is no space in a single line to include extensive data about specific movements, such as a 3-D animation. 10 PRINT relies on graphical images called PETSCII contained in the ROMs of the Commodore computers and simply refers to these using 205 and 206. Those two numbers are indexes into the "block graphics set" which 8-bit home computers used to draw simple graphics. The block graphics set uses more data to encode the image: 8 bytes for each graphic as opposed to the one byte used to point to it. | + | There is not enough space in a single line to include extensive data about specific movements, such as a 3-D animation. 10 PRINT relies on graphical images called PETSCII contained in the ROMs of the Commodore computers and simply refers to these using 205 and 206. Those two numbers are indexes into the "block graphics set" which 8-bit home computers used to draw simple graphics. The block graphics set uses more data to encode the image: 8 bytes for each graphic as opposed to the one byte used to point to it. |
Block graphics have collectively allowed a non-alphabetic visual vocabulary to flourish. They have been used to represent emotions, stick-figures, space travel, balance sheets, and graphical window systems. In 10 PRINT, block graphics characters more firmly represent the notion of a maze than the typographic slash and backslash, which would not necessarily form complete diagonal lines. | Block graphics have collectively allowed a non-alphabetic visual vocabulary to flourish. They have been used to represent emotions, stick-figures, space travel, balance sheets, and graphical window systems. In 10 PRINT, block graphics characters more firmly represent the notion of a maze than the typographic slash and backslash, which would not necessarily form complete diagonal lines. | ||
| Line 54: | Line 58: | ||
<code>10 poke 53248+rnd(0)*46,rnd(0)*256: goto 10</code> | <code>10 poke 53248+rnd(0)*46,rnd(0)*256: goto 10</code> | ||
| + | |||
| + | = Works Cited = | ||
| + | |||
| + | Lipton, Richard J. and Lawrence Snyder. "On the Power of Applicative Languages." Research Report 94, Department of Computer Science, Yale University, 1977. | ||
| + | |||
| + | McDonnell, Eugene E. "Life: Nasty, Brutish, and Short." APL '88, Conference Proceedings, February 1-5, 1988, Sydney, Australia. pp. 242-247. 1988. | ||
| + | |||
| + | Selfridge, R. G. "Fun and Games, Good and Bad, with APL." ACM-SE 15 Proceedings of the 15th annual Southeast regional conference. 1977. | ||
