home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 28 / Commodore_Free_Issue_28_2009_Commodore_Computer_Club.d64 / evolution < prev    next >
Text File  |  2023-02-26  |  15KB  |  497 lines

  1. u
  2.  
  3.  
  4. **************************
  5. * The Evolution of Forth *
  6. **************************
  7. Commodore Free; would like to thank
  8. "Forth Inc" for its help with
  9. articles about Forth language. The
  10. original article can be found here,
  11. reprinted below is just a small
  12. section of what is available online:
  13.  
  14.  http://www.forth.com/resources/
  15.   evolution/index.html
  16.  
  17. Forth Inc also have a very nice
  18. online version of the classic book
  19. Starting Forth this is still
  20. considered a classic book about the
  21. Forth language and you will see its
  22. name pop up many times the full
  23. online book is available from here:
  24.  http://www.forth.com/starting-
  25.   forth/Abstract
  26.  
  27. Forth is unique among programming
  28. languages in that its development and
  29. proliferation has been a grass-roots
  30. effort unsupported by any major
  31. corporate or academic sponsors.
  32. Originally conceived and developed by
  33. a single individual, its later
  34. development has progressed under two
  35. significant influences: professional
  36. programmers who developed tools to
  37. solve application problems and then
  38. commercialized them, and the
  39. interests of hobbyists concerned with
  40. free distribution of Forth. These
  41. influences have produced a language
  42. markedly different from traditional
  43. programming languages
  44. Authors
  45. Elizabeth D. Rather
  46. FORTH, Inc.
  47. 5959 W. Century Blvd..
  48. Suite 700
  49. Los Angeles, CA 90045
  50.  
  51. Donald R. Colburn
  52. c/o Digital Media Magic
  53. 14712 Westbury Rd.
  54. Rockville, MD 20853
  55.  
  56. Charles H. Moore
  57. Computer Cowboys
  58. 40 Cedar Lane
  59. PO Box 127
  60. Sierra City, CA 96125
  61.  
  62. Presented at the ACM SIGPLAN History
  63. of Programming Languages Conference
  64. (HOPL II, April, 1993). Published in
  65. ACM SIGPLAN Notices, Volume 28, No. 3
  66. March 1993.
  67.  
  68. Permission to copy without fee all or
  69. part of this material is granted
  70. provided that the copies are not made
  71. or distributed for direct commercial
  72. advantage, the ACM copyright notice
  73. and the title of the publication and
  74. its date appear, and notice is given
  75. that copying is by permission of the
  76. Association for Computing Machinery.
  77. To copy otherwise, or to republish,
  78. requires a fee and/or specific
  79. permission.
  80.  
  81. *************************************
  82. * Chuck Moore's Programming Language*
  83. *       Early Development           *
  84. *************************************
  85.  
  86. Moore's programming career began in
  87. the late 1950's at the Smithsonian
  88. Astrophysical Observatory with
  89. programs to compute ephemerides,
  90. orbital elements, satellite station
  91. positions, etc. [Moore, 1958], [Veis,
  92. 1960]. His source code filled two
  93. card trays. To minimize recompiling
  94. this large program, he developed a
  95. simple interpreter to read cards
  96. controlling the program. This enabled
  97. him to compose different equations
  98. for several satellites without
  99. recompiling. This interpreter
  100. featured several commands and
  101. concepts that survived into modern
  102. Forth, principally a command to read
  103. "words" separated by spaces and one
  104. to convert numbers from external to
  105. internal form, plus an IF  ELSE
  106. construct. He found free-form input
  107. to be both more efficient (smaller
  108. and faster code) and reliable than
  109. the more common Fortran practice of
  110. formatting into specific columns,
  111. which had resulted in numerous
  112. re-runs due to mis-aligned columns
  113.  
  114. In 1961, Moore received his BA in
  115. Physics from MIT and entered graduate
  116. school at Stanford. He also took a
  117. part-time programming position at the
  118. Stanford Linear Accelerator (SLAC),
  119. writing code to optimize beam
  120. steering for the (then) pending
  121. two-mile electron accelerator, using
  122. an extension of some of his prior
  123. work with least-squares fitting. A
  124. key outgrowth of this work was a
  125. program called CURVE, coded in Algol
  126. (1964), a general-purpose non-linear
  127. differential-corrections data fitting
  128. program. To control this program, he
  129. used an enhanced version of his
  130. interpreter, extended to manage a
  131. push-down stack for parameter
  132. passing, variables (with the ability
  133. to explicitly fetch and store
  134. values), arithmetic and comparison
  135. operators, and the ability to define
  136. and interpret procedures.
  137.  
  138. In 1965, he moved to New York City to
  139. become a free-lance programmer.
  140. Working in Fortran, Algol, Jovial,
  141. PL/I and various assemblers, he
  142. continued to use his interpreter as
  143. much as possible, literally carrying
  144. around his card deck and recoding it
  145. as necessary. Minicomputers appeared
  146. in the late 60's, and with them
  147. teletype terminals, for which Moore
  148. added operators to manage character
  149. input and output. One project
  150. involved writing a Fortran-Algol
  151. translator and file-editing
  152. utilities. This reinforced for him
  153. the value of spaces between words,
  154. which were not required in Fortran
  155. source.
  156.  
  157. Newly married and seeking a small
  158. town environment, Moore joined
  159. Mohasco Industries in Amsterdam, NY,
  160. in 1968. Here he developed computer
  161. graphics programs for an IBM 1130
  162. minicomputer with a 2250 graphic
  163. display. This computer had a 16-bit
  164. CPU, 8K RAM, his first disk,
  165. keyboard, printer, card reader/punch
  166. (used as disk backup!), and Fortran
  167. compiler. He added a cross-assembler
  168. to his program to generate code for
  169. the 2250, as well as a primitive
  170. editor and source-management tools.
  171. This system could draw animated 3-D
  172. images, at a time when IBM's software
  173. for that configuration drew only
  174. static 2-D images. For fun, he also
  175. wrote a version of Spacewar, an early
  176. video game, and converted his Algol
  177. Chess program into the new language,
  178. now (for the first time) called
  179. FORTH. He was impressed by how much
  180. simpler it became.
  181.  
  182. The name FORTH was intended to
  183. suggest software for the fourth
  184. (next) generation computers, which
  185. Moore saw as being characterized by
  186. distributed small computers. The
  187. operating system he used at the time
  188. restricted file names to five
  189. characters, so the "U" was discarded.
  190. FORTH was spelled in upper case until
  191. the late 70's because of the
  192. prevalence of upper-case-only I/O
  193. devices. The usage "Forth" was
  194. generally adopted when lower case
  195. became widely available, because the
  196. word was not an acronym.
  197.  
  198. Moore found the Forth-based 1130
  199. environment for programming the 2250
  200. superior to the Fortran environment
  201. in which the 1130 software was
  202. developed, so he extended it into an
  203. 1130 compiler. This added looping
  204. commands, the concept of keeping
  205. source in 1024-byte blocks and tools
  206. for managing them, and most of the
  207. compiler features we recognize in
  208. Forth today.
  209.  
  210. Most important, there was now a
  211. dictionary. Procedures now had names,
  212. and the interpreter searched a linked
  213. list of names for a match. Names were
  214. compiled with a count and three
  215. characters, a practice learned from
  216. the compiler writers of Stanford and
  217. which prevailed in Forth until the
  218. 1980's. Within a dictionary entry was
  219. a "code field" containing the address
  220. of code to be executed for that
  221. routine. This was an indirect
  222. threaded code implementation and was
  223. in use five years before Dewar's
  224. paper on indirect threaded coded
  225. appeared in Communications of the ACM
  226. The use of indirect threaded code was
  227. an important innovation, since an
  228. indirect jump was the only overhead
  229. once a word had been found.
  230. Dictionary entries could consist
  231. either of pointers to other "high
  232. level" routines or of machine
  233. instructions.
  234.  
  235. Finally, in order to provide a simple
  236. mechanism for nesting routines, a
  237. second stack called the "return
  238. stack" was added. The benefit of
  239. having a stack reserved for return
  240. addresses was that the other stack
  241. could be used freely for parameter
  242. passing, without having to be
  243. "balanced" before and after calls.
  244. The first paper on Forth was written
  245. at Mohasco In 1970 Mohasco assigned
  246. Moore to an ambitious project
  247. involving a new Univac 1108 handling
  248. a network of leased lines for an
  249. order-entry system. He ported Forth
  250. onto the 1108, and arranged for it to
  251. interface to COBOL modules that did
  252. the transaction processing. The 1108
  253. Forth was coded in assembler. It
  254. buffered input and output messages
  255. and shared the CPU among tasks
  256. handling each line. It also
  257. interpreted the input and executed
  258. the appropriate COBOL modules. This
  259. version of Forth added mechanisms for
  260. defining and managing tasks, and also
  261. an efficient scheme for managing disk
  262. block buffers similar to schemes in
  263. use today. Unfortunately, an economic
  264. downturn led Mohasco to cancel the
  265. 1108 project before completion. Moore
  266. immediately gave notice, then wrote
  267. an angry poem and a book on Forth
  268. that was never published. It
  269. described how to develop Forth
  270. software and encouraged simplicity
  271. and innovation
  272.  
  273. Philosophy and Goals
  274. To Moore, Forth was a personal
  275. response to his frustration with
  276. existing software tools, which he
  277. viewed as a sort of "tower of Babel"
  278.  
  279. The software provided with large
  280. computers supplies a hierarchy of
  281. languages: the assembler defines the
  282. language for describing the compiler
  283. and supervisor; the supervisor the
  284. language for job control; the
  285. compiler the language for application
  286. programs; the application program the
  287. language for its input. The user may
  288. not know, or know of, all these
  289. languages: but they are there. They
  290. stand between him and his computer,
  291. imposing their restrictions on what
  292. he can do and what it will cost.
  293.  
  294. And cost it does, for this vast
  295. hierarchy of languages requires a
  296. huge investment of man and machine
  297. time to produce, and an equally large
  298. effort to maintain. The cost of
  299. documenting these programs and of
  300. reading the documentation is
  301. enormous. And after all this effort
  302. the programs are still full of bugs,
  303. awkward to use and satisfying to no
  304. one.
  305.  
  306. Moore conceived of Forth as replacing
  307. the entire "vast hierarchy" with a
  308. single layer, requiring only two
  309. elements: a programmer-to-Forth
  310. interface, consisting of minimal
  311. documentation (minimal because the
  312. interface should be simple and
  313. natural), and the Forth-machine
  314. interface, consisting of the program
  315. itself. His view was entirely
  316. personal, considering his own needs
  317. in the light of his own experience.
  318. The following excerpts from his
  319. unpublished book describe this view:
  320.  
  321. I've written many programs over the
  322. years. I've tried to write good
  323. programs, and I've observed the
  324. manner in which I write them rather
  325. critically. My goal has been to
  326. decrease the effort required and
  327. increase the quality produced.
  328.  
  329. In the course of these observations,
  330. I've found myself making the same
  331. mistakes repeatedly. Mistakes that
  332. are obvious in retrospect, but
  333. difficult to recognize in context. I
  334. thought that if I wrote a
  335. prescription for programming, I could
  336. at least remind myself of problems.
  337. And if the result is of value to me,
  338. it should be of value to others.
  339.  
  340. Above all, his guiding principle,
  341. which he called the "Basic
  342. Principle," was, "Keep it simple!"
  343. Throughout his career he has observed
  344. this principle with religious
  345. dedication.
  346.  
  347. As the number of capabilities you add
  348. to a program increases, the
  349. complexity of the program increases
  350. exponentially. The problem of
  351. maintaining compatibility among these
  352. capabilities, to say nothing of some
  353. sort of internal consistency in the
  354. program, can easily get out of hand.
  355. You can avoid this if you apply the
  356. Basic Principle. You may be
  357. acquainted with an operating system
  358. that ignored the Basic Principle.
  359.  
  360. It is very hard to apply. All the
  361. pressures, internal and external,
  362. conspire to add features to your
  363. program. After all, it only takes a
  364. half-dozen instructions, so why not?
  365. The only opposing pressure is the
  366. Basic Principle, and if you ignore
  367. it, there is no opposing pressure.
  368.  
  369. The main enemy of simplicity was, in
  370. his view, the siren call of
  371. generality that led programmers to
  372. attempt to speculate on future needs
  373. and provide for them. So he added a
  374. corollary to the Basic Principle: "Do
  375. not speculate!"
  376.  
  377. Do not put code in your program that
  378. might be used. Do not leave hooks on
  379. which you can hang extensions. The
  380. things you might want to do are
  381. infinite; that means that each has 0
  382. probability of realization. If you
  383. need an extension later, you can code
  384. it later  and probably do a better
  385. job than if you did it now. And if
  386. someone else adds the extension, will
  387. he notice the hooks you left? Will
  388. you document this aspect of your
  389. program?
  390.  
  391. This approach flew in the face of
  392. accepted practice then as now. A
  393. second corollary was even more
  394. heretical: "Do it yourself!"
  395.  
  396. The conventional approach, enforced
  397. to a greater or lesser extent, is
  398. that you shall use a standard
  399. subroutine. I say that you should
  400. write your own subroutines.
  401.  
  402. Before you can write your own
  403. subroutines, you have to know how.
  404. This means, to be practical, that you
  405. have written it before; which makes
  406. it difficult to get started. But give
  407. it a try. After writing the same
  408. subroutine a dozen times on as many
  409. computers and languages, you'll be
  410. pretty good at it.
  411.  
  412. Moore followed this to an astounding
  413. extent. Throughout the 70's, as he
  414. implemented Forth on 18 different
  415. CPUs he invariably wrote for each his
  416. own assembler, his own disk and
  417. terminal drivers, even his own
  418. multiply and divide subroutines (on
  419. machines that required them, as many
  420. did). When there were manufacturer-
  421. supplied routines for these functions,
  422. he read them for ideas, but never
  423. used them verbatim. By knowing
  424. exactly how Forth would use these
  425. resources, by omitting hooks and
  426. generalities, and by sheer skill and
  427. experience (he speculated that most
  428. multiply/divide subroutines were
  429. written by someone who had never done
  430. one before and never would again),
  431. his versions were invariably smaller
  432. & faster, usually significantly so.
  433.  
  434. Moreover, he was never satisfied with
  435. his own solutions to problems.
  436. Revisiting a computer or an
  437. application after a few years, he
  438. often re-wrote key code routines. He
  439. never re-used his own code without
  440. re-examining it for possible
  441. improvements. This later became a
  442. source of frustration to Rather, who,
  443. as the marketing arm of FORTH, Inc.
  444. often bid jobs on the assumption that
  445. since Moore had just done a similar
  446. project this one would be easy  only
  447. to watch helplessly as he tore up all
  448. his past code and started over.
  449.  
  450. Today, Moore is designing Forth-based
  451. microprocessors using his own
  452. Forth-based CAD system, which he has
  453. re-written (and sometimes rebuilt,
  454. with his own hardware) almost
  455. continuously since 1979.
  456.  
  457. Moore considered himself primarily an
  458. applications programmer, and regarded
  459. this as a high calling. He perceived
  460. that "systems programmers" who built
  461. tools for "applications programmers"
  462. to use had a patronizing attitude
  463. toward their constituents. He felt
  464. that he had spent a great fraction of
  465. his professional life trying to work
  466. around barriers erected by systems
  467. programmers to protect the system
  468. from programmers and programmers from
  469. themselves, and he resolved that
  470. Forth would be different. Forth was
  471. designed for a programmer who was
  472. intelligent, highly skilled and
  473. professional; it was intended to
  474. empower, not constrain.
  475.  
  476. The net result of Moore's philosophy
  477. was a system that was small, simple,
  478. clean  and extremely flexible: in
  479. order to put this philosophy into
  480. practice, flexible software is
  481. essential. The reason people leave
  482. hooks for future extensions is that
  483. it's generally too difficult and
  484. time-consuming to re-implement
  485. something when requirements change.
  486. Moore saw a clear distinction between
  487. being able to teach a computer to do
  488. "anything" (using simple, flexible
  489. tools) and attempting to enable it to
  490. do "everything" with a huge,
  491. general-purpose OS. Committing
  492. himself to the former, he provided
  493. himself with the ideal toolset to
  494. follow his vision
  495.  
  496. ==================================
  497.