Saturday, November 15, 2008

Paladin: Code by Day and by Knight

Wow. I can hardly believe that it's been more than a month since I posted about working with Oliver and Tako on Niue. A *lot* has happened since then besides my R2 proposal. My small diversion turned into a not-so-small one. It's funny how that seems to happen, but it grew in a good way. I'll get back to the DeskPanel sooner or later -- I'm having *way* too much fun right now.

The more I worked on the Niue sources in an attempt to clean them up, the more I felt like it was spaghetti code which would be easier to rewrite from scratch than to clean up. One night I just decided to see what it would take to put together a rudimentary project manager and it all snowballed from there. The result? An MIT-licensed IDE called Paladin which is modelled after the illustrious BeIDE which is based on Metrowerks' CodeWarrior. Xcode it ain't, but should be a pretty good improvement upon BeIDE.

BeIDE is an excellent, if dated, IDE which lends itself pretty well to beginners picking it up. Just so you know, BeIDE has been my right-hand coding tool since Day 1 when I started tinkering with the sources for an open-source paint program called Photon that I sort-of developed into BePhotoMagic. With the hundreds of hours I've logged using it, I've learned a few of its quirks. I've also found myself wanting certain features that, obviously, weren't going to materialize. I now have that chance to fix that.

The only IDE that we have for C/C++ development which even comes close to BeIDE is Niue. Niue's got some great features, like code completion and the ability to see the actual compilation output as if you were watching it in a Terminal window. So far, the only major problems I've seen outside of the maintainability department are that it depends on make to do all the heavy lifting, it eats up screen space like candy, there are bugs in the editor, and the code is a mess. Keep in mind, though, that the last two are probably the result of having lived and breathed BeIDE for years.

The project manager has gone together quickly, but I wanted to be able to hit Alt+M to build the thing while I still had focus on the editor. I also had some other integration-related desires that I'd need to have a text editor for. As a result, I started looking for information about writing one or building upon existing code. In my search, I learned about (and am reading) the book Design Patterns: Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, and Vlissides. I also discovered that Niue's editor is, in fact, a quite-modified version of Yate and why: writing a text editor is hard and time-consuming. Yate's sources, by the way, are part of the reason for the mess of Niue's sources, because Yate's code is bad. Really bad. There aren't very many other open-source text editors for BeOS. I narrowed things down to a port of Scintilla or hacking Pe. After spending a weekend off and on playing with Scintilla, I decided to go with Pe. The only thing about Pe is that it uses a different resource compiler, rez, which supports other text-based resources, such as dialog boxes and menus.

The only bad news that I have is that the result of these antics isn't even in an alpha state yet, but it is quite a promising IDE nonetheless. Currently I can build quite a few different kinds of projects, including Paladin itself. Pe is being pared down into a leaner text editor primarily focused on C++ development, so, for example, the HTML palette has been given the heave-ho. This doesn't mean you can't use it for other things -- the syntax highlighting for other languages is staying -- it just means it would be a little like using BeIDE for writing Python or Perl.

Paladin has a lot of potential because of both the features it has and the ones that are coming. Project files are just special text files, so they are both user-readable and friendly with CVS, git, SVN, and so on. Paladin can also be executed from the command line to build a project without a GUI, so it can be scripted. While no visual editor is planned, a boilerplate code generator feature is in the works -- choose what class to add to the project, give it a name, check off options and virtual methods you want implemented, and voila! Instant skeleton code, both header and source file. I'll probably be adding a feature to generate makefiles and jamfiles from projects. Projects can be run in the debugger, run from the Terminal, or (eventually) run with predetermined command-line arguments. Adding libraries from the standard locations to a project is literally a matter of clicking on a menu item and checking (or unchecking) items in a list. There is also some basic project template code which will probably be expanded, as well. Best of all, the thing is MIT-licensed, so once it's released, anyone can contribute to its development or utilize its code in other projects. I'm also contemplating a code library feature for those bits of code that we codemonkeys seem to be reusing time and again.

I'm excited about the whole thing and I hope this gives you a little more to look forward to for Haiku's future. Obligatory screenshot:



There's a new code warrior on the block. Have a good weekend everyone. :)

1 comment: