Talk:K (programming language)

message: Is http://www.schneier.com/code/sol.k in this "K programming language"? — Preceding unsigned comment added by 207.65.110.114 (talk) 05:14, 10 February 2005 (UTC)
thread_title: Untitled

message: I'm missing NPOV here. Seems like this entry was written by the language designer, or (more likely) somebody who's using the language and a bit too fond of it.
Nothing wrong with that in itself, but not very informative - if somebody says "combines the best of foo, bar, and baz", I still don't know *which* features of foo, bar, and baz went into the language.
<rant> The section on the Hello World program is entirely misguided. Nobody is interested in how easy it is to write a Hello World program (except those who're learning the language, and the interest persists only until the program runs).</rant> (Sorry for ranting, but the section really deserves it. IMHO.)
Joachim Durchholz — Preceding unsigned comment added by 84.175.172.16 (talk) 06:59, 17 May 2005 (UTC)
replies: text: I like the Hello World program because it can give you an immediate sense of the language. A comparison of the K example with a comparable example from Java is representative of the differences between the two language in general. However I certainly agree that you need additional examples. I've added a word sort and prime number examples since they were the two examples used in the APL section. If you want a different example or additional ones say something and I should be able to help.
Abcarter 13:37, 25 November 2006 (UTC)

text: completely agree! Claims like "speed" and "expressive syntax" should be backed with facts and definitions. Fast compared to what? What does expressive mean?  A language is expressive to the extent that it is able to expresses the solution using abstractions from the problem domain. K expressions look like noise on an excessively long and capacitive RS-232 connection. It's possible that they are expressive if the surface syntax is transliterated into a notation which is readable. In 2011, it is not important to be able to cram an entire application onto a single 80 column punched card. That is not what "expressive" ought to mean, in any case. 24.85.131.247 (talk) 16:50, 29 September 2011 (UTC)
thread_title:  NPOV 

message: I followed the kuro5hin discussion, and looked at the Kx Systems website, but failed to find any information about how to get hold of K.
Along the way I found K Links put up by the other of the kuro5hin article, and "No Stinking Loops", a collection of links for various APL-derived languages; interpreting the latter my best guess is that versions 2 and 3 of K are obsolete and version 4 is now called "Q".
The link to "K4/Q" throws you into a directory which appears to contain libraries for the Q runtime, but there isn't much in the way of documentation there to tell you what to do with them.
Maybe this will help someone work out how to improve the current article ... Hv 02:24, 8 February 2006 (UTC)
thread_title:  Out of date? 

message: Anyone found any evidence that K is free for free software? I've gotten nothing but rude responses from their sales people.. note I said sales. :) 216.199.93.178 20:59, 6 June 2006 (UTC)
replies: text: It used to be the case that you could download a demo version of K from the Kx website. However, in 2003 Kx systems released Q which merges the features of K and Ksql and is meant to be the successor to both. At some point they deleted the K download since it is no longer a featured language; however they did not add a Q download. Kx still offers trial versions of Q, but it is on a by request basis. Abcarter 15:05, 25 August 2006 (UTC)

text: A correction and a comment. I had thought that Q was the successor to both ksql and k. It is the successor to ksql and it does merge the features of ksql and k, however it is still written entirely in k, though a newer version. It would be nice for Kx to offer older versions of k without support, but it's not clear that it is in their interest to do so. Abcarter 00:19, 1 December 2006 (UTC)
thread_title:  Free? 

message: Unless there are objections I will begin the process of merging the entry on KDB (database) with K (programming language). This is based on discussions on the KDB entry. This is based on the close linkage between the language and the database:
# Both KDB and KDB+ are developed in K
# Ksql and Q, the query languages for KDB and KDB+, respectively, are written in K.
# With a few minor exceptions in academia no, the K language is always used in conjunction with KDB.
Abcarter 23:12, 24 November 2006 (UTC)
thread_title:  Proposed merge with KDB 

message: I'll be making numerous changes to the K entry in the next few weeks and using this section for comments when necessary. Abcarter 11:59, 29 November 2006 (UTC)
thread_title:  Comments on changes 

message: Your remarks on performance characteristics is great stuff. I'm not too sure if I follow it completely, any change of providing a source that one could read for more detail? Also, do you have any objective sources giving performance benchmarks or numbers? Abcarter 00:42, 1 December 2006 (UTC)
thread_title:  65.254.63.193 

message: After thinking about it I've reverting the deletion concerning the Hello World program. The wikipedia definition of such programs is:
: A "hello world" program is a software program that prints out "Hello world!" on a display device.  
Interpreted languages such as k can do this in a trivial way. Look at the  list of Hello World programs and you'll see a number of similar languages with the same trivial example. While the example is trivial the point being made is not, the interpreted nature of k is a distinctive feature of the language and one of the first things you should know about it. Abcarter Talk 14:53, 3 January 2007 (UTC)
replies: text: This is nothing to do with the interpreted nature of the language; it would be trivial to design a language that had an identical "Hello World" program but compiled down to machine code.  It is, however, illustrative of K's concise syntax. 81.86.133.45 18:47, 6 September 2007 (UTC)
replies: text:  In K every statement is evaluated and the results immediately displayed. Literal values, like strings, evaluate to themselves. Consequently, you can argue that a Hello world program can just be the string, "Hello world!". While this feature of K facilitates an expressive and concise syntax, but it really isn't illustrative of it. A B Carter (talk) 04:16, 7 September 2007 (UTC)
thread_title:  Hello World Program 

message: I'm not sure if I understand some of this paragraph:
>> The performance of modern CPUs is improving at a much faster rate than their memory subsystems.
Check.  Memory is comparatively slow.
>> The small size of the interpreter and compact syntax of the language makes it possible for K applications to fit entirely within the level 1 cache of the processor. 
Check.  Smaller is better, but it would be nice to know exactly what a level 1 cache, and exactly what processor.
#Leveal 1 cache is the smallest memory cache in modern processors and therefore the fastest. The point is that the K executable is so small that it can stay resident in the L1 cache.
>> Vector processing makes efficient use of the cache row fetching mechanism and posted writes without introducing bubbles into the pipeline by creating a dependency between consecutive instructions. 
Suppose I have an array expression like D = A + 3*(B+C) and I apply the classic do loop treatment of this statement, i.e. D[i] = A[i] + 3*(B[i]+C[i]), factors which would degrade the speed as array length increases would be the locality of access and cache utilsation (i.e. individual vectors are farther than the cache apart).
But K is an interpreter and is more likely to do something like D = 3*(B+C) then D = A + D, assuming A does not promote the type of D.  But even if D, B, and C fit in the cache window for part 1 and A and D fit in part 2, would this really present such a speedup opportunity?
#Yeah, can't help you here. Hell, I don't even know what a pipeline "bubble" is. 
This pipeline bubble thing is explained nicely in at least two places - have a look at Jim Blinn's book, Notation, Notation, Notation, Chapter 7, pp. 107-121.  I often see it in Borders.  Although the article is nearly 10 years old and he's writing about MMX, I imagine this problem is not unique to Intel hardware.  Also, Intel has some nice code tuning tools and documentation on their web site.  I imagine the average Kdb user does not use this hardware.Cowznofski 21:52, 28 January 2007 (UTC)
replies: text: So for instance, if I use longer variable and function names in my C program, I can expect to exceed the L1 cache and get slower behavior? What insipid crock!!!24.85.131.247 (talk) 17:18, 29 September 2011 (UTC)

text: Ouchie. 69.255.27.90 (talk) 00:49, 14 July 2010 (UTC)
thread_title:  Performance Characteristics 

message: This might give some insight as to how Arthur Whitney thinks and why K is so fast.  Arthur's first prototype J interpreter 
   typedef char C;typedef long I; 
   typedef struct a{I t,r,d[3],p[2];}*A; 
   #define P printf 
   #define R return 
   #define V1(f) A f(w)A w; 
   #define V2(f) A f(a,w)A a,w; 
   #define DO(n,x) {I i=0,_n=(n);for(;i<_n;++i){x;}} 
   I *ma(n){R(I*)malloc(n*4);}mv(d,s,n)I *d,*s;{DO(n,d[i]=s[i]);} 
   tr(r,d)I *d;{I z=1;DO(r,z=z*d[i]);R z;} 
   A ga(t,r,d)I *d;{A z=(A)ma(5+tr(r,d));z->t=t,z->r=r,mv(z->d,d,r);R z;} 
   V1(iota){I n=*w->p;A z=ga(0,1,&n);DO(n,z->p[i]=i);R z;} 
   V2(plus){I r=w->r,*d=w->d,n=tr(r,d);A z=ga(0,r,d); 
   DO(n,z->p[i]=a->p[i]+w->p[i]);R z;} 
   V2(from){I r=w->r-1,*d=w->d+1,n=tr(r,d); 
   A z=ga(w->t,r,d);mv(z->p,w->p+(n**a->p),n);R z;} 
   V1(box){A z=ga(1,0,0);*z->p=(I)w;R z;} 
   V2(cat){I an=tr(a->r,a->d),wn=tr(w->r,w->d),n=an+wn; 
   A z=ga(w->t,1,&n);mv(z->p,a->p,an);mv(z->p+an,w->p,wn);R z;} 
   V2(find){} 
   V2(rsh){I r=a->r?*a->d:1,n=tr(r,a->p),wn=tr(w->r,w->d); 
   A z=ga(w->t,r,a->p);mv(z->p,w->p,wn=n>wn?wn:n); 
   if(n-=wn)mv(z->p+wn,z->p,n);R z;} 
   V1(sha){A z=ga(0,1,&w->r);mv(z->p,w->d,w->r);R z;} 
   V1(id){R w;}V1(size){A z=ga(0,0,0);*z->p=w->r?*w->d:1;R z;} 
   pi(i){P("%d ",i);}nl(){P("\n");} 
   pr(w)A w;{I r=w->r,*d=w->d,n=tr(r,d);DO(r,pi(d[i]));nl(); 
   if(w->t)DO(n,P("< ");pr(w->p[i]))else DO(n,pi(w->p[i]));nl();} 
   C vt[]="+{~<#,"; 
   A(*vd[])()={0,plus,from,find,0,rsh,cat}, 
   (*vm[])()={0,id,size,iota,box,sha,0}; 
   I st[26]; qp(a){R a>='a'&&a<='z';}qv(a){R a<'a';} 
   A ex(e)I *e;{I a=*e; 
   if(qp(a)){if(e[1]=='=')R st[a-'a']=ex(e+2);a= st[ a-'a'];} 
   R qv(a)?(*vm[a])(ex(e+1)):e[1]?(*vd[e[1]])(a,ex(e+2)):(A)a;} 
   noun(c){A z;if(c<'0'||c>'9')R 0;z=ga(0,0,0);*z->p=c-'0';R z;}  
   verb(c){I i=0;for(;vt[i];)if(vt[i++]==c)R i;R 0;} 
   I *wd(s)C *s;{I a,n=strlen(s),*e=ma(n+1);C c; 
   DO(n,e[i]=(a=noun(c=s[i]))?a:(a=verb(c))?a:c);e[n]=0;R e;} 
   main(){C s[99];while(gets(s))pr(ex(wd(s)));}
Personally, I like this style.  Tradition goes out the window, where it belongs.  My eyes don't have to wander too far, nor do I have to turn any pages, to find something.193.8.106.71 14:09, 9 February 2007 (UTC)
replies: text: Ouchie. 69.255.27.90 (talk) 00:49, 14 July 2010 (UTC)
thread_title: first prototype J interpreter

message: This desperately needs to be forked into "k3" (historical interest only) and "k4" (actually useful) articles, especially since a personal version of q is now available free (as in beer)
i'm capable of porting all the k3 code here to k4, it's not that hard and i'm quite familiar with both, but i'm not sure what the "wiki way" is to do a major change like this--do i just change this into the k4 article and create a k3 stub saying "obsolete functional language from Kx"?
Adavies42 (talk) 18:35, 22 August 2008 (UTC)
thread_title:  K3, K4 and Q 

message: k vs. kdb
this article is more a product placement of kx/kdb+ than explanation of k. The reference to the free k-language implementation is missing (https://github.com/kevinlawler/kona/wiki/Group) and it is focusing to much on kdb+ the database which is finally based on q which is based on k. So there is only a second level link to k. — Preceding unsigned comment added by 78.53.59.35 (talk) 09:27, 12 May 2013 (UTC)
thread_title: Untitled

message: I attempted to run the code samples provided on this page using the KDB, which includes a k4 interpreter, and of all the samples only "x@>#:'x" actually ran without errors.  For example:
q)k)2!!7!4
'type — Preceding unsigned comment added by 208.100.48.30 (talk) 20:31, 11 February 2014 (UTC)
thread_title:  Code samples do not appear to work 

message: Since the switch from Geshi to Pygments for syntax highlighting (phab:T85794), support for 'q' was unfortunately dropped, as can be seen with the plain text formatting on this page. Are there other pages using this syntax? If we want 'q' syntax highlight support again, it will need to be added to Pygments.  However, Pygments does include support for 'apl', which may be a suitable fallback, and it can be very easily added like this patch. John Vandenberg (chat) 03:44, 13 July 2015 (UTC)
thread_title:  q syntax highlighting lost