blob: 842d681b6df2fe4b0944237b38b90b532504b3f7 [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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Title" content="Schliemann in the Field"/>
<meta name="Author" content="Geertjan Wielenga"/>
<meta name="description" content="Overhyped or a Practical Basis for Language Editors?"/>
<meta name="copyright" content="© 2007 NetBeans"/>
<meta name="Designer" content="pH Design"/>
<link rel="stylesheet" type="text/css" href="../magazine.css" media="screen"/>
<title>NetBeans Magazine, Issue 4 . Schliemann in the Field</title>
</head>
<body>
<div id="nb04-schliemann">
<div class="story"><span class="nb-article-title"><img src="../../../../images_www/magazine/issue04/top-schliemann.jpg" alt="Schliemann in the Field" width="770" height="200" /></span></div>
<div class="story">
<p class="nb-body"><span class="nb-body-bold">I</span>n the previous issue of the NetBeans Magazine, we highlighted a new and simplified approach to providing syntax highlighting, code completion, and other language-support features for programming languages. Instead of a multi-file Java-based approach using complex NetBeans APIs, we have a “new way” known as Schliemann. The idea behind it is to have a simple set of declarations in a single file, written in the form of regular expressions that describe the language tokens and grammar, together with their assignment to features in the IDE. Using these declarations, the IDE is then able to do the lexing and parsing for you, so there’s no need to provide such functionality yourself.</p>
<p class="nb-body">But how viable is this approach? Can it be used in real-life scenarios? Or is it just a fuzzy story without real usage in the workplace? In this article, we investigate a number of actual Schliemann-based implementations by NetBeans developers around the world. </p>
<p class="nb-body">At the time these implementations were started, the day was still young for the Schliemann framework, which was created for NetBeans 6.0. Despite that, several language developers who liked living on the edge had already started working with milestones and daily builds, writing editors for their favorite languages even before the framework on which they were basing their project was actually complete. </p>
<p class="nb-body">There are dangers in this, of course, but Schliemann has been stable enough to allow it, judging by the advanced results some of these implementations already provide. Each implementation is briefly discussed below, in the context of the developer who implemented it, and accompanied by some screenshots to give you an impression of the achievements thus far.</p>
<p class="nb-section">Erlang Language Support, by Caoyuan Deng</p>
<p class="nb-body">Erlang is a Functional Programming language with many dynamic features, such as being dynamically typed, with hot code swapping. “Erlang is ideal for soft real-time, heavy concurrent-load network applications,” says Caoyuan Deng, who is adding Erlang support to NetBeans. In <span class="nb-body-bold">Figure&nbsp;1</span> you can see a segment of the editor that Caoyuan has created, showing syntax coloring and code folding.</p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23122_opt.jpeg" alt="Figure" /><br />
</span><span class="nb-body-bold">Figure 1. </span> Editing Erlang in NetBeans<br />
</p>
<p class="nb-body">When asked about the usability of the framework, Caoyuan says that, “with Schliemann you define a grammar file for a new language and you not only get features like syntax highlighting, indentation and code-folding, but also a visual incremental AST tree. This is helpful for writing IDE support for new languages. When you’re typing code, Schliemann parses the syntax incrementally in real-time, and you know immediately a lot of context information about the code, such as whether there is a variable in the current function’s scope.”</p>
<p class="nb-section">OpenGL Shading Language Support, by Michael Bien</p>
<p class="nb-body">OpenGL Shading Language (GLSL) is a language for graphical effects, such as lighting, fog, water, reflections, and refraction. It defines how an element is rendered in an OpenGL scene. Michael Bien created an editor for this language as part of his recently released NetBeans OpenGL Pack (see it at work in <span class="nb-body-bold">Figure&nbsp;2</span>). </p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23128_opt.jpeg" alt="Figure" /><br />
</span><span class="nb-body-bold">Figure 2. </span><span class="image">GLSL support<br />
</span></p>
<p class="nb-body"> “I am currently working on a Schliemann-based language validator for GLSL in combination with the NetBeans Lexer API, for an alternative to validation via compilation,” says Michael. “This is an important feature because GLSL shader programs are compiled by the VGA driver, and this can lead to different results on different hardware (or even driver versions).” </p>
<p class="nb-body">About his experience with Schliemann, he says that the declarative language the framework supports is very intuitive and provides access to most of the features you would expect from an IDE’s editor, without limiting the developer. He also highlights that you can call Java code from inside the Schliemann definition file.</p>
<p class="nb-section">D and MiniD Language Support, by Björn Lietz-Spendig</p>
<p class="nb-body">Giving his reasons for creating editor support for D and the MiniD scripting language, Björn says: “I don’t like C++, especially its preprocessor and template language. But, despite being a database developer who is used to working with RAD tools, I have a need for low-level programming. And now we have a stable D 1.x, including a module system, single inheritance, interfaces, garbage collector, design by contract, class invariants, in addition to templates as a natural part of the language.” <span class="nb-body-bold">Figure&nbsp;3</span> shows the results so far for a simple MiniD code fragment.</p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23134_opt.jpeg" alt="Figure" /></span> <br />
<span class="nb-body-bold">Figure 3. </span> MiniD programming in action </p>
<p class="nb-body">Commenting on the future of his editor support, Björn says: “The D implementation could open new horizons to NetBeans developers. Can you imagine being able to use a C++ class directly from Java and vice versa? With the D language plugin you can call D classes (via TioLink) and D can call Java classes. You have the power to create platform-independent eye-candy applications based on the NetBeans Platform, while having seamless integration with D”.</p>
<p class="nb-section">3DSL Support, by Max Calderoni &amp; Marco Thiele</p>
<p class="nb-body">“We are currently developing a plugin supporting an internal format for a file that in our industry (oil) is currently edited by hand,” says Max Calderoni. “It’s the input file for a numeric simulator, not a programming language, and is called 3DSL. The simulator is used for oil reservoir analysis”. Such input files, the authors continue, are difficult to edit even for advanced users, “so it would be a blessing to have code folding, code completion, syntax highlighting and inline documentation for 3DSL files”. And they are well on that track using Schliemann (see <span class="nb-body-bold">Figure&nbsp;4</span>).</p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23140_opt.jpeg" alt="Figure" /></span><span class="image"> <img src="../../../../images_www/magazine/issue04/image23146_opt.jpeg" alt="Figure" /></span><br />
<span class="nb-body-bold">Figure 4. </span> Support for 3DSL in complex, structured input files<br />
</p>
<p class="nb-section">TorqueScript Support, by Mohamed el Shami</p>
<p class="nb-body">TorqueScript is the scripting language of the Torque Game Engine and the Torque Game Builder (TGB), by GarageGames. TorqueScript has a C++-like syntax and includes features like Datablocks, Objects, and Namespaces. “What I’ve done so far with TorqueScript is only a start,” says Mohamed. “Since I’ve been learning along the way, I’m firstly working to complete the grammar rules. Then I’d like to add support to run ning the game from within the editor.” <span class="nb-body-bold">Figure&nbsp;5</span> shows an example with TorqueScript.</p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23152_opt.jpeg" alt="Figure" /><br />
</span><span class="nb-body-bold">Figure 5. </span><span class="image">TorqueScipt editing, with syntax coloring and code folding support</span></p>
<p class="nb-body">“I’d also like to add a project template for a new TGB game project which creates the game project structure,” says Mohamed. “Later, the plan is to include advanced features like debugging, refactoring, and a dynamically populated auto-complete list from the game engine APIs.” </p>
<p class="nb-section">JFugue Support, by the author</p>
<p class="nb-body">JFugue notation provides the music strings that let you specify notes, chords and instruments when you use the JFugue API for music programming. The notation is simple, but syntax coloring is always useful. In the example shown in <span class="nb-body-bold">Figure&nbsp;6</span>, the formatting is applied to a<span class="nb-techtext-bold"> JEditorPane</span>. This is simple to do, by assigning the MIME type as the value of the <span class="nb-techtext-bold">ContentType</span> property. As a result, the notes and their duration can be distinguished from each other, and from the instrument selection (shown in yellow).</p>
<p class="nb-body"><span class="image"><img src="../../../../images_www/magazine/issue04/image23158_opt.jpeg" alt="Figure" /></span><br />
<span class="nb-body-bold">Figure 6.</span> Syntax-colored JFugue notation</p>
<p class="nb-section">Conclusions</p>
<p class="nb-body">Despite its youth, the Schliemann framework is proving extremely useful in a number of varying scenarios. It is easy to use and the results are surprisingly effective. Why not take it for a spin? </p>
</div>
<div class="image">
<div id="nb04-maven-platform">
<div class="story">
<p class="nb-body"></p>
</div>
<div class="image">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#663300">
<tbody>
<tr>
<td height="30" bgcolor="#000033"><p class="nb-table-title">Links</p></td>
</tr>
<tr>
<td valign="top"><div class="group">
<div class="story">
<p class="nb-link-legend-url2"><br />
<a href="http://wiki.netbeans.org/wiki/view/Schliemann">http://wiki.netbeans.org/wiki/view/Schliemann</a></p>
<div class="group"><div class="story"></div>
<div class="story">
<p class="nb-link-legend">Schliemann Wiki</p>
</div>
</div>
<div class="group">
<div class="story">
<p class="nb-link-legend-url2"><a href="https://netbeans.org/projects/contrib/">https://netbeans.org/projects/contrib/</a></p>
</div>
<div class="story">
<p class="nb-link-legend">Generic Languages Framework (Project Schliemann)</p>
</div>
</div>
</div>
</div>
<div class="group"><div class="story"><div class="group"><div class="story"></div>
</div>
<p class="nb-link-legend"></p>
</div>
</div></td>
</tr>
</tbody>
</table>
<br />
</div>
<div class="image">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#663300">
<tr>
<td><img src="../../../../images_www/magazine/issue04/geertjan_wielenga_opt.jpeg" alt="Geertjan Wielenga" width="82" height="85" /></td>
<td><div class="story">
<p class="nb-minibio"><span class="nb-autor-name">Geertjan Wielenga</span> is a technical writer for the NetBeans project. He mainly focuses on the NetBeans Platform and is a co-author of the book “Rich-Client Programming: Plugging into the NetBeans Platform”. He lives in Prague, in the Czech Republic.</p>
</div></td>
</tr>
</table>
</div>
</div>
</div>
<div class="nb-figura-t-tulo"></div>
<div class="story"></div>
</div>
</body>
</html>