7 ms·
Cirru – An editor for AST
- maelito 10y agoSome context : https://medium.com/cirru-project/stack-editor-programming-by-functions-a961f1d9555c https://medium.com/cirru-project/stack-editor-programming-by...
- rafiei 10y agoSo the units in Stack editor is not “files”, it’s “functions”(or “definitions”). And we navigate by functions, edit by functions, and finally program by functions. It’s more like the program is running and we got a call stack here. We edit the code that’s collected for a specific purpose without constantly switching the context. It can be faster. This is a very neat idea.
- catshirt 10y agogetting OT now but check out http://witheve.com http://witheve.com
- deleted 10y ago[deleted]
- vinceguidry 10y agoWhat I want is for the editor to be aware of the semantics of the language and offer me language-unique tools to edit code, also to generate and work on macros, in the language it's editing, or at least one that is close enough to it I don't have to switch gears in order to get a tough task done. Otherwise it really doesn't improve on a text editor. All of these things would require a ton of work, so I stick with Sublime for now. Text isn't that bad. IDEs are kinda close, but I've yet to see one that could effectively work with dynamic languages. RubyMine is interesting-looking, but seems to want to impose a lot of its opinions on your workflow. I don't really see how RubyMine would really be that much better than Sublime and a terminal.
- nothrabannosir 10y agoYou're describing the Common Lisp, emacs and slime combo. But that's only for lisp, though.
- DougBTX 10y ago> I've yet to see one that could effectively work with dynamic languages That is a hard nut to crack, a dynamic language will frustrate static analysis.
- TeMPOraL 10y agoLisp languages cheat on that by pulling relevant metadata from the image after you loaded the code in. So if you just open a project as text, SLIME won't help you find e.g. a list of places that call a particular function - but after you load it into your Lisp image, cross-referencing features become available.
- sedachv 10y agoThis is true under the hood of most static language IDEs as well. If they are not using a custom compiler (like JDT Core in Eclipse) they end up implementing a partial compiler to support features beyond ctags. ctags itself is the tokenizing and partial parsing step of a compiler.
- fiatjaf 10y agohttp://www.graspjs.com/ http://www.graspjs.com/
- sdegutis 10y agoIn my experience, Clojure + CIDER are pretty much exactly what you're describing. Especially once you get into the advanced evaluation features. I no longer think in terms of s-expressions or text, but I think in terms of the actual semantic objects I'm dealing with on screen. It's neat.
- jiyinyiyong 10y agoAuthor here. Your are right. Graphical editor is just a favor of myself and happened to make implementing this features easier. If you are skilled enough to parser code in text and build a tree underneath, it's definitely the same result that you got smart IDE that helps write code faster. BTW, I don't know much about building IDEs, so I won't analyze code by myself and let the editor recognize the code. Could be very tough work.
- ungzd 10y agoMay be good idea for mobile devices, where editing text is hard but it's possible to make usable tree editing UI.
- pcmonk 10y agoI was about to ask who edits code on a mobile device, then I remembered a brilliant young coworker of mine who, as far as I could tell, coded exclusively on his iPad when he joined the company. I guess it goes to show you the huge variance of workflows out there. He transitioned to a laptop soon after joining the company.
- TeMPOraL 10y agoOne idea for a side project I have (that I lack time for) is an app (or maybe a keyboard, I don't know how far one can push Android's keyboards, but from what I saw it could be quite far) for editing Lisp code. Could be useful with e.g. ECL app, but personally, I'd use that to do quick fixes / small bursts of development while away from home / office.
- RubyPinch 10y agoI find myself wanting to edit the textual version of the AST itself, as the tree interface seems too cryptic edit: I'm guessing its probably a bug that is confusing me the most, as I'm getting both a inline tree and a indented tree at the same time for a node
- jiyinyiyong 10y agoAuthor here. Try http://text.cirru.org http://text.cirru.org see if it fits your mind. I guess people always hate news things that breaking others. Me too....
- RubyPinch 10y agoThat does feel a lot clearer I guess my main thing is I don't know if I should trust my understanding of the tree display or not Perhaps, as a sort-of training assistant, have the resulting "code" optionally appear beside the editor? e.g. https://i.imgur.com/92stVmi.png https://i.imgur.com/92stVmi.png (I also noticed that you are looking for TCO for python, In some cases Coconut can do TCO, and can compile to python, but its somewhat of an unweildly tool to use http://coconut.readthedocs.io/en/v1.2.2/DOCS.html#function-definition http://coconut.readthedocs.io/en/v1.2.2/DOCS.html#function-d... )
- jiyinyiyong 10y agoI agree. I'm just too lazy to add that. Actually on http://cirru.org/ http://cirru.org/ there's a button named "Show me data". By clicking at the button you get the data in vectors, which is almost the thing you shown in the png. Personally I'm already familiar enough to read AST from the UI with nothing like assistant. I think reading by a JavaScript programmer, TCO is "Tail Call Optimization".
- wyldfire 10y agoBut ... which language(s)' AST? Clojure? It feels like we could all use more context here.
- jiyinyiyong 10y agoAuthor here. Theoretically it can any language that has a simple way to generate code from a simple AST. But in my case it's Clojure because in Lisp I can generate code from data easily with https://github.com/brandonbloom/fipp/ https://github.com/brandonbloom/fipp/ . I wrote several posts before I guess it's can not be explained with only two pages.
- wyldfire 10y agoOk, great. If nothing else, the title of this submission could clarify the context.
- jiyinyiyong 10y agoI uploaded a new video, hope it explains my ideas better. https://youtu.be/zsiYPppEDp0 https://youtu.be/zsiYPppEDp0
- didibus 10y agoThe benefits of AST editors is that the source can be stored and revisioned controlled much better. And the AST can be projected to different visualizations or text representation.
- chadrs 10y agoReminds me of http://www.lamdu.org/ http://www.lamdu.org/ while trying to remember the name I discovered: https://www.facebook.com/notes/kent-beck/prune-a-code-editor-that-is-not-a-text-editor/1012061842160013/ https://www.facebook.com/notes/kent-beck/prune-a-code-editor... http://jetbrains.com/mps http://jetbrains.com/mps https://github.com/cxxtree/cxxtree https://github.com/cxxtree/cxxtree http://www.greenfoot.org/frames/ http://www.greenfoot.org/frames/ http://unisonweb.org/ http://unisonweb.org/ https://github.com/chrisdone/structured-haskell-mode https://github.com/chrisdone/structured-haskell-mode https://www.emacswiki.org/emacs/ParEdit https://www.emacswiki.org/emacs/ParEdit https://github.com/projectured/projectured https://github.com/projectured/projectured
- jiyinyiyong 10y agoAwesome! You may also add these projects: https://github.com/shaunlebron/parinfer https://github.com/shaunlebron/parinfer https://github.com/prettier/prettier https://github.com/prettier/prettier They are fixing the same problem Cirru Project was trying to solve, just in a more practical way.
- sedachv 10y agoNote that some of these (like ParEdit) are just macros for text-oriented editors, and not real structured editors. The earliest structure editor was Interlisp's original structure editor for teletypes, which worked on Lisp lists directly. Editing on teletypes is not anything like editing on video terminals - you are basically forced to edit one line at a time instead of viewing the whole file. That's how ed works. Structured editing made a lot of sense for teletypes because you did not have to worry about putting delimiters in the wrong place, which is very hard to spot when you are doing things one line at a time. There was an Interlisp structured editor (maybe more than one? I'm not sure) written for video terminals in the 1970s. On video terminals structured editing loses a lot of its advantages over text editing and structured editors fell out of style in the 1990s.
- Samis2001 10y agoAn addition to this list: http://www.pawfal.org/dave/index.cgi?Projects/Scheme%20Bricks http://www.pawfal.org/dave/index.cgi?Projects/Scheme%20Brick...
- jiyinyiyong 10y agoAuthor here. Added another quick video on Youtube, check this out https://news.ycombinator.com/item?id=13774829 https://news.ycombinator.com/item?id=13774829 Guess I need help from someone because English is not my mother language, and I even got cough these days.
- microcolonel 10y agoI don't want to be a downer, but the visual presentation is awful, I could not work with the nesting direction changing all the time. If there were a good language-specific pretty printer, and it looked like regular text in the language, I could probably stomach it.
- jiyinyiyong 10y agoI've used it to write web pages for nearly a year, so I believe we can. The problem is, like people may hate using indentations, they just hate. There's also a text version of Cirru http://text.cirru.org http://text.cirru.org , but withouth benefits of structural editing.
- microcolonel 10y agoI'll give it a try instead of just criticizing it. :- ) I've used Paredit, which is similar in concept; I think it's really cool if it can be generalized well to languages which aren't LISP.
- jiyinyiyong 10y agoMaybe Prettier? It's for JavaScript: https://github.com/jlongster/prettier https://github.com/jlongster/prettier https://twitter.com/search?q=atom%20prettier&src=typd https://twitter.com/search?q=atom%20prettier&src=typd
- closed 10y agoWhat is the benefit of this? It seems like oftentimes editing ASTs is much more verbose than code that would generate an AST. For example, in python's builtin ast library, writing the variable > x in AST is.. > Expr(value=Name(id='x', ctx=Load())) while assigning the variable > x = 1 in AST is.. > Assign(targets=[Name(id='x', ctx=Store()),], value=Num(n=1)) There is a lot packed in there! I looked at the site, and a few videos, but the goal and motivation for this project has gone way over my head (probably my fault!).
- TeMPOraL 10y agoThat's because the representation of that AST seems to be defined in terms of Python's objects, so it looks unwieldy. Compare with Lisp: Code: x AST: x Code: (let ((x 5)) (+ x x)) AST: (let ((x 5)) (+ x x)) And as for the very little syntactic sugar most Lisps have: Code: 'x AST: (quote x) :).
- closed 10y agoAh, that helps a lot--thanks for the example! Most ASTs I've have seen look much more gruesome than that. That AST looks straight delightful. (actually now that I think about it, R may do something a bit similar)
- jiyinyiyong 10y agoAnd we can map Cirru AST to a language AST like I did in http://script.cirru.org/ http://script.cirru.org/ ;)
- kruhft 10y agoParedit[1] is (almost) from the gods as an AST editor. The only issue I have is that it doesn't automatically reformat your code so it is not only always syntactically correct, but also properly formatted at the same time. [1] https://www.emacswiki.org/emacs/ParEdit https://www.emacswiki.org/emacs/ParEdit
- TeMPOraL 10y agoParedit does try and keep the subtree you're editing correctly indented. Moreover, it has a paredit-reindent-defun command (bound to M-q), which reindents the whole tree you're editing. Bind it to whatever auto-reindent facility Emacs has (Electric keys? I don't know - I never had a need to configure it for myself.), and there you go. Personally, I'm fine with manual M-q on code if I see the identation got messed up.
- kruhft 10y agoM-q is useful, but something more useful IMO would be the same feature but one that removes unneeded white space within the sexpr between expressions and keep everything indented. A contrived example: (defun x () (+ x x)) => (defun x () (+ x x))
- sedachv 10y agoYou can write an interactive function that runs fill-paragraph (or whatever M-q is bound to in the mode you are using), then deletes multiple spaces (something like http://stackoverflow.com/questions/8674912/how-to-collapse-whitespaces-in-a-region http://stackoverflow.com/questions/8674912/how-to-collapse-w...). That would not be a good default because some people, like me, like to align their code in columns (for example, things like let clauses). What I would like to see come as an Emacs default is just-one-space working on regions with the behavior you describe.
- kruhft 10y agoWhat I've noticed after using paredit is that I'm doing a lot less paren matching (well none) and a lot more white space clean up, so I think such a function would be very useful to run as a hook on insert char. Since the program is always syntactically correct, it might almost work... And @sedachv, thanks for Parenscript. It makes Javascript almost...well, now I can work it it :) Much appreciated.
- steego 10y agoI love seeing prototypes like this. Excellent job! One suggestion: I would implore you to add undo sooner rather than later.
- jiyinyiyong 10y agoThat would be a huge feature. I got some ideas but have no time to finish it. It's can be something like something like Redux devtoos, because it's not just files...
- amenghra 10y agoreminds me http://tratt.net/laurie/blog/entries/an_editor_for_composed_programs.html http://tratt.net/laurie/blog/entries/an_editor_for_composed_...
- iamcreasy 10y agoCan someone explain what is the use of an AST editor?