A Mind Lost

Anything and everything.


As I mentioned a while back (three weeks already, how time flies), I’ve been trying to find a replacement for ConTEXT, my editor of choice.  While I’m slowly becoming accustomed to Vim, the whole modes paradigm still confuses me.

Feeling brave this weekend past, I decided to see if I couldn’t make sense of the ConTEXT source code.  Checking a copy out from it’s repo on Google Code, I started poking around.  I also spent a bit of time catching up with Borland Inprise CodeGear Embarcadero Delphi.  I’ve always considered Delphi, known outside of the commercial camp as Object Pascal, to be a toy language.  Aside from a brief affair with Pascal in the early 90’s, during highschool, I’ve had little to do with it over the years.

Unfortunately, things didn’t look so hot.  The gentleman who bought the ConTEXT source code, one “Beanie”, hasn’t posted to his forums since May 11th, 2010, over a year ago.  According to his profile, he’s visited recently, but isn’t contributing anything.  Similarly, there has been little activity on the repo, and while the issues list has numerous entries, nothing seems to have been accomplished since late 2009.

Undaunted, I managed to rustle me up a few versions of Delphi, as well as Free Pascal, though in the end I didn’t even bother with FPC after reading a post from someone knowledgeable who basically said it wouldn’t work (can’t find the post, but he mentioned that lots of the third-party stuff just wouldn’t work with FPC).

The first hurdle was figuring out which version of Delphi was used to compile the code.  The ConTEXT forums were of little help, as no one seemed to know which versions were capable of compiling the code!

First I tried something relatively old, Delphi 7.  I began with this one because, throughout all the intervening years and versions, it is still relatively pervasive and very much in-use.

A slight aside here – to avoid the hassle of installing/removing various bits of software that were designed years ago for the Windows of their times, I opted to try things out in Windows XP running under VirtualBox.  Old applications can be uncooperative with modern Windows’ like Vista and 7, and it’s fairly trivial to setup a throwaway virtual machine to give these ancient programs a whirl.

Unfortunately, Delphi 7 wouldn’t even open the project file – the IDE hung, consuming 99% CPU but doing nothing.  Being unfamiliar with the way the IDE and compiler work, coupled with musty memories of Pascal’s “units” and the way they coexist with the actual program, I didn’t feel brave enough to start with an empty project and just add files to it.  I wanted something that would work out-of-the-box with the existing project.

So Delphi 7 was out.  Next I tried something a little newer, Embarcadero Delphi 2009.  I managed to get a little further in with this – the project opened fine, and it appeared to recognize everything, but compilation halted with several errors.  It turns out that this version featured a major rewrite of the various libraries to support Unicode.  However, the components used by ConTEXT are quite ancient, and are not Unicode-aware.  In particular, the actual editor, SynEdit, generated numerous errors due to the difference in the way characters are handled in this modern Delphi.  Put simply, Delphi 2009 treats characters and strings as Unicode by default, requiring … hmm, I’m not sure what the Pascal terminology for it is, but basically a function that casts the value to the appropriate type (Char(), AnsiChar()).

Again, I want it to “just work”, without mucking in third-party components.  As mentioned, the version of SynEdit used is quite old (rcsids date it to 2006).  While ConTEXT could likely be massaged into working with a newer release of SynEdit, it is beyond my skills at the moment.

So that’s the relatively old and relatively new versions of Delphi ruled out.  The last option available to me, aside from a very old copy of Delphi 5, lay with Borland Delphi 2006.  Setting up another virtual machine, I installed and unpacked the source of v0.98.7 (rather than the repo code), retrieved from another forum post linking here.  The project opened fine in BDS, but compilation failed due to a missing component.

Taking heart, I instead went back to the repo code, which again opened just fine in the IDE.  Compilation halted on a missing unit (ExceptionLog).  A brief search with Google indicated that this was perhaps a commercial component, which I naturally did not have.  Commenting the unit inclusion out, I tried again and, lo and behold, the whole thing built fine aside from a handful of easily remedied warnings!

So, for any interested parties intent on improving the ConTEXT code, Delphi 2006 aka Delphi 10 seems to be the way to go.  Unfortunately, after a quick poke around eBay I was unable to find anyone selling a copy of Borland Developer Studio/Delphi 2006.  Apparently Amazon offered it at one time for around $250 USD, but it’s out of stock and is likely to stay that way.  Further digging didn’t turn up anything on buying the compiler.  Supposedly there’s some fan-made, stripped installers floating around, but I couldn’t find any reliable links (and wouldn’t post them even if I had, sorry).

Updating the ConTEXT code to work with a modern compiler seems like it would be a very frustrating, time-consuming endeavour, not to mention costly.  As mentioned, the editor component would require either a major overhaul or replacement.  As for costly, the crippled “hobbyist” version of Embarcadero’s latest Delphi suite, “Delphi XE Starter Edition”, is approximately $200 CDN, while the Professional version is just shy of $900.  The Starter Edition also features a restriction – if you or your company make over $1,000 a year, then you must purchase an upgrade to at least the Professional Edition. In fact 9 of the questions in the Starter Edition FAQ make mention of that $1,000 dollar revenue/year limitation.

I’ve got nothing against a company trying to turn a profit, but $200 seems to be a bit excessive for the “hobbyist” edition of a compiler, especially when one considers the availability and cost of C and C++ compilers, such as the somewhat free versions of Visual Studio Express (though not complete, only the 32-bit compiler is supplied and ATL and MFC cannot be used with the Express edition of C++), the Free Software Foundation’s GNU Compiler Collection (available on Windows via Cygwin and MinGW), OpenWatcom, and DigitalMars.  Again, $200 for a crippled compiler/environment that only works with Windows and is largely non-portable/retargetable is no bargain.

My conclusion is that the Delphi version of ConTEXT is a wash.  The codebase is old and outdated and the language used restricts many people from contributing.  Sure, bugs could be fixed, but modernizing the editor with features such as Unicode would be such an undertaking that it might be best to instead reimplement the whole thing using Free Pascal, or (even better in my humble opinion) in C or C++.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: