Interview: Allan Davis, nbPython Developer

DZone 's Guide to

Interview: Allan Davis, nbPython Developer

· Java Zone ·
Free Resource

Allan Davis recently posted a screencast of something called "nbPython", here, over on NetBeans.tv. Later, the screencast was reposted here on NetBeans Zone. Python is one of the handful of hot languages that is still missing support in NetBeans IDE and, now that the NetBeans language APIs are growing in versatility, the time is right for support being created for Scala and Groovy, for example, as well as, now, Python.

So let's meet Allan and find out what nbPython is all about and look under the hood at some of the API magic...

Can you tell us a bit about yourself, who you are and where and what you do?

Sure, my name is Allan Davis. I have been working in Software development for about 15 years. I started learning and using Java in 1998, gaining my SCJP in 2003. I began working with NetBeans in 2002, utilizing version 3.3. I have jumped around to different IDE's (JDeveloper, Eclipse, JBuilder, to name a few), always coming back to NetBeans, every time. Recently, I have built 3 different RCP applications.

Currently, I am working as a GIS/Java developer for General Dynamics. We are developing a web-based JSF map editor.

What's nbPython?

NbPython is an extension of the NetBeans IDE to provide support for the Python programming language.

How did it get started and why?

After having to do some GIS scripting with Python and pydev, I thought it would to be cool if I could use NetBeans. About the same time, NetBeans 6.0 was released with Ruby support. I realized that a Python extension would be a perfect fit. Recently, our office has started a switch from Eclipse to NetBeans as well, so, the needs keep growing for this development.

What does it aim to provide?

NbPython aims to provide first-class support for the Python language in NetBeans. This includes a full editor, interactive console, a Python platform manager, and Django support. The full editor includes syntax highlighting, code completion, editor hints, and numerous other features.

What does it provide right now?

Right now nbPython provides syntax highlighting, a basic Python project template, and basic execution of any Python script

You must have been using quite a few NetBeans APIs. Which ones and how has the experience been?

There have been a lot of changes to the API since I started working with NetBeans. For this project, one of my favorites has been GSF. GSF, or Generic Scripting Framework, is used to provide support for scripting languages such as Ruby, Python, and PHP. It has eased some of the load of coding requirements, allowing for easier coding milestones. The prime example of this is the Editor window itself:

The only items I have to define are the Lexer and a language file that extends DefaultLanguageConfig. I then create a link to GSF in the layer.xml, as per the examples below:

public class PythonLanguage extends DefaultLanguageConfig {

public String getLineCommentPrefix() {
return "#"; //NOI18N


public Language getLexerLanguage() {
return PythonTokenId.language();

public String getDisplayName() {
return "Python";

public String getPreferredExtension() {
return "py";

public Parser getParser() {
return new PythonParser();

public boolean hasStructureScanner() {
return true;

public StructureScanner getStructureScanner() {
return new PythonStructureScanner();

<folder name="GsfPlugins">
<folder name="text">
<folder name="x-python">
<file name="language.instance">
<attr name="instanceOf"
<attr name="instanceClass"
<file name="structure.instance">
<attr name="instanceClass"

Another great API for NetBeans is extExecution. This API allows for easing the creation of external execution processes in NetBeans. We use it for execution to both Jython and Cpython.

// Setup process Information 
ExternalProcessBuilder processBuilder =
new ExternalProcessBuilder(command);
processBuilder.pwd(new File(workingDirectory));
processBuilder.addEnvironmentVariable("PYTHONPATH", path);
//build Service
ExecutionService service =
(Callable<Process>) processBuilder.create(),
execBuilder.create(), displayName);
// Start Service

The experience using these APIs has been very good. I can't complain about a thing.

Do you have tips to share with others doing similar things?

One of the biggest tips I can suggest is to utilize the mailing lists. Everyone is willing to share what they have done. Also, examples are posted and check out the "contrib" module, as well as "trunk". When I first began developing the Lexer module and trying to use ANTLR for grammar processing, I searched for an example on how to make this work. The one I found linked to the NetBeans 6.0 Lexer. This page pointed to code from the CVS Server that did not migrate to Mercurial. I posted a question to the development mailing list and was pointed to the javafx.editor module that was doing the same thing I was. After studying their code I was able to create the Lexer with no problem.

Is it just you or are there others working on it? Can others join in?

There is no way I could do this alone. The project is open, so anyone can join. I started out building a team from friends at work. We work on this project in our off-time. Interest in the project has been incredible. Not two days after posting the project pages on java.net, I started receiving feature requests. Stuff like that really fuels me. I have also had a lot of interest from Sun, Tor Norbye (Ruby) and Martin Adamek (Groovy) have been indispensable in helping to getting me going with GSF.

If you want to join, go to the project page (http://nbpython.dev.java.net). Request membership to the project, and while you are there sign up for the development mailing list (https://nbpython.dev.java.net/servlets/ProjectMailingListList).

What's the timeline from here on? How often and what will you be publishing next?

We are targeting to be in sync with the 6.5 release of NetBeans, with milestone releases about every 2 to 3 weeks. We want everyone to be able to see how the project progresses. In the next milestone release, there will be some editor enhancements and the Python platform manager.

How do I get started using it?

To start using the program, you can just download the bits from the project page under "Documents & files". There you will find archived downloads of all milestone files including the source code at that time. Or, if you are so inclined, you can check out the source code from Subversion. Then open up the project within the latest development build of NetBeans IDE and then... simply click "Run"!


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}