Hacker News new | past | comments | ask | show | jobs | submit login
Functional Programming and the J Programming Language (2008) (trinity.edu)
25 points by agarttha on May 14, 2014 | hide | past | favorite | 5 comments

I took Howland's (author of the linked page) functional programming class five years ago. Definitely the hardest course in Trinity's CS department (sorry Lewis).

J was a lot of fun for the first few days when you have the novelty of averaging a list of numbers in four characters. It wears off fast after that, especially since (at the time) this course came after three semesters of C, Java and C++ respectively so students hadn't yet been introduced to concepts like currying and now had to learn both the concept and an obtuse syntax at the same time. Fortunately (or unfortunately) the course was required for graduation so students had no choice but to tackle both. Definitely kicked my ass and scared me away from FP for a while. Now that I write Scala for my day job some of the concepts from this course have come back to me and I've started to grok J, though I have no desire to ever use it.

It's worth noting that Trinity now starts freshman in Scala and though J has been dropped, the functional programming class is now taught in Scheme and Haskell so students there wind up with a very strong background in FP.

Fun fact: the entire department's website is written in J, which is why it's never been updated. Howland retired two years ago and no one has the inclination to learn J to update it, so it remains in all its 1998 glory. Not necessarily a bad thing, it's very usable. On the other hand, half the faculty listed have retired and no one ever updated the site...

J is a rather odd choice for teaching functional programming. It distinguishes "nouns" (first-order data), "verbs" (first-order functions), and "adverbs"/"conjunctions" (essentially second-order functions -- not arbitrarily high order) at the syntax level. This means currying is pretty limited, common higher-order operations like composition (@:) and partial application (&) can only be done to first-order functions, putting functions into data structures gets awkward.

The article doesn't seem to say much about J's treatment of all functions as aggregate operations on arbitrarily high-dimensional arguments. Since functions are "polymorphic in dimensionality", instead of a bunch of nested loops, you write just the loop body. You control the orientation of the loop nest by changing what a function expects as its lowest possible argument dimensionality. This mechanism is what J has that isn't readily available elsewhere, and it's sad to see it left aside.

I think forks and hooks are also interesting higher-order functions.

> Note that in C we say that the value 4 is assigned to foo, but in J we say that the name foo is assigned to the value 4.

I like this succinct description of functional programming at the beginning. I never really understood what defined "functional programming" before other than using higher-order functions.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact