JWithATwist Mock Parser

I am designing a twisted version of J. I call it JWithATwist. Today I made a first pre-release of a parser with some mock language elements. I think this is interesting mainly in the community of J programmers. I have aired some opinions about Tacit J. The response is always a question – How should it be instead. This parser is made to answer that question.

You can find information about the J programming language at www.jsoftware.com .

Tacit J is in my opinion a very cryptic language, mainly due to what I call the hook and fork logic. Tacit J is supposed to be functional. However the data types can not contain functional values. The code is made up of all functions, called verbs, adverbs and conjunctions. The code is mainly written in units of three verbs, two verbs are actors and the third in the middle describes how to merge the results. To understand an expression you have to start by counting the verbs, if an expression ends with a unit of only two verbs the meaning of the expression is totally different.

You can write very short expressions. This is how you calculate the mean of a vector:

(+/ % #) 1 2 3

The sum divided by the length. Seems simple enough? Well, it’s not. Let’s say you want to negate something. There are numerous ways, just not the one you would expect. To specify that you mean negate when you write “-” and not subtract you can use the Cap verb “[:”.

There is nothing like named variables, so the thing called a noun, a value, that you want to negate is delivered either as something called a constant function, written “1:” if it is one, or the noun is delivered through the Left verb or Right verb, placeholders for the left and right noun arguments. These are written “[” and “]”.

Another way is to use the Atop conjunction, written “@”. The atop conjunction is very similar to a composition operator. It tells that the result of the function to the right is going to be input to the function to the left.

Here are these three ways to do a negation:

 ([: - ]) 1
 _1
 (-@]) 1
 _1
 ([: - 1:) 77
 _1

I don’t want to say that this is crazy. There are powerful operators and you can probably get more functionality into a line of code than in any other programming language. I think it is too complicated for most practical use. I also think it is too complicated to use as a notation to describe algorithms that you later implement in other languages. This is what I particularly dislike, since I would like it to be a notation you could use when you communicate about algorithms with others, and as a tool of your own thought.

So, to state my point I have written this little interpreter and I will later release it with a more realistic J-like language behind.

My main goal with this is to learn F# and a parsing tool called FParsec.

You find the code and a Windows installer here.

All opinions are welcome. You can comment on this blog. There will probably be discussions in the J chatroom #jsoftware at Freenode and in the mailing lists at http://www.jsoftware.com. You can also comment to my user @erlheldata on Twitter.

3 thoughts on “JWithATwist Mock Parser

  1. In the negate example this would also work.
    (_1:) 77
    _1

    I still look forward to the areas that you explore in this process.

Leave a comment