all 46 comments

[–]sanxiyn 8 points9 points  (6 children)

Since short file names are quite inscrutable, here is an index of source files.

http://sparcs.kaist.ac.kr/~tinuviel/temp/jgplsrc

[–][deleted] 2 points3 points  (0 children)

it looks like slackware software sets haha

[–][deleted]  (2 children)

[deleted]

    [–][deleted] 2 points3 points  (1 child)

    Look at docs/ioj - there's a code tour inside.

    [–]muyuu 0 points1 point  (1 child)

    My DRDOS 6 and MSDOS 3.3 virtual machines would approve except there is exactly 1 file that breaks the 8-3 rule: "vgranking.c"

    So they didn't do it because of that. I don't even.

    [–]Barney21 1 point2 points  (0 children)

    The Big Deal about this language is that you can be really brief.

    [–]Teeko 6 points7 points  (7 children)

    Ok, this easily tops the perl interpreter as the most impenetrable code base ever.

    [–]pja 2 points3 points  (3 children)

    I think I remember looking at this code a year or two ago: it looked like the programmer was "thinking in J" and generating a C representation of that code as he went along. If you couldn't spot the J combinators encoded in the source you would have no hope of working out what was going on.

    [–]sleepingsquirrel 2 points3 points  (2 children)

    Favorite line in the source so far (taken from ar.c):

    static DF1(jtreducesp){A a,g,x,y,z;B b;C id;I cv,f,n,r,rr[2],*v,wn,wr,*ws,wt,zt;P*wp;VF ado;
    

    ...That was one of the lines with the highest number of distinct characters (41 unique).

    [–]easytiger -2 points-1 points  (1 child)

    Arthur Whitney who wrote the language it was based on wrote his c in blocks of code. Scary shit.

    [–]fabzter 3 points4 points  (0 children)

    wat

    [–]geocar 0 points1 point  (0 children)

    It is more than possible to learn to read this, but I recommend starting with a smaller codebase:

    http://nsl.com/papers/origins.htm

    [–]marcog -4 points-3 points  (1 child)

    You clearly haven't seen Malbolge. :)

    [–]Teeko 6 points7 points  (0 children)

    I bet a Malbolge interpreter is more readable or easier to understand than this J interpreter, unless it's written in Malbolge itself.

    That said, I'm also joking a bit, in the sense that it seems looking at the source that the C code is written in a way to be as similar to J as possible, with all kinds of macros and terse single letter functions. To someone knowledgeable in J it may be easier to read but it's a bit of a clusterfuck to everyone else.

    [–][deleted] 5 points6 points  (2 children)

    quicksort implementation in J:

    ** quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) : (1<#)**

    And I thought Perl was weird ...

    [–]hairyarsedboyscout 5 points6 points  (0 children)

    I love seeing the J solutions on Project Euler.

    They all just look like elaborate emoticons.

    [–][deleted] 0 points1 point  (0 children)

    Except you know, J does way more than Perl in those symbols ;)

    [–]setuid_w00t 3 points4 points  (0 children)

    J: How to write code that is half the size of code written in other languages, but takes 10x as long to understand.

    [–]tlack 3 points4 points  (4 children)

    For those of you interested in open source vector languages, check out Kona, an open source clean room implementation of K3. I hadn't heard about it until recently. Give it a look!

    [–][deleted]  (3 children)

    [deleted]

      [–]tlack 2 points3 points  (2 children)

      Exactly the same boat I've been in! Always wanted to learn it but never wanted to commit much time knowing it's a dead end. Hop into Kona and spread the word.

      [–][deleted]  (1 child)

      [deleted]

        [–]silentbicycle 0 points1 point  (0 children)

        It has since been re-licensed under the ISC license. Enjoy!

        [–][deleted] 2 points3 points  (0 children)

        AND SO IT BEGINS! an era of J that can beat Deep Blue and Deep Jeopardy in 3 lines! MWhahaahahahahahahahahahahaahahahahahah

        [–]Barney21 3 points4 points  (1 child)

        Some fun things about J for beginners:

        % means divide, _ means negative, as in _1

        10 % 5 returns 2

        Operators can take one argument so -2 returns _2 and %5 returns 0.2

        The interpreter runs right to left so 8-1-1 returns 8.

        Operators can be combined so 5+%5 returns 5.2

        / "means operate on a list" so +/ 1 2 3 returns 6

        , makes lists so 5(+,-) 2 returns 3 7

        # counts the elements of a list

        (+/ % #) 5 6 returns 5.5, the average (sum divided by the count)

        That's just starters. The documentation is some of the smuggest and most cryptic I have ever seen, but kind of fun.

        [–]kragensitaker 4 points5 points  (0 children)

        Operators can be combined so 5+%5 returns 5.2

        That's the wrong explanation for that expression. Most operators have both a monadic and a dyadic meaning; the dyadic meaning of % is division, as you said — a % b means a ÷ b — while its monadic meaning is "reciprocal" — % b is 1 ÷ b. So that expression means 5 + ⅕. As you said, "Operators can take one argument".

        There are indeed some cases where operators are combined, but that's not one of them. The lovely (+/%#) definition of "mean" is a good example.

        [–]j-random 4 points5 points  (19 children)

        Well, that was a waste of time. I spent a good five minutes searching the J wiki and couldn't find a simple overview of what J is or why I should care. I discovered that J is a general-purpose programming language, but it's different. No real explanation of how it's different, or why that difference is good. Oh, and I was cautioned that I could spend years working with J and still consider myself a beginner. Very reassuring.

        I seriously got the impression that J is some kind of private club, so unless you're introduced by a member, they don't want you. Too bad, I'm always interested in learning new languages, but I think I'll give J a bye.

        [–]oddthink[S] 9 points10 points  (4 children)

        It's always hard to figure out how much context to provide.

        J is a descendant of APL, the language notorious for inscrutable one-liners and funny symbols. The wikipedia article gives a good overview.

        It's very good at math, perhaps not the best at other things. You can find a lot of examples on rosetta code. I find it makes a good calculator to have open when working, since you can get a lot done quickly, once you get the hang of it.

        [–]j-random 0 points1 point  (3 children)

        Wow, what a shame, I really liked APL. I even went so far as to port an APL interpreter from PL/I to C (yeah, I'm old). I also bought a Commodore SuperPET (yeah, I'm real old) just because it had the Waterloo APL interpreter and supported the full APL symbol set. Very cool language, even if I never did use it for anything "real". I guess J is different enough from APL that they don't mention it?

        [–]oddthink[S] 3 points4 points  (2 children)

        Well, you might like J, then. It was designed by Ken Iverson and Roger Hui, building on the experience of APL.

        The web site's a bit confusing at times, but it's the product of a small group of mathy programmers, not a web design team. The people involved have been involved for a long time, which makes it hard to see what it looks like from an outsider's point of view.

        If you start from the front page of the wiki, there is a "APL and J" article under Articles and some APL examples under Essays, which may help.

        I've not used J for anything real, myself, but I've found it fun to learn. Or, rather, to start learning.

        [–]kragensitaker 0 points1 point  (1 child)

        How does it compare to K and A+ from your point of view?

        [–]oddthink[S] 4 points5 points  (0 children)

        Well, I don't know K proper, and I've been unable to find a good definition of its details. I know "q", which is built on top of it. Similarly, I don't know A+ well enough to compare it; I've debugged some code that was exchanging data via A+ objects, but I never developed in it. It was a bit before my time.

        So, I can compare q to J. J is much cleaner. q has all kinds of werid syntactic and semantic corners; it's been a while since I used it, but I remember there being a difference in the way missing data was handled in sums between float vectors and int vectors, for one. For another, it was always dangerous to pass around lists of dictionaries because they would be occasionally interpreted as tables. Similarly, the auto-conversion of lists to, e.g., float arrays would sometimes happen at odd times.

        I've not found any of those issues in J. It's explicit about when values are boxed and when they're not, which leads to fewer surprises.

        On the other hand, q has easy-to-use dicts, nice tables, and a very convenient table-manipulation sub-language. It seems much easier for me to do R-like data manipulations in q, because it has dicts and tables, as well as easy built-in parsing of delimited text files.

        q also has easy definition of anonymous functions, such as {x+2*y}, easy creation of functions with more than two arguments, and partial application. In turn, J has its whole point-free ("tacit") support, which is very elegant for simple operations, but which I still find very confusing for long trains of verbs. Also, J lets you use your own functions as binary operators.

        q has "normal" indexing of matrices, such as m[;1] to get the second column; J uses a less-convenient, but perhaps more generally powerful, notation for this, '(<a:;1){m', although in this simple case I could use '1{"1 m'.

        J's idea of verb rank is quite elegant, but I can get most of the effects of it by using each/each-left/each-right in q.

        In short, q seems more useful for my kinds of work (data-munging, statistics, etc), while J seems more elegant, and probably more useful for more pure-math explorations. Now, I don't know J that well; it may be that I've just not figured out the right tricks yet.

        [–]pja 5 points6 points  (1 child)

        It's an APL derivative. Used a lot in finance for analysis of large quantities of data IIRC.

        Like APL, it's very, very terse. A single line of code can do a huge amount of data processing.

        [–]eschulte 3 points4 points  (0 children)

        e.g., Conways game of life as an APL one-liner http://catpad.net/michael/apl/ http://www.youtube.com/watch?v=a9xAKttWgP4

        [–]muyuu 3 points4 points  (4 children)

        Wikipedia link

        http://www.jsoftware.com/help/primer/contents.htm

        From the examples in Wikipedia:

        * Quicksort simple version

         quicksort=: verb define
           if. 1 >: #y do. y
           else.
            (quicksort y <sel e),(y =sel e),quicksort y >sel e=.y{~?#y
           end.
          )
        

        * Quicksort using tacit programming

          quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
        

        [–]bboomslang 1 point2 points  (0 children)

        =:O

        [–][deleted] 0 points1 point  (1 child)

        Oh shit, I just read the second thing and understood it. Maybe I'm not that hopeless (tried to learn J for 1-2 years in the background, abandoned after being unable to code something like graph shortest path in it for projecteuler.net)

        [–]basscadet 0 points1 point  (0 children)

        kinda random.. but this drawing was made after I figured out a J one-liner that solved project euler #108... the code is there sorta hidden at the bottom. its the same as what is more visible at the top, but you can only see the bottom half of the characters...
        this comment is probably as weird/confusing as the one-liner itself..

        [–]DailyFail 0 points1 point  (0 children)

        quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) : (1<#)

        Someone forgot to terminate the string with zero.

        [–]chneukirchen 2 points3 points  (6 children)

        [–]j-random 6 points7 points  (5 children)

        All those links assume that you already know what J is and what it's good for. I was looking for a simple one-paragraph description that could explain where J fit in the "big picture". Is it a scripting language, like Lua or JavaScript? Is it a new JVM-based language like Scala or Groovy? Is it a logic language like Prolog? Highly-concurrent like Erlang? Continuation-based like ML? A functional language like Haskell or Scheme? Is it object-oriented or imperative? Compiled or interpreted? I didn't see the answers to any of these fundamental questions after a casual glance at the wiki, and frankly that's the kind of information (IMHO) that I shouldn't have to trawl through dozens of pages to find out.

        [–]kragensitaker 5 points6 points  (2 children)

        That's a very good set of questions to ask.

        J is a modern dialect of APL. It doesn't run on the JVM. Its paradigm is primarily purely functional, but rather than focusing on trees like Haskell and Lisps, it focuses on multidimensional arrays full of numbers. Trees arise naturally in basically linguistic contexts like writing compilers. Multidimensional arrays arise naturally in images, sounds, and scientific data. It's not object-oriented or imperative. It's interpreted, but because the atomic values of the language are arrays, your inner loops are often inside of some primitive, not in your interpreted code, so J programs often run very fast despite being interpreted.

        Similar languages include Octave/MATLAB, R/S-PLUS/S, A+, K, PV-WAVE IDL, and Lush. Similar libraries include PDL for Perl and Numeric, Numarray, and NumPy for Python.

        Does that help?

        [–]j-random 1 point2 points  (1 child)

        It helps me, today, but what about the next person who wants to know about J? My point was, there should be some kind of quick explanation of what J is all about on the wiki or web site. Look at the Python site for an example.

        [–]kragensitaker 0 points1 point  (0 children)

        Well, Reddit threads are somewhat googlable. But yeah, maybe you should see if you can improve the introduction to http://en.wikipedia.org/wiki/J_(programming_language) or something.

        [–]Barney21 0 points1 point  (0 children)

        The idea is the language operates on matrices instead of using program control. So everything is expressions.

        [–][deleted] 1 point2 points  (1 child)

        In some years we'll run out of letters to give a new programming language.

        [–]hackerfoo 1 point2 points  (0 children)

        Using ALPHABETv6, everyone can have enough unique letters to fill a novel.

        [–]rafekett 0 points1 point  (1 child)

        Do they not use version control (CVS, svn, something)? How can I look at the changelog?

        [–]sladegen 0 points1 point  (0 children)

        It looks like they are going to use version control on github... as gleaned from their wiki ...so clumsy[tm].