Sunday, January 6, 2013

Starting Open Source Development with wxMaxima

wxMaxima is written in C++ using wxWidgets. My primary development environment is Linux (Ubuntu) with gcc, and I'm building wxMaxima against a version of wxGTK which I compiled from source.

Since I've made enough contributions to wxMaxima now to feel like I have a reasonable handle on the code base, I thought I would share my experiences developing for this project and what I've learned about open source in general.

Also my hope is that my keeping a blog about the work I'm doing, I'll force myself to justify the decisions I make, and I can learn from my mistakes, and hopefully other wxMaxima and Open Source developers can learn from my mistakes as well.

Open Source Development in General

I'll start by saying that most open source projects I've seen are pretty stuffy. You can write about issues in the issue tracker and they never seem to get any attention, and if they get any attention at all it is usually fairly delayed. If you try to make submissions you'll get buried in bureaucracy and they'll be unlikely to be looked at for their content, let alone integrated into the program.

Well, many people feel intimidated by open source and are discouraged by the obstacles that appear, but I happened to read some good advice that recommended working with a much smaller projects than those which get a lot of visibility. Everyone wants to work on the BIG projects, but there are a lot of smaller projects out there which are very useful and where you can make a difference.

My history with wxMaxima

I started visiting the forums, mailing list, and issue tracker about 3 years ago, shortly after I started using wxMaxima. From the beginning I understood that wxMaxima was a wrapper for Maxima, but spending some time with those resources helped me understand just where the line is. Even now, looking at the issue tracker, there are some issues in there where it could be argued either way, and occasionally, issues are posted to wxMaxima that are really Maxima issues, which shows how much visibility wxMaxima is getting that many users don't distinguish them.

Last winter break I tried to contribute, but because of some issues with the version of wxWidgets I had a hard time building the project, and I ended up making some very superficial changes to the code which helped clear up some of those issues. Unfortunately I never had a chance to work on any real issues from the issue tracker, and then I headed back to school for another year (with an internship in the Summer). All in all I was kept really busy, and since I hadn't made any real contributions to the project last winter, I wasn't too jazzed up about trying to contribute again.

Luckily, this winter break gave me a good opportunity to take some time to look at the project. I chose Linux because it generally is easier to develop cross-platform projects on Linux than on Windows, and I started with some simple issues from the issue tracker, and gradually built up to bigger issues, and features (some of my own request, and some from other users). Even the simple issues often require touching many parts of the code.

The owner of the project has been very patient with me and often reviews my pull requests within a few days, and then offers advice for improvement, or accepts my modifications right away. I am now listed as a developer on the project, and I hope to continue working on the project in my spare time.

Since the project is very open and relaxed about contributions from other developers, but the code can be somewhat confusing, I thought it would be a good idea to chronicle the process as I go, so that future developers on wxMaxima or other wxWidgets-based applications have something to refer to.


IDE/Tools

Whenever you're working on a project you're not familiar with, it's always good to have a good IDE at your disposal. I use Eclipse with CDT because I'm familiar with Eclipse from my days of Java development and I know that it includes great code analysis, navigation, and refactoring tools, which make navigating and understanding unfamiliar code SO much easier.

Some features that I use all the time in Eclipse to help me figure out the code:
  • Pressing F3 while the cursor is on a symbol will take you to its definition. You can also Ctrl-LeftClick on the symbol. This is great for navigating code in multiple files especially when you're not sure which file declared a class or method in Object-Oriented systems.
  • Ctrl+Alt+H: Call Hierarchy. This lets you see in one place all of the locations a symbol is used and for fields/members, makes it easy to see which of those uses are reads and which are writes. This is especially useful when you're adding a feature with similarities to another feature. You can see how parts of the code work together in the feature you're emulating so you can make sure you haven't missed any minor details about its implementation.
  • F4: Class Hierarchy. If you don't have documentation about the Object-Oriented structure of the source code, this is a valuable tool to help you see how classes fit together.
There are obviously many others, but learning to use them comes with learning to use the IDE a bit better.

No comments:

Post a Comment