
K as a Prototyping Language - cubix
http://www.cs.nyu.edu/courses/fall02/G22.3033-007/kintro.html
======
dats
Last year someone benchmarked a simplified raytracer in a few different
languages--primarily to show off OCaml. Later, someone wrote the raytracer in
7 lines of K. <http://www.nsl.com/k/ray/ray.k>. The original comparison:
<http://www.ffconsultancy.com/languages/ray_tracer/index.html>

~~~
ajross
Nifty reference, thanks. You absolutely have to read the description in the
original page though. The K looks pretty much line line noise; I've seen raw
sendmail scripts that look cleaner. As terse as the language might be, a
little whitespace and naming conventions might still be a good idea for us
newbies...

~~~
gruseom
_a little whitespace and naming conventions might still be a good idea for us
newbies_

The culture around K is fanatical about concision. This goes back to APL,
though the K people (following the lead of Arthur Whitney, the designer of K
and Q) take it further than anybody else. To the unfamiliar, K looks like a
bad joke (check out the 40 lines of code at <http://www.nsl.com/k/s/s.k>,
which implement the spreadsheet at
<http://www.nsl.com/papers/spreadsheet.htm>), but these people know what
they're doing. Whitney's product includes the language interpreter, a
massively scalable RDBMS, a web server, and God knows what else, and the last
time I downloaded it, the total size was 380 KB. My experience with that stuff
was that the more I looked at it, the more in awe I became. It's a shame it's
not more widely available.

------
tdoggette
/ Right to left precedence:

3*2+5 / yields 21

Why should I learn this language that I've never heard of if it can't even do
math in any sensible way? Not left-to-right, not order of operations, not
lisp-like prefix. Who thought that was a good idea?

~~~
halo
My own personal opinion is that whatever language you're using (or, indeed, in
mathematics) using redundant brackets is generally the best idea anyway.

Removes any ambiguity, easier to read, doesn't need you to remember precedence
rules and there's negligible difference in execution speed.

~~~
ajross
Isn't python (no brackets at all) an existence proof that you're wrong,
though? The eye learns rapidly to ignore brackets. What it reads is
indentation. And most editors will try to enforce indentation levels even
without brackets present.

Or maybe you're just talking about parentheses in precedence grammars? I guess
I have no objections there, but still: the fact that "multiplication has
higher precedence than addition" is taught in grade schools and is used
everywhere, in every language I know that supports precedence at all. What
_conceivable_ purpose could one have to buck this trend? All you gain is maybe
a few lines of complexity in the parser (I mean, it's not like these things
are hard to write) at the cost of a lifetime of newbie syntax errors.

~~~
stcredzero
If the newbie programmers are professionals worthy of the name, those errors
won't make it into production. A less complex parser will have tremendous
leverage by making it easier to craft syntax-aware programming tools.
Smalltalk has a history of amazing ground-breaking programmer tools written by
single individuals years ahead of their appearance in other languages.
Contrast this with Ruby. I like Ruby a lot. It's a great language. The syntax
is a bit hairy, however. Teams of people worked for a couple of years to
produce an ANTLR parser which is independent of the Ruby VM's parser and could
be used for programming tools.

A good programmer can just crank out a top-down Smalltalk parser in one day.
If you make your language easy to work with, you get a more powerful toolset
sooner. On top of that, the lowered barrier to entry gets you more real
innovation in that toolset.

------
dangoldin
If anyone is interested in some examples, take a look at projecteuler.net -
it's a series of mathematical/programming puzzles.

After you solve a particular problem you gain access to a forum where people
detail their solution. A good amount of the solutions tend to be written in
these APL languages (J, K) and may serve as a nice way to learn.

------
42flicks
Very interesting, thanks for posting the link.

I'm also interested in what industries this language perfoms well.

~~~
cubix
From what I gather, it's used mainly by quantitative analysts in finance (so
called "quants"), but I'm sure it could be applied to a wide variety of other
fields.

------
ahold
Is it "K" or "Q" language?

~~~
Kaizyn
It's K, a successor to the J programming language.

~~~
gruseom
Not so much a successor as a sibling rival. I've always assumed the name was a
bit of (typically cryptic) humor.

