[HN Gopher] K Programming Language
___________________________________________________________________
K Programming Language
Author : ColinWright
Score : 89 points
Date : 2021-09-11 16:31 UTC (6 hours ago)
(HTM) web link (kparc.com)
(TXT) w3m dump (kparc.com)
| Jenk wrote:
| Maybe it's because I'm tired. Maybe it's because I'm half reading
| this article while my 2yo is bathing/playing in the bath
|
| But that looks like a really error prone syntax.. error prone
| like writing Brainfuck I mean.
| gaze wrote:
| The argument is that your entire program fits on one screen. It
| may be hard to read (without practice) but you can stare at the
| whole thing all at once. I don't know if I buy the argument but
| it's an interesting one.
| quag wrote:
| You're not wrong. While writing K you sit in the repl and work
| out each piece as you go and make sure it gives the result you
| expect and then build up.
| Nekorosu wrote:
| It's just a first impression. This is a very effective tool.
| Ofc it requires some effort to use (as well as mathematical
| notation). Required reading
| https://www.eecg.utoronto.ca/~jzhu/csc326/readings/iverson.p...
| beagle3 wrote:
| Yea and no.
|
| Consider mathematical notation. That digit 2 could mean "power
| of 2" if it's small and upper right of an object; "index 2" if
| small and bottom right. "Multiply by 2" if regular sized and to
| the left - very confusing! Indeed, it _is_ very confusing if
| you are not versed in the accepted syntax of math expressions.
|
| But if you are used to it, there's no confusion - it's just a
| very concise and useful way to express various concepts.
|
| K is similar.
| quag wrote:
| K made a lot more sense to me after I realised it is three
| things: a library of functions, operators, and a set of types.
| The only way to access the function library is through the
| operators/type overloading. Different versions of K (or related
| languages) then choose different libraries of functions, or
| different operators. Code is essential a very dense encoding of
| function calls into a fixed library.
| gaze wrote:
| K is cool but really, really expensive. Kevin Lawler's Kona seems
| nice. Shakti (next K version) could be good but I can't figure
| out a damn thing about it.
|
| And then there's J, which, man. Hard to learn, but cool.
| huhtenberg wrote:
| > really, really expensive
|
| Can't find any pricing info on their website. How expensive is
| "expensive"?
| threatofrain wrote:
| What is the largest open-source community for a K-like
| language?
| rscho wrote:
| If you consider J K-like, then J. Otherwise, ngn K or Kona
| gbronner wrote:
| A number of orgs have perpetual site licenses, or so I've been
| told. It can solve many problems elegantly and with minimal
| code and development time. But it requires a core group of
| people who do almost nothing else.
| mlochbaum wrote:
| There's now ngn/k[0] for a free implementation of K6. The
| author prefers K6 to Shakti, which is K9. And there are a
| number of other open-source K dialects and array languages as
| well[1]. For learning about K, the recently-created K wiki[2]
| is a great resource.
|
| [0] https://codeberg.org/ngn/k
|
| [1] https://aplwiki.com/wiki/List_of_open-
| source_array_languages
|
| [2] https://k.miraheze.org/wiki/Main_Page
| Bostonian wrote:
| Do Octave and R qualify as array languages? You could say
| that Python is not because Numpy is not part of the language.
| mlochbaum wrote:
| It's hard to say how exactly to draw the line, but "array
| language" to an APLer usually means a language whose
| primary influence is APL. So these scientific languages
| that throw out most of the syntax are nearby but don't
| quite belong. From a practical standpoint the APL Wiki is
| centered on APL and exists to document the kind of niche
| material Wikipedia wouldn't cover, which is why there's
| nothing about these more mainstream languages currently.
| stingraycharles wrote:
| I'd argue that array languages are far, far more limited
| than Python, to the point that the only thing you can
| reasonably do with them is processing array data (but
| they're really good at it!)
| mlochbaum wrote:
| Sounds like you're generalizing, based on... early APLs?
| NumPy? You could translate any BASIC code to, say, Dyalog
| APL easily without significant loss in fidelity.
| Different languages take different approaches but most
| modern ones (the ones that aren't just made to be
| calculators like Ivy) support either a generic functional
| or imperative style just fine.
|
| K is inspired by Lisp, although you can't adapt that
| style directly because of the limited scoping rules:
| variables are either local or global, so a function can't
| see variables from containing functions. This means no
| closures, which K implementers consider a feature (I
| don't).
| eiz wrote:
| > This means no closures, which K implementers consider a
| feature (I don't).
|
| having not touched K in about 15 years, when did this
| change? in k3: K 3.2 2004-09-23
| Copyright (C) 1993-2004 Kx Systems LIN32 16CPU
| 15985MB ubuntu 0 EVAL
| f:{a:x+1;{a+x}} g:f 1 g {a+x}
| g 2 4 a value error a
| ^ parse error
| mlochbaum wrote:
| This comes as a surprise to me! I thought none of
| Whitney's Ks had closures--although I did neglect to
| mention that kuc and oK add them. Digging around and
| asking on the K Matrix/Discord I found some posts that
| suggest that the K3 form is very limited. My read of
| these is that functions can refer to variables in the
| immediately surrounding scope (only one level up), and
| their values will be copied in when the function is
| reached in the source code. So it would be equivalent to
| adding extra arguments to g and passing the variable
| values in that way. And it wouldn't allow the programmer
| to create object-like things and couldn't create
| reference loops requiring garbage collection.
|
| See https://news.ycombinator.com/item?id=22572778, as
| well as https://chat.stackexchange.com/transcript/message
| /53999576#5... with more discussion on following days.
| smabie wrote:
| No closures is one of the biggest pain points of k/q,
| it's incredibly limiting and frustrating. Besides that
| though, it's a wonderful language which allows you to
| solve problems _very_ quickly with pretty good
| performance, assuming the problem is naturally
| vectorizable.
| [deleted]
| aseipp wrote:
| Is there any summary of what's changed between K versions, or
| their lineage, for someone who's not "K-fluent" but a tiny
| bit familiar with array languages? What changed between K6,
| 7, and 9?
|
| Since Kx is the proprietor of the main toolchain I assume
| such any such description would be more of an oral history
| rather than a technical document with a changelog, but I'm
| curious either way!
|
| EDIT: There is a wiki page for this but it hasn't been filled
| out (yet) unfortunately. Sad trombone.
| https://k.miraheze.org/wiki/History
| invalidOrTaken wrote:
| Comment from a year
| ago(https://news.ycombinator.com/item?id=22562344):
|
| >A story, since in retrospect I think it's worth telling. Some
| years ago I was at the SF Clojure meetup. Arthur Whitney's
| daughter worked at the sponsoring company, and he agreed to come
| tell us about K.
|
| >In retrospect, I don't think we gave him the welcome he
| deserved. No one was rude or anything, but it seemed there was a
| disconnect: Arthur was keen to show off how fast K (and Kdb) was,
| over zillions and zillions of rows.
|
| >But the thing that the Clojurists were all searching for (that
| got them into Clojure in the first place) was expressivity. Is
| Clojure fast? I don't know, generally the problems I face come
| down to avoiding balls of mud rather than performance
| bottlenecks. And I think that was true of most there.
|
| >So Arthur got something of an underwhelming reception. I
| remember someone asking "Does K have the ability to self-modify,
| a la Lisp macros?" When Arthur said no, you could see most people
| in the room just sort of mentally shrug and move on.
|
| >And this was too bad. Because recently I've been playing around
| with J (another APL descendant) and been very impressed by some
| expressivity/readability benefits. Some small things that have
| very big effects on the codebase you actually end up with.
|
| >The first thing is the avoidance of abstraction. To use a
| Twitterism:
|
| >Broke: Just write your code and don't divide it into functions,
| creating one long main method
|
| >Woke: Divide your code up, naming parts that get reused
|
| >Bespoke: If your code is made up of really really short things,
| it ends up being shorter than the names you would use, so you can
| just write the thing rather than your name for it. An analogy
| would be: there is no human-comprehensible way to communicate the
| idea of "picosecond" in less time than an actual picosecond.
|
| >The other thing I didn't expect was the benefit of multiple
| dispatch being baked into e v e r y t h i n g. In Clojure I might
| write (map + a b) to add each index together; in J I could just
| write a+b.
|
| >This is neat stuff! Best practices for keeping complexity down
| in APL's tend to be the opposite of what they are in other
| languages. Aaron Hsu gave a talk about this:
| https://www.youtube.com/watch?v=v7Mt0GYHU9A
|
| >It's too bad! Arthur came to tell us about speed---there's a
| reason it's used on giant datasets in finance, where performance
| translates directly into cash---but I wish we'd had the presence
| of mind to ask more about experience of writing K.
|
| >So, Arthur, if you're reading this: Sorry everyone seemed kinda
| bored in SF a few years ago when you kindly came to present. We
| missed out!
| nudpiedo wrote:
| It's been a while now since I first met on theoretical level
| array languages. I like the symbolic representation of Dyalog and
| APL in spite of its input problem. Is there a language of those
| well sure for mobile development or llvm and web compilation?
|
| Also missing some comprehensive guide on its philosophy and way
| of thought to solve problems? I remember there were some videos
| on YouTube solving the advent Of code and comparing to Haskell.
| These were awesome in order to get into the APLer mindset.
| rscho wrote:
| J runs on Android. To see J in action, you can check out
| TangentStorm's channel on Twitch
| CraigJPerry wrote:
| BQN has an online repl
|
| https://mlochbaum.github.io/BQN/
| dotnwat wrote:
| What does "k4 is proprietary" mean? Does that mean one way run
| into problems building an open-source implementation of the
| language itself?
| huyage wrote:
| Clicking on examples gives me 403.
| AzzieElbab wrote:
| Consider your self lucky
| AzzieElbab wrote:
| K and Q have to die along with MUMPS and maybe some other
| sadistic experiments in pl development I may not be familiar
| with
| rak1507 wrote:
| Why?
| rscho wrote:
| You could at least elaborate so we could tell you why
| you're wrong :-D
| dang wrote:
| " _Please don 't post shallow dismissals, especially of
| other people's work. A good critical comment teaches us
| something._"
|
| https://news.ycombinator.com/newsguidelines.html
| imachine1980_ wrote:
| dumb question but where is the source ? what is the license?where
| i can install the program(linux/ubuntu)?
| marcelnita wrote:
| K is proprietary and licensed by Kx Systems. Reading further on
| it I gather it isn't cheap.
| smabie wrote:
| It costs an arm and a leg. I think Kx systems fucked up in
| making the language proprietary and closed source and
| charging for licenses. The smarter long-term play would have
| been to charge for support/special features/etc ala julia
| computing or lightbeam.
| andylynch wrote:
| I don't the Arthur Whitney feels like he missed out.
|
| Looking quickly at the revs for Julia and Lightbeam, KX are
| doing rather better.
| hogFeast wrote:
| They have a huge database product (kdb). The company that
| owns Kx is a billion dollar company.
|
| It really isn't clear to me why they do what they do (not
| just with regards to the language). They have a large
| consulting business (q/kdb consultants can make PS1k/day
| easily) so it doesn't make a difference. I believe some
| parts of q/kdb are open-source but some parts are not. And
| I think this really does hurt them because there isn't a
| big eco-system around their products (for example, they
| have had to hire people internally to build ML libraries
| for q).
|
| It is very weird: they are at the eye of the storm for data
| analytics, their product is fast, they are growing modestly
| doing lots of business with banks and in other industries
| that need streaming analytics particularly...but they are
| still niche, and growing a lot slower than you would expect
| (part of this is that management insists on being
| profitable...people rip on SV companies for not making
| money...well, Kx are the other side of this...they are
| modestly profitable, but not really growing).
|
| EDIT: I should add, if you see the stuff that is open...a
| lot of the code is a total shitshow.
| rscho wrote:
| Given the combined cost of K licenses in banks and other
| large companies, I'd say they are really far from having
| messed up. The main goal of the company is not to promote K
| the language.
| rak1507 wrote:
| commercial ks are not open source
|
| ngn/k is foss and can be installed on linux
| https://codeberg.org/ngn/k
| andylynch wrote:
| It's proprietary but free for personal use and worth trying out
| (the download is absurdly small!)
|
| Download + licenses are at https://kx.com/developers/download-
| licenses/
|
| The Q for Mortals book (free online) is a good place to start,
| as is https://code.kx.com/q/learn/tour/
|
| The licenses aren't cheap but are worth it for the right
| problems. Definitely worth adding that the relatively few
| people skilled in k/q are very much in demand and paid
| accordingly.
___________________________________________________________________
(page generated 2021-09-11 23:00 UTC)