Arc Forumnew | comments | leaders | submitlogin
Klong: Array programming, not for the faint of heart
6 points by jsgrahamus 2612 days ago | 7 comments
I've been involved in a project downloading web pages, extracting text, reducing it into words and phrases and computing/plotting their changes in usage over time.

To get the web pages I've employed bash and curl. Sifting through the text was mostly Awk: Love that language. But now comes the time for analyzing almost a gigabyte of data.

And for that I'm using Klong, which I first heard about on Hacker News (https://news.ycombinator.com/item?id=10586872).

Klong is a homegrown version of the K programming language developed by Nils Holm. Both are array languages which make dealing with arrays a piece of cake. Additionally in honor of their predecessor, APL, they are terse. Very terse. As in single-character operators.

I have been having more fun with Klong than I've had in programming for a very long time. You might want to take a look. You can download it from Nil's site at http://t3x.org/klong/. In addition to the base language, there is documentation and Nils has created a statistics and plotting library. And he has been more than gracious in answering my questions.

A writeup of the K programming language can be found here: http://archive.vector.org.uk/art10501320.

Personally I'm sticking with Klong for now.

Steve



3 points by jsgrahamus 2610 days ago | link

I work with MUMPS as my work programming language. Assuming you had an array of 10 numbers, to get the sum you would do something like this:

  F I=1:1:10 S ARR(I)=I   ; Stores 1-10 in array ARR
  S SUM=0
  F I=1:1:10 S SUM=SUM+ARR(I)
  W !,SUM                 ; Writes sum
In Klong you would do as follows: arr::1+!10 :" Initializes list arr with values of 1-10" .p(+/arr) :" .p() prints and +/arr sums all elements of the list"

I always thought that MUMPS was terse, but for certain things at least, it doesn't hold a candle to Klong. Of course, I thought Minnesota was green until I saw Wisconsin. And now I live in Washington state.

-----

3 points by jsgrahamus 2608 days ago | link

Fixing the formatting.

I work with MUMPS as my work programming language. Assuming you had an array of 10 numbers, to get the sum you would do something like this:

  F I=1:1:10 S ARR(I)=I   ; Stores 1-10 in array ARR
  S SUM=0
  F I=1:1:10 S SUM=SUM+ARR(I)
  W !,SUM                 ; Writes sum
In Klong you would do as follows:

  arr::1+!10 :" Initializes list arr with values of 1-10"   
  .p(+/arr) :" .p() prints and +/arr sums all elements of the list"
I always thought that MUMPS was terse, but for certain things at least, it doesn't hold a candle to Klong. Of course, I thought Minnesota was green until I saw Wisconsin. And now I live in Washington state.

-----

3 points by jsgrahamus 2600 days ago | link

akkartik was kind enough to provide a spot for the paper on this project:

https://drive.google.com/file/d/0Bwqm_FatZFB3MGFDQVRlNXBNekU

Thanks, akkartik!

-----

3 points by jsgrahamus 2607 days ago | link

I published a paper on my results of using Klong. Would like to share it with this group, but am not sure where to put it so that you all could access it.

-----

3 points by akkartik 2606 days ago | link

Google Drive? You can share a document so anyone with the link can access it.

Another option is Gitlab or Bitbucket. Put the file in a repository (ideally with any of your code for the paper!) and push it.

I can do it for you if you like. Just email the paper to me. (My address is in my profile.)

-----

3 points by jsgrahamus 2612 days ago | link

Not sure how this applies to arc. They are both niche programming languages? They both strive for brevity?

-----

2 points by akkartik 2612 days ago | link

Seems reasonable to me :)

-----