Mailing List Archive

Uglliness scale: Python <<< awk << p*** < SNOBOL4
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
BAR = ZOT
"The statement
$INPUT = X
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']])

======================
References:
[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, gawk.info, section entitled "History of
`awk' and `gawk'"
======================

Did-anyone-we-know-write-a-SNOBOL4-mode-for-the-IBM-026-keypunch?-ly
yours,

John
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
In message <19990816205639474.AAA315.413@max41127.izone.net.au>, John
Machin <sjmachin@lexicon.net> writes
>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.
>
I still have my snobol4 manual. All sorts of memories with that.
>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
...
--
Robin Becker
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
[Robin Becker]
> I once described perl as being like awk on steroids and lsd

[John Machin]
> Actually perl is more like SNOBOL4 on sedatives.

While I'm tickled by the image, nothing is like SNOBOL4 -- not even its
modern successor, Icon. SNOBOL4 was unique, and is still the Best Language
on Earth for writing string pattern-matching algorithms.

> [a nostalgic look at S4's pioneering features]
> ...
> 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.

Neither does Python <wink>: S4's "immediate assignments" allowed capturing
partial results even if the overall match failed. Perl may yet get the
effect of that by allowing embedded Perl code in regexps, but Python likely
won't.

> 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.

Its syntax was fine! I expect that what you really object to is the absence
of control structures other than goto, and the LT/GE/etc spelling of
comparison operators. That was common enough in its day, and even by the
time Pascal came around the keypunch I used still didn't have a semicolon
key. It looks ugly in retrospect only because it is <wink>.

> For example [1]
> FLIP = LEN(*I) . HEAD LEN(1) $ X LEN(1) $ Y *LGT(X,Y)

All obvious to the most casual observer <snort>. It's interesting that you
*still* can't spell this algorithm fragment with comparable ease in Python
or Perl! Roughly, FLIP is a pattern fragment that skips the first I
characters of a string (or fails if the string is shorter than I chars),
assigns the next two characters to variables X and Y (or fails if there
aren't two more), and then succeeds if X is lexically greater than Y else
fails. And the first I characters are assigned to HEAD iff the pattern as a
whole succeeds. In context, the next line is

STR FLIP = HEAD Y X

which matches FLIP against string STR, and interchanges X with Y if they're
lexically out of order (replacing the HEAD characters with themselves
unchanged). In Python you'd be provoked to

def flip(str, i):
try:
if str[i] > str[i+1]:
str = str[:i] + str[i+1] + str[i] + str[i+2:]
except IndexError:
pass
return str

To modern eyes I'm sure that looks clearer, but six delicate indexing
expressions are a half dozen chances to blow it that the S4 fragment can't
suffer. I will admit that the call-by-reference Perl

sub flip {
my ($s, $i) = @_;
substr($$s, $i, 2) = $2 . $1 if $$s =~ /^.{$i}(.)(.)/ && $1 gt $2;
}

is much closer to the S4 <wink>.

> ...
> Did-anyone-we-know-write-a-SNOBOL4-mode-for-the-IBM-026-keypunch?-ly
> yours,

yes-but-it-was-in-fortran2-and-kept-blowing-the-tubes-ly y'rs - tim
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Tim Peters wrote:
> While I'm tickled by the image, nothing is like SNOBOL4 -- not even its
> modern successor, Icon. SNOBOL4 was unique, and is still the Best Language
> on Earth for writing string pattern-matching algorithms.
> > ...
> > Did-anyone-we-know-write-a-SNOBOL4-mode-for-the-IBM-026-keypunch?-ly
> > yours,
>
> yes-but-it-was-in-fortran2-and-kept-blowing-the-tubes-ly y'rs - tim
Tim, you are the longest running bot in history :-) I hope one day we
the mere humans will get a chance at reading your source code.

some-bots-are-better-than-others-ly y'rs - Alex
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Robin Becker wrote:
> =

> In message <19990816205639474.AAA315.413@max41127.izone.net.au>, John
> Machin <sjmachin@lexicon.net> writes
> >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.
> >
> I still have my snobol4 manual. All sorts of memories with that.
> >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
> ...
> --
> Robin Becker

it went even further than that. It allowed for overloading of any and al=
l
pre-defined symbols and had a CODE function that would let you feed in "c=
ode"
that could either augment or replace the underlying runtime engine.

Basically, you could start out in SNOBOL4 and end up with something compl=
etely
different.

-- =

Perl? Python? If we all programmed in SNOBOL4 the way g-d intended, =

we wouldn't have to worry about debates like that!
---------------------------------------------------------------------
Howard S. Modell =AA=BF=AA howard.s.modell-at-boeing.c=
om
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Tim Peters <tim_one@email.msn.com> wrote;

> While I'm tickled by the image, nothing is like SNOBOL4 -- not even its
> modern successor, Icon. SNOBOL4 was unique, and is still the Best Language
> on Earth for writing string pattern-matching algorithms.

There are those of us who still use and develop SNOBOL4.

I've done a free port of the original Macro SNOBOL4, souped up with
some features of SPITBOL. It will run pretty much on anything with
pointers that are at least 32 bits long, and has a C compiler; Macro
SPITBOL is available for a wide variety of platforms from Catspaw Inc,
who also runs a SNOBOL4 mailing list.

For further information see;

http://snobol4.com
http://people.ne.mediaone.net/philbudne/snobol.html

For those who like SNOBOL4 but need a dose of syntactic sugar should
try Andrew Koenig's SNOCONE.

-phil
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Howard S.Modell <howard.s.modell@boeing.com> wrote:
[snip[
> Perl? Python? If we all programmed in SNOBOL4 the way g-d intended,
> we wouldn't have to worry about debates like that!

Funny, I read that 'the way g-d indented'. :)

Regards,

Martijn
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Martijn Faassen wrote:
>
> Funny, I read that 'the way g-d indented'. :)

Hey, what a great signature that would make!

Python: Programming the way g-d indented.
Greg
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Greg Ewing <greg.ewing@compaq.com> wrote:
> Martijn Faassen wrote:
>>
>> Funny, I read that 'the way g-d indented'. :)

> Hey, what a great signature that would make!

> Python: Programming the way g-d indented.

*laughs*

Go and use it!

Regards,

Martijn
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Martijn Faassen wrote:
> =

> Howard S.Modell <howard.s.modell@boeing.com> wrote:
> [snip[
> > Perl? Python? If we all programmed in SNOBOL4 the way g-d intended,
> > we wouldn't have to worry about debates like that!
> =

> Funny, I read that 'the way g-d indented'. :)
> =

> Regards,
> =

> Martijn

I would assume that when g-d writes python code, it just naturally
falls into divine alignment, no spaces or tabs necessary ...

-- =

Perl? Python? If we all programmed in SNOBOL4 the way g-d intended, =

we wouldn't have to worry about debates like that!
---------------------------------------------------------------------
Howard S. Modell =AA=BF=AA howard.s.modell-at-boeing.c=
om
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
On Fri, 20 Aug 1999, Greg Ewing wrote:

> Martijn Faassen wrote:
> >
> > Funny, I read that 'the way g-d indented'. :)
>
> Hey, what a great signature that would make!
>
> Python: Programming the way g-d indented.

Make that:
Python: Programming the way g--d- indented.
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Moshe Zadka wrote:

> Make that:
> Python: Programming the way g--d- indented.

Ha ha! Now that's clever!

Chad
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
On Fri, 20 Aug 1999 07:08:16 -0400 (EDT), Moshe Zadka
<moshez@server.python.net> wrote:

>On Fri, 20 Aug 1999, Greg Ewing wrote:
>
>> Martijn Faassen wrote:
>> >
>> > Funny, I read that 'the way g-d indented'. :)
>>
>> Hey, what a great signature that would make!
>>
>> Python: Programming the way g-d indented.
>
>Make that:
>Python: Programming the way g--d- indented.

Why does this remind me of Douglas Hofstadter's _Gödel, Escher, Bach_?
:-)

Robert Kern |
----------------------|"In the fields of Hell where the grass grows high
This space | Are the graves of dreams allowed to die."
intentionally | - Richard Harter
left blank. |
Uglliness scale: Python <<< awk << p*** < SNOBOL4 [ In reply to ]
Pada Fri, 20 Aug 1999 21:12:55 GMT, Robert Kern bilang:
| >> > Funny, I read that 'the way g-d indented'. :)
| >>
| >> Hey, what a great signature that would make!
| >>
| >> Python: Programming the way g-d indented.
| >
| >Make that:
| >Python: Programming the way g--d- indented.
|
| Why does this remind me of Douglas Hofstadter's _Gödel, Escher, Bach_?
| :-)

Programming the way g-d-- intended? Now that's just scary..


--
cliff crawford http://www.people.cornell.edu/pages/cjc26/
There are more stars in the sky than there are
-><- grains of sand on all the beaches of the world.