I've been 100% python for the last few years, after a career mostly in Java and I definitely miss the sweeping refactoring abilities and hard-breaks during those kinds of refactorings. It does lend courage for sure. I'm just SO MUCH MORE productive in python for most of what I do that I'm not willing to throw out the baby with the bathwater yet. Instead I've been trying to focus on leveling up test coverage, and experimenting with Rope for refactorings ( http://rope.sourceforge.net/ ). I'm also slowly learning patterns for coding to make refactorings easier moving forward.. choosing code and data structures that are more easily affect-able later, or even things as simple as naming things for grep-ability.
val object = MyObject(someOtherObject(12, "hello")) // Scala
instead of:
MyObject object = new MyObject(new someOtherObject(12, "hello")); // Java
saves a lot of time and it just looks nicer. All the while retaining the advantages that static, strong typing have (great potential for refactoring, a lot of errors can't happen at all). Of course, there are some things that will still take up more space than they do in Python or Ruby but it's a great improvement. Languages like Rust, Scala or C# also have a good variety of functional programming tools that can make your life a lot easier.
Even C, kind of:
#define AUTO_TYPE(X,Y) __typeof(Y) X = Y
... though I'm not sure I'd recommend it.
Type inference in full generality can give you a bunch more, as I just went into over here: https://news.ycombinator.com/item?id=6327327
People just don't do that because it makes them less productive, but it may be a huge bonus for refactoring.
Though, it gets a little more complicated when dealing with overloaded methods. In that case, Find All References really is a lot better.
nmap <silent> <Leader><Tab> :make search PATTERN='\<^R^W\>'<Cr>
Where ^R and ^W are literal ctrl-R and ctrl-W (typed with a leading ctrl-v).Then my Makefile contains:
search:
git grep -n "$$PATTERN"
plus some project-specific bits to prune out portions of the tree which should be skipped.The following are also nice:
clip:
xclip -o
todo:
PATTERN=TO''DO make search | sed -n 's/\([^ \t]*\)\(.*TO''DO \(([0-9]*)\)\):\?\(.*\)/\1 \3 \2\4/p' | sort -k 2
I've also found it useful to make sure my unit tests output some relevant file:line: info and run those from my makefile.Relatedly, I have:
nmap <silent> <Tab> :cnext<Cr>
nmap <silent> <S-Tab> :cprev<Cr>
to make it easy to jump between quick-fix items.
EDIT: refactoring large systems has also convinced me of the superiority of statically typed programming languages for large projects. When I break code, I want it to break as hard as possible. I want to see absolutely everywhere function XYZ is called, and one way to do that is to rename XYZ to XYZ___ and see where all of the compiler errors show up.