
On being the maintainer and sole developer of SPITBOL (2012) - Zuider
http://daveshields.me/2012/09/02/on-being-the-maintainer-sole-developer-and-probably-the-sole-active-user-of-the-programming-language-spitbol/
======
101914
This is from 2012.

He's wrong of course about being the only user.

I love this software, along with k/q. I admire the work Mr. Shields has put
into this project. I especially like the use of musl and provision of static
binaries.

I do not use Perl, Java, Python, Javascript, Go, Rust, Closure, etc., etc.
Whatever the majority of people are recommending, that is generally not what I
use. It just does not appeal to me.

I guess I am stubborn and stupid: I like assembly languages, SPITBOL, k/q, and
stuff written by djb. Keep it terse. Ignore the critics.

Yet this is now on the front page of HN. Maybe because it is the weekend? I
really doubt that the software I like with ever become popular. But who knows?
Maybe 10 years from now I will look at this post and marvel at how things
turned out.

There is no "structured programming" with spitbol. No curly braces. Gotos get
the job done. Personally, I do not mind gotos. It feels closer to the reality
of how a computer operates.

Would be nice if spitbol was ported to BSD in additon to Linux and OSX. As
with k/q I settle for Linux emulation under BSD.

~~~
malux85
Fascinating, I'm curious, what do you do with such languages and tools? I'm
not trolling or trying to start a flame war, I'm genuinely curious as to the
best use of these tools. Also - are you doing it as a hobbit, or commercially
(or both)? How did you discover this tech?

~~~
nalllar
> are you doing it as a hobbit

Thanks for that typo, I laughed immediately after drinking some tea and now
it's all over my monitor :(

~~~
kyberias
Bilbo Bugends

------
braythwayt
The first programming language I used was WATFIV, a Waterloo FORTRAN
implementation. It seemed straightforward, and if that’s all there was to
programming, I probably would have dropped it in 1974 to play more D&D.
FORTRAN felt like the same arithmetic I already knew how to use. It was
obviously way more powerful to use a program to do calculations, but it was
all stuff I could have done by hand or with a calculator.

But one day, as I waited for a keypunch to make some changes to some program
or other I was writing, my eye fell upon a copy of the Green Book left behind
by some other programmer. I started reading it, and my little mind was
completely blown.

SNOBOL was something else, it forced me to think about programs in a
completely different way. It wasn’t about specifying steps to be taken one by
one, it was about designing a way to pattern match.

And more than in the obvious, RegExp way, but you could do things as the
pattern was matching, and thus you were writing a kind of program where the
control flow was determined my backtracking and success or failure of matches.

To this day, my programming is highly influenced by one feature of SNOBOL, I
guess it “imprinted” on me: Patterns are first-class values (like regular
expressions in other languages), but they are also composable, there is an
arithmetic of patterns. To this day I favour designs where things can be
composed and decomposed at will rather than used as opaque, monolithic
entities.

I’m not saying SNOBOL was better than the FP and OOP and multi-paradigm
languages that dominate today, but the experience of learning a new way to
think was intoxicating, and once a year or so I re-read the Green Book and
think about thinking differently.

If you are interested, I highly recommend you read the whole book. If you see
“pattern matching” and think “Regular Expressions,” you will miss the forest
for the trees. I’m not sure that anybody needs to _know_ SNOBOL (or its
descendants), but I think that it’s a valuable exercise to learn it once.

"A language that doesn't affect the way you think about programming, is not
worth knowing.”

\--Alan Perlis

~~~
Zuider
The Green Book you mention is available for download on the Google Code page
for SPITBOL:

[https://code.google.com/p/spitbol/downloads/list](https://code.google.com/p/spitbol/downloads/list)

------
geophile
I love SNOBOL4/SPITBOL. It was a completely bizarre and original language that
was quite powerful.

In the late 70s, I took two compiler courses with RBK Dewar, one of the
creators of SPITBOL. Those courses were wonderful. He mentioned SPITBOL
occasionally, and I remember one story in particular. The implementation was
done in assembler, (if I'm remembering correctly), and it took 20 runs to get
a working system, (I guess that means a basic suite of tests running
successfully). That style of working is completely alien today, and arguably
less effective.

Dewar also spent some time talking about his work on the SETL language (for
processing sets). Flow analysis for global optimization could be expressed
extremely concisely, and was of course applied to SETL itself.

~~~
tootie
I took some undergrad courses with Prof Dewar in the 90s and all he talked
about was Ada and Assembly (using an assembler he wrote). Never heard of
SPITBOL. His class was great.

~~~
geophile
Forgot to mention it in my original comment, but in the grad-level compiler
course, we actually wrote a compiler in SPITBOL. I don't remember if the
language choice was optional or mandatory, but I did enjoy it.

------
breadbox
Since this is all about obscure languages, it maybe worth pointing out here
that the original INTERCAL compiler was written in SPITBOL.

On one or two occasions I asked Don Woods to clarify some feature of the
language that was incompletely described in the original INTERCAL document,
and he dug out the original SPITBOL code in order to answer my question.

~~~
epalmer
I was project manager over a FORTRAN project in the early 1980's. I remember
very clearly how our team's productivity went up as well as satisfaction when
the developers starting using the Ratfor (Rational Fortran) preprocessor.
[https://en.wikipedia.org/wiki/Ratfor](https://en.wikipedia.org/wiki/Ratfor)

At the time I did not realize that Brian Kernighan created Ratfor. Ratfor
changed my thinking about program structure and coding style more than any
other single event in my professional life.

------
ORioN63
If you're searching for examples, search instead for SNOBOL.

From Wikipedia: > SPITBOL (Speedy Implementation of SNOBOL) is a compiled
implementation of the SNOBOL4 language.

Also from wikipedia SNOBOL page shows some examples:
[https://en.wikipedia.org/wiki/SNOBOL](https://en.wikipedia.org/wiki/SNOBOL)

And C2 talks about it as well:
[http://c2.com/cgi/wiki?SnobolLanguage](http://c2.com/cgi/wiki?SnobolLanguage)

------
coderdude
[https://github.com/spitbol/x64/blob/master/demos/sentenc.sbl](https://github.com/spitbol/x64/blob/master/demos/sentenc.sbl)

In Python, you would probably use regex for the pattern matching. In SPITBOL,
you can accomplish the task at the language level. I doubt the pattern
matching is as capable as regex but that's a useful feature to have (edit:
based on braythwayt's comment, it sounds like the pattern matching is more
capable than regex). It might be better suited to NLP tasks. According to the
developer, "SPITBOL is unique in the power it provides to manipulate strings
and text. I’ve yet to see anything else come close."

See Zuider's comment for more information.

I hope all-caps-keywords is optional.

~~~
wging
Wikipedia says that the parsing can handle CFGs, which means it is strictly
more powerful than regex.

"SNOBOL4 patterns subsume BNF grammars, which are equivalent to context-free
grammars and more powerful than regular expressions." \-
[https://en.wikipedia.org/wiki/SNOBOL](https://en.wikipedia.org/wiki/SNOBOL)

------
millstone
> Can you name a widely-used contemporary programming language that still uses
> the 60’s software technology of reference counts to manage storage?

As opposed to the 50's software technology of garbage collection?

What an off-putting remark to include.

~~~
TazeTSchnitzel
Yes, age here is irrelevant.

At the very least, Objective-C, Swift and PHP still use reference counting.

~~~
SomeCallMeTim
And C++11 just got reference counting as an official library option.

Reference counting is _better_ than mark-and-sweep GC for several use cases:

* Real time code where you don't _ever_ want a GC to steal cycles. I know that a lot of research has been done to decrease the amount of time stolen, but it's always non-zero.

* Immediate, deterministic clean-up of resources as soon as they are no longer referenced: If you have a limited number of file handles, for instance, you want them closed ASAP, and not when some GC decides it's time.

* No performance penalty for having weak references. I use this in asset management: A map of asset handles to weak references to currently loaded assets. If an asset is no longer used, it's deallocated immediately. Having weak references in a GC system can increase processing complexity.

~~~
jkarneges
Reference counting in C++ can be done really well even in the absence of
language support.

For example, with the Qt library you can pass objects around by value, yet
behind the scenes everything is reference counted with automatic copy-on-
write. It's the best of all worlds. You get easy, value-based coding (no
pointers), speed (because deep down everything is a reference), and
deterministic destruction (no GC). [http://doc.qt.io/qt-5/implicit-
sharing.html](http://doc.qt.io/qt-5/implicit-sharing.html)

I'm curious if any languages have adopted a Qt-style approach natively.

~~~
beagle3
I know for sure the K (of the J / K / APL) family does, and I suspect they all
do.

------
jopamer
A few years back, Dr. Dobb’s posted a pretty great series of articles on some
of the techniques RBK Dewar employed when building the original SPITBOL
compiler: [http://www.drdobbs.com/cpp/some-programs-are-poorly-
designed...](http://www.drdobbs.com/cpp/some-programs-are-poorly-designed-on-
pur/232300070)

(I was lucky enough to study compilers under Prof. Dewar when I was a grad
student at NYU - I still have my notes on SPITBOL’s architecture, somewhere…)

~~~
jallmann
Excellent article, very clever optimizations given the tradeoffs. From the
article:

> We were talking about students' tendency to let the compiler substitute for
> thinking

This is actually why I use OCaml. Not going to comment on whether useful error
messages are a detriment to pedagogy, but offloading thinking to the compiler
is a lifesaver.

~~~
mercurial
Definitely. It doesn't prevent, say, off-by-one errors (and in general, errors
when you manipulate several items of the same type), but if you structure your
program correctly, you can be very confident about your code.

Though OCaml's errors are not always the most explicit or nicely written.

------
dwharrison
I first encountered SNOBOL when I was 15, running an implementation on an old
IBM 360 at university. It was the 3rd language I mastered (after Fortran and
an early T/S version of Basic...both on the same 360) and the first I
completely fell in love with.

It awoken me to just how different and amazing a programming language could be
and bent my mind around something very different than what I'd been doing with
Fortran. It was an entirely new way to think about designing solutions.

Years later when I was introduced to Prolog, everything thing felt very much
at home...Prolog's backtracking algorithm being very much like SNOBOL's
pattern matching system.

Of all the languages I've worked with over the years, SNOBOL and FORTH are in
class by themselves for how they informed my thinking about problem
solving...lessons I carried with me in work done in many other languages.

It's a shame that both languages have passed into history...they each had
subtle things to teach a developer just learning their craft...

------
floatboth
I think parser combinator libraries are pretty similar. In Haskell, people
often use Parsec instead of regular expressions.

------
raldi
_> SPITBOL is unique in the power it provides to manipulate strings and text.
I’ve yet to see anything else come close._

Can anyone elaborate on this?

~~~
Zuider
From Wikipedia entry on SNOBOL/SPITBOL

'SNOBOL4 stands apart from most programming languages by having patterns as a
first-class data type (i.e. a data type whose values can be manipulated in all
ways permitted to any other data type in the programming language) and by
providing operators for pattern concatenation and alternation. Strings
generated during execution can be treated as programs and executed.'

By contrast, other languages such favor the use of regular expressions.

I am not so sure about the claim to uniquness. Ralph Griswald went on to
develop the Icon language which included this feature. The Unicon language, a
superset of Icon also has this distinction.

~~~
raldi
I'm having a hard time understanding the parenthetical. If you grok it, and
could take a moment to explain it in your own words -- or give an example of
its use -- I'd very much appreciate it. Thanks!

~~~
braythwayt
If you have a pattern that matches FIRSTNAME and another that matches
LASTNAME, roughly:

    
    
        FULLNAME = FIRSTNAME LASTNAME
    

Whitespace is a catenation operator, and catenating two patterns gives you a
new pattern that matches a string matching the first and the second pattern.

Maybe you want to handle old-school people like raganwald:

    
    
        OLDSCHOOLNAME = LASTNAME ‘, ‘ FIRSTNAME
    

Or both:

    
    
        ANYNAME = FULLNAME | OLDSCHOOLNAME
    

The vertical bar is an alternate operator.

Regular expressions work the same way, but in most languages, the regular
expression language is really a DSL embedded in the syntax for a regular
expression literal. Whereas in SNOBOL, all those operators are ordinary
language operators and you can use them anywhere.

So you can manipulate patterns programatically.

~~~
plorkyeran
How does that differ from a parser combinator library beyond that it's baked
into the language? It took a few decades for other languages to catch up, but
patterns being first-class objects that can be combined in various ways isn't
that unusual. For example, in Lua with LPeg those examples would be:

    
    
        full_name = first_name * last_name
        old_school_name = last_name * P', ' * first_name
        any_name = full_name + old_school_name
    
        (* is sequence, + is or, P is a function that converts a string to a pattern)

~~~
abecedarius
While I don't remember enough Snobol to say, in Icon _every_ expression may
participate in the pattern-matching search process. For example, `a < b`
doesn't produce a boolean value, it either fails (cutting off the current
branch of the search) or succeeds (producing b's value as its value, so you
can write `a < b < c` with the conventional meaning without any special
handling of that form of comparison).

That's the kind of way that patterns are more deeply baked into these
languages.

------
jhallenworld
This makes me think of a generic assembler I wrote at one point (in C++ I
think, I should put it on github). The idea was that you could define the
instruction set right in the assembly source. It included a backtracking BNF
parser to support it with these pseudo ops:

    
    
       .rule name value pattern  ; Define a syntax rule
    
       .insn pattern    ; Define an instruction
           ...            ; Macro expanded on pattern match
       .end
    
       "pattern" contains literal characters, whitespace and
       references to other rules with "<rule-name>" or <expr>
       for a math expression.
    
       "value" is a comma separated list of expressions which
       can contain "argN" to reference the Nth value from the
       pattern (as returned by embedded rules).
    
        For example, this is how you could construct the
        instructions "lda <expr>", "lda #<expr>", "ldb <expr>",
        and "ldb #<expr>":
    
       .rule dual 0x01 lda
       .rule dual 0x02 ldb
       .rule mode 0xf8,arg1 <expr>
       .rule mode 0xfa,arg1 #<expr>
    
       .insn <dual> <mode>
          .byte arg1|arg2  ; Emit op-code
          .word arg3       ; Emit argument
       .end
    

SNOBOL4 itself is not an assembler, but I think you could make one like this
from it.

~~~
kragen
This is a very interesting idea, and I have been finding inspiration in it.
New machine architectures by way of #include files! Or cat! I've been thinking
that maybe the right compile-time programming model is something like term-
rewriting (more or less like C++ templates or Prolog or Aardappel) rather than
textual substitution. I wrote some more thoughts on the matter at
[https://lobste.rs/s/kfpsou/what_is_everyone_working_on_this_...](https://lobste.rs/s/kfpsou/what_is_everyone_working_on_this_week/comments/sfij7y#c_sfij7y)
but I still haven't gotten very far on it.

------
thisjepisje
Just found this on wikipedia: SnoPy, snobol pattern matching for python.

[http://snopy.sourceforge.net/user-
guide.html](http://snopy.sourceforge.net/user-guide.html)

------
Zuider
SPITBOL is an enhanced version of the SNOBOL language.

From Wikipedia:

SNOBOL (StriNg Oriented and symBOlic Language) is a series of computer
programming languages developed between 1962 and 1967 at AT&T Bell
Laboratories by David J. Farber, Ralph E. Griswold and Ivan P. Polonsky,
culminating in SNOBOL4.

[https://en.wikipedia.org/wiki/SNOBOL](https://en.wikipedia.org/wiki/SNOBOL)

TkS*LIDE is a Tcl/Tk based IDE for SPITBOL (along with SNOBOL4). Binaries for
SNOBOL4 and SPITBOL are included with the IDE, along with a tutorial and
sample programs.

[http://rms.republika.pl/slide.html](http://rms.republika.pl/slide.html)

SNOBOL is also distinguished by being described in Guy Steele & Richard
Gabriel: 50 in 50 speech as one of the three languages worth knowing:

[https://vimeo.com/25958308](https://vimeo.com/25958308)

------
Pyxl101
> I have several reasons to push on:

> SPITBOL is unique in the power it provides to manipulate strings and text.
> I’ve yet to see anything else come close.

I would be interested to know more about what features SPITBOL offers for
string processing. I'm going to take a look at the "Green Book" [1] Dave
mentions, but if anyone else has relevant focused resources on that topic I'd
love to give them a look.

[1]
[https://code.google.com/p/spitbol/downloads/detail?name=Gree...](https://code.google.com/p/spitbol/downloads/detail?name=Green%20Book.pdf&can=2&q=)

------
geophile
I was thinking about why I liked SNOBOL4/SPITBOL so much. The bizarre syntax
and control structures appealed to me for some reason. If you haven't used the
language, each statement can succeed or fail. At the end of the statement, you
can optionally specify a goto target for success and for failure. There are no
higher level control structures that I remember (except for functions), so
indenting is not something you (OK, I) normally did. This resulted in very
clean looking source code, for some reason. I just remember that impression
very strongly. But that doesn't really explain the appeal completely.

The string processing is fantastic -- extremely powerful. I think regexes have
a lot of the same power, but I always found SNOBOL4 more readable after the
fact, when I had to go back and read and fix my own code. But that's not it
either.

I think the main reason I liked SNOBOL4 so much was that it was the first
dynamic language I used. Values have types, variables do not. That was a big
revelation. I don't think I actually exploited it very often, but it was a
cool new idea. And the absence of type declarations also contributed to the
sense that the code looked clean. Automatic memory management was also very
nice. I had spent a lot of time dealing with memory management in C. I must
have in Pascal also. And I really don't remember what Algol-W did for memory
management -- a free or delete statement maybe? And of course in FORTRAN,
COBOL, and BASIC, there was no dynamically allocated memory at all, so you had
to guess high, keep track, etc. Not having to worry about tracking memory was
a nice change.

------
ZenoArrow
It's unfortunate the article doesn't have any examples to show off SPITBOL's
expressiveness, or have any benchmarks to show how fast it is compared to
solutions in other languages. Reading the comments here, it seems like it
could have some decent benefits.

Would be interested to know what built-in types are currently available. I
wonder also whether this language would also be a good fit for test case
writing.

------
ruricolist
On the subject of SNOBOL descendants still in use, there is also Snowball,
designed and used exclusively for writing stemming algorithms:

[http://snowball.tartarus.org/](http://snowball.tartarus.org/)

------
ChristianMarks
I used SNOBOL4 in the 80s. It was beautiful for parsing.

------
Pyxl101
> If you know of anyone else who is maintaining an open-source implemenation
> of a programming language that has only one user, please let me know [...]

The author of HolyC and TempleOS, Terry Davis, might be in a similar position:

[http://www.templeos.org/Wb/Doc/HolyC.html](http://www.templeos.org/Wb/Doc/HolyC.html)

Though I imagine with the exposure it's gotten over the years, Terry might not
be the sole user (probably sole regular user).

