Hacker News new | ask | show | jobs
by kaosjester 4036 days ago
I went to Trinity and Howland attempted to teach us J there. The entire thing went terribly. I agree with Iverson's assessment: learning J is a lot like learning math in that mathematicians often use weird and cryptic syntactic forms that are only tangentially related to other, similar forms. Unlike APL, this problem occurs in absurd detail in J. APL, at least, has strictly different symbols. J, on the other hand, uses strangely and opaquely-overloaded syntax. By way of example, consider the following:

A programmer may expect < to perform less-than. In J it does, when used as a dyad. Used monadically, it acts as a boxing operator (similar to Scheme's box). That's strange, but livable. The problem, though, is in J, <. means 'lesser of' (min), and <: means 'less than or equal'. Again, this is a potentially livable arrangement. Except that . means determinant (or dot product, depending on monadic or dyadic appearance) and : means either 'explicit' or 'monadic/dyadic', a sort of combinator that accepts a monadic and dyadic operator and yields a new one. That is, in Scheme, dyadic usage of : is akin to a case-lambda that checks if it uses one or two arguments.

If I present to you the program <., what does it do? Well, it certainly does something different from < ., which does something different from < :, which does something different from <:, which does something different from < . :, which again differs from <. :, and so on. This is exacerbated by operations such as 'table', written /, which bleed into other places. For example, </ inserts box, while <:/ inserts a decrement! And < :/ boxes up the result of an 'explicit' being 'inserted', whatever that means. And this syntactic problem plagues the entire vocabulary of the language:

http://www.jsoftware.com/help/dictionary/vocabul.htm

A clear optimization would be to just give these things their real names, use text, and write S-expressions. At least then the programs would be readable!

The largest problem, however, is that for being a functional language, J does little if anything to convey the important idea that have been developed in functional programming: recursion. It simply isn't how things 'are done' in J. So we have a language with bad syntax, good semantics, and a horrible problem from an educational perspective. It has some nice additions above and beyond other APLs, but after that it falls flat. I'd urge anyone who has read this far to learn APL instead of J; it will at least be readable by other APL programmers.

(I didn't mean to go on a rant, but I suffered through Howland's class on J at Trinity, and it wasn't until I had a professor show me Scheme in ~3 hours that I saw why functional programming was truly worthwhile.)

4 comments

Learning advanced mathematical notation requires correlating the notation with the concept.

   < x 
is no less intuitive than

  box x
in regard to the mathematical concepts. Maybe the latter is slightly easier to google...if we can filter out the use of "box" in all sorts of other contexts including those in computing where "box" is some sort of graphic element. Which is to say that "box" is far more overloaded than a monadic use of "<".

We didn't learn Σ intuitively.

> So we have a language with bad syntax, good semantics, and a horrible problem from an educational perspective.

"bad syntax" in case of J triggers begging to differ.

Yes, it's hard to decipher without the dictionary. However, math notation - and J descended from there - isn't that obvious either, unless learned.

A crucial idea of APL is "good notation enables thinking". This is quite valid for at least some J programmers. And J was born as a better APL, evolving from latest APL versions of the time with some problems visible in the retrospect fixed. Though I think had Unicode developed earlier J could look differently.

Yes, there is the recursion in J; yes, it's not used too often. Why that should be a problem?

Hello fellow Trinity alum!

I too suffered at the hands of Howland. That's why I sat in on Eggen's FP class after he took over the course (he's probably the one who taught you Scheme?).

He was a good guy but he scared years of students away from FP with that course.

I find k to be far more consistent and simple to understand. k5 language spec: http://kparc.com/k.txt