Ask HN: Why are there no powerful free refactoring libraries for text editors?

5 points by dmortin ↗ HN
Editors like Emacs, VI, etc. are great, but IDEs can do much for you if they know the language more intimately like IntelliJ knows Java.

But why are there no free alternatives for refactoring? Is there some difficult technical problem?

If we consider, for example, Java and refactoring then Rename Variable, Extract Method and similar features do not look very hard to implement. There are libraries for parsing Java and if we have the syntax tree then it's just a matter of performing the modifications on it.

Parsing broken code may be a challenge, but a powerful refactoring library would be very helpful even if it could work only on compilable code. Text editors could just call the library and reload the source files after the refactoring is done.

LSP is a step in the good direction by providing completion, jump to definition, etc. Why are there no similar libraries for source code refactorings? What is the difficulty here?

7 comments

[ 4.9 ms ] story [ 30.4 ms ] thread
Using Emacs or VI for Java is something for masochists. Helping them with refactoring support would take away their fun/pain. Doesn't use the Java LSP the Eclipse IDE? Maybe it would just be easier to configure your IDE like emacs.
Unlike VIM people don't use emacs for the keybindings, so you can't just configure the IDE to work like emacs, because IDEs do not have those features (e.g. creating quick throwaway functions for some current task which can be inserted into the editor live, without restarting, etc.)

If Emacs has access to a refactoring library and completions via LSP then it could have the strength of Emacs combined with the strong language support of IDEs. I'm saying this as a long time Emacs user who also used Android Studio a lot for Java programming, so I can appreciate the fortes of both sides of the fence.

You are mainly talking about compile time checking. But due to the weak types in Java, you’ll end up with uncaught compile and runtime errors.

I’d look into a strong type system like Haskell, F#, shoot even Rust will help in large refactorings being easier

I did not talk about compile time checking, but refactoring, making assisted transformations on the source code.
Ok at what point does this occur, pre runtime or during runtime ?
When you edit the source code, so pre compilation, pre running. Refactoring is a tool to automate manual editing.
How is that relevant to the thread ? Is not like people or businesses will start moving to those languages with lower adoption because it is easier to have a refactoring library ... ?