# Purely Forward Programs.

## John Carter — 2007-01-03 03:14:50

    I'm not quite sure where this notion fits in relative to concatenative

    languages, but I suspect there may be some common ground.

    First some background so that you may see where I'm coming from...

    My day job is refactoring very large commercial C/C++ programs,

    extracting reusable components out of them.

    Originally I had the notion of extracting a classic "Layered

    Architecture", but I found the topology of the system was fundamentally

    more complex than a layered system.

    So eventually I settled on the notion of extracting bundles of files

    whose interdependency between bundles was an Acyclic Digraph.

    This worked very well, and I found it had all the same desirable

    properties that a layered architecture has.

    Now looking back, I can make a curious and very strong observation....

    As I removed a cyclic dependency I found either the result ..

    1) Significantly improved the Design and/or

    2) Reduced the total line count and/or

    3) Removed a bug and/or

    4) Removed a Thread Race condition and/or

        several and/or all of the above.

    So I'm thinking about the following coding paradigm...

    Let me make a Hypothesis. The advent of Multipass compilers and

    Linkers were a wrong turn in the evolution of computing.

    So let me define a subset of _any_ language, which I will call the

    Linear subset.

    Consider the symbols of any language. Any occurrence of a symbol is either

    a declaration, definition or reference.

    If we define the Linear subset of _any_ language such that programs have

    the following characteristics...

    1) There are no forward declarations.

    2) The declarations and the definitions are lexically together.

    3) All references are lexically after the declaration _and_ definition.

    4) You can concatenate all the files of the system once into one file, which

        can be compiled in one pass, resolving all symbols leaving nothing

        for the linker to do.

    5) The above 4 criteria apply at every level of granularity. At a

        function and function call level, at a class level, at file by

        file level, at a directory by directory level, at package by package

        level, at a library by library level, at subsystem by subsystem level.

    6) Recursion should be limited to Tail Calls only.

    One obvious property is that it is easy to create Linear programs out

    of Linear components.

    Another property is it is easy to reuse subsystems.

    How does this all relate to concatenative languages?

    Well, I'm not quite sure.

    They are almost orthogonal concepts in fact.

    Except that I suspect that for certain things we will find a synergy.

    Manfred has so beautifully demonstrated that things like algebras and

    proofs and rewriting are much easier (and prettier) in concatenative

    languages like Joy.

    I suspect that a Linear subset of a concatenative language would be

    even easier and more scalable to large systems.

    I'm rambling now since I can't quite place a finger on why my

    intuition is that the notions of Linear subset and Concatenative

    Languages belong so well together.

    Any suggestions?

    John Carter                             Phone : (64)(3) 358 6639

    Tait Electronics                        Fax   : (64)(3) 359 4632

    PO Box 1645 Christchurch                Email : john.carter@...

    New Zealand