Live data from Hacker News

Impending kOS

archive.vector.org.uk

221–230 of 242 posts

Re: Impending kOS

#221
post #126

Earlier quoted context omitted.

I do enjoy learning about such things, but, for most of the work I do, performance is nowhere near at the top of the list of things I care about. Also in the past I've been burned by code that's small/fast but is otherwise utterly unmaintainable. I'm not saying that's the case here, but... past experience, and all that tends to color perceptions. I think with a language like k or q, which appears to be purpose-built…

> I think with a language like k or q, which appears to be purpose-built for certain types of problems, The thing is, it's not purpose built, and it doesn't even appear to be if you suspend your disbelief. The only reason you'd think it is purpose built is because "well, it can't be this short if it wasn't purpose built". But if you go over the manual, and find special built operators, please tell us what they are. e…

How would you represent a graph and implement DFS in K?

Re: Impending kOS

#223
post #221

Earlier quoted context omitted.

> I think with a language like k or q, which appears to be purpose-built for certain types of problems, The thing is, it's not purpose built, and it doesn't even appear to be if you suspend your disbelief. The only reason you'd think it is purpose built is because "well, it can't be this short if it wasn't purpose built". But if you go over the manual, and find special built operators, please tell us what they are. e…

How would you represent a graph and implement DFS in K?

Numbers in arrays can be treated as pointers, into that same array, giving a graph. It's just a question of context. If you were storing RDF triples in K you'd simply have an array for subjects, one for objects, one for predicates, and one of the URIs/text. Simply store the index of the URI/text item in each of the subject, object and predicate columns. An individual triple would be formed by the same index applied to the subject, object and predicate arrays.

DFS is then a variation of the more familiar functional style of tackling the problem where you have your end condition (i.e. something that matches what you're looking for) and failing that do something else (typically recursion).

I can't recall enough of the K syntax these days to actually implement that right now though, or if K has TCO.

Re: Impending kOS

#224

Earlier quoted context omitted.

> First, it is not equivalent - next() cannot apply to range() output, for example - you will need to do some iter() games and watch out for iteration order side effects if your values are iterators vs. lists. It uses generator/iteration semantics instead of list semantics. If you wrap the whole thing with a decorator like function that does: def scan_wrapper(f, x0, x): return list(scan(f, iter(x), x0) You get the ex…

> Second, it is ~10% faster... > It potentially uses less memory... > Yeah, I think you are understating it to say the least. I actually measured it. It was 10% faster with a call to 'r.append', and within 0.1% with the append lookup hoisted out of the loop, on 1000 external iterations over 50,000 list items, minimum of 3, inconsistent which version was faster. my scanned function was def f(x,y): return max(0,x+y) >…

> Can we agree that your latest scan(), if we dropped the two lines that have "scan_helper" in them, is the most efficient, most idiomatic, most (py2 and py3) compatible and clearest?

Yeah. Actually, I just generally liked your feedback here.

Re: Impending kOS

#225
post #135

So, I read about the fast interpreter and small language. How do something like this? "Whitney’s strategy was to implement a core of the language – including the bits everyone thought most difficult, the operators and nested arrays – and use that to implement the rest of the language. The core was to be written in self-expanding C. As far as I know, the kdb+ interpreter is built the same way. Unlike the tall skinny C…

There are two opposite schools of readable C. The mainstream says: readable C has function and variable and type names that express meaning, so a function is read like a narrative with verbs, adjectives and nouns. The fact that this narrative scrolls over pages, is unimportant. The APL/K/J school says: readable C has functions, variables, and types named with single letters, so that the totality of a function is shor…

Ok, so APL/K/J is for people that read compressed code..

But that how relate to how build a fast interpreter? Faster than C?

Re: Impending kOS

#226
post #166
post #148

Earlier quoted context omitted.

I think part of the difficulty here is that it's almost like Haskell's point free style, but not quite. It isn't really clear where the arguments to avg go. It seems that it's meant to be a bit like this: avg list -> (sumall list) / (tally list) I guess you just need to know how the argument you give to avg when you use it distributes over the functions that comprise the expression. The list argument to tally isn't a…

In J there are two special ways to combine functions which are written using special syntax. Namely, 1) when you want to calculate f(y, g(y)) , you write (f g) y - this is "hook" of one argument (monadic, in J terms) 2) when you want to calculate f(x, g(y)) , you write x (f g) y - this is "hook" of two arguments (dyadic) 3) when you want to calculate f(g(y), h(y)) , you write (g f h) y - this is monadic "fork" 4) whe…

A mite of pedantry: the J train (a b c d) is a hook with a fork on the right, and so dyadically acts like

a(x, c(b(y), d(y)))

Roger himself has dismissed [0] hooks as an unfortunate result of J4's myriad train rules, made in the name of tacitable everything, which I lament because for some reason, tacit programming is just so much more satisfying than normally solving the problem.

[0]: http://www.jsoftware.com/jwiki/Essays/Hook%20Conjunction%3F

Re: Impending kOS

#227

Does a good formal introduction exist for K, or Q, or APL, or J, or any other languages in this family? Something with, you know, a syntax definition at least, and any kind of formal definition of the semantics. The closest I could find is this [1] but "The model is expressed in SHARP APL", so from the start, it's circular. [1] http://www.jsoftware.com/papers/APLSyntaxSemantics.htm

It's not formal, but it is helpful to watch these series of videos by Martin Saurer on J:

https://www.youtube.com/watch?v=VSJpJt3c11c

It goes form solving some Euler problems to a full-blown web app in J.

Re: Impending kOS

#228
post #221

Earlier quoted context omitted.

> I think with a language like k or q, which appears to be purpose-built for certain types of problems, The thing is, it's not purpose built, and it doesn't even appear to be if you suspend your disbelief. The only reason you'd think it is purpose built is because "well, it can't be this short if it wasn't purpose built". But if you go over the manual, and find special built operators, please tell us what they are. e…

How would you represent a graph and implement DFS in K?

If you are really interested, http://nsl.com/ is a treasure trove - quite a few of the examples are extremely well documented, some or not, but there's a wealth of information there.

Specifically about graphs, you can look at:

http://nsl.com/papers/order.htm - topological sorting

http://nsl.com/k/tarjan.q - strongly connected components

http://nsl.com/k/loop.q - find loops in graphs

I think in all of these the graph is represented either as a list of edges or a dictionary of node->(list of nodes that it has edges to)

Re: Impending kOS

#229
post #17
post #10

Earlier quoted context omitted.

If I posted four lines of Chinese or Sanskrit, it's likely that native English speakers would disagree that they had much meaning either. However, this doesn't mean that those lines are inherently devoid of meaning or difficult to parse.

That is a fun experiment. I studied linguistics in college, and I do not think anyone ever discussed textual density of different languages with the "same" content (the latter part would be its own terrifying chestnut; if you have not studied machine translation and semantic eval and good luck ever confirming such a statement). I studied Arabic a lot, and Chinese about a year. I cannot speak to Chinese with only one…

Those crazy middle-easterners. How can they calculate with such terse number notation? As if 27 is more readable than XXVII! ;-)
Post reply on HN