Live data from Hacker News

Ki Editor - an editor that operates on the AST

ki-editor.org

131–140 of 154 posts

Re: Ki Editor - an editor that operates on the AST

#131

I think the challenge with AST editing is discoverability. Like, I know what I want to select, I can see it there on the screen, but I don't know its name. I've been dreaming of writing a plugin that surrounded the cursor in differently colored scopes. So instead of "next function" I'd be thinking "next blue" (blue being the color that functions are currently painted in).

In Ki you don't have to know the name of the syntax node, you can just press `d m`, and the editor will show the labels of all the syntax node visible that you can jump to.

Oh neat, I'm gonna give it a try!

Re: Ki Editor - an editor that operates on the AST

#132
post #55

I don't like the positional keybindings. There is no real difference from regular keybindings configured with profiles for Qwerty, Dvorak, etc. In practice, it just means presenting them drawn into keyboards in a way that is hard to quickly search or use in the terminal and anywhere really. Where's the "line" key? Search the drawing! (Oh... it is there in th top left corner, but which exact key?) I prefer a list. So,…

Have you actually tried it?

Re: Ki Editor - an editor that operates on the AST

#134
post #79

/* A source code editor that operates directly on the AST, and affords different visual representations on top of it, was the topic of my (unfinished) PhD thesis about 30 years ago. */

What can you tell us about it? What worked and what didn't? What was hard?

Re: Ki Editor - an editor that operates on the AST

#135

Earlier quoted context omitted.

> The challenge is getting this to be a useable way of entering programs. Well exactly. When the path between Program A and Program B can only be valid programs, you are going to end up with either a much longer, less intuitive path, or deleting everything and starting again. It can also be quite possible to invent structures which are valid but have no valid path to creating them.

> It can also be quite possible to invent structures which are valid but have no valid path to creating them. I'm curious if you have an example of such a structure? Pedantically: if, for every valid tree, there exists a bidirectional path to the empty root node, there's always at least one path between all given pairs of valid trees ... albeit one that no developer would ever take.

You are quite right to call this out - and quite right in general. With AST verification alone your statement holds strongly.

I was remembering a professor I had who was very into formal verification and had an IDE that would only accept valid programs - however his validity checks were more than just tree based, they involved passing a type check. Which now you've called me on it, is quite definitely beyond valid AST editing.

The base case: if you have a structure with a mandated cyclical reference that doesn't accept a second (e.g. nil) type, you cannot construct it without creating an intermediate invalid program. This doesn't tend to show up if the cyclical reference is all the same type (A1 -> A2 -> A1) because you can often cheat and self reference, but it does if it is different types (A1 -> B1 -> A1). You can't construct an A without a B, which cannot be constructed without an A.

But that's still not a problem you cry! And quite right, you can edit the type itself to remove and re-add the reference.

That is until the type is built into the language, or a library.

Re: Ki Editor - an editor that operates on the AST

#137

Many years ago, I created an editor operating on syntax trees that I think is more "hard-core" than this - that is, only tree-oriented operations are done. There is no parsing of text, since entering plain text, rather than a tree, is impossible. Hence, there can be no syntactically invalid programs. The challenge is getting this to be a useable way of entering programs. I think I made progress on this, but the feasi…

I actually used a language and editor like this in a previous large company. It was an experimental language that they wanted to replace their current application level language and was built ontop of JetBrains MPS https://www.jetbrains.com/mps/ which has that feature among others. My personal opinion after working with that lang is all of this is that its theoretically interesting. But a dead end in practice along w…

What was the issue with MPS? MPS also looks like "custom widgets in normal text-based java" i.e. mixed paradigms and not "ground up ast-based editing".

I'm not sure if I can agree with your other points. I can't think of the last time I cat'd or maniuplated rust/java/go outside a heavy and slow editor. Many languages have more or less "one" editor with all the features that most people use, and often use it for change review too. And it seems weird to characterize needing new tools as a "dead end"... all languages need new tools and won't have them at the start.

Plenty of people use go, rust, and java which are not gradually typed.

Re: Ki Editor - an editor that operates on the AST

#138

Earlier quoted context omitted.

Mine are: Cmd+Shift+V - Stacked clipboard, you can start typing to search or hit a number to choose what to paste (keeps everything you've copied/cut inside jetbrains for a while) Cmd+Shift+E - Recent locations, you can start typing to search - shows little buffers of where you've been recently Cmd+Shift+A - Action tab of the command palette - fuzzy search for any command (really the only shortcut you need, other tha…

Hero! I had not done my homework/have not been aware, but these all look fantastic! The stacked clipboard is something I periodically mentally complain about (Why is clipboard on every OS/tool I've used single item?) I will add one that are possibly more well-known: - ctrl + shift + F: Find text in any file - ctrl + N: Find types (structs, classes etc) - ctrl + shift + N: Find any file by name or path

> Why is clipboard on every OS/tool I've used single item?

The wonderful Flycut (https://apps.apple.com/us/app/flycut-clipboard-manager/id442...) fixes this on macOS.

Re: Ki Editor - an editor that operates on the AST

#140
I always liked Lisps for how easy it is to edit them with proper editor support such as Paredit in EMacs. Always wanted something like that for more syntactically dense languages.

If it’s all tree-sitter based though I think it ought to be possible to do this in EMacs too.

Post reply on HN