So 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.
What 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.
Lisp 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.
This 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.
In 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.
Author 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.
Have you tried VSCODE, their open language server protocol means that most popular languages have code completion, refactoring, code lens and debugging support.
It's totally free and open source. I was a hard core JetBrains user but vscode has been amazing. They even got minimap like sublime in last release.
Every month they move at an amazing velocity working on features devs ask for. I feel it's the modern democratic IDE
No. But I have a friend who writes in C# and he showed me quite some tips on VS Code. I know it's very smart and IDE understands code in semantics, that can be a lot better than Stack Editor that only recognize the structure. I will keep an eye on that.
Language Server, which parent mentioned, is kinda independent from VSCode and provides the groundwork for most of the fancy language level stuff. You could look into integrating langserv into your editor to get the best of both worlds.
In terms of context sensitive info...well let's put it this way: If you don't see what utility RubyMine offers beyond Sublime, you haven't used it. It's not perfect (obviously), but it's generally quite good; I think I'm more often baffled by just how well some stuff works than I am disappointed in things working poorly (at least when it comes to context sensitive info).
That said, it's not the perfect text editor. I don't know that it really imposes any particular workflow (beyond obvious requirements like having access to the libraries you require), but there are certainly many things that you can do in Sublime that aren't going to work in RubyMine.
It lets you build a language and an editor that forces you to follow the syntax and semantics of your language. Pro tip: Your language can be based on java :)
This is how editing was done in the InterLisp-D environment on Xerox Dolphins, Dorados and Dandelions (the last being sold commercially as the Xerox Star).
Not surprisingly the first thing I did when I arrived at PARC in 1984 was write an Emacs for Interlisp.
I 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.
One 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.
(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
I agree. I'm just too lazy to add that. Actually on 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".
Author 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/ . I wrote several posts before I guess it's can not be explained with only two pages.
The 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.
Note 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.
I'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 , but withouth benefits of structural editing.
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!).
Paredit[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.
Paredit 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.
M-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:
What 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.
That 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...
52 comments
[ 4.4 ms ] story [ 119 ms ] threadThis is a very neat idea.
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.
That is a hard nut to crack, a dynamic language will frustrate static analysis.
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.
It's totally free and open source. I was a hard core JetBrains user but vscode has been amazing. They even got minimap like sublime in last release.
Every month they move at an amazing velocity working on features devs ask for. I feel it's the modern democratic IDE
That said, it's not the perfect text editor. I don't know that it really imposes any particular workflow (beyond obvious requirements like having access to the libraries you require), but there are certainly many things that you can do in Sublime that aren't going to work in RubyMine.
It lets you build a language and an editor that forces you to follow the syntax and semantics of your language. Pro tip: Your language can be based on java :)
Not surprisingly the first thing I did when I arrived at PARC in 1984 was write an Emacs for Interlisp.
He transitioned to a laptop soon after joining the company.
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
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
(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-d... )
I think reading by a JavaScript programmer, TCO is "Tail Call Optimization".
http://www.lamdu.org/
while trying to remember the name I discovered:
https://www.facebook.com/notes/kent-beck/prune-a-code-editor...
http://jetbrains.com/mps
https://github.com/cxxtree/cxxtree
http://www.greenfoot.org/frames/
http://unisonweb.org/
https://github.com/chrisdone/structured-haskell-mode
https://www.emacswiki.org/emacs/ParEdit
https://github.com/projectured/projectured
You may also add these projects:
https://github.com/shaunlebron/parinfer https://github.com/prettier/prettier
They are fixing the same problem Cirru Project was trying to solve, just in a more practical way.
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.
Guess I need help from someone because English is not my mother language, and I even got cough these days.
If there were a good language-specific pretty printer, and it looked like regular text in the language, I could probably stomach 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.
https://github.com/jlongster/prettier https://twitter.com/search?q=atom%20prettier&src=typd
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!).
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)
:).
(actually now that I think about it, R may do something a bit similar)
[1] https://www.emacswiki.org/emacs/ParEdit
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.
And @sedachv, thanks for Parenscript. It makes Javascript almost...well, now I can work it it :) Much appreciated.
One suggestion: I would implore you to add undo sooner rather than later.