7 ms·
Refactoring goes a lot further than just renaming types. A refactor script _WILL_ rename both sides of 'Foo x = new Foo();' to 'Bar x = new Bar();', so given th
by desdiv 12y ago
Refactoring goes a lot further than just renaming types. A refactor script _WILL_ rename both sides of 'Foo x = new Foo();' to 'Bar x = new Bar();', so given the right utilities (and if you use java for everything, it's _MUCH_ easier to become an expert at the tools!) this is not any more effort at all.
Ctrl-Shift-R B A R
No, not much effort at all. Just twice as many keystrokes.
I wouldn't even mind the verbosity if it actually gave me some speed improvements, but it doesn't. There are plenty of statically typed languages where you just write x = new Foo() and the compiler will figure out the types for you.
- pjmlp 12y agoF2 on my IDE. One key, no need for Ctrl-Shift-R
- mytochar 12y agoOne hand position still over the keys and uses common fingers, and is easy for emacs users (Ctrl + Shift + R), versus leaving the typing keys entirely to climb to a command key that's used sufficiently infrequently that you have to look at where it is. At least that's my experience. Oh, and more fun. If you're on a modern keyboard, you have to type the function key since apparently volume up and down and expose are more important than function keys. Long story short: what's faster and 'less' for some, is more for others. And this is why we have options! :D
- tormeh 12y agoIt will give you faster compilation speed, though.
- desdiv 12y agoThink about it, does it really? To parse Foo x = new Foo();, javac has to perform type inference on the right hand side to figure out its type, and then check whether that type is a subtype of the left hand side. Telling the compiler: "hey, trust me, variable x is of type Foo" doesn't make the compiler's job any easier at all.
- one-more-minute 12y agoIn that case specifically, no, but in general doing type inference means running a constraint solver over the entire program, which will definitely add some overhead to the compilation time.
- avita1 12y agoYup, the best example I know of is resolving implicit scopes in Scala.
- waps 12y agoI don't understand the point. Are you claiming that search and replace functionality provides the same ease of use as an actual rename refactor ? Foo x = new Foo(); int Fool = 5; I'm sure you see the problem. Dynamic languages are great, until the program grows. Then you hate yourself for having picked a duck/dynamic typed language (including Go, btw : programs become unmaintanable if they grow, not as bad as python and the like, but ...).
- desdiv 12y agoI don't understand the point. Are you claiming that search and replace functionality provides the same ease of use as an actual rename refactor ? No, I'm saying you need extra key strokes to activate that rename refactoring functionality, which is unnecessary in an ideal situation. To refactor the java code Foo x = new Foo(); you need to hit the key combo to active your IDE's refactoring thingy, then type the new name. To refactor a less verbose statically typed language: x = new Foo(); You just type over the old name, no refactoring key combo necessary. This discussion isn't about static versus dynamic. It's about useless verbosity versus less useless verbosity.
- waps 12y agoStill don't understand. Let's take the changes you need to make : Foo.java ... class Foo { ... } SomeOtherFile.java ... Foo x = new Foo(); ... Equivalent in Python: some_file_in_a_library.py class Foo: ... some_other_part_of_the_program.py: x = Foo() Keystrokes to change the name "Foo", in Java : 1) Position cursor on Foo. 2) Alt-shift-R "Bar" (+ enter) Keystrokes to change this name, in Python : 1) position cursor on Foo 2) Change to bar (5 or 6 keystrokes) 3) Open some_file_in_a_library.py (couple dozen keystrokes, most people I see do this have to switch to mouse and use that) 4) Change the classname 5) Go through all the unit tests that you should have that test the class (you need 5x more unit tests in Python compared to Java as well, to have equivalent tests), and do the same. Yes, all of them. Java wins out, by a factor of 3, maybe even 5. Even if the class definition and the usage were in the same file, it would still win by a lot. Refactoring simply doesn't work reliably in Python. Heroic efforts by Jetbrains notwithstanding, it just doesn't compare. So I don't see what you're complaining about. Making changes is only faster in Python in tiny programs, where you don't have the problem of interdependencies. As soon as you have some of them, Python starts losing out, bigtime.
- bozho 12y agoCounting keystrokes in programming is like counting letters in a novel - the amount of time put to think of something, to discuss it, takes the vast majority of time. Keystrokes used to write something is irrelevant (especially if you type with more than 2 fingers) And if the whole arguments boils down to Java not having a var/val keyword - yes, that would be handy; but you would then still need tools to figure out what is the type of val foo = calculateSomething();
- AnimalMuppet 12y agoGreat, I suppose, but you didn't answer his execute() example at all. I don't care if you do it in vim, emacs, or an IDE, the problem is that in a dynamic language, you can't do it safely at any speed or with any number of keystrokes. Counting keystrokes is therefore completely beside the point.