blob: cf23c8bfedd08de7f4b24cb601c05bb9646cea3b [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- -*- xhtml -*- -->
<title>Meet a NetBeans Module Writer: Vladimir Voskresensky</title>
<link rel="stylesheet" type="text/css" href="https://netbeans.org/netbeans.css">
<meta name="AUDIENCE" content="NBUSER">
<meta name="TYPE" content="ARTICLE">
<meta name="EXPIRES" content="N">
<meta name="AUTHOR" content="Geertjan Wielenga">
<meta name="developer" content="gwielenga@netbeans.org">
<meta name="indexed" content="y">
<meta name="description"
content="">
<!-- Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. -->
<!-- Use is subject to license terms.-->
</head>
<body>
<h1>Meet a NetBeans Module Writer: Vladimir Voskresensky</h1>
<p><small><a href="mailto:nbdocs_feedback@usersguide.netbeans.org?subject=Feedback:%20Meet%20A%20NetBeans%20Module%20Writer:%20Vladimir">Feedback</a></small></p>
<table width="210" border="1" cellspacing="0" cellpadding="5" align="right" class="ltblue">
<tbody>
<tr>
<td align="center"><img align="center" src="nbm_interviews/vladimir/vladimir_voskresensky.png" alt="Vladimir's picture">
<br><b>Vladimir Voskresensky</b></td>
</tr>
<tr>
<td>Vladimir's Hot Links:
<ul>
<li><a href="https://netbeans.org/products/cplusplus/index.html">NetBeans C/C++ Pack</a>
<li><a href="http://cnd.netbeans.org/">NetBeans C/C++ Development Area</a>
<li><a href="http://developers.sun.com/prodtech/cc/index.jsp">Sun Studio</a>
<li><a href="http://wiki.netbeans.info/wiki/view/NetBeansDeveloperFAQ">NetBeans Developer FAQ</a>
</ul>
</tr>
</tbody>
</table>
Vladimir Voskresensky, together with his team in St. Peterburg and Menlo Park, is
responsible for providing the <a href="https://netbeans.org/products/cplusplus/index.html">NetBeans C/C++ Pack</a>,
which enables developers to use NetBeans IDE, in conjunction with their specified set of
compilers and tools, to build native applications for supported platforms, including Microsoft Windows,
Linux, and Solaris Operating Systems. In working on the NetBeans C/C++ Pack, Vladimir
made extensive use of the <a href="https://netbeans.org/download/dev/javadoc/">NetBeans APIs</a>,
as well as NetBeans IDE itself. Here, he shares his experiences.
<p><h3>Vladimir, where in the world are you and what do you do there?</h3>
<p>I'm in St. Petersburg, Russia. I work at Sun Microsystems as part of the
<a href="http://developers.sun.com/prodtech/cc/index.jsp">Sun Studio</a>
team. Sun Studio is a set of tools for native C/C++/Fortran development.
Sun Studio isn't just an IDE. It is a full set of compiler tools: C, C++, Fortran compilers,
Performance Analyzer, DBX debugger and more... as well as an IDE. The tools themselves are really
the best in the world, but the user interface is not sufficiently user friendly.
So, our group is working on the next generation of Sun Studio IDE.
<p><h3>Are you active in the Java community there?</h3>
<p>In terms of pure Java, not yet. I'm new to Java. The NetBeans sources were
my guide to Java programming. But I like to learn, like to acquire
new knowledge, and I like to be helpful, so you can find me increasingly on the
<a href="https://netbeans.org/projects/openide/lists/dev/archive">NetBeans Platform mailing list</a>. I'd be even more helpful there,
if Jesse Glick wouldn't be so fast in answering questions! :-)
<p><h3>Before going further, what's the difference between the NetBeans C/C++ Pack and Sun Studio?
When should I use one and when the other?</h3>
<p>It's a good question! Here's a brief overview of the distinctions:
<ul>
<li><b>NetBeans C/C++ Pack.</b> Add-on for NetBeans IDE, enabling developers to use
NetBeans IDE, in conjunction with their specified set of compilers and tools,
to build native applications for supported platforms, including Microsoft Windows,
Linux, and Solaris Operating Systems. Compilers and tools are not shipped with the pack,
the user uses the compilers available on the local machine. The
pack also has a development area, <a href="http://cnd.netbeans.org/">http://cnd.netbeans.org/</a>,
where we develop the pack. It could be interesting for module developers and users,
because there are pack-specific mailing lists (a user list, an issues list, and a
developer list), which is standard practice for most parts of NetBeans, such
as <a href="http://profiler.netbeans.org/">http://profiler.netbeans.org/</a>.
Of course, from this place you can also download the latest version of the pack
and find some useful user and development information.
<p><li><b>Sun Studio.</b> This is a big project, with compilers, a debugger, an analyzer,
and an IDE. The IDE is based on the NetBeans platform. It does not have Java support.
It is oriented to C/C++/Fortran, while the debugger (named DBX) and Analyzer
(analogous to the NetBeans Profiler), can debug multilanguage code, such as Java with embedded
calls to C++ code. Supported platforms are Linux and Solaris. Sun Studio has many performance
world records and Sun has now made it freely available!
</ul>
<p>When to use the pack? And when to use Sun Studio? Well, use the pack for development on Windows,
because Sun Studio does not support that operating system. Also use the pack for Mobile development, that is, on Symbian OS.
Or you can use the pack for developing existing projects with a previously chosen and predefined set of compilers. However,
any Linux development is better to be done using Sun Studio, especially on new platforms, so that you can take advantage of
multicore, multiprocessor, and multithreaded technology. Any Solaris development that does not use Sun Studio is nonsense!
High Performance Computing would better go with Sun Studio, as well as any other performance-sensitive application.
If the application engages parallelization, OpenMP, or MPI... it has almost no choice: <i>Sun Studio is the best!</i>
<p>For further details, take a look at these slides by
Roman Strobl: "<a href="http://roumen.name/work/Poland06/Roman_Strobl_Sun_Tools_Overview.odp">Sun Tools Overview: NetBeans IDE, Java Studio Creator, Java Studio Enterprise, Sun Studio&#8212;Which one to choose? Feature highlights, demos, future plans</a>".</p>
<p><h3>What areas of NetBeans do you use in your day-to-day work?</h3>
<p>From the NetBeans IDE, I use everything related to Java SE and module
development.
<p>From the NetBeans Platform, I used the various editor APIs, because
I worked on the editor features for C/C++ development. I implemented the UI
for C++ code completion, which looks as follows:
<p><img border="1" src="nbm_interviews/vladimir/codecompletion.png" alt="code completion">
<p>I also implemented other features, such as hyperlink support in the editor for jumping
from an element to its definition or declaration, auto completion of
matching brackets and some work on syntax highlighting. Here are two Wink demos that
show the features implemented in the NetBeans C/C++ Pack for hyperlinking to declarations and definitions
and for auto completion of matching brackets:
<p><ul>
<li>Hyperlinking:<p><a href="https://netbeans.org/files/documents/4/1017/hyperlinks.htm">
<img alt="nbm_interviews/vladimir/wink1.png"
src="nbm_interviews/vladimir/wink1.png" border="1"></a>
<p>
<li>Auto completion of matching brackets:<p><a href="https://netbeans.org/files/documents/4/1019/autocompletion.htm">
<img alt="nbm_interviews/vladimir/wink2.png"
src="nbm_interviews/vladimir/wink2.png" border="1"></a>
</ul>
<p>Click on the screenshots above to start the Wink demos! (Many thanks to Sergey Grinev for these demos.)
<p>In addition, I extended the IDE's Options window, as you
can see here:
<p><img border="1" src="nbm_interviews/vladimir/options.png" alt="options">
<div style="float: left;"><img src="nbm_interviews/vladimir/quote2.png" alt="quote 2"></div>
<p><h3>Can you tell us something about how you've experienced
NetBeans module development, in general?
</h3>
<p>Well, I joined Sun one and a half years ago when our small group started
experimenting with prototyping a new IDE for Sun Studio. We had the
main task... the IDE for native languages
based on NetBeans Platform and some legacy code. And we had
freedom in how we reached that goal!
<p>We had very tough time constraints,
a lot of ideas and features to add, lack of good documentation on
NetBeans development... those were very tough days. But we made it, made
it from scratch. After half a year we had a very nice IDE with
code folding, code completion, hyperlink support as well as class
view, native project system, improved debugger workflow and remote
development.
<p>We were getting good responses for the work done and
there was the decision to let the NetBeans community see our results.
Everyone is welcome to try the <a href="https://netbeans.org/products/cplusplus/index.html">NetBeans C/C++ Pack</a>,
which is the new
iteration of native development inside our favorite NetBeans IDE.
Not all prototypes are there, and a lot of work has still to be done, so
all developers are welcome to join us and improve C/C++ integration
in NetBeans IDE, because we have the ambition to reach the same usability
progress in C/C++ areas as NetBeans has for Java over the years.
<p><h3>Do you have any code snippets to share that others might
learn from? Maybe your favorite API or something tricky that you
learnt that others might find useful?</h3>
<p>I had various tips and tricks in NetBeans module development and I'm really glad
that I don't need to share them anymore, because the module development support
starting from NetBeans 5.0 deprecated these tricks! It is impressive
how easy it is to start with Platform-based development now.
<p>However, a useful tip is to not forget about the differences
between line separators on different operating systems, as I did... If you programmatically
get the text of documents opened in the IDE, then you realize that there is always
only "\n" as the line separator (note, it is only one character), even if the document corresponds to a file
on disk where "\r\n" (2 chars on Windows) or "\r" (on Mac) is used. This means that the size of the file
could not be equal to the number of characters in the document that you open in the IDE. The IDE itself uses for such
conversions the special class <tt><a href="https://netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-lib/org/netbeans/editor/Analyzer.html">org.netbeans.editor.Analyzer</a></tt>,
which helps to read from <tt>java.io.Reader</tt> to <tt>org.netbeans.editor.BaseDocument</tt>
by substituting line separators with line feeder "\n" and vise versa... write <tt>BaseDocument</tt>
into <tt>java.io.Writer</tt> while restoring the original line separator.
<p>In my case it was funny: when jumping with the hyperlink you landed some positions after
the declaration where you were supposed to land. The problem was trivial: we use our
own internal lexer working with files on disk (when not opened in editor), some files were
originally from Windows, so there were 2 characters for the line separator. As a result,
the lexer-provided offsets from the file were not the same as the offsets in the editor and we
failed with text correspondence.
<p>So, don't repeat this mistake! Use the <tt>org.netbeans.editor.Analyzer</tt> class
or the <tt><a href="https://netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-lib/org/netbeans/editor/LineSeparatorConversion.html">org.netbeans.editor.LineSeparatorConversion</a></tt>
class, when you're writing tests and don't want to deal with the differences between
line separators on different operating systems. For example, just pass a <tt>String</tt>, <tt>char[]</tt>
or <tt>Reader</tt> through
the end-of-line converter <tt>org.netbeans.editor.LineSeparatorConversion</tt> class or use the
<tt>org.netbeans.editor.Analyzer</tt> class when you are reading from file and plan to
work with text as it will be in the editor. Something like this:
<p><pre class="examplecode">String test1 = "string\r";
String test2 = "string\n";
String test3 = "string\r\n";
String fromMac = org.netbeans.editor.Analyzer.convertLSToLF(test1);
String fromUnix = org.netbeans.editor.Analyzer.convertLSToLF(test2);
String fromMs = org.netbeans.editor.Analyzer.convertLSToLF(test3);
assert(fromMac.equals(fromUnix));
assert(fromUnix.equals(fromMs));</pre>
<p>Do I have other tricks in mind? Maybe... I use a laptop, so I neither have dual monitors
nor a 21 inch screen. But, I want to see as much of the sources as possible and preferably
without horizontal scrolling... For this reason, there's one parameter that
I always add to my <tt>etc/netbeans.conf</tt> file:
<p><pre class="examplecode">netbeans_default_options="...-J-Dorg.netbeans.spi.java.project.support.ui.packageView.TRUNCATE_PACKAGE_NAMES=true..."</pre>
<p>It saves me space for the editor by decreasing the necessary width of the Projects window. For example,
here you see one of my modules. On the left, you see what the Source Packages folder in the
Projects window looks like <i>without</i> the TRUNCATE_PACKAGE_NAMES
parameter. On the right, you see what the same folder looks like <i>with</i> the parameter set:
<p><img border="1" src="nbm_interviews/vladimir/truncate_before.png" alt="truncated">
<img border="1" src="nbm_interviews/vladimir/truncate.png" alt="truncated">
<p>So, the left screenshot is twice as wide as the right screenshot! That makes a big difference
to the size of the editor, which should be as wide as possible.</p>
<p>Another tip... it's a good idea to check out the available editor shortcuts (Tools->Options->Keymap)
now and then as a quick review of the features provided by the IDE! Then, select a new one to use, starting from now.
Later, have a look again, and start using one more. It could significantly improve your coding.
Some engineers say that completion and other "auto" features aren't necessary and that they are coding much
faster without them, but I'd recommend that even they pay attention to the configurable
abbreviations (Tools->Editor->Code Templates), which are <i>very</i> powerful and at
least "<tt>fori</tt>", "<tt>forc</tt>", and "<tt>fore</tt>" should save a <i>lot</i> of typing.
And, you can even <i>add</i> any of your own frequently-used constructions and customize them with parameters.
<p><h3>What are some of the problems that you've encountered?</h3>
<p>I had to become familiar with NetBeans Platform development as
quickly as possible, to pick up responsibility for the interesting tasks
assigned to me. And I had to
implement my own ideas for the C++ editor, but the lack of exact examples
of platform usage was a problem. I was pampered by the MSDN knowledge
base during my pre-Sun work activities and expected the same level of
documentation for the NetBeans Platform. I wasn't that lucky, although I must say that it was a lot of fun
to adapt to the new world with new rules where you are an investigator
and discoverer of all the hidden platform features.
<p><h3>How did you solve them?</h3>
<p>I was looking for any available information on Platform development:
I started with the book "Definitive Guide" by Tim Boudreau and Jesse Glick,
but as it was already obsolete, I greedily gulped down all available tutorials
and impatiently waited for new ones... I was still hungry... and as result I
just read the one big example of how the NetBeans Platform is used&#8212;the
NetBeans IDE sources themselves! Do you want UI for code completion? Not a problem!
Read the Java editor sources. Interested in hyperlink support or code folding?
Not a problem! It should already be somewhere in the sources, you just need to find it.
<p>At the same time, invisible to the NetBeans community, I read
all of the questions/answers on <tt>nbdev@netbeans.org</tt> and <tt>dev@openide.netbean.org</tt>
and from time to time answered them to also be helpful.
<p><u>Now</u> the situation is <i>much</i> better:
<ul>
<li>A lot of useful tutorials at <a href="https://netbeans.org/kb/trails/platform.html">http://www.netbeans.org/kb/trails/platform.html</a>.
<li>As well as flash demos for getting started, at <a href="https://netbeans.org/kb/articles/flash.html">http://www.netbeans.org/kb/articles/flash.html</a>
<li>Several NetBeans bloggers with their knowledge and tricks at <a href="https://netbeans.org/about/press/blogs.html">http://www.netbeans.org/about/press/blogs.html</a>.
(Want to see how quick you can learn the APIs? Have a look at
<a href="http://blogs.sun.com/geertjan">http://blogs.sun.com/geertjan</a>
and his day-by-day growth.)
<li>NetBeans FAQ in Twiki at <a href="wiki.netbeans.info/wiki/view/NetBeansDeveloperFAQ">http://wiki.netbeans.info/wiki/view/NetBeansDeveloperFAQ</a>
<li>Fortunately, the <a href="https://netbeans.org/projects/openide/lists/dev/archive">NetBeans Platform mailing list</a> is becoming increasingly active and you can ask
the Gurus about <i>anything and everything</i>! (I only miss Tim Boudreau's advice and the level of his activity in this direction last year, but always thank him for tutorials!)
</ul>
<p><h3>What do you enjoy about creating NetBeans modules?</h3>
<p>I enjoy the help that the IDE gives you in module development. It helps you by, for example,
quickly detecting compile-time problems, by highlighting errors and providing quick fixes with suggestions.
Also, if you miss something in the IDE, you can always search on <a href="http://www.nbextras.org/">http://www.nbextras.org/</a>,
which provides a cool collection of small, free, and useful NetBeans modules from the community. If a
feature is still absent, you can write it yourself and the NetBeans Platform will help you with this.
You can use the great modularity of the NetBeans Platform to construct your small but very helpful module
by reusing existing components.
<p>When you start developing rich client applications, you can start from scratch and, for example,
without any coding, compose the editor application as a base. Then add some other lovely features of
the IDE itself to the application with the help of wizards and minimal effort on your part.
<p>Also, I enjoy using hyperlinks to navigate in my code and review others sources.
Without question, I wanted C++ developers to have the same! So I added hyperlink support to the
C++ editor and you can see the result by looking at the Wink demo earlier in this interview. However,
I want to the IDE's hyperlink support improved. For example, look at the following snippet:
<p><pre class="examplecode">A a = new A();
foo(a);</pre>
<p>Let's say I realize that the current usage of <tt>foo</tt> in the code is okay, but I
want to change
the type of <tt>a</tt> from <tt>A</tt> to <tt>AA</tt>.
If I do that, then <tt>foo(AA a)</tt> doesn't exist and I've lost
the hyperlink from <tt>foo(a)</tt> completely. So, I'd like to jump to <tt>foo</tt> in this case
anyway and want the IDE to help me, i.e., by a pop up list of unambiguous hyperlink destinations.
Frankly, now it isn't so easy to jump between a base function implementation and an overridden version of a function,
without using "Find Usages". However, if the NetBeans Platform were to provide us with pop-up list of hyperlink destinations,
we would be able to add some new and useful features. For example, Ctrl-Alt-Click would pop up a list to see where the
function was defined originally and where it was overridden, as well as allowing us to quickly jump to the related parts of the sources.
<p><h3>So if you could change one thing in the IDE, what would it be?</h3>
<p>Well, when I look at my shortcuts, I have F7 for the "Step into" action while
I'm debugging and so if I try to assign F7 to "Edit Text" in the Form editor,
the IDE informs me about a conflict and removes F7 from "Step Into"...
To me, this is nonsense, because I know that the Form editor and the Debugger are
areas without any intersections. As a user, I don't see any problems with having
the same events being handled by absolutely different actions in
absolutely different modes of development. The same is true for the development
cycle areas with intersections. It seems absolutely impossible to have
the same F5 shortcut for "Debug Main Project" and "Continue" action even
if I know that I don't ever need to start two parallel debugger sessions.
<div style="float: right;"><img src="nbm_interviews/vladimir/quote1.png" alt="quote 1"></div>
<p><h3>What are your favorite NetBeans features?</h3>
<p>In the IDE I like the new module development support introduced in
NetBeans IDE 5.0. I especially like
Libraries->Add Dependency, in the Project Properties dialog box,
where I can just type the name of a
class I'm interested in and the module provider will be foundH. So, I don't need
to look for the module name (something like <tt>org.netbeans.modules.cnd.modelimpl/1</tt>)
and its current version value in the module sources to update my <tt>Manifest.mf</tt>
file and my my <tt>project.xml</tt> file with the correct dependency.
<p>In NetBeans Platform, the <a href="https://netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/Lookup.html">org.openide.util.Lookup</a> class
is awesome!
<p>In my previous job, at <a href="http://www.infomind.ch/bph/en/">Infomind</a>, we had Einstein's rule for project
development: <i>"Things should be made as simple as possible&#8212;but not
simpler!"</i> Lookup follows this approach perfectly and provides a very powerful and
easy-to-use mechanism for intermodular communication.
<p>In a well-designed project, the API, API clients and API implementations
should be separated. Clients of an API should not be interested in the
current implementation. So, the NetBeans "Lookup" concept helps to "look
the implementation up", something like this: <i>"Hey, is there someone
who can provide me with 'cool_feature'?"</i> In code, you do it like this:
<p><pre class="examplecode">Cool_feature_provider provider = (Cool_feature_provider) Lookup.getDefault().lookup (Cool_feature_provider.class);
if (provider != null) {
provider.use_cool_feature();
}</pre></p>
<p>I could try and explain everything about this in my own words... but there
is already an excellent set of information available:
<ul>
<li><a href="http://openide.netbeans.org/lookup/">Lookup Library</a>: The solution to comunication between components.
<li><a href="https://netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/lookup/doc-files/lookup-api.html">Lookup Library API</a>: For those interested in <i>using</i> Lookup.
<li><a href="https://netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/lookup/doc-files/lookup-spi.html">Lookup Library SPI</a>: For those interested in <i>providing</i> Lookup.
</ul>
<p><h3>Any final thoughts?</h3>
<p>I'm glad that Sun is offering such a great open source development platform
as the NetBeans Platform, as well as the ready-to-use IDE based on this platform. I hope
it will be improved not only by Sun, but the community as well. I'd like
to invite everyone to share their experiences in module development to help us, for example,
add first class support for C++ development
to NetBeans. It could be especially interesting if a DBX debugger would
be integrated and we could get real multilanguage Java-C++ debugging
support inside one IDE.
<p>So, if you have any ideas about the best C++
development lifecycle... let us know, we will add them to our feature list.
If you find something annoying in your current C++ IDE... let us know, because
we don't want to go in wrong direction. If you have free time and knowledge
towards improving your favorite IDE? Let us know, you can help our
small team in moving forward our C/C++ development support for NetBeans.
<p><h3>Thanks Vladimir, and have fun with NetBeans!</h3>
<p>
<!-- ======================================================================================== -->
<h2><a name="nextsteps"></a>Further reading</h2>
<p>For information about creating and developing plug-in modules and rich-client applications, see the following resources:
<ul>
<p><li><a href="https://platform.netbeans.org/tutorials/quickstart-nbm.html">Introduction to NetBeans Module Development</a></li>
<p><li><a href="https://platform.netbeans.org/tutorials/nbm-paintapp.html">Introduction to Rich-Client Application Development</a></li>
<p><li><a href="https://platform.netbeans.org/tutorials/index.html">NetBeans Modules and Rich-Client Applications Learning Trail</a></li>
<p><li><a href="https://netbeans.org/download/dev/javadoc/">NetBeans API Javadoc (Current Development Version)</a></li>
<p><li><a href="http://www.planetnetbeans.org">Blogs by NetBeans Engineers and NetBeans Users</a></li></ul>
</p>
<hr>
</body>
</html>