Category:J: Difference between revisions

m
→‎The J language: link to some well thought out reflection on implications
(added both bytecode and interpreted to page)
m (→‎The J language: link to some well thought out reflection on implications)
 
(48 intermediate revisions by 12 users not shown)
Line 3:
|exec=interpreted
|site=http://www.jsoftware.com
|strength=strong (but regular)
|safety=safe
|checking=dynamic
|tags=j
|hopl id=1558
|LCT=yes
|bnf=httphttps://wwwcode.jsoftware.com/jwikiwiki/Backus%E2%80%93Naur_FormGuides/Language_FAQ/J_BNF}}
{{language programming paradigm|Dynamic}}
{{language programming paradigm|functional}}
Line 14 ⟶ 15:
{{language programming paradigm|procedural}}
{{language programming paradigm|Reflective}}
{{language programming paradigm|Tacit}}
 
== theThe J language ==
 
A frequent reaction when one first encounters a J program is often something along the lines of "that's cheating". The thought here is that the problem could not possibly be that simple, so — instead — the issue must be that J was specifically designed to tackle that problem.
 
The flip side of this issue is that J is a dialect of APL — a language whose development started in the 1950s and which was implemented in the early 1960s. And, originally, APL was designed as a language to describe computer architecture. The implementation as a programming language was motivated by its original successes in documenting computer hardware and instructions, and the relative simplicity of its concepts.
 
See also https://github.com/cratelyn/j for some reflection on some of the linguistic character of J.
 
== Introduction ==
 
J is a notational programming language designed for interactive use.
Line 25 ⟶ 35:
Object-module and imperative techniques are supported, but not required.
 
The J programming language was designed and developed by [[wp:Ken Iverson]] and Roger Hui. It is a closely related successor to [[APL]], also by Iverson which itself was a successor to the notation Ken Iverson used to teach his classes about computers in the 1950s.
<br clear="all"/>
 
The notation draws heavily from concepts of [[wp:Abstract algebra|Abstract algebra]] and [[wp:Tensor calculus|Tensor calculus]], simplified for describing computer architecture and design to a pragmatic business audience. (The ideas themselves are simple, but for some reason the topics scare most teachers.)
 
== tryReading meJ ==
 
J is meant to be read with the aid of a computer. J sentences are single lines and trying variations and simplifications of an expression is common practice. The first step in understanding any J sentence is to understand the data you started with and the data which resulted.
When learning how a J sentence works, you can also try simpler sentences with the same data or perhaps related data.
When trying to understand contexts that use large data structures, it can often be wise to investigate small, representative samples until you understand how the code works.
 
Unless you attend an institution which has made a J interpreter available to you through your web browser (or preinstalled on your machine), if you want to see how J works you should probably [https://code.jsoftware.com/wiki/System/Installation install] a copy of J -- or you can try one of the "try me" links, below.
If you want to understand how to experiment with alternative expressions you should probably also be studying some of its [[j:Guides/Getting%20Started#Documentation|documentation]].
 
For example, the phrase <code>(+/ % #)</code> finds the average of a list of numbers.
 
<syntaxhighlight lang="j">
(+/ % #) 1 2 3
2
</syntaxhighlight>
 
To understand how this works, you might try working with simpler sentences and their variations.
 
<syntaxhighlight lang="j">
+/ 1 2 3
6
+/4 5 6
15
# 1 2 3
3
# 2 3 4
3
6 % 3
2
15 % 3
5
(+/ % #) 4 5 6
5
</syntaxhighlight>
 
By themselves, these experiments mean nothing, but if you know that +/ was finding the sum of a list and # was finding the length of a list and that % was dividing the two quantities (and looks almost like one of the old school division symbols) then these experiments might help confirm that you have understood things properly.
 
== Some perspective ==
 
If you wish to use J you will also have to learn a few grammatical rules (J's parser has [http://www.jsoftware.com/help/dictionary/dicte.htm 9 reduction rules] and "shift" and "accept" - the above examples use four of those rules). J verbs have two definitions - a single argument "monadic" definition and a two argument "dyadic" definition.
These terms are borrowed from music and are distinct from Haskell's use of the word "monad".
The dyadic definitions are in some sense related to LISP's "cons cell" but are implemented as grammar rather than data structure, and are a pervasive part of the language.
 
Another pervasive feature of the language is [[wp:Rank_(J_programming_language)|rank]].
 
The language represents capabilities of hardware.
For example, if language did not have an internal stack, a word's definition could not be used during the execution of that word. All current J implementations support recursion, but in some sense this is a convenience, and it's reasonable to imagine J implementations which do not (perhaps in a "compile to silicon" implementation).
 
=== Types ===
 
Perhaps also worth noting is that when thinking about J programs, it can be convenient to think of an instance of an array as a type. This is in some ways different from the usual treatment of type (where all potential values in a syntactic context are treated as a type but the types are typically far more constrained than "an array").
 
J's type hierarchy supports arrays of arbitrary size and dimension, and array contents may be numeric, character or boxed. Thus, for example, we might work with an array of boxes, each box containing a one dimensional array of characters -- or, informally: strings.
 
In addition to arrays, J's type hierarchy includes procedural types: verbs, adverbs, and conjunctions. These roughly correspond to functions (J's verbs) and metafunctions (J's adverbs and conjunctions) of other languages.
 
As a simple example: 2 is an array (with zero dimensions), 3 is an array, and < is a verb. The expression (2<3) compares 2 and 3 and returns a truth value indicating that 2 is less than 3. But the expression (<3) returns a box which contains the array 3. While the details here are a bit different, the general concepts should be familiar to users of other programming languages. (For example, in C, 2&3 performs a bitwise and between the two numbers, and &y returns a pointer to the value referred to by y.)
 
J would be considered dynamically typed because of the generality of its arrays. But its type based syntax would lead some to consider it to be statically typed (though the simplicity of its syntax might invite criticism from people who prefer more complexity).
 
== J on RosettaCode ==
Line 32 ⟶ 104:
Discussion of the goals of the J community on RC and general guidelines for presenting J solutions takes place at [[J/HouseStyle|House Style]].
 
== JersJedi on RosettaCode ==
 
*[[User:DanBronRoger_Hui|DanRoger BronHui]]: [[Special:Contributions/DanBronRoger_Hui|contributions]], [[j:DanBronUser:RogerHui|J wiki]]
== Jers on RosettaCode ==
*[[User:Roger_HuiTBH|RogerTracy HuiHarms]]: [[Special:Contributions/Roger_HuiTBH|contributions]], [[j:RogerHuiUser:TracyHarms|J wiki]]
*[[User:TBHDanBron|TracyDan HarmsBron]]: [[Special:Contributions/TBHDanBron|contributions]], [[j:TracyHarmsUser:DanBron|J wiki]]
*[[User:DanBron|Dan Bron]]: [[Special:Contributions/DanBron|contributions]], [[j:DanBron|J wiki]]
*[[User:Gaaijz|Arie Groeneveld]]: [[Special:Contributions/Gaaijz|contributions]]
*[[User:Rdm|Raul Miller]]: [[Special:Contributions/Rdm|contributions]], [[j:User:Raul_Miller|J wiki]]
*[[User:96.57.161.34|Jose Quintana]]: [[Special:Contributions/96.57.161.34|contributions]], [[j:Stories/JoseQuintana|J wiki]]
*[[User:tikkanz|Ric Sherlock]]: [[Special:Contributions/tikkanz|contributions]], [[j:User:RicSherlock|J wiki]]
*[[User:Avmich|Avmich]]: [[Special:Contributions/Avmich|contributions]]
*[[User:VZC|VZC]]: [[Special:Contributions/VZC|contributions]]
*[[User:Bathala|Alex 'bathala' Rufon]]: [[Special:Contributions/Bathala|contributions]], [[j:bathala|J wiki]]
*[[User:Lambertdw|David Lambert]]:[[Special:Contributions/Lambertdw|contributions]]
*[[User:JimTheriot|JimTheriot]]: [[Special:Contributions/JimTheriot|contributions]]
*[[User:DevonMcC|Devon McCormick]]: [[Special:Contributions/DevonMcC|contributions]]
 
== Try me ==
 
Want to try one of those cryptic J lines you see peppered through RC?
Try pasting it into this [https://jsoftware.github.io/j-playground/bin/html/emj.html browser-based implementation of J]. Here's a short [https://youtu.be/W_f7wUILcoc video intro], for people who would prefer some guidance.
 
If you want to be a bit more interactive, and get some guidance from J gurus, you can join the actual J IRC channel on Freenode, #jsoftware. Buubot and several other J eval bots run there.
If you want to be a bit more interactive, and get some guidance from J gurus, you can join the actual J IRC channel on Freenode, #jsoftware. Buubot and several other J eval bots run there. If you don't have an IRC client you can try [http://webchat.freenode.net/?randomnick=1&channels=jsoftware freenode's web interface] (or just [http://webchat.freenode.net/?channels=jsoftware&randomnick=1 give it a quick spin]). More [[j:Community/IRC|details about the J IRC community]] is available.
More [[j:Community/IRC|details about the J IRC community]] is available.
 
If any of that piques your interest, and you want to explore a little more, you can [http://www.jsoftware.com/stable.htm download J] and [http://www.jsoftware.com/forums.htm join the J forums].
== try me ==
 
If you have problems executing any of the J code here on Rosetta, please make a note of it either on the task page itself, on the talk page, or on the appropriate [http://forums.jsoftware.com J forum], whichever is best.
Want to try one of those cryptic J lines you see peppered through RC? Try pasting it into the [http://www22.brinkster.com/olegyk/jserver/Test.aspx online single-line J interpeter] or the [http://erxz.com:10080/ web interface for buubot] (a [[Perl]] IRC bot which has a J evaluation mode: just prefix your line with '''''jeval''''').
It might be that there's a version dependency that needs to be documented, or you might have found an actual bug.
 
==Todo==
If you want to be a bit more interactive, and get some guidance from J gurus, you can join the actual J IRC channel on Freenode, #jsoftware. Buubot and several other J eval bots run there. If you don't have an IRC client you can try [http://webchat.freenode.net/?randomnick=1&channels=jsoftware freenode's web interface] (or just [http://webchat.freenode.net/?channels=jsoftware&randomnick=1 give it a quick spin]). More [[j:Community/IRC|details about the J IRC community]] is available.
[[Tasks_not_implemented_in_J]]
 
See also: [[Find_unimplemented_tasks#J|the "unimplemented tasks" task page]] for a mechanism for finding rosettacode tasks and draft tasks which have not been implemented in J (or any other language, for that matter).
If any of that piques your interest, and you want to explore a little more, you can [http://www.jsoftware.com/stable.htm download J] and [http://www.jsoftware.com/forums.htm join the J forums].
6,951

edits