Uglliness scale: Python <<< awk << p*** < SNOBOL4

John Machin sjmachin at
Mon Aug 16 22:51:57 CEST 1999

On 14 Aug 99, at 19:12, Robin Becker wrote:

> I once described perl as being like awk on
> steroids and lsd

Actually perl is more like SNOBOL4 on sedatives.

There is nothing new under the sun. SNOBOL4, which was up to version 3 
by 1969, had goodies like arrays (like Python lists, but with multiple 
dimensions that were fixed when the array was created), tables (like 
Python dictionaries), user-defined functions, user-defined data-types 
(about the same functionality as C's struct), built-in pattern 
matching, operator over-riding, extensibility through "external 
functions" written in FORTRAN or assembly language, automatic garbage 
collection, ...
It even had the ability to assign the result of a partial pattern match 
to a variable ... about 30 years later, Python got this in the re 
module's ?P<name> feature, and AFAIK perl doesn't have this even yet.

However SNOBOL4 also had the ugliest syntax that I've ever seen in a 
language that was genuinely intended for serious work -- Intercal is 
far uglier but is a parody.

For example [1]
	FLIP = LEN(*I) . HEAD LEN(1) $ X LEN(1) $ Y *LGT(X,Y)
	I = LT(I,LIMIT) I + 1 :S(LOOP)

That last line has this effect, expressed in C:
	if (i < limit) { i++; goto loop; }

Another "feature" was indirection.
	FOO = 'BAR'
	$FOO = 'ZOT'
gives the same result as
"The statement
is an extreme example in which a string is read in and used as a 
variable" [2]

awk, which started out in 1977, has no arrays, no structs, and didn't 
get user-defined functions till 1985 [4]. Interestingly, both SNOBOL4 
and awk came from the one source: Bell Labs.

By the way, SNOBOL4's arrays had the same (documented) trap-for-young-
players as Python's:

"Each element of an array is given the same initial value. 
Consequently, execution of the instructions 
	A1 = ARRAY(5)
	A2 = ARRAY(5, A1)
creates only two arrays. Each element of A2 has the same array, A1, as 
value" . [3]

In Python, using a size of 3 instead of 5 so's it'll fit on a line:
>>> a1 = [''] * 3
>>> a2 = [a1] * 3
>>> a1, a2
(['', '', ''], [['', '', ''], ['', '', ''], ['', '', '']])
>>> a2[0][0] = 'x'
>>> a1, a2
(['x', '', ''], [['x', '', ''], ['x', '', ''], ['x', '', '']])
>>> a1[2] = 'z'
>>> a1, a2
(['x', '', 'z'], [['x', '', 'z'], ['x', '', 'z'], ['x', '', 'z']])

[1] Griswold, R.E., Poage, J.F., and Polonsky, I.P., "The SNOBOL4 
Programming Language", 2nd ed., Prentice-Hall, Englewood Cliffs NJ, 
1971. -- page 80.
[2] ibid, p. 192
[3] ibid, p. 114
[4] GNU gawk distribution,, section entitled "History of 
`awk' and `gawk'"



More information about the Python-list mailing list