Live data from Hacker News

Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

medium.com

51–60 of 154 posts

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#51
post #44

Earlier quoted context omitted.

Tedious and annoying for one-off commands maybe. It's like regex. Pretty compelling if you're writing a one-off pattern, you get immediate feedback and then you throw it away. But it's not a good idea to use regexes in code that you're going to use long term. It's justifiable for simple regexes, and many people go against this advice, but really for anything remotely complex regexes become totally unreadable and extr…

What would you propose as an alternative to regexes that provides the same functionality without the unreadable syntax? I wrote something like that in C# once [0] but I'm not getting the impression that there's a lot of demand for that kind of thing. [0] https://github.com/Timwi/Generex

Parsing expression grammars (pegs) are usually IME more maintainable long term, partially just because of much more testable and composable they are

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#52
post #50

Another example of this is Claude placing unnecessary imports when writing Python, because it's hedge-importing modules that it suspects it might need later.

Is it hedging or did the training data just have lots of unecessary imports?

Especially in Python, where it can be hard to tell if something is being imported purely for side effects.

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#53
post #6

Humans can't either? I think if this convention had been more usable form of programming, we'd know by now

Once you get used to it, traditional ways look tedious and annoying to me. I think the power is in 'once you get used to it'. That will keep out most people. See python llm implementations vs k ones as a novice and you will see verbose unreadable stuff vs line noise. When you learn the math you see verbose code where the verbose code adds nothing at all vs exactly what you would write if you could.

I mean, I got used to RPN and think that's the utmost bestest way to write. Objectively it's not as usable. Learnability is a part of usability

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#54
most mainstream models are decoders vs. encoders-decoders, diffusers, etc. and lack reversible causal reasoning, which of course can be counter-intuitive since it doesn’t feel that way when models can regenerate prior content

some hacks for time / position/ space flipping the models:

- test spate of diffusion models emerging. pro is faster, con is smaller context, ymmv is if trained on that language &/or context large enough to ICL lang booster info

- exploit known LTL tricks that may work there’s bunch of these

- e.g., tell model to gen drafts in some sort RPN variant of lang, if tests tell it to simulate creating such a fork of this and then gen clean standard form at end

- have it be explicit about leapfrogging recall and reasoning, eg be excessively verbose with comments can regex strip later

- have it build a stack / combo of the RPN & COT & bootstrapping its own ICL

- exploit causal markers - think tags that can splinter time - this can really boost any of the above methods - eg give each instance of things disjoint time tags, A1 vs K37 for numbered instances of things that share a given space - like a time GUID

- use orthogonal groups of such tags to splinter time and space recall and reasoning in model, to include seemingly naive things like pass 1 etc

- our recent arXiv paper on HDRAM / hypertokens pushes causal markers to classic-quantum holographic extreme and was built for this, next version will be more accessible

- the motivators are simple - models fork on prefix-free modulo embedding noise, so the more you make prefix-free, the better the performance, there’s some massive caveats on how to do this perfectly which is exactly our precise work - think 2x to 10x gain on model and similar on reasoning, again ymmv as we update preprint, post second paper that makes baseline better, prep git release etc to make it tons easier to get better recall and exploit same to get better reasoning by making it possible for any model to do the equivalent of arbitrary RPN

- our future state is exactly this a prompt compiler for exactly this use case - explainable time-independent computation in any model

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#55

Earlier quoted context omitted.

Yes, there are already diffusion language models, which start with paragraphs of gibberish and evolve them into a refined response as a whole unit.

Right, but that smoothly(ish) resolves all at the same time. That might be sufficient, but it isn't actually replicating the thought process described above. That non-linear thinking is different than diffuse thinking. Resolving in a web around a foundation seems like it would be useful for coding (and other structured thinking, in general).

With enough resolution and appropriately chosen transformation steps, it is equivalent. E.g., the diffusion could focus on one region and then later focus on another, and it's allowed to undo the effort it did in one region. Nothing architecturally prohibits that solution style from emerging.

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#56
post #31

There is something deep in this observation. When I reflect on how I write code, sometimes it’s backwards. Sometimes I start with the data and work back through to the outer functions, unnesting as I go. Sometimes I start with the final return and work back to the inputs. I notice sometimes LLMs should work this way, but can’t. So they end up rewriting from the start. Makes me wonder if future llms will be composing…

I think long term LLMs should directly generate Abstract Syntax Trees. But this is hard now because all the training data is text code.

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#57
post #31

There is something deep in this observation. When I reflect on how I write code, sometimes it’s backwards. Sometimes I start with the data and work back through to the outer functions, unnesting as I go. Sometimes I start with the final return and work back to the inputs. I notice sometimes LLMs should work this way, but can’t. So they end up rewriting from the start. Makes me wonder if future llms will be composing…

> Sometimes I start with the final return and work back to the inputs.

Shouldn't be hard to train a coding LLM to do this too by doubling the training time: train the LLM both forwards and backwards across the training data.

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#58
post #6

Humans can't either? I think if this convention had been more usable form of programming, we'd know by now

The popularity of a convention has no relationship with its usability.

Everybody learns in school the traditional convention for writing mathematical expressions.

It appears that for most people it is difficult or impossible to unlearn later such a convention, even if they encounter a superior convention.

On the other hand, I am among those fewer for which this is not true, so when I have first read the book "A Programming Language" of K. Iverson, on which the later APL language and its successors have been based, I have immediately recognized that the Iverson convention is much better than the school convention, and I have no trouble in using it.

When reading a program written with the Iverson convention, you still read from left to right, but you typically do not read until the end of the line, but only as much of the left part as necessary to understand the purpose of the line. (Because the right operand of any operator is everything that follows it until the end of the line, and the details of that computation may be irrelevant. With school notation, when searching where a variable has been modified and how, you must jump between the beginning of the line and the end of the line, to find the last operations that have generated the stored value, when reading and understanding the complete expression would be a waste of time.)

The original motivation of the Iverson convention, which remains very important, was to give a useful meaning for a sequence of identical non-commutative operators, e.g. subtraction and division. This is particularly desirable when the operators are used in vector reductions.

(With school notation, a0 - a1 - a2 - ... - an is seldom a useful expression, but with the Iverson convention it becomes alternate sum, which is needed very frequently. Similarly for division.)

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#59
Languages that are difficult for LLM to read & write are also difficult for the general public. These languages have always had poor uptake and never reach critical mass, or are eventually replaced by better languages.

Language designers would be smart to recognize this fact and favor making their languages more LLM friendly. This should also make them more human friendly.

Re: Why LLMs Can't Write Q/Kdb+: Writing Code Right-to-Left

#60
post #50

Earlier quoted context omitted.

Is it hedging or did the training data just have lots of unecessary imports?

Especially in Python, where it can be hard to tell if something is being imported purely for side effects.

That does happen, but not frequently in the common libraries that are going to be in public training data.

Is there a top 100 package that does something funny on import?

Post reply on HN