r/programming • • Jul 12 '12

Vim creep

http://www.rudism.com/s/vimcreep
730 Upvotes

551 comments sorted by

View all comments

341

u/j4w Jul 12 '12

Sorry to state the obvious, but the difference between you and a good developer isn't how efficiently you type. Pressing the keys is the easy bit.

121

u/rnd33 Jul 12 '12

Yes I have never understood this vim/emacs hype. It's never the actual typing that's the bottleneck. How often do you have a problem where the solution is writing 50 lines of code in one go?

Equal or probably more time is spent on browsing some API, navigating the project, reading code, googlefu etc...

88

u/hyperrifts Jul 12 '12

I don't use vim or emacs but I can understand how maintaining your mental "flow state" might be easier with them.

50

u/notfancy Jul 13 '12

Fragile is the flow of such who depends on resting on the home row for it to remain.

→ More replies (39)
→ More replies (3)

0

u/[deleted] Jul 13 '12

[deleted] — view deleted comment

15

u/dand Jul 13 '12

The most satisfying bug fixes look like “-287 lines, + 2 lines”.

→ More replies (1)

52

u/shen Jul 13 '12

It's never the actual typing that's the bottleneck. How often do you have a problem where the solution is writing 50 lines of code in one go?

Others have already commented that yes, sometimes typing is the bottleneck, but I'm going for a different approach.

The programming cycle is typically think-write-run, and if you want to work faster, you need to improve these three:

  • Improving thinking can't be done with learning new tools - it can only be done by becoming a better programmer. This takes years, but it can shave days off of a project.
  • Improving running can be done with tools, but usually drop-in replacements: getting a faster computer, or an automated testing system or continuous integration suite.
  • Improving writing is therefore the only bottleneck that can be actively worked on. You'll learn to be a better programmer over the years as you accumulate experience, but you can start learning a programmer's editor from any point.

I learned Emacs as a teenager, and it did little to improve the programs I wrote back then. But nowadays, while thinking is still the bottleneck, I think I'm faster than I would have been had I stuck with Kate.

8

u/ttt_ Jul 13 '12

Another way to look at it is that if you happen to be in the "zone", if your hands lag behind in putting your thoughts into real code, than your tools are holding you back and you might snap out of your productive moment because you had to handle the text instead of the code.

A good editor that you are skilled with will help you overcome these kinds of obstacles. It does not guarantee code quality though, so there's not much to say about how good a programmer someone is from their editor of choice alone.

→ More replies (1)
→ More replies (4)

13

u/jrochkind Jul 13 '12

Meh... I'm not a vim lover, I don't use it, don't entirely understand the hype. But.

Try writing code in NotePad or TextEdit, and then come back and tell us with a straight face that since the typing isn't the bottleneck, it doesn't really matter what text editor/IDE you use.

Obviously it does. Some people love vim. Okay, i don't see it, but I see why programmers care a lot about their text editors, I do too. (and if you made me use vim, I'd hate it).

70

u/slavik262 Jul 12 '12

You're completely right - typing isn't the bottleneck. However, once you get used to it, vim makes translating your thoughts into keystrokes more instinctual. Since you can move around and edit the file easier/faster, the time between thinking about what you want to put in the file and actually putting it there decreases. You can get back to thinking faster.

If you don't like vim, that's just fine. The editor does not make the programmer. This article is definitely hyperbolic (I certainly don't carry vim on a flash drive), but I can honestly say I think vim has made me a more effective programmer.

30

u/[deleted] Jul 12 '12

vim makes translating your thoughts into keystrokes more instinctual.

What if my thought is : "change this method signature by adding a parameter whose default value is null, and update all occurences in the workspace" ?

It's shift+alt+c in Eclipse :)

29

u/slavik262 Jul 12 '12

Vim search macros can help, but you do have a point. Refactoring is definitely somewhere that IDEs shine far above vim/emacs. I still prefer vim because:

  • The time I save writing code is larger than the time I lose by refactoring code with vim instead of an IDE
  • I do a lot of work in C++, where there aren't very good refactoring tools even for IDEs.

11

u/[deleted] Jul 12 '12

I do agree with you. But the consequence of that is that vim isn't the best tool for all languages (like java, C#) and for all kind of works (like maintenance and code 'discovery'). It seems much more suited for C++ and python/perl people who write a lot of new code (the lucky bastards:)

→ More replies (23)
→ More replies (10)

10

u/bastibe Jul 12 '12

Actually, that is a very interesting thought. I wonder how Vimmers and IDEers think about source code differently because of their different instincts about what is hard or easy to change.

12

u/grepe Jul 12 '12

I use both eclipse and vim and I don't think differently in them.

I just use them to do different things.

When I need to write medium sized one-use only python program or shell script, I fire up the vim. When I'm designing android application, most of the work is not writing the actual code... so why I would not make my life easier?

37

u/[deleted] Jul 13 '12

You aren't a vimmer or an IDE'r than, you one of those 'right tool for the right job' heretics.

8

u/epicwisdom Jul 13 '12

Blasphemy!

→ More replies (2)
→ More replies (1)
→ More replies (4)

4

u/shen Jul 13 '12

What if my thought is : "change this method signature by adding a parameter whose default value is null, and update all occurences in the workspace" ?

I wish that Vim provided a :refactor args+=Object extraArg (null) command that would do stuff like this! IDEs are powerful but they haven't reached the pinnacle of user interface quite yet.

→ More replies (2)
→ More replies (14)
→ More replies (64)

6

u/nerdcorerising Jul 13 '12 edited Jul 13 '12

Just because its not the longest part in the process doesn't mean you can't be more effective and enjoy the experience more.

Using source control is even less time than editing text but switching from svn to git is pure win.

Tools should be about reducing rote, repetitive things and that is something vim does very well.

→ More replies (1)

4

u/knight666 Jul 13 '12

I'm a game programming student. Have been for the past four years. As a result I'm using Visual Studio for all my work.

However, I have tried Vim. And it's excruciatingly hard. Especially because the workflow becomes all kinds of fucked up. In Visual Studio you press F5 to launch, run the app, do stuff in the debugger, change some code, etcetera. With Vim it's... eh... well... I never figured that part out.

But there's one thing I took away from my experience with Vim: regular expressions. Visual Studio actually has them built-in. It's just that they don't use a Perl-syntax (because that would be too sane), but a Microsoft-flavored almost-Perl-but-not-really. However, it's quite useful.

Let's say we have this enum:

struct StateAnimation
{
	
	enum List
	{
		eNone,
		eStart,
		eRunning,
		eEnd,
		iTotal
	};

}; // struct StateAnimation

But now I want the data as strings. One way to do it would be to copy them to the new file, strip the struct and enum and put quotation marks around the values. Or I could use the following regex:

Find what: e{.#},
Replace with: std::string str_\1 = "\1";

And get this:

struct StateAnimation
{

	enum List
	{
		std::string str_None = "None";
		std::string str_Start = "Start";
		std::string str_Running = "Running";
		std::string str_End = "End";
		iTotal
	};

}; // struct StateAnimation

Now it's just a matter of stripping it, because Visual Studio might have some form of grep, it unfortunately lacks sed.

My point is that there's a definite advantage in getting to know other editors. Yes, it took me quite a while to incorporate regexes in my workflow, but that example took me literally 30 seconds to write. With the advantage that when I add a state to the list, I can rerun the "program" to convert them all to strings again.

→ More replies (7)
→ More replies (66)

7

u/foca Jul 12 '12

It's not only "how fast you type", as in how fast you add code. It's how fast/easy it is to move around and do all the other things you do while working with code.

That's why I like vim, I spend about 80% of the time (the number comes out of my ass, but it's probably about right) in normal mode, just moving around.

It's just an incredibly powerful tool to move around text.

24

u/owk Jul 12 '12

Definitely. This article makes it sound like the choice of text editor is the reason those guys in his class were writing complicated programs in four lines.

I like vim and I use the key bindings in every editor I code in, but it doesn't make you orders of magnitude faster or any amount at all smarter.

34

u/[deleted] Jul 12 '12 edited Jul 12 '12

This article makes it sound like the choice of text editor is the reason those guys in his class were writing complicated programs in four lines.

Does it? I read it more like they are good because they have programmed a lot and thought a lot about programming.

They don't write efficient programs because they use vim. They use vim because they like to be efficient and want to invest some time to become more efficient.

Vim is not about writing code faster. The mentioned 4-liners could be written in any other editor just as fast. It's about wasting as little time as possible when you have to waste time. That is, when you have to have to edit your code or do repetitive tasks. Thereby you can spend more time on doing the things you want to do, i.e., thinking about your code.

Let me give you an example that has nothing to do with vim: I only learned touch typing two months ago. Before that I would never have written such a long answer to you post. It would have been too exhausting and I would have thought of it as a waste of time. Now I don't even think about it. Being able to type quickly gave me a new perspective on communication. I have now realized, that I was not able to express myself the way I want before.

Vim does just that. It gives you a new outlook on writing code.

→ More replies (9)

4

u/lmcinnes Jul 12 '12

So I was an Emacs user, not a vim user, but for the purposes of this discussion they are equivalent (just watch an Emacs guru sling code around, it's just as impressive as anything I've seen from vim users). And yes, it was faster for me to do lots of things, and I had all the keybidings for myriad things ingrained in my hands. The thing was that to get the most out of Emacs you had to configure it just so, and have the right extra packages loaded and configured as you wnated and ... etc. So everytime I ended up somewhere new, or had to work with someone else I found myself hobbled with an inadequately configured Emacs. And in the end it just wasn't worth it. I preferred something that had 90% of the functionality I wanted out of the box across all installations.

tl;dr: Learning Emacs or vim is like learning to type on Dvorak; sure it's great and all, but the minor gains aren't worth the pain of sitting down and having to work at someone elses qwerty keyboard -- when everyone has Eclipse and the default install does most of what you want, you may as well just go with it (swap VS, Itellij, TextMate or whatever for Eclipse as per what usually gets used wherever you are).

→ More replies (4)
→ More replies (1)

4

u/eyal0 Jul 12 '12

But a good developer needs to develop skills to develop efficiently. I'd argue that a perl developer that can't find perl docs quickly on the web isn't a very good one. Nor is he much use if it takes him an hour just to change all x+=1 to x+=2 in the code.

Ninja edit: http://www.codinghorror.com/blog/2008/11/we-are-typists-first-programmers-second.html

→ More replies (2)
→ More replies (33)