HNHacker News
TopNewBestAskShowJobs

chrispsn

1,055 karma · joined July 21, 2017

Sydney, Australia.
submissionscomments
chrispsn··on Determining an Election in K
Correction: I think the above can be a bit faster and shorter if we skip the dict, and just index into the keys. Compare:

     \t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s
    941
     \t:100000 `freq(s/!s*#v)s#>,/v%\.5+!s
    901
chrispsn··on Determining an Election in K
Yes. When each function is a single character [1], juxtaposition is enough to show the calling order - eliminating the need for brackets in many cases, and reducing syntactic noise.

[1] There's a handful of two-character primitives, as well as some special callable symbols (eg `freq @), but they don't come up nearly as often as the base set.

chrispsn··on Determining an Election in K
Another approach to the 'highest averages' method, using a k9 dict:

    v: 10400 3400 6200
    s: 15

    quotients: ,/v%\.5+!s
    labels:    s/!s*#v              / list of 15x 0, 1, 2. arbitrary; could instead be party names
    top:       s#>labels!quotients  / k dicts can have duplicate keys; can sort items by key(^) or val(<>)
    seats:     `freq@!top           / count appearances of dict's keys
The ability to transform a dict's values while keeping the labels (keys) unchanged - sort, arithmetic, etc - is really powerful.

This answer is longer when minified, but it's faster in 2020.03.27:

    \t:100000 +/s>(#v)^<>,/v%/.5+!s           ⇒ 1494
    \t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s  ⇒ 691
chrispsn··on TXR Lisp
kazinator provided examples in two recent k threads:

https://news.ycombinator.com/item?id=22631649

https://news.ycombinator.com/item?id=22666539

chrispsn··on Example of a Shakti-powered spreadsheet application [video]
The Shakti co-founder's previous tech was a very fast time series language+DB - this is his next iteration. https://tech.marksblogg.com/billion-nyc-taxi-kdb.html
chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Shakti k (k9)!

https://shakti.com/

How to install: https://www.youtube.com/watch?v=l19Ef9v2uVI

chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Kind of - in Excel everything just has a location reference, even if you name it. So that means you can get collision errors if a dynamic array expands into another cell.
chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Thanks! And hopefully the README helps too:

https://github.com/chrispsn/mesh/blob/master/README.md

chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Hi everyone! The Shakti k version of Mesh is under development, but for now you can try the JavaScript prototype: http://mesh-spreadsheet.com/

Slides (view in Powerpoint slideshow mode to see the animated GIFs): https://github.com/chrispsn/presos/raw/master/2020-02-26%20M...

And past demo videos of the JS prototype:

- Basics: https://www.youtube.com/watch?v=_U6gE3cNgbI

- Dynamic tables: https://www.youtube.com/watch?v=x32tBLGrLAQ

chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Thanks! That's great feedback for next time.
chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Not dead, just evolving! I hope to bring some of the insights from doing the k version into the free JS version. But even then, the formula language is unlikely to be raw JS - maybe jq, or a k subset. JS, as a moving target, is just too hard to parse in a small package.

Mesh's backend sits in one giant file because that's how we can write it in a Mesh sheet. But unfortunately the JS parsing library is huge and forms the bulk of the code. Happily, the k version is currently ~100 lines excluding tests.

If JSX were used, would the code need to be compiled? Mesh used to have a compilation step but it just added complexity (config files, build process, increased download size). Keep it simple! React.createElement is fine.

chrispsn··on Example of a Shakti-powered spreadsheet application [video]
Users have strong expectations about what features a "spreadsheet" application should have, so I say it merely "feels like" a spreadsheet to help manage those expectations.

For example, in existing spreadsheet programs, each cell gets an A1-style location reference (even in an Excel table or a dynamic array).

That's not the case in Mesh, but it does something similar: a cell's default name is where it was entered in the grid UI, and (soon!) we update that name when the cell gets moved around.

chrispsn··on K Language (2011)
I'm sure they'd be open to discussing that with you! Try Fintan: f@shakti.com
chrispsn··on K Language (2011)
k9: yes to all.
chrispsn··on K Language (2011)
BTW, some examples of AoC 19 answers in k:

ngn's; targets ngn/k (dude's a machine): https://bitbucket.org/ngn/k/src/master/aoc19/a.k

Mine; progressively porting from k7 to k9. Not as many answers and probably worse coding than ngn's, but perhaps more approachable for newcomers. https://github.com/chrispsn/aoc2019

llelf's; targets k7. Pretty slick. https://github.com/llelf/advent2019/blob/master/sol.k

chrispsn··on K Language (2011)
Q/KDB+ for something production ready now.

k9 (Shakti) for a simpler product that's in the active language design phase and with not as much integrations - yet.

ngn/k for an actively developed version that's free and targets k6-era (for now).

chrispsn··on APL a Day
BTW, a little easter egg that the creators built in: try Ctrl-[ and ] at console.
chrispsn··on APL a Day
Try this: https://kparc.github.io/ref/
chrispsn··on APL a Day
It's really neat!

Note this is k7 - dev has since moved to k9. k7 will be remembered as the 'Unicode symbols' experiment of k; for example nulls were slashed zeroes (Ø) and pi was, well, the pi symbol. k9 dropped them as they're not easy to type across all OSes without config or a dedicated editor.

k9 also has the nice dedicated 'cut' symbol, and a few other improvements, but it's not done yet.

chrispsn··on Stages of denial in encountering K
What does this do?
chrispsn··on Stages of denial in encountering K
k9 (from Shakti) will have optional word equivalents for some symbols (or at least common compositions) by default.

Have you looked at q?

numpy has a lot of k/APLish primitives built in.

fml was also interesting but never made it past the spec stage:

https://www.reddit.com/r/apljk/comments/etpbbf/fml_an_optimi...

chrispsn··on Stages of denial in encountering K
I started with Python and still miss its lazy generators. K's grain favours calculations that drive down long 'straights' of arrays without many conditional turns, but it's eager-first, which can be a drag for some problems (eg making a prime number generator object that I can take an arbitrary number of elements from lazily). Still, it hasn't been as bad as I feared.

I like the choices of primitives in K and the novel ways they can be combined to do things more efficiently (and with fewer pieces!) than you may expect. Good examples are 'where' (&), the grade twins (< and >), scan (\), and eachprior (':).

I love the adverb syntax: each (') lets you map a function over a data structure with zero syntactic effort, and 'over' (/) and 'scan' (\) make reductions trivial.

With regards to an on-ramp, I started with John Earnest's oK REPL and did a bunch of Project Euler and Advent of Code problems. I then moved to trying to understand the examples on kparc.com. I then converted a spreadsheet application from JS to k7. In all of this, John's documentation was essential.

For me, having single variable names isn't paramount, but in some cases - particularly functions - I can see it helps to 'drive' your mind towards finding simpler ways to do things. It lets the characters that do the 'real' work come to the forefront.

chrispsn··on Stages of denial in encountering K
What would be a more obvious symbol choice for range (aka til or seq)? Pound (#)?
chrispsn··on Stages of denial in encountering K
This may help - I found it confusing at first too: https://twitter.com/kcodetweets/status/1236904643684270080?s...
chrispsn··on Stages of denial in encountering K
There's a q Mandelbrot here:

https://github.com/indiscible/qmandel

And Arthur's version in k (also below):

http://www.kparc.com/z/comp.k

I should convert it to k9 (Shakti)...

    +/~^+/b*b:49{c+(-/x*x;2**/x)}/c:-1.5 -1+(2*!2#w)%w:10
chrispsn··on Stages of denial in encountering K
Arthur tries to choose primitives carefully so that the amount of steps is smaller than other languages (see the 'product' quote in another comment). So even if you give each symbol an English name, the code will often end up smaller.
chrispsn··on Stages of denial in encountering K
How about an OS?

https://gist.github.com/chrispsn/da00835bb122c42f429a084df83...

chrispsn··on Stages of denial in encountering K
From Arthur:

    design goal: speed
    write fast, run fast, modify fast.
    minimize product of vocabulary and program size.
https://a.kx.com/a/k/readme.txt

    comprehensive programming environments 
    (programming, files, comms, procs, ...)
    are depressingly complex.
    commonlisp, c/lib/syscalls, java, winapi
    are all in the 1000's of entry points.
    many with multiple complex parameters.
    with k we try to do more with less
    in order to write correct programs faster.
https://web.archive.org/web/20041024065350/http://www.kx.com...

    > Just curious, but does the state of California charge you a large tax
    > for each character in a variable name?
    
    yes.
    
    we also try to fit our algorithms onto licence plates.
https://web.archive.org/web/20040823040634/http://www.kx.com...

For some 'licence plate' K algorithm dissections, you might like this Twitter account:

https://twitter.com/kcodetweets

chrispsn··on A bestiary of single-file implementations of programming languages
> Looking back on it I see many opportunities left to simplify.

What would you do?

chrispsn··on Fml: An optimizing array programming language
Joe says it was purely a design doc:

https://twitter.com/jckarter/status/1221232990233038848?s=20

← PreviousPage 2 of 4Next →