# ANN: Joy in Java

## raybaquirin — 2006-01-06 09:12:14

    Joy in Java (JoyJ), an interpreter for Joy implemented in Java, is now

    available for download from

    http://appforge.apc.edu.ph/frs/?group_id=114&release_id=221

    Installation instructions are in the README.html file.  Ignore the

    mention of a zip file in the README, the project files are directly

    downloadable from the URL above.

    Questions, comments, bug reports, patches welcome.  Please address to:

    rayb@...

    Happy New Year!

    Ray

## John Cowan — 2006-01-06 18:48:55

    raybaquirin scripsit:

     > Joy in Java (JoyJ), an interpreter for Joy implemented in Java, is now

    > available for download from

    > http://appforge.apc.edu.ph/frs/?group_id=114&release_id=221

    > Installation instructions are in the README.html file.  Ignore the

    > mention of a zip file in the README, the project files are directly

    > downloadable from the URL above.

     Congratulations!  I'm especially impressed that the implementation language

    is NetRexx, a language I particularly like.  I've had a soft spot for

    Rexx ever since it was the only dynamic language that could bind to the OS/2 EE

    database; I wrote a Smalltalk program that generated a Rexx program that

    output database data in comma-separated-value format that could be loaded

    back into Smalltalk or directly into Excel.

    As you know but others may not, NetRexx is a statically typed language

    masquerading as a dynamically typed one that compiles into JVM class files;

    the masquerade is arranged by the flexible value class Rexx cooperating

    with some neat assumptions by the NetRexx compiler.

    --

    John Cowan      cowan@...        http://www.reutershealth.com

            "Not to know The Smiths is not to know K.X.U."  --K.X.U.

## raybaquirin — 2006-01-09 03:37:14

    Hi, John,

     --- In concatenative@yahoogroups.com, John Cowan <cowan@c...> wrote:

    [snipped]

    > Congratulations!  I'm especially impressed that the implementation

    language

    > is NetRexx, a language I particularly like.

    Thank you.

    >I've had a soft spot for

    > Rexx ever since it was the only dynamic language that could bind to

    the OS/2 EE

    > database; I wrote a Smalltalk program that generated a Rexx program that

    > output database data in comma-separated-value format that could be

    loaded

    > back into Smalltalk or directly into Excel.

    I also encountered Rexx on OS/2 and earlier on the AS/400.  One reason

    I chose to use NetRexx is with a view to re-using the code for a pure

    Rexx port of Joy.  But of course I should concentrate first on

    fleshing out and improving the current implementation.

    >

    > As you know but others may not, NetRexx is a statically typed language

    > masquerading as a dynamically typed one that compiles into JVM class

    files;

    > the masquerade is arranged by the flexible value class Rexx cooperating

    > with some neat assumptions by the NetRexx compiler.

    I'm wondering, though, if I shouldn't just transition to a pure Java

    implementation.  I have a feeling that that would lower the bar for

    participation in the project for the young guns out there.

    > John Cowan      cowan@c...        http://www.reutershealth.com

    >         "Not to know The Smiths is not to know K.X.U."  --K.X.U.

    >

    Ray

## Manfred Von Thun — 2006-01-16 06:23:00

    Congratulations, Ray, this looks very impressive.

    Your choice of an implementation language really did pay off,

    just judging by the size of the entire interpreter  it is very neat.

    I did notice that you put the ³quit² command into the main loop.

    In my prototype it is just an ordinary Joy operator  and this has the

    consequence that one can use it (deeply) inside ordinary programs,

    such as

        [stack null]  [³stack is empty  bye² put quit]  []  ifte

    Did you put the ³quit² command inside the main loop because

    Netrexx does not have an exit command or the very useful

    setjmp/longjmp combination of the C language?  (Not that it

    matters much, it is a trifling difference.)

    Also, I was intrigued by the comments you and John Cowan made

    about the way Netrexx and Java differ in their handling of types.

    Would either of you care to comment further? Is this a promising

    approach to take for a Joy compiler?

    Again, congratulations, and best wishes for the continuing development.

      - Manfred

     On 6/1/06 8:12 PM, "raybaquirin" <raybaquirin@...> wrote:

    > Joy in Java (JoyJ), an interpreter for Joy implemented in Java, is now

    > available for download from

    > http://appforge.apc.edu.ph/frs/?group_id=114&release_id=221

    > Installation instructions are in the README.html file.  Ignore the

    > mention of a zip file in the README, the project files are directly

    > downloadable from the URL above.

    >

    > Questions, comments, bug reports, patches welcome.  Please address to:

    > rayb@...

    >

    > Happy New Year!

    >

    > Ray

    >

    >

    >

    >

    >

    >

    >

    >

    >

    >  YAHOO! GROUPS LINKS

    >

    > *  Visit your group "concatenative

    > <http://groups.yahoo.com/group/concatenative> " on the web.

    > *

    > *  To unsubscribe from this group, send an email to:

    > *  concatenative-unsubscribe@yahoogroups.com

    > <mailto:concatenative-unsubscribe@yahoogroups.com?subject=Unsubscribe>

    > *

    > *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service

    > <http://docs.yahoo.com/info/terms/> .

    >

    >

    >

    >

    [Non-text portions of this message have been removed]

## John Cowan — 2006-01-16 09:01:14

    Manfred Von Thun scripsit:

     > Did you put the ³quit² command inside the main loop because

    > Netrexx does not have an exit command or the very useful

    > setjmp/longjmp combination of the C language?  (Not that it

    > matters much, it is a trifling difference.)

     Java (and therefore Netrexx) programs can exit by calling System.exit(n)

    with the exit code.

     > Also, I was intrigued by the comments you and John Cowan made

    > about the way Netrexx and Java differ in their handling of types.

    > Would either of you care to comment further?

     I'd be happy to comment further, but I don't know what on.  Ask me

    a question and I'll try to answer it.

    --

    John Cowan  cowan@...  www.reutershealth.com  www.ccil.org/~cowan

    This great college [Trinity], of this ancient university [Cambridge],

    has seen some strange sights. It has seen Wordsworth drunk and Porson

    sober. And here am I, a better poet than Porson, and a better scholar

    than Wordsworth, somewhere betwixt and between.  --A.E. Housman

## raybaquirin — 2006-01-19 02:54:07

    --- In concatenative@yahoogroups.com, Manfred Von Thun

    <m.vonthun@l...> wrote:

     >

    > Congratulations, Ray, this looks very impressive.

     Thank you.

     > Your choice of an implementation language really did pay off,

    > just judging by the size of the entire interpreter ï¿½ it is very neat.

     I would call this a case of serendipity--I chose NetRexx because, of

    all the languages that run in the JVM, it is the one I am most

    comfortable with. And since it uses Rexx strings for most things, that

    was what I used too.

     >

    > I did notice that you put the ï¿½quitï¿½ command into the main loop.

    > In my prototype it is just an ordinary Joy operator ï¿½ and this has the

    > consequence that one can use it (deeply) inside ordinary programs,

    > such as

    >     [stack null]  [ï¿½stack is empty ï¿½ byeï¿½ put quit]  []  ifte

    > Did you put the ï¿½quitï¿½ command inside the main loop because

    > Netrexx does not have an exit command or the very useful

    > setjmp/longjmp combination of the C language?  (Not that it

    > matters much, it is a trifling difference.)

     No, that was just me dropping the ball.  Anyway, s John Cowan said in

    his post, that's easy to fix and will be in the next release.  I am

    just struggling with subversion at the moment and would like to get

    that running first.

     >

    > Also, I was intrigued by the comments you and John Cowan made

    > about the way Netrexx and Java differ in their handling of types.

    > Would either of you care to comment further?

     Well, I guess all latently typed languages implemented on the JVM have

    some strategy to deal with type conversions.  For NetRexx the details

    are in the NetRexx Language Definition (which I have gone over but not

    read in detail) and are such that type conversion is mostly automatic.

     >Is this a promising

    > approach to take for a Joy compiler?

     Maybe, if Joy objects are represented as strings (with some internal

    structure).

     >

    > Again, congratulations, and best wishes for the continuing development.

    >

    >   - Manfred

     Ray

     >

    > On 6/1/06 8:12 PM, "raybaquirin" <raybaquirin@y...> wrote:

    >

    > > Joy in Java (JoyJ), an interpreter for Joy implemented in Java, is now

    > > available for download from

    > > http://appforge.apc.edu.ph/frs/?group_id=114&release_id=221

    > > Installation instructions are in the README.html file.  Ignore the

    > > mention of a zip file in the README, the project files are directly

    > > downloadable from the URL above.

    > >

    > > Questions, comments, bug reports, patches welcome.  Please address to:

    > > rayb@a...

    > >

    > > Happy New Year!

    > >

    > > Ray

    > >

    > >

    > >

    > >

    > >

    > >

    > >

    > >

    > >

    > >  YAHOO! GROUPS LINKS

    > >

    > > *  Visit your group "concatenative

    > > <http://groups.yahoo.com/group/concatenative> " on the web.

    > > *

    > > *  To unsubscribe from this group, send an email to:

    > > *  concatenative-unsubscribe@yahoogroups.com

    > > <mailto:concatenative-unsubscribe@yahoogroups.com?subject=Unsubscribe>

    > > *

    > > *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service

    > > <http://docs.yahoo.com/info/terms/> .

    > >

    > >

    > >

    > >

    >

    >

    >

    >

    > [Non-text portions of this message have been removed]

    >

## Manfred Von Thun — 2006-01-23 04:35:30

    On 19/1/06 1:54 PM, "raybaquirin" <raybaquirin@...> wrote:

     > --- In concatenative@yahoogroups.com, Manfred Von Thun

    > <m.vonthun@l...> wrote:

    >

     [..]

     >

    >> > Your choice of an implementation language really did pay off,

    >> > just judging by the size of the entire interpreter ï¿½ it is very neat.

    > I would call this a case of serendipity--I chose NetRexx because, of

    > all the languages that run in the JVM, it is the one I am most

    > comfortable with. And since it uses Rexx strings for most things, that

    > was what I used too.

     Many years ago I came across a language in which ³everything

    was a string², with a severe performance penalty. I cannot

    remember what it was, but because of the penalty I did not take

    it seriously. From what I read about Netrexx, this judgement

    should not be generalised to all such languages. It seems that

    Netrexx is a fine implementation language indeed. My puzzle was

    how the compiler manages to translate that into a reasonably

    efficient target code. But I suppose that serious compiler writers

    (and I am not) are pretty smart at that sort of thing.

     >

     [..]

     >

    >> > Also, I was intrigued by the comments you and John Cowan made

    >> > about the way Netrexx and Java differ in their handling of types.

    >> > Would either of you care to comment further?

    > Well, I guess all latently typed languages implemented on the JVM have

    > some strategy to deal with type conversions.  For NetRexx the details

    > are in the NetRexx Language Definition (which I have gone over but not

    > read in detail) and are such that type conversion is mostly automatic.

    >

     I looked at the Netrexx Language Overview, and was intrigued by a

    particular detail, page 9, ³Doing things with strings². There is some

    code:

        phrase=¹Now is the time for a party¹

        say phrase.word(7).pos(r¹)

    takes the 7-th word of phrase(party¹), then position of r

    which yields 3. This is contrasted with the Rexx equivalent

        say pos(r¹,word(phrase(7))

    that gives the same result but is harder to read.

    I found it interesting that Rexx uses pretty conventional

    prefix order (like Lisp, but different syntax), whereas the

    Netrexx version uses what the documentation describes as

    message passing, in an almost postfix style. In a concatenative

    language this would be written even more consistently in full

    postfix style as

        phrase 7 word r¹ pos say

    Would anyone care to implement these string handlers in

    Joy either using the existing functions or as new primitives

    directly implemented in the C source?

      - Manfred

     >

    >

    >

     [Non-text portions of this message have been removed]

## Keith Gaughan — 2006-01-23 14:11:37

    Manfred Von Thun wrote:

     > On 19/1/06 1:54 PM, "raybaquirin" <raybaquirin@...> wrote:

    >

    >> --- In concatenative@yahoogroups.com, Manfred Von Thun

    >> <m.vonthun@l...> wrote:

    >>

    >>>> Your choice of an implementation language really did pay off,

    >>>> just judging by the size of the entire interpreter ï¿½ it is very neat.

    >>

    >> I would call this a case of serendipity--I chose NetRexx because, of

    >> all the languages that run in the JVM, it is the one I am most

    >> comfortable with. And since it uses Rexx strings for most things, that

    >> was what I used too.

    >

    > Many years ago I came across a language in which ³everything

    > was a string², with a severe performance penalty. I cannot

    > remember what it was, but because of the penalty I did not take

    > it seriously.

     <delurk>

    Sounds like Tcl, which is a fine glue/embedded language, but not the

    kind of thing I personally would be comfortable using for anything other

    than that.

    </delurk>

    K.

## John Cowan — 2006-01-25 22:27:26

    Manfred Von Thun scripsit:

     > Many years ago I came across a language in which "everything

    > was a string", with a severe performance penalty.

     Most likely a version of TCL prior to 8.0.  In TCL even blocks of

    code are strings; the conditional is actually "if <expr> <string> else

    <string>", and { and } are matched string delimiters whose contents are

    not processed until run time.  TCL 8.0 and later have a smart compiler

    that can precompile strings when it can prove it is safe to do so.

     > It seems that Netrexx is a fine implementation language indeed. My

    > puzzle was how the compiler manages to translate that into a reasonably

    > efficient target code. But I suppose that serious compiler writers

    > (and I am not) are pretty smart at that sort of thing.

     They are, but NetRexx is not an example of efficient compilation in

    that sense.  Strings and numbers in NetRexx are by default instances

    of the class Rexx, which provides run-time support for both basic strings

    and arbitrary-precision rational numbers in decimal radix (internally

    expressed as digit strings).  Mike Cowlishaw, author of the Rexx family,

    considers accuracy and precision more important than speed in Rexx

    languages.

    In order to get access to binary integer or floating-point types in

    NetRexx, one must cast values to Java types such as int, long, float,

    and double.  Variables, however, do not need to be declared, as the

    compiler assumes that the first assignment to a variable also declares

    its type.  Thus given the code fragment:

    	i = 5

    	j = int 5

    	k = int

    the literal 5 is of type Rexx, and so the variable i is declared to

    be of type Rexx as well.  The cast "int 5" is an expression of type

    (32-bit) int, so j will be declared to have this type and assigned the

    32-bit integer value 5.  The expression "int" is a type without a value,

    so k is also declared to be of type int with an unspecified value.

    All three can be used in any context that expects either a Rexx or an int,

    or indeed any numeric type.

    Later in the program, i can be reassigned to a string, since strings

    are also of type Rexx, but j and k cannot.  The compiler assumes that

    the statically first assignment is the declaration, even though it may

    or may not be executed first.

     > I found it interesting that Rexx uses pretty conventional

    > prefix order (like Lisp, but different syntax), whereas the

    > Netrexx version uses what the documentation describes as

    > message passing, in an almost postfix style.

     That is an adaptation to the Java environment, where function

    invocation is always in the form a.foo(b, c, ...), thus

    syntactically signaling the importance of a's (dynamic) type

    in choosing the particular implementation of foo to invoke.

    --

    It was dreary and wearisome.  Cold clammy winter still held way in this

    forsaken country.  The only green was the scum of livid weed on the dark

    greasy surfaces of the sullen waters.  Dead grasses and rotting reeds loomed

    up in the mists like ragged shadows of long-forgotten summers.

            --"The Passage of the Marshes"          http://www.ccil.org/~cowan

## Manfred Von Thun — 2006-01-30 07:24:54

    On 26/1/06 9:27 AM, "John Cowan" <cowan@...> wrote:

     > Manfred Von Thun scripsit:

    >

    >> > Many years ago I came across a language in which "everything

    >> > was a string", with a severe performance penalty.

    >

    > Most likely a version of TCL prior to 8.0.  In TCL even blocks of

    > code are strings; the conditional is actually "if <expr> <string> else

    > <string>", and { and } are matched string delimiters whose contents are

    > not processed until run time.  TCL 8.0 and later have a smart compiler

    > that can precompile strings when it can prove it is safe to do so.

    >

     It was when I was ³in my computational nappies² (now here is something

    immensely quotable!), in the late 70¹s. A friend of mine thinks it was

    probably a simple Basic-like language called Aid, on what was then our

    only computer, ³the DEC10² by Digital Equipment Corporation. Our first

    Vax came later, in 1980.

          > It seems that Netrexx is a fine implementation language indeed. My

    >> > puzzle was how the compiler manages to translate that into a reasonably

    >> > efficient target code. But I suppose that serious compiler writers

    >> > (and I am not) are pretty smart at that sort of thing.

    > [..about strings and numbers in NetRexx..]

    >

     Thank you very much for the detailed explanation. It answers all the

    ill-formed questions I had.

     >> > I found it interesting that Rexx uses pretty conventional

    >> > prefix order (like Lisp, but different syntax), whereas the

    >> > Netrexx version uses what the documentation describes as

    >> > message passing, in an almost postfix style.

    >

    > That is an adaptation to the Java environment, where function

    > invocation is always in the form a.foo(b, c, ...), thus

    > syntactically signaling the importance of a's (dynamic) type

    > in choosing the particular implementation of foo to invoke.

     Yes, that makes sense. I have sometimes wondered how a concatenative

    language should handle this sort of thing. It should look like this:

        p q r a b c .. foo bar

    where the implementation has to know that b c .. are parameters,

    and that a is the recipient of the message foo, and that p q r

    are other things (maybe parameters, maybe objects) that have been

    pushed but so far not used.

    To do so efficiently, there could be

    a second stack to keep track of the most recently pushed object

    (here a) that is a potential recipient of a message (here foo)

    and parameters (here b c ..). After the message foo has been

    processed, presumably something, say x, replaces a b c ..,

    and message bar is sent to the top object, say q, which is

    now the top element on the second stack, with parameters r and x.

    So the second stack would duplicate some of the work of the ordinary

    stack. The increased efficiency is probably not all that great,

    and maybe the cost of maintaining it outweighs the gain. Without

    a second stack the implementation would need to search from the top

    of the ordinary stack down until it finds an object to which a

    message (foo or bar) could be sent. Presumably the list of

    parameter (b c ..) that need to be skipped is rarely very long.

    I have no practical experience with object oriented programming,

    and there are no plans to add it to Joy. But maybe somebody else is

    thinking along such lines.

    Thanks for your comments, John.

      - Manfred

    [Non-text portions of this message have been removed]