Japanese Lisp, Forth, and historical contingency

Yusuke Shinyama speculates: what would Lisp look like if it had been invented by speakers of a consistently postfix language like Japanese? Might it be written postfix instead of prefix?

Maybe so. But this is superficial. The car of a Lisp form is special because it's the head, not because it's first; as long as there are head and rest operators, it makes no difference whether the head is stored first or last or even in the middle. So while a postfix Lisp looks different, this is only a superficial matter of syntax; Lisp would work the same way if it had been invented in Japan.

Forth, though, might be dramatically affected — not in nature but in timing. Despite its simplicity, Forth appeared rather late: it was developed in the 1960s and not publicized until 1970, which was too late to become part of the cultural foundation of computing. I suspect this was an anomaly; Forth is so simple that it could easily have been discovered earlier, had anyone bothered to explore postfix notation. Speakers of a postfix natural language have an obvious example to encourage them. (Postfix mathematical notation would be an even stronger encouragement. IIUC Japanese arithmetic words are infix, so a Japanese-inspired notation would also be infix; postfix arithmetic could arise more naturally in a natlang where arithmetic operators are postpositions, and postpositional phrases follow their head noun, but this is not a common combination.)

If Forth had been known by the mid-1950s, it could have outcompeted Fortran to become the canonical high-level language. This would have exerted significant pressure on hardware: machines would be designed to run Forth, much as they're designed to run C today, so there would be a lot of stack machines. Since Forth makes such a good assembly language for such machines, there would be less pressure to develop other high-level languages. Programmers accustomed to its simplicity and flexibility and convenience would see all proposed alternatives as unusable and crippled and insanely complex, so other language families could go unexplored. Forth and its descendants might rule computing unchallenged for decades, until some long-delayed development made tree languages competitive.

History could be different. Lisp, Fortran, Algol — all the great old language families — might not exist, if the pioneers of computing had spoken a head-last natural language and found Forth first.

4 comments:

  1. I hope I haven't missed the thrust of your post in making this comment --

    I've thought about the Forth/Japanese thing quite a bit in the past. I actually doubt that, in your hypothetical, today's mainstream languages would look all that different than they do in our reality. I think Java would still essentially be Java, for instance, it just wouldn't have the C syntax legacy, arithmetic would be in RPN, and the method name would go on the right side of the arguments instead of the left.

    I certainly consider Forth to be a fairly low-level language. It has certain properties, such as being easy to bootstrap*, that helped make a niche for it (and, perhaps, to keep it there.) For it to compete with Fortran, it would have had to solve at least the same application-domain and software engineering problems Fortran did, and not fail any worse than Fortran in other areas.

    For example, juggling values on the stack is really not much different from addressing variables by offset into memory. (Some would say it's worse. I certainly find it tiresome.) I suspect giving temporary names to things is a conceptual tool that goes beyond what language you happen to speak natively; thus Forth would have had to develop a decent local binding concept somewhere along the way. Block scope is a natural extension of this, when you don't want your temporary names to clash. Then types, and objects, and so on...

    In the end, legacy cruft that doesn't count for anything anymore does tend to hang around in our technologies, and while it's sometimes annoying or detrimental (the dominance of the QWERTY keyboard layout for instance,) it's rarely a deal-breaker or show-stopper (otherwise there would have been evolutionary pressure for it to change.) My point is that it's usually superficial, and I see no reason that modern-day Forth-isms left over from an early adoption of Forth wouldn't be similarly so. (Indeed, wouldn't a hard-line Chomskian linguist consider head-final-ness to be itself a fairly superficial parameterization of UHG anyway?)

    *(Bootstrapping was obviously not a concern of the FORTRAN folks, what with them willing to throw dozens of programmer-years of effort at the first compiler. As much as I cringe at the thought, Chuck Moore's engineering style would probably be called "lean" today.)

    ReplyDelete
  2. The big problem Fortran solved was make programs smaller and more readable than assembly code. Forth does this at least as well (and with less complexity), because it supports points-free style. Doing everything in points-free style is painful, but it makes an attractive default, and one that's hard for other language families to copy.

    Presumably some Forths would acquire types and local variables; neither is particularly hard to add, and Forth derivatives in our world have both. But I don't think the results would look like our Algol- and Fortran-derived languages, because those don't support Forth's expressive style, and programmers don't like to abandon their basic expressive tools, especially such a surprisingly simple and powerful one.

    On the other hand, Lisp is at least as seductive as Forth, and it existed in the 1950s, but didn't become popular, because it wasn't good yet — Lisp didn't acquire basic features like static scope until the 1970s. (It's also further from the hardware, which was a significant barrier back then.) So I'm being a bit unfair in comparing the Forth of 1970 to the Fortran of 1957. In the dawn of programming languages, everyone was ignorant, and language families rose and fell by accidents of poorly understood design decisions. It's entirely possible that Forth could be discovered early, but languish because no one knew how to make it good. This is nearly what happened in our history: stack machines existed by 1960, but apparently no one until Moore realized that they could be convenient languages.

    ReplyDelete
  3. There is one other element, I think: Fortran made it possible to write programs smaller and more readable than the equivalent assembly code, but with comparable performance. The first Fortran compiler was an optimizing compiler. The very idea of an optimizing compiler is somewhat foreign to the Forth world and its tradition of bootstrapped, threaded code. Any optimization would have to be done by the Forth programmer (at quite a low level.) For this reason, I don't think it could have gotten a significant foothold in the early industry, with its limited resources and focus on numerical computation. A similar line of reasoning goes against Lisp here too, I suppose (replace "bootstrapped, threaded" with "meta-circularly defined, garbage collected".)

    To point-free style: perhaps if point-free style was a prominent feature of Japanese (or English, or any natural language,) things would be different. As it stands, it isn't; I don't think it's a coincidence that it is also widely considered painful!

    ReplyDelete
  4. On a stack-based machine, Forth is close enough to native code that it doesn't need much optimization (just peephole optimizations that eliminate most stack manipulation). Threaded code is a historical accident that probably wouldn't be repeated. So if the hardware were suitable, I don't think it would be at a disadvantage. I don't know how well stack machines compared to register machines in 1950s technology, though; maybe they required too many expensive gates?

    Points-free style is a common feature of natural language. It's usually achieved through ellipsis instead of high-order-ness or catenation, but the result is the same: you can often avoid mentioning the arguments even by pronoun. (Japanese, coincidentally, is very accepting of omitting arguments.) Forth users don't seem to consider points-free style painful, and they usually prefer it even in dialects with alternatives; apparently in Factor, only "about 1% of all words use lexical variables".

    ReplyDelete

It's OK to comment on old posts.