Icon Language Implementation and Unicon News

Icon has always impressed me as the most elegant and useful string processing language. In fact, I still use it. The speed impresses me to this day. Lately the out-of-print Implementation of the Icon Programming Language book went online as a PDF download. Not only that, the copyright is public domain.

The successor language Unicon has published the first issue of The Generator, a journal devoted to that language. Unicon is an open-source project. Therefore code from the Icon implementation book lives in Unicon's public code repository. What Unicon adds to Icon is OO, POSIX, and other goodies.

My own plea is for language folks to study (Un-)Icon's string scanning mechanisms. How I wish they were more common. No matter what my task or language du jour, I always find myself longing for Icon when it comes to strings. Doug Bagley offers some OCaml libraries which imitate Icon string techniques.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Just wondering... have you ev

Just wondering... have you ever looked at Gema?

No, why?

Does it bear any resemblance?

I'm not familiar enough with

I'm not familiar enough with Icon (or Gema) to say. I was wondering if you knew how they compared.

Read the handbook

No, I do not, but if Gema falls into the family of unix geek tools listed on its web site, then there is no contest. Read the Icon language handbook.

Job security?

My own plea is for language folks to study (Un-)Icon's string scanning mechanisms.

That will kill many products, and frameworks, and patterns. What will do the maintainers of all the XML-parsing libraries, for example? Refactoring SAX to generators? That wont keep them alive for too long...

A New Implementation of the Icon Language

...or rather Icon in Java - Jcon (it's not actually so new anymore).

Looks like interesting application of attribute grammars.
Also, their four-chunks remind me of CPS for some reason...

Some humorous excerpts:

...produces constructs not expressible as Java code.


...limitations are annoying, but in general Java provides a good implementation platform.

My guess is that Parrot might prove a better platform for Icon... I was unable to google it, are there any plans for that?

[on edit: actually, this paper is heavily based on Simple Translation of Goal-Directed Evaluation, which is much shorter]

...and Icon via List monad

A Unifying Approach to Goal-Directed Evaluation

Goal-directed evaluation, as embodied in Icon and Snobol, is built on the notions of backtracking and of generating successive results, and therefore it has always been something of a challenge to specify and implement. In this article, we address this challenge using computational monads and partial evaluation.


I've implemented Moiell along the same lines. In my case I used the list monad in combination with the exception monad. Once I had figured out how to implement monads in Javascript (by figuring out how to implement continuations in Javascript) implementing generators and things like (1 to 5) * (2 to 4) were very easy. (I really have to start working on it again, so I can put it online)

String Scanning, Please

Jcon I know about. Icon spawned several variations, and there was even a mysterious C code generator at some point, not well marketed. Has anyone data on Minicon?

Dave Hanson, Ray Pereda and Todd Proebsting recently [late 1999] completed a new implementation of Icon at Microsoft Research. This implementation, "Minicon," implements all of Version 9 Icon except for graphics.

Minicon is implemented in C++, and its object-oriented run-time architecture is inspired by the Jcon implementation done at the University of Arizona. This architecture enables the easy addition of data types to the run-time system.

The implementation team is using Minicon for research into adding new data types to Icon.

Currently, there are no plans for making Minicon available outside of Microsoft.

To my knowledge Minicon never left Microsoft. Unicon is vastly more interesting at this point. It is implemented in C++, too, and open source. All that makes Minicon worthy of note is Microsoft's interest. I wonder if Minicon was some kind of precursor to .NET or at least inspired .NET in some way.

Goal-directed evaluation is a valuable part of the Icon heritage. The string scanning, however, is what I want on a daily basis. In principle someone could embed Unicon into C/C++. I often hear about goal-directed evaluation in other languages. I never hear about Icon-style string scanning, although some quarters acknowledge a vague influence. It is not the same thing.

About the Icon implementation book, the Unicon FAQ indicates its continuing relevance:

We wish to develop, improve, and promote Icon-style goal-directed very high level languages. One way to do this is to do a new implementation of an existing language; Icon translators into C code and Java code are examples of this approach. Another way to do this is to design a new language that is not constrained by the syntax or semantics of an existing language; the Godiva programming language is (to some extent) an example this approach. Unicon pursues a third path: that of evolving an existing language to support new capabilities in a manner that is as compatible and consistent with the original design philosophy as possible.

The Unicon translator generates out Icon as an intermediate step; for regular Icon source the resulting virtual machine code is almost identical.

The relationship above sounds like the early days of C++, with a CFront-like translator to, and backward compatibility with the mother language. There are changes like this, though:

Icon provides support in its run-time system for type conversions and defaulting of parameters that comprises some of the basic character of the language. Yet at the source-level, writing procedures that coerce their parameters is clumsy. We have extended to the source language some constructs discovered in the implementation; this is (part of) how Icon was carved out of Snobol4's legacy.

CoCo/R in Unicon

The Unicode links led to this compiler generator written in Unicon.

Related Discussion

...on Unicode strings and their implementation.

SNOBOL-Style Patterns for Unicon

As long as we're digging up old topics, some may find the thesis SNOBOL-Style Patterns for Unicon of interest. The attempt is made to build a data type that brings the power of SNOBOL patterns to Unicon, comparing regular expressions, Icon's string scanning, and SNOBOL patterns. An interesting read for those that are interested in ideas for string processing within PLs.