I am a programmer and architect (the kind that writes code) with a focus on testing and open source; I maintain the PHPUnit_Selenium project. I believe programming is one of the hardest and most beautiful jobs in the world. Giorgio is a DZone MVB and is not an employee of DZone and has posted 638 posts at DZone. You can read more from them at their website. View Full User Profile

NetBeans vs. Vim for PHP development

08.25.2010
| 25731 views |
  • submit to reddit

I am accustomed to using Vim for writing my PHP scripts and full-fledged applications. I'm not alone in this tool choice since many geeks prefer terminal tools over IDEs.

However I recently started using both Vim and NetBeans in the company I am consulting. They have NetBeans on all the development machines, and while exploring their codebase I found it very user-friendly, also due to its plugged in PHP-related functionality that can aid every developer in managing his application. In comparison with other IDES, I love it.

But actually, on my side there's not only Vim: within its environment I can take advantage of many command line tools, so it's more a comparison between Unix command line tools and NetBeans as an Integrated Development Environment. I will use Vim as an umbrella term for the use of the command line and the terminal over the IDE.

In general, command line tools can be used quickly without exiting Vim simply by prefixing the commands with the ! character (which can be used to call any external binary).

Since this is an old religion war and it can't be solved out of context, my points will be specifically related to these programs. In this comparison, I collected examples of where Vim and NetBeans differ in behavior and performance. The point of view is that of a PHP developer, since I experienced much worse results with Unix tools while programming in other languages such as Java.

Speed

Vim obviously wins here, since it opens in less than a second: for what concerns the user experience, immediately, to the point that I do not pause Vim between editing sessions but simply open and close it everytime.

In this field, NetBeans closely follow. It is written in Java, but this does not result in a heavyweight environment. Eclipse would lose badly here, both in startup time and in responsiveness.

Codebase navigation

NetBeans wins since it has automagic features for exploring the codebase of an application, available just right a checkout from the version control system. It interprets the docblocks and follow variable definitions to a certain extent; then it jumps to the definition of a class or an object at a keystroke.

Vim has no features of this kind out of the box. There are many available plugins but I haven't found a particularly impressive one in my experience.

Autocompletion

Vim can be setup for using ctags, which is a generated list containing all the tokens that appear in the codebase. It is not very useful unless you have very specific identifiers and method names.

However NetBeans uses its CPU cycles proficiently: it has automatic completion of methods, constants and fields every time it can find out the class of an object.

Vim has also a quite useful 'complete with a word in the current file' feature, which you can usually activate natively with CTRL + N. It is usually sufficient for many autocompletion use cases, but won't save you from looking up an API like NetBeans does.

Portability

A build setup implemented as a phing target which comprehends test and static analysis reports is by far more portable than an IDE setup, being it NetBeans or Eclipse. Continuous Integration tools like Hudson work with automatic scripts, and not with IDE metadata. Moreover, unless you save the metadata in the version control system, which is a practice not everyone is comfortable with, at every checkout you will have to set up the project in NetBeans or your IDE of choice, specifying information like the test suite folder and PHPUnit's configuration files.

Ease of use

Even considering that I am an hardcore Vim fan, NetBeans wins here. In general, there is a steeper learning curve for Vim and command line tools, while IDEs are more user friendly and comes with bundled wizards which can be skipped when the curve is finally over.

Productivity

There is no clear winner, but keyboard shortcuts are very important in both cases. When the hands do not left the keyboard typing speed increases much and they are not a strict bottleneck to the speed of thought anymore. NetBeans does not force to use the mouse nor its wizards, and it has many useful shortcuts that can match Vim's ones.

Third-party tools support

PHP-related tools for software development usually come with a command line interface: PHPUnit, phing, phpcs, or the official clients of git and Subversion are all command line tools. This means they are natively interfaceable with Vim (see the introduction).

NetBeans has good support for the famous tools like PHPUnit and Subversion, and can be extended via plugins. I still prefer the simplicity of command line output: even NetBeans can show the output of the command he uses when the plugin support doesn't cut it.

From this point of view NetBeans is very clever: it takes advantage of already-installed tools and it wraps them well, without reinventing the wheel each time. Eclipse and its Subversive plugin for example are veru ugly instead.

Versatility

Command line tools win here, since they are chained together easily, in ways that IDE developers cannot predict. In comparison, it is usually not straightforward to extend the functionality of an IDE like NetBeans (via plugins?) for a quick'n'dirty workflow which you may execute only one or two times.
For example, today I was wondering if I left debugging calls in my code. In Vim, I could get a quick response via typing !svn diff | grep var_dump. In NetBeans I didn't know where to start, but it may be due to my little experience with it.

In conclusion, we should try both the IDE and the small, orthogonal tools approach to software development. Never make assumption over one of the two styles when you do not have at least tried both for a continuative period of some days.

Published at DZone with permission of Giorgio Sironi, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Jani Hartikainen replied on Thu, 2010/08/26 - 2:19am

You forgot to mention that after you actually learn most of Vim's useful commands, it's about 1000x faster to edit any text in it compared to traditional text editors - code or code, IDE or no ide. :)

However I do agree that you do get significant productivity gains in larger projects with an IDE, mainly because of the code-completion/hint systems and codebase navigation.

This is one of the reasons why I largely prefer IntelliJ based IDE's, as the IdeaVim plugin is simply the best Vim/IDE-integration I have used.

Petr Jiricka replied on Thu, 2010/08/26 - 7:50am

With respect to NetBeans integration with the command line tools, did you try Window -> Output -> Terminal ?

This is a new feature in NetBeans 6.9, I hope you will find it useful.

 

Clay Hinson replied on Thu, 2010/08/26 - 8:54am

I've been struggling with this same issue. I prefer the keyboard-based power of vim but the autocompletion and hinting of NetBeans. I just found jVi, a vim plugin for NetBeans similar to IdeaVim mentioned above.
http://jvi.sourceforge.net/
I'm not sure how it'll ultimately work out, but at the moment it might be the best compromise for me.

Bj Begui replied on Thu, 2010/08/26 - 11:46am

jVi works very well. I have been using it for sometime now. You kinda get best of both worlds.

Thiago Silva replied on Thu, 2010/08/26 - 2:03pm

Codebase navigation. This is where vim kicks ass in my opinion. If you haven't learned ctags code navigation (which is a vim default feature) you're missing very good stuff (auto-completion doesn't bother me too, it's enough for my needs).

Ctrl + ] takes you to the current word tag. Ctrl + w ] opens a new split with the tag. Ctrl + w } opens a preview window with the tag above (useful to quickly see a method signature, just like netbeans does). Ctrl + w z closes the preview window. If there is more than one match, vim pops up above to let you chose wich one you want. It's true that navigation isn't very specific, since there may be many methods with the same name. But I overcome that issue by first opening the class (:tag Zend_Form) and then issuing (:tag getMethod). It first looks the tag into the current opened file. If the method name is unique, I can get directly into it using tab completion. Everything is very easy and quick with tab completion.

I configured vim to read the tags file whenever I :cd into a dir. To quickly open a class file I just fire up vim and type :tag MyCla[TAB], that opens a class beginning with these letters. :stag opens the tag in a split window. If there is more than one match, :tnext and :tprevious to navigate between the tags. :tags list the opened tags. Suppose I want to open a class that I partially remember the name. (:tag /Form[TAB]) does the job of listing all the tags for you, or directly jumping into the first match. Set (wildmode=longest,full) for great navigation between them. If I am confused between the methods to choose, I just open the tagged class and issue :TlistToggle to help me find my way. I use the tag feature so much that I mapped simple key strokes to do ":tag ", ":stag " and so on. No need to keep changing dirs, vim's buffer (like :b buffer[TAB]) and tags navigation is killer. Netbeans may have a more specific and smart navigation, but I doubt if it's quicker (I'm not the right person to talk about that, since I am very used to vim). Netbeans doesn't have split windows, which is useful to see different parts of the same file without messing it all up. Marks are very useful in some situations, too. Another cool stuff: place the cursor under a variable and type gd to see where it is defined on the current file. If it is in another file, tags or unix tools may help you.

This is my ctags script, if you find it useful (the best I ever got to). Just map a keystroke to fire up this command:

ctags-exuberant -f ./tags -h ".php" \
-R --exclude="\.hg" --totals=yes --tag-relative=yes \
--PHP-kinds=+cf --regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
--regex-PHP='/(public \|static \|abstract \|protected \|private )+function ([^ (]*)/\2/f/' \
--exclude="*.js"

Mark Haniford replied on Fri, 2010/08/27 - 12:13pm

Has anybody got jVI working with NB 6.9?

Mario Guenterberg replied on Sat, 2010/08/28 - 10:46am

Yes, it works perfect here. NB 6.9.1 + nbvi-1.3.0.x1.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.