Advanced Windows Programming with APL and Delphi; Eric Lescasse; No ISBN; 197 pages, diskette, soft cover; available from Lescasse Consulting.
Of the many ways to build APL applications my current preference is to use APL (or indeed J – do we have to keep saying this?) for the data processing which is its forte, specific GUI tools for the user interface and industry-compatible database packages for long-term data storage. The all-in-one APL approach is still viable, and certainly appeals for the quick/simple job, but it seems that there are too many wheels to reinvent and too much external progress to emulate for it to be realistic to build industrial-strength applications in APL alone.
The key task for the APL programmer is to learn enough about the outside world not only to use these tools effectively but also to integrate them seamlessly with the APL core of the application.
Eric Lescasse’s book addresses these issues, with examples of both Dyadic’s APL/W and APL2000’s APL+Win code; the ‘real world’ tool used is Borland’s Delphi 2. Clearly there are version-specific aspects to the work, but it can also be applied in the abstract.
The book (195 pages) is supplied along with a companion diskette; the sample code requires Dyalog APL/W Release 7.2 or higher; my rather old copy of APL+Win was unhappy about some of the code samples – I did not pursue these examples very much. The installation procedure for the supplied software was (as is the fashion) a little intrusive and made some unannounced changes to my Windows 3.1 path.
I was able to check out the Dyalog APL examples, but without a copy of APL+Win to hand it was not possible for me to check these (my overall impression is that Lescasse has done a thorough job, problems with the Dyalog APL examples were few and easily overcome, I would expect the same to apply to the APL+Win examples).
The forms editors of both APL/W and APL+Win lag a long way behind both Delphi and Visual Basic; this seems to be inevitable. Furthermore, it seems fruitless (to me) for the APL vendors to seek to continually pursue complete GUI functionality; far better to be able to climb on the back of the Delphi or VB bandwagon and have the power of APL in reserve when data processing becomes of the essence.
What Lescasse does in this chapter is to describe a translation program (unfortunately, the program is not part of the supplied software) which takes a Delphi form definition and mutates it into APL code.
An aspect of the book which is excellent is the step-by-step discussion of what the reader needs to do in Delphi (if my own biases are anything to go by, the APL programmer quickly meets uncharted waters when trying to use some of these ‘mainstream’ tools).
The concept is attractive, and certainly offers a more productive approach to GUI development than the alternative of hand-coding the APL statements; but it does still suffer from the catch-up problem. It would also have been more valuable if the translation program had been included.
The ability to call compiled routines from APL has obvious advantages (although they seem not to be as obvious to some as to others). DLLs (dynamic link libraries) are one sort of compiled routine and the first step is to be able to write your own DLLs.
Again, Lescasse leads the reader very carefully through the Delphi steps (indeed it might not even be necessary to know anything about Delphi to become able to use it in this context).
One thing to be very careful about when using DLLs is that mistakes in argument specifications will lead to software crashes (thank you very much Microsoft).
There are one or two typos which are quite easily overcome and it would have been helpful to see the importance of case more firmly emphasized (Delphi sometimes seem quite schizoid about whether it does or does not care about case in names).
The examples give a good grounding in how to call Delphi routines with a variety of arguments, leaving this reader with just one shudder of incomprehension about why pointers are used for numeric arguments, but character strings appear not to be. Clearly a gulf between the hardened APLer and the mindset (not to mention digital stamina) of the scalar programmer.
This chapter introduces techniques for using forms generated with Delphi from within APL. At one extreme this allows us full access not only to the Windows interface as seen by Delphi, but also to use any of the many add-on components which are readily available for Delphi. Given that the approach of Chapter 1 is, at best, clunky there begin to be some clear(ish) gains here.
Delphi provides a visual forms editor; it’s a lot easier to make sure that controls fit together visually than manually editing Dyalog form definitions (and I still have not grown to love the Dyalog visual form editor).
The onus for keeping up with the Windows interface is shifted onto the Delphi developers, allowing Dyadic to get on with the task of developing APL itself; although one might reasonably observe that Dyadic Systems are far more reachable and responsive than Borland (similar observations doubtless hold for the other APL vendors).
Your APL application can readily use Delphi’s own components (and there is a significant market for add-in components).
The down-side to this is that not only is there an awful lot more writing to do on the Delphi side than there is for equivalent tasks in APL, but the technique appears to work best when there’s a clear create-initialise-react-process cycle. It’s not clear to me, from this chapter, how best to tackle the issue that some form events need to trigger activity on the APL side of the code. I need to think about this, and maybe try a small application or two.
So far as the chapter itself is concerned, it makes some play about coding techniques to avoid GPFs although this problem appears to have been resolved since the book was written. There are some inconsistencies in the text and a few items either missing or which I have been to impatient to find (code for the Calendar control example is shown, but there seems to be no mention of the need to make sure Delphi connects the form events to it).
A ‘feature’ of GUI applications written in vanilla Dyalog APL is the plethora of bitmap files needed to support all of the toolbar buttons; by embedding these into a DLL some significant simplification is achievable (not just of the number of files, but also – in a FAT-dominated world – in disk space utilisation).
Lescasse presents two Delphi-based techniques for encapsulating bitmaps withing DLLs, not having the Delphi RadPack to hand I was only able to check out the less flexible option using the Delphi Image Editor. The accompanying APL example took me rather deeper into the world of the author’s techniques for APL GUI programming than I really care to (surely there’s a simpler way, or at least a need for an explanation of what’s going on).
Of course, even with all the bitmaps wrapped neatly into a single resource file, the workspace continues to be populated with hundreds of bitmap objects; but that’s not the book’s fault.
Two examples are presented; a ‘splash screen’ opener for an application and an executable to play a sound file. Once again, the presentation is clear and complete.
Running through a number of approaches to access databases (both Paradox and Access) from APL; again the treatment is thorough and the results gratifying.
The ability to mix-and-match APL with other programming tools is not only advantageous for APL it is also an essential skill for the modern APL programmer. One of the problems that the APL programmer faces is that the scalar language texts assume a different knowledge focus than is appropriate (the self-congratulatory tone of some of these texts is also often irritating).
Lescasse does an excellent job of explaining how APL programmers using either Dyalog APL or APL+Win can utilise Delphi to expand their ability to provide appropriate solutions in a RAD environment.
Many of the topics beg further exploration by the interested reader. We should also consider whether similar techniques may be applied in J and the long-forthcoming APL2 Windows product; also whether a similar level of symbiosis is achievable with Visual Basic.
Some could reasonably argue that Lescasse has to a degree put the cart before the horse; there is definitely a sense here that what we have is a vehicle for launching Delphi applications from an APL framework. What might have been at least equally useful might have been an exploration of how APL could be used to solve the data-manipulation deficiencies of Delphi, and Delphi programmers in search of algorithmic complexity might easily be a larger market than APL programmers in search of a GUI builder.
But the book we have is the book we have, and it should be on the shelves of everyone with an interest in applying APL effectively in today’s computing environment.
Copyright © Dick Bowman 1998-2013; latest update 14 March 2013 (repaired links)
Back to the J\APL Contents Page