The Artima Developer Community
Sponsored Link

Leading-Edge Java
JavaScript and PHP Support in NetBeans 6.1
An Interview with Sun's Gregg Sporar
by Frank Sommers
May 22, 2008

Advertisement

Summary
Continuing its tradition of providing support for an increasing number of languages and environments, NetBeans 6.1 introduces advanced JavaScript and PHP features. In this interview with Artima, Sun NetBeans evangelist Gregg Sporar discusses JavaScript and PHP support, such as refactoring and intelligent code completion.

In the past two years, NetBeans has become a multi-lingual IDE, supporting not only Java, C, and C++, but also Ruby and, with the recent release of NetBeans 6.1, PHP and JavaScript as well. Support for working with those languages in the IDE goes far beyond syntax highlighting. The IDE tries to understand as much about the code's structure as it can, and provides intelligent refactorings, code completion, and the ability to work with multiple languages within one source file.

In this interview from JavaOne 2008, Sun NetBeans evangelist Gregg Sporar discusses PHP and JavaScript features in NetBeans 6.1:

In the new NetBeans 6.1 release, we have an early-access release of PHP editing support. This is very similar to to the process we went through last year, when we were adding Ruby and Rails support to NetBeans. With the PHP support, we're leveraging what we've done already to support dynamic scripting languages in the IDE. We're taking that same functionality, and making that available to those using PHP.

With the Ruby support we provided an early-access version, and received a lot of very useful feedback. That helped us to shape what the ultimate end-result would be, which you can see in NetBeans 6.0. We are hoping that we'll be similarly helpful feedback with the PHP support as well.

With Ruby, we really wanted to support Rails at the same time also, because a lot of developers use Ruby in order to write Rails applications. With PHP, we'll be supporting PHP programming in general. There are several PHP frameworks and tools people use, and we're not focusing on any of those in particular. Rather, what we're trying to achieve is to implement an excellent PHP coding framework that can be targeted to a variety of PHP development tasks. Again, we're very interested in receiving community feedback, because that's how we'll learn what specific focus our PHP support needs to have.

What we're trying to make especially easy with the PHP tooling in NetBeans is a local deploy of the application. We don't yet have the ability to deploy to a remote server, but we're looking at that now. We also don't yet have a way for you to deploy your PHP application onto a Java app server, using one of the Java PHP implementations, such as Coucho, that brings an interesting angle and is analogous to JRuby.

There are also some new features in NetBeans 6.1 that make it easier to work with MySQL databases, a common tool for PHP programmers. The "I" in IDE stands for integrated, and we're trying to make the development workflow simpler with this integration. Technically speaking, that's not part of deployment, but it's part of the developer workflow, of being able to touch things and systems that are outside your code. Starting and stopping the server, creating and managing databases, those are what we provide now. We also integrated the MySQL admin tool into NetBeans as well.

In addition to PHP, we're very excited to have first-class support for JavaScript now in NetBeans 6.1. Although JavaScript in NetBeans has had a long history, we believe we have something quite powerful now. JavaScript is not a statically-typed language, so the infrastructure you need for supporting JavaScript is very similar to what you need in the Ruby world. Leveraging the support we built for Ruby last year, we can deliver the same types of features in JavaScript that we have for people editing Ruby code.

For example, syntax highlighting, code folding, and code completion are all there now for JavaScript. We can also do inline renaming of variables, and do some refactoring of JavaScript code.

The code completion in NetBeans 6.0 was very simple: it would show just what's in the DOM, and that's about it. In 6.1, we understand included JavaScript libraries, for example. We can parse an HTML file, recognize the JavaScript libraries included in that page, and show you intelligent code completion based on the contents of those libraries. If you're chaining calls, we can also show you code completion.

It's interesting note that the JavaScript world has some coding standards, compared to the Ruby world. Those standards are used, in effect, in the in-line documentation that allows the NetBeans parser to be a little smarter in the heuristics deciding what would appropriate completions for some code be. The more likely completions then go on the top of the list of possibilities offered by the NetBeans JavaScript editor. That makes the JavaScript code completion in NetBeans 6.1 very sophisticated.

The best of the JavaScript features in NetBeans 6.1, however, is that we ask you which of the browsers you want to support with your code. When you bring up the code completion options, if some of your required browsers don't support a version of a method, that method will be crossed out. You can place the cursor on top of that line, and the editor will tell you what version of what browser doesn't support that method. That's the sort of productivity boost that JavaScript programmers have been waiting for.

What do you think of NetBeans' JavaScript and PHP support?

Post your opinion in the discussion forum.

Resources

NetBeans 6.1:
http://www.netbeans.org

About the authors

Frank Sommers is Editor-in-Chief of Artima Developer. He also serves as chief editor of the IEEE Technical Committee on Scalable Computing's newsletter, and is an elected member of the Jini Community's Technical Advisory Committee. Prior to joining Artima, Frank wrote the Jiniology and Web services columns for JavaWorld.



Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us