Debian Codegraph @

doc/faq.htm

raw
1 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <META NAME=viewport CONTENT="width=device-width, initial-scale=1">
5 <META CHARSET="UTF-8">
6 <TITLE>Icon Programming Language FAQ</TITLE>
7 <LINK REL="STYLESHEET" TYPE="text/css" HREF="istyle.css">
8 <LINK REL="SHORTCUT ICON" HREF="shortcut.gif">
9 </HEAD>
10 <BODY>
11 <!-- Archive-name: comp-lang-icon-faq-->
12 <P><IMG SRC="wwwcube.gif" WIDTH="128" HEIGHT="144" ALT="" ALIGN=RIGHT>
13 <H1>Frequently Asked Questions about the Icon programming language</H1>
14 <A HREF="http://www.cs.arizona.edu/icon/uguide/faq.htm">
15 www.cs.arizona.edu/icon/uguide/faq.htm</A>
16 <BR>Last updated July 10, 2022<BR>
17
18 <P><STRONG>Learning about Icon</STRONG><BR>
19 <A HREF="#whatsicon">A1. What is Icon?</A><BR>
20 <A HREF="#whatgood">A2. What is Icon good for?</A><BR>
21 <A HREF="#features">A3. What are Icon's distinguishing characteristics?</A><BR>
22 <A HREF="#library">A4. What is the Icon program library?</A><BR>
23 <A HREF="#intro">A5. Where can I learn more about Icon?</A><BR>
24 <A HREF="#examples">A6. Where are some simple examples?</A><BR>
25 <A HREF="#documentation">A7. How about comprehensive documentation?</A><BR>
26 <P><STRONG>Implementations</STRONG><BR>
27 <A HREF="#platforms">B1. What platforms support Icon?</A><BR>
28 <A HREF="#getstarted">B2. How do I get started with Icon?</A><BR>
29 <A HREF="#unicode">B3. Is there a Unicode version of Icon?</A><BR>
30 <A HREF="#iconc">B4. What happened to the compiler?</A><BR>
31 <P><STRONG>Administration</STRONG><BR>
32 <A HREF="#iconproject">C1. What is the Icon Project?</A><BR>
33 <A HREF="#updates">C2. How often is the on-line material updated?</A><BR>
34 <A HREF="#lineage">C3. Where did Icon come from?</A><BR>
35 <A HREF="#futures">C4. Where is Icon going? </A><BR>
36 <P><STRONG>Programming</STRONG><BR>
37 <A HREF="#evread">D1. Why doesn't <CODE>read()</CODE> work with <CODE>every</CODE>?</A><BR>
38 <A HREF="#strinv">D2. Why doesn't string invocation such as <CODE>"foo"()</CODE> work?</A><BR>
39 <A HREF="#callc">D3. How can I call a C function?</A><BR>
40 <A HREF="#rwpipe">D4. Can I open a bidirectional pipe?</A><BR>
41
42 <HR><H2>Learning about Icon</H2>
43
44 <H3><A NAME="whatsicon">A1.</A> What is Icon?</H3>
45 <P>
46 Icon is a very high level general-purpose programming language with
47 extensive features for processing strings (text) and data structures.
48 Icon is an imperative, procedural language with a syntax that is
49 reminiscent of C and Pascal, but with semantics at a much higher level.
50 <P>
51 Icon has a novel expression-evaluation mechanism that integrates
52 goal-directed evaluation and backtracking with conventional control structures.
53 It has a string scanning facility for pattern matching that avoids the tedious
54 details usually associated with analyzing strings.
55 Icon's built-in data structures include sets and tables with associative
56 lookup, lists that can be used as vectors or stacks and queues, and records.
57 <P>
58 Icon is a strongly, though not statically, typed language.
59 It provides transparent automatic type conversion:
60 For example, if an integer is used in an operation that requires a string,
61 the integer is automatically converted to a string.
62 <P>
63 Most implementations of Icon have high-level graphics facilities with
64 an easily programmed window interface.
65 <P>
66 Icon manages storage automatically.
67 Objects are created as needed during program execution and space is
68 reclaimed by garbage collection as needed.
69 The sizes of strings and data structures are limited only by the amount
70 of available memory.
71
72 <H3><A NAME="whatgood">A2.</A> What is Icon good for?</H3>
73 <P>
74 As a general-purpose programming language with a large computational
75 repertoire, Icon can be used for most programming tasks.
76 It's especially strong at building software tools, for processing text,
77 and for experimental and research applications.
78 <P>
79 Icon is designed to make programming easy;
80 it emphasizes the value of programmer's
81 time and the importance of getting programs to work quickly.
82 Consequently, Icon is used both for short, one-shot tasks and for
83 very complex applications.
84
85 <H3><A NAME="features">A3.</A>
86 What are Icon's distinguishing characteristics?</H3>
87 <UL>
88 <LI> A high-level, general-purpose programming language
89 <LI> Friendly line-oriented syntax (no semicolons needed)
90 <LI> Emphasis on programmer productivity
91 <LI> Usually interpreted
92 </UL><UL>
93 <LI> Evolved from programming languages (vs. scripting languages)
94 <LI> Procedural control flow plus generators and goal-directed evaluation
95 </UL><UL>
96 <LI> Values have types; variables are typeless, accept any value
97 <LI> Static scoping: global or (procedure) local
98 <LI> Automatic garbage collection
99 </UL><UL>
100 <LI> All integers have arbitrary precision
101 <LI> Uses strings (not chars) as basic text datatype
102 <LI> Has lists that function as arrays, queues, and stacks
103 <LI> Also has sets, tables, records (structs), reals (doubles), more
104 <LI> No second-class "primitive types"
105 </UL><UL>
106 <LI> Not "object-oriented" (no classes, inheritance, or instance methods)
107 <LI> No exception catching
108 <LI> No concurrency (no threads, monitors, semaphores, or synchronization)
109 <LI> Has co-expressions (coroutines)
110 </UL><UL>
111 <LI> Basic least-common-denominator system interface (a la ANSI C)
112 </UL><UL>
113 <LI> Procedural graphics (event-driven paradigm available but not mandated)
114 <LI> Retained windows (programs are never called to repaint)
115 <LI> Simple GUI builder that can re-edit its generated code
116 <LI> Turtle graphics package
117 </UL><UL>
118 <LI> Large library of contributed procedures and programs
119 </UL>
120
121 <H3><A NAME="library">A4.</A> What is the Icon program library?</H3>
122 <P>
123 The library is a collection of programs and procedures written in Icon.
124 User contributions form a significant portion of the library.
125 <P>
126 Library procedures effectively augment the built-in functions
127 available to an Icon program.
128 A wide variety of procedures currently exists, and most
129 graphically-based programs are built around library procedures.
130 The <A HREF="http://www.cs.arizona.edu/icon/library/src/procs/core.icn">core</A>
131 and <A HREF="http://www.cs.arizona.edu/icon/library/src/gprocs/graphics.icn">
132 graphics core</A> modules are the most carefully vetted.
133 <P>
134 The programs in the library range from simple demonstrations to
135 handy tools to complex graphical applications.
136 <P>
137 The library is a resource for both new and experienced programmers.
138 In addition to their basic utility,
139 its programs and procedures serve as examples of how things can be
140 written in Icon.
141 <P>
142 The library is indexed at
143 <A HREF="http://www.cs.arizona.edu/icon/library/ipl.htm">
144 www.cs.arizona.edu/icon/library/ipl.htm</A>.
145
146
147 <H3><A NAME="intro">A5.</A> Where can I learn more about Icon?</H3>
148 <P>
149 There is lots of material at the Icon website,
150 <A HREF="http://www.cs.arizona.edu/icon/">www.cs.arizona.edu/icon</A>.
151 <P>
152 Here are some good places to start:
153 <UL>
154 <LI> Ralph Griswold's overview:
155 <A HREF="http://www.cs.arizona.edu/icon/docs/ipd266.htm">
156 www.cs.arizona.edu/icon/docs/ipd266.htm</A>
157 <LI> Dave Hanson's introduction:
158 <A HREF="http://www.cs.arizona.edu/icon/intro.htm">
159 www.cs.arizona.edu/icon/intro.htm</A>
160 <LI> Bill Mitchell's introduction and slides:
161 <A HREF="http://www.mitchellsoftwareengineering.com/icon/">
162 www.mitchellsoftwareengineering.com/icon</A>
163 </UL>
164 <P>
165 For a more thorough introduction to the base language,
166 chapter 2 of the Icon
167 <A HREF="http://www.cs.arizona.edu/icon/gb/">graphics book</A>
168 (a free download) is especially good.
169 <P>
170 For a whirlwind tour of the graphics facilities, see:
171 <UL>
172 <LI> The Icon Project Overview:
173 <A href="http://www.cs.arizona.edu/icon/ftp/doc/ipd281.pdf">
174 www.cs.arizona.edu/icon/ftp/doc/ipd281.pdf</A>
175 </UL>
176
177 <H3><A NAME="examples">A6.</A> Where are some simple examples?</H3>
178 <P>
179 For some simple text-based programs, see any of those
180 introductory documents in the preceding question.
181 For some simple graphics programs, see
182 <A HREF="http://www.cs.arizona.edu/icon/gb/progs/progs.htm">
183 www.cs.arizona.edu/icon/gb/progs/progs.htm</A>.
184 <P>
185 Many more examples, typically larger, are found in the
186 Icon program library; see the indexes of
187 <A HREF="http://www.cs.arizona.edu/icon/library/cprogs.htm">Basic Programs</A>
188 and <A HREF="http://www.cs.arizona.edu/icon/library/cgprogs.htm">
189 Graphics Programs</A>.
190
191 <H3><A NAME="documentation">A7.</A> How about comprehensive documentation?</H3>
192 <P>
193 Two books define the Icon language.
194 The core language is covered in
195 <A HREF="http://www.cs.arizona.edu/icon/lb3.htm">
196 <CITE>The Icon Programming Language (third edition)</CITE></A>,
197 by Griswold and Griswold.
198 Graphics facilities are described in
199 <A HREF="http://www.cs.arizona.edu/icon/gb/">
200 <CITE>Graphics Programming in Icon</CITE></A>
201 by Griswold, Jeffery, and Townsend.
202 These books contain both tutorial and reference material.
203 <P>
204 Icon's internals are detailed in
205 <A HREF="http://www.cs.arizona.edu/icon/ibsale.htm">
206 <CITE>The Implementation of the Icon Programming Language</CITE></A>
207 by Griswold and Griswold.
208 Although considerable changes have occurred since Version 6,
209 described in the book, the basic structure of Icon remains the same.
210 Two technical reports,
211 <A HREF="http://www.cs.arizona.edu/icon/docs/ipd112.htm">IPD112</A> and
212 <A HREF="http://www.cs.arizona.edu/icon/docs/ipd239.htm">IPD239</A>,
213 describe subsequent changes.
214 <P>
215 Printed copies of the
216 <CITE>Language</CITE> and <CITE>Graphics</CITE> books
217 are available from Jeffery Books
218 (<A HREF="http://unicon.org/books/">http://unicon.org/books/</A>).
219 All three books can be downloaded at no charge from the Icon books page,
220 <A HREF="http://www.cs.arizona.edu/icon/books.htm">
221 www.cs.arizona.edu/icon/books.htm</A>.
222 <P>
223 A 2010 revision of the book <CITE>Icon Programming for Humanists</CITE>,
224 by Alan Corr&eacute;, is also available for purchase or download from
225 <A HREF="http://unicon.org/books/">Jeffery Books</A>.
226 <P>
227 The <CITE>Icon Programming Language Handbook</CITE>,
228 by Thomas W. Christopher, is available on the web at
229 <A HREF="http://www.tools-of-computing.com/tc/CS/iconprog.pdf">
230 www.tools-of-computing.com/tc/CS/iconprog.pdf</A>.
231 <P>
232 An on-line index to the Icon program library is found at
233 <A HREF="http://www.cs.arizona.edu/icon/library/ipl.htm">
234 www.cs.arizona.edu/icon/library/ipl.htm</A>.
235 <P>
236 There is a large amount of additional information at the
237 Icon web site,
238 <A HREF="http://www.cs.arizona.edu/icon/">www.cs.arizona.edu/icon</A>,
239 including complete sets of back issues of the
240 <A HREF="http://www.cs.arizona.edu/icon/inl/inl.htm">
241 <CITE>Icon Newsletter</CITE></A> and
242 <A HREF="http://www.cs.arizona.edu/icon/analyst/ia.htm">
243 <CITE>Icon Analyst</CITE></A>.
244
245 <HR><H2>Implementations</H2>
246
247 <H3><A NAME="platforms">B1.</A> What platforms support Icon?</H3>
248 <P>
249 The primary implementation of Icon is written for Unix-based systems.
250 These include Linux, BSD, Solaris, Macintosh, Haiku, and the
251 <A HREF="http://www.cygwin.com/">Cygwin</A> environment under Windows.
252 Version 9.5 of Icon has been tested on all these platforms.
253 <P>
254 A native implementation for
255 <A HREF="http://www.cs.arizona.edu/icon/v95w.htm">Windows</A>,
256 derived from this code, is available in binary form.
257 An alternative Java-based implementation for Unix,
258 <A HREF="http://www.cs.arizona.edu/icon/jcon/">Jcon</A>,
259 is also available.
260 Older versions for other systems are also hosted on the Icon website.
261 <P>
262 Icon does not provide a window-based development environment.
263 While Icon programs can open windows and use graphics,
264 programming is done using editors and other tools from a command shell.
265
266 <H3><A NAME="getstarted">B2.</A> How do I get started with Icon?</H3>
267 <P>
268 Icon is distributed in source form from GitHub at
269 <A HREF="https://github.com/gtownsend/icon">github.com/gtownsend/icon</A>.
270 A copy can be downloaded and built without learning Git.
271 Select the "Download ZIP" pulldown from the green "↓ Code" button.
272 <P>
273 The most recent prebuilt Unix release can be downloaded from
274 <A HREF="http://www.cs.arizona.edu/icon/v95u.htm">
275 www.cs.arizona.edu/icon/v95u.htm</A>.
276 Source and binary packages are available, each with the
277 complete Icon program library.
278 <P>
279 The Windows implementation is at
280 <A HREF="http://www.cs.arizona.edu/icon/v95w.htm">
281 www.cs.arizona.edu/icon/v95w.htm</A>.
282 <P>
283 For other implementations, start at
284 <A HREF="http://www.cs.arizona.edu/icon/implver.htm">
285 www.cs.arizona.edu/icon/implver.htm</A>.
286
287 <H3><A NAME="unicode">B3.</A> Is there a Unicode version of Icon?</H3>
288 <P>
289 No.
290 Icon is defined in terms of 8-bit characters, and changing this presents
291 several design challenges that would likely break existing programs.
292 Modifying the C implementation is probably infeasible anyway,
293 although a Unicode version of Jcon might be possible.
294 <P>
295 The clever design of UTF-8, the usual Unicode encoding,
296 allows code such as <CODE>write("E♭F♯G♮")</CODE> to work;
297 but to Icon, <CODE>"E♭F♯G♮"</CODE> is a string of length 12 because
298 the music accidentals ♭♯♮ are encoded in three bytes each.
299
300 <H3><A NAME="iconc">B4.</A> What happened to the compiler?</H3>
301 <P>
302 For a while, Unix distributions included both an interpreter and a compiler.
303 The compiler was an interesting research project but it has not been
304 maintained and is no longer supported.
305 The interpreter is much easier to use and is generally quite fast enough,
306 even for production applications.
307
308 <HR><H2>Administration</H2>
309
310 <H3><A NAME="iconproject">C1.</A> What is the Icon Project?</H3>
311 <P>
312 The Icon Project name identifies the group that
313 distributes and supports the Icon programming language.
314 A non-commercial organization, the project is supported by the
315 Department of Computer Science at the University of Arizona.
316 <P> Gregg Townsend, now retired from Arizona, maintains the
317 Unix implementation and the Icon website.
318 Carl Sturtivant of the University of Minnesota maintains
319 the native Windows implementation and the Cygwin port.
320
321 <H3><A NAME="updates">C2.</A> How often is the on-line material updated?</H3>
322 <P>
323 Web pages and other files are updated occasionally,
324 on an unscheduled basis, when warranted.
325 <P>
326 The Icon implementation is now in maintenance mode.
327 No more formal releases are currently planned,
328 but one is not precluded should a compelling reason arise.
329
330 <H3><A NAME="lineage">C3.</A> Where did Icon come from?</H3>
331 <P>
332 Icon is the latest in a series of high-level programming languages designed
333 to facilitate programming tasks involving strings and structures.
334 The original language, SNOBOL, was developed at Bell Telephone Laboratories
335 in the early 1960s.
336 SNOBOL evolved into SNOBOL4, which is still in use.
337 Subsequent languages were developed at the University of
338 Arizona with support from the National Science Foundation.
339 Although it has similar objectives and many similar capabilities,
340 Icon bears little superficial resemblance to SNOBOL4.
341 <P>
342 Icon implementations were developed by faculty, staff, and students
343 at the University of Arizona,
344 with significant contributions from volunteers around the world.
345 An <A HREF="http://doi.acm.org/10.1145/155360.155363">Icon history</A>
346 by Ralph and Madge Griswold appears in the preprints
347 of the second History of Programming Languages Conference (HOPL-II),
348 ACM SIGPLAN Notices, March 1993 (Vol 28, No 3).
349 <P>
350 The name Icon is not an acronym, nor does it stand for anything in
351 particular, although the word <CITE>iconoclastic</CITE> was mentioned
352 when the name was chosen.
353 The name predates the now common use of <CITE>icon</CITE>
354 to refer to small images used in graphical user interfaces.
355 This sometimes misleads people into thinking
356 that Icon is designed to create or manipulate icons,
357 but there's no good solution to that problem.
358
359 <H3><A NAME="futures">C4.</A> Where is Icon going? </H3>
360 <P>
361 We continue to use Icon on a daily basis, but no significant changes
362 are planned.
363 We expect to support the Unix version for the foreseeable future,
364 and to distribute ports to other systems as supplied by volunteers.
365 <P>
366 The Unicon project continues to develop an object-oriented language
367 based on Icon. For more information, see
368 <A HREF="http://unicon.sourceforge.io/">unicon.sourceforge.io</A>.
369
370 <HR><H2>Programming</H2>
371
372 <H3><A NAME="evread">D1.</A>
373 Why doesn't <CODE>read()</CODE> work with <CODE>every</CODE>?</H3>
374 <P>
375 <CODE>every s := read() do {...}</CODE>
376 doesn't loop because <CODE>read()</CODE> produces a single value and
377 then fails if resumed.
378 Other "consumer" procedures such as <CODE>get()</CODE> and <CODE>pop()</CODE>
379 work the same way.
380 Use a <CODE>while</CODE> loop with these procedures, and save
381 <CODE>every</CODE> for use with generators such as <CODE>!x</CODE>
382 or <CODE>key(T)</CODE>.
383
384 <H3><A NAME="strinv">D2.</A>
385 Why doesn't string invocation such as <CODE>"foo"()</CODE> work?</H3>
386 <P>
387 String invocation works if the procedure is present;
388 the catch is that the linker removes unreferenced procedures.
389 To ensure a procedure's presence, reference it in the
390 <CODE>main()</CODE> procedure.
391 A simple reference suffices, as in
392 <CODE>refs := [foo, bar, baz]</CODE>;
393 it's not necessary to actually call it.
394 <P>
395 (Why does the linker remove unreferenced procedures?
396 Because that <EM>greatly</EM> reduces the memory requirements of
397 programs that use the library.
398 There was a time when this mattered.)
399
400 <H3><A NAME="callc">D3.</A> How can I call a C function?</H3>
401 <P>
402 You can't call an arbitrary C function, but you can load and call one
403 that is written to Icon's specifications.
404 A tutorial appears in
405 <a href="http://www.cs.arizona.edu/icon/analyst/backiss/IA36.pdf">
406 Icon Analyst 36</a>.
407 Some examples can be found in the
408 <A HREF="http://www.cs.arizona.edu/icon/library/ccfuncs.htm">
409 <CODE>cfuncs</CODE></A> and
410 <CODE>packs/loadfuncs</CODE> directories of the Icon program library.
411 <P>
412 The <A HREF="http://www.cs.arizona.edu/icon/jcon/">Jcon</A> implementation
413 allows Icon programs to call Java code that is written to Jcon specifications.
414
415 <H3><A NAME="rwpipe">D4.</A> Can I open a bidirectional pipe?</H3>
416 <P>
417 No, this is not possible.
418 Although the concept is simple &mdash;
419 write a line to a program via a pipe, then read that program's output
420 &mdash; it probably wouldn't work.
421 Most I/O libraries don't write anything to a pipe until
422 they've filled a buffer, and the most likely consequence would be
423 a deadlock, with each program waiting for the other to send more data.
424
425 <HR>
426 <SMALL>
427 This FAQ is edited by Gregg Townsend.
428 It includes contributions from
429 Ralph Griswold, Cliff Hathaway, Clint Jeffery, Bob Alexander,
430 and Todd Proebsting.
431 </SMALL>
432 </BODY>
433 </HTML>