(But apparently they can support libraries that have C shared library interfaces, so... there's that?)
While J is fast, and can be practical, I would never recommend it for that reason, if only because it's so niche. But if you want to glimpse what a small sliver of all possibility the world of your day to day programming is, you will love J.
I think it would be a wonderful way to write deep learning modules, since it is such a powerful tensor manipulation language. Unfortunately however, even although it should be perfectly suited to SIMD and GPU acceleration, this work hasn't been done yet.
So it ends up not really being fast enough for modern numeric programming - but I hope one day someone smarter than me will invest in making this happen.
I should add that the J community is wonderfully helpful. If you decide to take the plunge in learning this great language, be sure to join the mailing list.
Myth: line noise syntax required for efficient machine code.
Teenagers believed this about C versus Pascal in the 1980's. "Stuff like while (* s++ = * d++); looks faster so it must be."
Or else, what do you mean by efficiency?
Cheaper software engineering life-cycle, end-to-end?
Fewer keystrokes?
For example, every verb is infix, but the right side is evaluated before the left. thus expressions like '2+34' is unambiguously different from '43+2' (the former evaluates to 14 while the latter is 24). J is a language similar to C in that it will oftwn assume you meant what you typed, but has much less undefined behavior.
Re: types, J has a type system, albeit most are numeric (support for complex and rationals are built in). I dont, personally, imagine a type system akin to Haskell or Ocaml would benefit J greatly. Almost every verb in the language is overloaded with respect to the numeric types, thats why addition works as it should with ints, floats, complex, and rationals. Whats more, it handles all that stuff in the underlying system, so that everything works together correctly (coercion and whatnot). A type systen would introduce complexity and virtually nothing more to an already complex language.
> [..] For example, consider pairs of malloc/free, acquire/release, and open/close.
> All of them follow the pattern captured in the Under idiom: We do something to
> create a context, apply some functions in that context, and then leave our context
> by undoing the initial effects with a logical inverse like free, close, etc.
How do function inverses interact with error handling? What happens when a file cannot be opened because it doesn't exist? Or when the file can be opened but subsequent reads fail because the file is empty?
How do you typically work with errors in programming languages like APL / J / K? (I don't mean how do you work with errors in the REPL but how do you catch and handle/report errors in your program and recover/continue gracefully?)
I guess pushing the envelop with a language like J, where everything is an array, plus the unusual function manipulation, would make it even more alien; it's like touring another planet. At least that's what I felt while reading this.
---
That said, it's really boggles me that every time someone tries to explain a new paradigm or idiom, they feel obliged to make it look as superior way of doing things. (Such as in : "J helps us get better at expressing that universal pattern.").
Can't we just express difference just like that; a different new thing. It doesn't have to be better, or worse.
Otherwise, I really enjoyed the article.
Everything else in the article seems like plain old functional programming to me, with a little syntax sugar here and there.
It’s not that the compiler can invert a hash, or automatically derive a logarithm function from an exponentiation function, or anything like that.
Essentially, if you have a composition of functions in a “pipeline” (h ∘ g ∘ f):
[ f g h ]
Then to get the inverse of the composition, you just invert each function and reverse the whole thing (f⁻¹ ∘ g⁻¹ ∘ h⁻¹): [ f g h ] undo
[ \ h undo \ g undo \ f undo ]
“undo” is defined for a set of primitive words. If there isn’t an inverse defined for some function you used in the composition, then it fails; however, you can just define a custom inverse for your function. And obviously this relies on having some kind of reified representation of functions available.“undo” can be used for things like pattern-matching: a destructuring function, which takes some value and produces its fields, is the inverse of a constructor, which takes the fields and constructs a value.
Basically, you can represent each invertible function by a pair of functions (pseudo-Haskell, because I don't use it very often and can't test on mobile):
data Invertible a b = Invertible { forward :: a, backward :: b }
apply :: Invertible (a -> b) (b -> a) -> a
apply f a = forward f a
invert :: Invertible (Invertible a b -> Invertible b a) (Invertible b a -> Invertible a b)
invert = Invertible { forward = invert', backward = invert'}
where
invert' :: Invertible a b -> Invertible b a
invert f = Invertible { forward = backward f, backward = forward f}
Then you can for example invert invert itself by apply invert invert == invert
But because there is no built-in language support, you'll end up doing lots of parallel construction of the standard library before you can even think of using it productively. Apparently someone already did that for Haskell (https://hackage.haskell.org/package/invertible), but it likely doesn't cover everything.For example, I have a meta language in which we can define a box and unbox:
subcode: box_a
instructions that un-boxes a type ...
BLOCK
instructions that boxes a type ...
subcode: box_b
instructions that un-boxes b type ...
BLOCK
instructions that boxes b type ...
main_code:
&call box_a
&call box_b
your code
That is a verbose version of J's under adverb with my meta-layer that I can use in any languages (C, Python, ...).You can compare it to regular expressions for manipulating text.
I don't know if it's academia or what - but if I spent the effort on creating a whole programming language that I believed was actually good - I'd have a very different front page.
As for J, it was released by a startup, J Software, founded by Kenneth Iverson and Roger Hui in 1990 for that purpose. It was later open sourced in 2011.