How are J/K/APL classified in terms of common paradigms?
Asked Answered
S

2

20

I've just started learning J, which is very interesting, but I was wondering what kind of language it is exactly, in relation to common paradigms and classifications. For example, you could say that F# is a strongly typed, mainly functional (it supports OO and procedural programming, but it's considered to be "functional") language which belongs to the ML family. For J, however, I couldn't find much on how to classify it "conventionally", or find anything on Stackoverflow confirming that it's a functional programming language. Wikipedia says that it "is a very terse array programming language", "supports function-level programming", and "is not a Von Neumann programming language", none of which are more helpful.

I have a couple of questions:

  1. What main paradigm (procedural, OO, functional, logical) do J/K/APL fall under? If their paradigm is only "array programming", what paradigm does that fall under or is most similar to?

  2. What well-known programming languages are J/K/APL most similar to? For example, I'd guess that they're like Lisp, since they operate on arrays (lists) and have minimal, no comma syntax.

I'm just trying to categorize these languages in my head according to what I already know. Thank you.

Suctorial answered 13/12, 2013 at 2:39 Comment(7)
Can you ask a more concrete set of questions? I don't think non-controversial objective answers to the question are possible, and this should be closed.Cyclorama
Are you trying to say that "array programming language" is not a common paradigm? Well, okay, maybe it's not common, which might or might not be a shame. But it's certainly a paradigm!Veronaveronese
@Cyclorama Updated question to make it more clear.Suctorial
@DanielWagner What is array programming most similar to?Suctorial
@Suctorial I think the impulse to force a familiar label onto something can be dangerous, especially if that thing is genuinely new. I don't know much about J and friends, so I won't try to make such a strong claim as "J does not fit any existing label"; though I encourage you to introspect a bit and try to discover why it is important to you that you label it in one way or another. Are you sure you can't just call it J?Veronaveronese
I would say J/APL/K are functional style DSL(Domain specific language).Sniffy
I agree with @DanielWagner, I don't believe you can put these languages down as fitting entirely into one of the categories you suggested. They need a new category because they force you to think in a different paradigm. Of course they share some things with other paradigms, but that doesn't mean they only fit into one of them.Waylen
M
11

While other tags could also apply (as with other languages), J is certainly a functional language. It has most major attributes attributed to functional languages, such as functions being 'first class citizens,' currying, higher order functions, etc. Furthermore, if it means anything to you, I have read articles where the language creators themselves described the language as 'functional.'

You could also say that it is an array programming language, as all functions operate on arrays vs. single elements.

I think the short answer you are looking for is that J is a functional array programming language. You could also throw other descriptors out there, such as non-statically typed, etc.

As to your numbered questions:

  1. Functional and array programming.
  2. As far as array programming goes, they are not similar to any other well-known language; rather they are in their own category of 'array programming languages.' As far as functional aspects go, they'd be in the functional category.
Malayalam answered 13/12, 2013 at 7:40 Comment(1)
J does support some object oriented programming as well through the use of locales, but it would be a stretch to call it an object-oriented programming language. If you are interested in that aspect, there are some good labs included with the language under the studio menu.Rectilinear
K
17

J is related to the kind of functional programming (sometimes known as function-level programming, as opposed to value-level) advocated by John Backus, who is probably better known as the inventor of Fortran but spent the latter part of his career trying to move programming away from the style used by Fortran.

In his Turing Award Lecture entitled "Can Programming be Liberated from the von Neumann Style?" Backus presented an overview of his ideas, which he experimented with in his FP and FL languages. Those were inspired largely by Ken Iverson's APL, and Iverson in turn borrowed from Backus' languages when he developed J.

The key idea behind these, which was expanded and developed as a paradigm as the language family grew, was the formation of an algebra of programming. Using these algebraic tools, a programmer could derive or calculate a correct program to solve a problem by combining standard higher-order functions according to well-known mathematical rules. From the abstract of the lecture above:

Associated with the functional style of programming is an algebra of programs whose variables range over programs and whose operations are combining forms. This algebra can be used to transform programs and to solve equations whose "unknowns" are programs in much the same way one transforms equations in high school algebra. These transformations are given by algebraic laws and are carried out in the same language in which programs are written. Combining forms are chosen not only for their programming power but also for the power of their associated algebraic laws. General theorems of the algebra give the detailed behavior and termination conditions for large classes of programs.

Although there doesn't seem to be a lot of recent research that uses the notation of this family of languages, the key ideas have seen somewhat recent development in other functional languages. Richard Bird and Lambert Meertens worked on a related formalism for algebraic manipulation and derivation of programs and the data they operate on; this is known as the Bird-Meertens Formalism or, informally, Squiggol.

Bird and Philip Wadler later wrote a text, "Introduction to Functional Programming", which introduced students to the more well-known "value-level" functional programming based on the lambda calculus. It originally used the Miranda programming language, a forerunner to Haskell, but in its 2nd edition was translated to use Haskell. I mention this because Erik Meijer, Maarten Fokkinga, and Ross Paterson used the example functions in the text as the motivating examples in their well-known paper "Functional Programming with Bananas, Lenses, Envelopes, and Barbed Wire", where they extend the Bird-Meertens Formalism, give it a basis in Category Theory, and show how the solution to each of the examples can be calculated based on the laws of the formalism and the recursion schemes captured by its higher-order functions.

These ideas took root in Haskell, and there you can find a style of programming known as "point-free" that bears a strong resemblance to FP programming. It eschews named variables and creates a new function purely by composition of other functions. Most of the language is not optimized for this use, so many functions are awkward to create in point-free style using only the standard libraries, but alternate libraries that provide more Squiggol-style combinator functions are available.

The algebraic style of constructing programs, thanks to its mathematical nature, is amenable to high-level analysis and transformation by sophisticated compilers. This has led to developments in "Fusion" or "Deforestation" optimizations in functional language compilers that allow algorithms expressed in this style to be reduced to highly efficient machine code loops without all the garbage data and redundant loops that a more naive translation would require. Earlier this year, a framework for generalized stream fusion was presented that showed very practical results from this style of programming.

Hopefully this background gives you a better idea of what the Wikipedia article was talking about and how the underlying paradigm works.

Kynthia answered 20/12, 2013 at 18:44 Comment(1)
Excellent answer. Thank you!Kindling
M
11

While other tags could also apply (as with other languages), J is certainly a functional language. It has most major attributes attributed to functional languages, such as functions being 'first class citizens,' currying, higher order functions, etc. Furthermore, if it means anything to you, I have read articles where the language creators themselves described the language as 'functional.'

You could also say that it is an array programming language, as all functions operate on arrays vs. single elements.

I think the short answer you are looking for is that J is a functional array programming language. You could also throw other descriptors out there, such as non-statically typed, etc.

As to your numbered questions:

  1. Functional and array programming.
  2. As far as array programming goes, they are not similar to any other well-known language; rather they are in their own category of 'array programming languages.' As far as functional aspects go, they'd be in the functional category.
Malayalam answered 13/12, 2013 at 7:40 Comment(1)
J does support some object oriented programming as well through the use of locales, but it would be a stretch to call it an object-oriented programming language. If you are interested in that aspect, there are some good labs included with the language under the studio menu.Rectilinear

© 2022 - 2024 — McMap. All rights reserved.