Live data from Hacker News

Stages of denial in encountering K

nsl.com

351–360 of 432 posts

Re: Stages of denial in encountering K

#351
post #308

Earlier quoted context omitted.

It's a little funny comparing a language with another language+plus-its-entire-ecosystem, but k fares remarkably well I think. Counter could be #:'=: (count each group) c:#:'=: Values would just be dot. Counter[x]&Counter[y] is a bit tricky to write, because while the documentation says set intersection, what they really mean is the set intersection of the keys with the lower of the values. This is entirely clear in…

> It's a little funny comparing a language with another language+plus-its-entire-ecosystem This is pretty much my point: any ‘reimplement this weird built-in thing in $OTHER_LANG’ is going to involve overheads unless $OTHER_LANG also has that thing. I don't think keeping most types out of prelude should be a downside; you can always ‘from myprelude import * ’ if you disagree. > How would you do this in Python? I don'…

> I don't think keeping most types out of prelude should be a downside

I don't understand what that means.

> I don't really know what "persists the unique index of f" means, but this seems similar to shelve. I can misuse that to give the same effect as what you showed.

I think you got it, but it seems like a lot of typing!

How many characters do you have to change if you want it purely in memory? In k I just write:

    `x?`f

Re: Stages of denial in encountering K

#352

I have the same question for K aficionados as I have for Forth ones: what real-world, human-usable, important software has been written in it? A GUI framework, a web browser, a window manager, a text editor, etc. Anything? I'm asking because the article is poking at C-like languages, i.e. implying that K is good for general-purpose use. Yet all I hear about is that K is good at multiplying numbers and matrices, which…

Forth:

OpenFirmware (previously seen in Power Macs, pretty much every Sun device until Sun died, so on.

Canon Cat (greatest text editor of all time, by Jef Raskin, the guy who made the Macintosh)

Forth Has Been to Space (multiple times, but who's keeping score?): https://www.forth.com/resources/space-applications/

OKAD, which was used to create the processor with the lowest power usage per instruction in the entire world.

k:

Important, no, but a substantial volume of stuff. Text editors, GUIs, window managers, operating system completely independent of any other, a pretty important and very expensive database, so on.

k, unlike Forth, came after software was seen as IP. Software as IP has made a lot of people very angry and been widely regarded as a bad move.

k's ancestor, APL, was used in quite a few things quite elegantly, and while k is different, it's not different enough to be a different paradigm. Some examples: first practical electronic mail system, first widely-used electronic mail system (used for Carter's successful Presidential campaign, for example), first worldwide computer network, I could go on.

That k hasn't seen as much groundbreaking work done in it is less because of the language itself and more because of the insane costs, trigger-happy lawyers of kx, and money.

Of course, when you asked this of Forth the other day, you were trolling ( https://news.ycombinator.com/item?id=22319154 ), so I imagine I might be wasting my time.

Re: Stages of denial in encountering K

#353

I use to program financial applications in K/Q for a stint. Very elegant and orthogonal language. And very well documented. One major issue I had with it and other APL-ish languages: lack of skimmability. I can easily skim thousands of lines of Perl and Java in seconds and have a rough idea of what the code does. Reading K, however, requires careful and deliberate attention to every single character. I found it usefu…

Yeah, I agree. I wrote some mortgage prepayment models in q for a while, but didn't dip into K itself. Q is fantastic as a database query language (assuming you have time-series databases and are mostly doing fairly simple operations.) Implementing a full model in it is fine, but can get hard to maintain. Also it has (or had, maybe they fixed it) a bunch of weird quirks, like "sum foo" skipping all the NAs in a list…

I believe they have fixed it. I just did the following:

  q)a: 1 2 3 0N 3 4
  q)sum a
  13
  q)+/[a]
  13

Re: Stages of denial in encountering K

#354
post #321

Earlier quoted context omitted.

> kdb isn't written in an external language. But it's an external database with its code and its optimizations. In this case it seemed that it was just doing a binary search, but it was using an already sorted dataset that the OP of that comment wasn't using. > kparc.com/$/ Well, I can't get anything out of this. See http://kparc.com/$/file.k . The language is cryptic and the variable names are even more cryptic. It'…

But it's an external database with its code and its optimizations. In this case it seemed that it was just doing a binary search, but it was using an already sorted dataset that the OP of that comment wasn't using. I again point to the C standard library. Modern standard-compliant C can do almost nothing without it. I don't even think it can handle IO without it. The language is cryptic and the variable names are eve…

> You're thinking of it in a light that doesn't help you understand; don't think of it as a variable, think of it as a definition. "jk is defined as..."

I was just trying to read the code for "file" and see if I understood a little bit of the implementation they did. In this case I don't even know where even is the function that opens a file or writes to a file. I don't think that's good code and I don't believe that thinking of it in terms of a definition is going to help.

Re: Stages of denial in encountering K

#355
post #284

Earlier quoted context omitted.

And specifically in that example, using an external database when defending the speed of the language kdb isn't written in an external language. Has he? Couldn't find anything (I'd like to see it, honestly, seems a fun experiment). Not entirely him, of course. There are a few remaining files on kparc.com: kparc.com/z/ kparc.com/$/ so on. Not free software, and they seem reluctant to show it off. 'geocar has done a li…

> kdb isn't written in an external language. But it's an external database with its code and its optimizations. In this case it seemed that it was just doing a binary search, but it was using an already sorted dataset that the OP of that comment wasn't using. > kparc.com/$/ Well, I can't get anything out of this. See http://kparc.com/$/file.k . The language is cryptic and the variable names are even more cryptic. It'…

> But it's an external database with its code and its optimizations.

You're completely mistaken. It's not an "external database". That's a regular, ~600kb interpreter download from kx.com

Those lines are all the lines typed into a q) prompt one at a time on my laptop (A 1.6ghz macbook air).

> In this case it seemed that it was just doing a binary search,

Yes. That's all okon does as well, they just do it over a B-tree instead of a contiguous list. If you read the writeup you'll see the author actually eschewed using a contiguous list for reasons of random insertion then took to a B-tree generation algorithm that couldn't handle unsorted input. I suppose they just forgot what they were doing at some point.

> but it was using an already sorted dataset that the OP of that comment wasn't using.

Again, you're mistaken. The author (Stryku) might not have known the sorted file existed, but the first thing they tried to do was sort it. They just had a problem sorting a 22GB file because they were using terrible tools. They had to make tools because they didn't have any good ones. The rest of their algorithm took advantage of the fact the input (to these later stages) was sorted.

> Well, I can't get anything out of this.

> I can't honestly believe anyone that says that's a good way to create code.

I spent 5 minutes to write something (in q) someone else wrote over twenty days (in C++).

I can't honestly believe anyone that thinks spending twenty days on a problem is better than five minutes.

If you can't get there, it's going to be really hard to talk about what's amazing in k!

Re: Stages of denial in encountering K

#356
post #324

Earlier quoted context omitted.

> How do you figure? Programmers too, have a "native language" Unless everybody is born learning a language, no we don't. Even 'The one they use the most' varies over time. > What would be the point of communicating such an opinion to others? An easy use case: you're in your company and you need to do a simple script for some computation. The more readable the language you use is, the more coworkers will be able to f…

> Unless everybody is born learning a language, no we don't. Even 'The one they use the most' varies over time. Nobody is born having learned a language. It's something even babies have to learn and they know nothing! People can even "switch" their native spoken language up to a point although it seems to get much harder as they get older and more experienced with one language, as they're constantly comparing their a…

> Nobody is born having learned a language. It's something even babies have to learn and they know nothing!

I meant a programming language (it gets confusing, sorry). But anyways, our native language is much more embedded in the brain than programming languages.

> I think if you decided to write your "simple script" in even a well-known language like JavaScript, you'd cause some grumbles in a Python+C# shop; k isn't special in this regard.

Yes. And I'd cause even more grumbles if it was written in Haskell, and even more if it was on K. That's the point.

> HIBP offers the data pre-sorted, so I used that.

Yes, and that changes how you access the data. So the evaluation was not fair, as the OP was not using sorted data.

> db is a database in exactly the same way that Python could be if you just pickle/unpickle everything, except it's actually fast enough that people do this, even for large data sets.

That's nice, I'd actually wish Python had better serialization facilities.

> f=42 returns 010b and g=69 returns 010b -- do you see why

What if "f:42 1 2"? f=42 returns 100b (is that a value or a vector?) so under the common "and" definition "(f=42)&(g=69)" should return 000b, under the "less than" returns 010b?

Re: Stages of denial in encountering K

#357
post #329

Earlier quoted context omitted.

> How do you figure? Programmers too, have a "native language" Unless everybody is born learning a language, no we don't. Even 'The one they use the most' varies over time. > What would be the point of communicating such an opinion to others? An easy use case: you're in your company and you need to do a simple script for some computation. The more readable the language you use is, the more coworkers will be able to f…

> "harmonises" in the sense that it takes one of the most common programming symbols and changes it? I don't know of anyone that sees "2 & 3 = 2" and thinks "yeah this makes sense". There are a few of us in this thread, trying to explain why. You find outrageous that 2&3=2, almost everyone (all the non-programmers of the world) will find more outrageous that i=i+1. You get used to it quite fast. It's obvious as soon…

> will find more outrageous that i=i+1

Yep, it is hard to understand. That's precisely why I don't like having even more unintuitive things.

> It's obvious as soon as you realize that, with booleans, min is and, and max is or.

But it's not min and max with the rest of types.

Re: Stages of denial in encountering K

#358

Look, I don't hate K. It's probably a pretty good language for the task it seems to have been designed for, which appears to be numerical computing. Being able to fit an entire code on a screen is an interesting concept; while I'm not completely convinced it should be a goal in and of itself it's certainly something I can't rule out as a possible productivity booster. However, I still find it problematic, and it's no…

If you're going to use a language (call it X; we're not just talking about K), then you really have to know X's syntax and primitives. There's just no other way.

You also would be much better off learning X's idioms. These are standard ways of saying something. They're standard for a reason - because they work, and because everybody understands them. If you can't read them, then a lot of code is going to be difficult to understand.

That's just table stakes for using X. If you want to use X, but don't want to learn the syntax and the primitives, then you don't really want to use X. You may want the benefits that you think X would get you, but you don't actually want X.

Now for the other side: If you're a proponent of X, you need to remember that many languages are magic within certain domains, and anywhere from "meh" to horrible outside it. Take K, for instance. I'm pretty sure it wouldn't be a good fit for most embedded systems. I'm fairly sure it wouldn't be a good fit for web programming. I'm not sure I'd want to do text processing in K. So it's not "the one way" (except possibly within certain domains). It's not "the way of the future" (except possibly within certain domains). It's not "what all the smart and enlightened people are using" (except possibly within certain domains). And, unless we're working in those certain domains, it really isn't all that important whether the rest of us learn it or understand it.

Re: Stages of denial in encountering K

#359
post #355

Earlier quoted context omitted.

> kdb isn't written in an external language. But it's an external database with its code and its optimizations. In this case it seemed that it was just doing a binary search, but it was using an already sorted dataset that the OP of that comment wasn't using. > kparc.com/$/ Well, I can't get anything out of this. See http://kparc.com/$/file.k . The language is cryptic and the variable names are even more cryptic. It'…

> But it's an external database with its code and its optimizations. You're completely mistaken. It's not an "external database". That's a regular, ~600kb interpreter download from kx.com Those lines are all the lines typed into a q) prompt one at a time on my laptop (A 1.6ghz macbook air). > In this case it seemed that it was just doing a binary search, Yes. That's all okon does as well, they just do it over a B-tre…

> I can't honestly believe anyone that thinks spending twenty days on a problem is better than five minutes.

Nobody thinks that and I didn't say that. I was talking about that specific file (although the rest of them are equally unapproachable).

> If you can't get there, it's going to be really hard to talk about what's amazing in k!

Well, the thing is that at this point the only amazing things that have been talked about is that it's fast (in some specific use cases of data queries) and extremely concise. What more there is to K? What more reasons are there to use it, and with which downsides does it come with?

Re: Stages of denial in encountering K

#360

Earlier quoted context omitted.

Performance depending on your use case. APL/J/K can be very fast for an interpreted language, but they won't beat C, C++, Fortran, and Java in most cases. Also, think about distribution. With most of the array languages, it is commercial, so I'd be cautious about building a business around it. With other languages, it is free to use and deploy as you see fit and some have binary executables that don't need a runtime.…

> APL/J/K can be very fast for an interpreted language, but they won't beat C, C++, Fortran, and Java in most cases. Do APL/j/k/q work well for some performance-sensitive situations but not others? Some of the comments here by people who appear to be very familiar with the language make it seem like it performs quite well compared to the traditional high-performance languages. Distribution is definitely something I h…

So the language isn't really amazingly fast from certain benchmarks I've seen like fibbonachi, but the entire integrated database solution for analysis purposes is very fast. I wouldn't do high frequency trading or high performance scientific computing in it, but data analysis is great.
Post reply on HN