4 ms·
Makes you wonder why most languages don't come with good refactoring tools.
by amelius 6y ago
Makes you wonder why most languages don't come with good refactoring tools.
- cratermoon 6y agoSafe automatic refactoring requires the ability to do static analysis of the code. Many refactorings are harder in loosely-typed languages.
- grahamlee 6y agoRefactoring tools were invented in Smalltalk and worked just fine.
- disgruntledphd2 6y agoThis has always surprised me, since I learned it. What are the features of Smalltalk that allowed this to happen? Conversely, what is stopping this from existing in more modern dynamic languages?
- xkriva11 6y agoSmalltalk has simple and strong reflective features. Moreover, it does not make a difference between the developed program and IDE. This means that doing things like that are very natural and well established in the Smalltalk cultural background.
- grahamlee 6y agoIndeed. Having the whole system in front of you, and knowing how patterns like MVC or Thing-Model-View-Editor encapsulate parts of it, makes it very easy to "reason about" wholesale changes to the system.
- cratermoon 6y agoSmalltalk is dynamically typed, but I wouldn't call it loosely typed. It's closer to Ruby's "duck typing". I was thinking more of Javascript and PHP. Weak and loose.
- bobthepanda 6y agoAt least in the languages I work primarily in (JS and Java), I find my IDE to be pretty good at analyzing a lot of it. Refactoring is kind of subjective, because there is rarely One Right Way to solve a problem, and you need context, so I could see why it’s not something that languages themselves take strong opinions on.
- realusername 6y agoI don't think refactoring tools are that useful for refactoring, most of the time you are doing non-obvious refactoring tools can't help with anyways. Depends what we call "refactoring", tools are mostly useful for what I would call "housekeeping".
- amelius 6y agoWell, every refactoring can be seen as a series of correctness-preserving housekeeping operations.
- uhhhhhhhhhhhhhh 6y agoHigh confidence syntax-aware identifier renames will take you pretty far
- analog31 6y agoI should have added that I am probably abusing the term refactoring if it has a precise definition. What I'm talking about is working on improving the readability of my code, but also improving its structure. Today, "spaghetti" probably doesn't refer to a tangled mess of code sequences because we've gotten rid of the GOTO, but tangled interactions between modules, many of which are vestigial. A lot of my code interacts with hardware configurations that will cease to exist when a project is done, but I mainly look at the stuff that's potentially reusable, and making it worth re-using. I'm using Python, and there are a lot of tools for enforcing coding styles and flagging potential errors. I try to remove all of the red and yellow before closing any program file. I don't trust myself with too much automation! "Walk before you run."