| ||||||||||||||||||||
| ||||||||||||||||||||
|
||||||||||||||||||||
|
LPA have long been at the front of Prolog development. Their latest incarnation of Win-Prolog (4.1) definitely keeps up that tradition with a fast and efficient compiler.
Interface
The interface is nothing spectacular. It looks like a multi-document version of Notepad - one document consists of a standard Prolog console where all querying occurs and other documents appear as you open source files.
There are no fancy GUI gadgets like Microsoft's Visual-series (or any professional developer IDE for that matter) to aid coding. This may please some people but I find code navigation, compilation, and debugging much easier with a good GUI wrapping it. Win-Prolog doesn't have accelerator keys (for example, F3 brings up Search dialog) or a toolbar, let alone something like ClassWizard to aid code management. This means even saving and compiling requires accessing the menu, either by mouse or keyboard - either way, more inefficient than Ctrl+S or F7. The editor also has no colour syntax and no modified cursor movement to accommodate the programming language. The only thing that can be altered is the font and font size. The thing is, it actually has some neat code management features in place (more on this in a minute) like the "Goto Definition" function which lists all the functions in the source file and allows you to jump to any one. Adding a toolbar with the definitions listed and a goto button would definitely aid the functionality of the editor. This is not to say the interface is bad. It just lacks the GUI finesse of most professional compilers and interpreters. The interface has some excellent utilities for understanding the code and, most importantly, debugging.
Code ManagementWhile there is no GUI support for code management, there are 4 features that can aid code management and navigation very nicely. The "Goto Definition" has been covered, the "Goto Next Definition" does exactly what it states and helps the programmer find other definitions of the same predicate that might be scattered about the source file. The next two are very helpful: the call graph and the cross reference functions. The call graph graphically plots how the predicates are called within your program, with each predicate being assigned a button that will redraw the graph to that specific predicate's perspective. The cross reference function will create a new document and list the built-in predicates called, predicates that were defined and called and predicates defined but not called. Very useful even for small projects.DebuggerThe debugger in Win-Prolog is excellent. With two different debugging modes and 3 different monitors, you are bound to track down the particularly nasty bugs that can occur in Prolog. For each debugging and monitor mode, you firstly set a "spypoint" (breakpoint) in the code and when the program hits the spypoint, the debugger or monitor kicks in.There is a source level and a box model debugger. The source level debugger is excellent - allowing you to step through (or over) each predicate and observe the backtracking and logic that occurs. See the right-hand screenshot above for a look at the source level debugger. The box level debugger is much like source level, except it doesn't step through the source, but uses the Prolog run-time instantiations for the variables. The box level debugger also lists a few additional properties that I won't go into here. The other 3 modes are all non-interactive monitors. There are call, mismatch and fail monitors. The monitors are great to quickly find where bugs surface without stepping through a huge amount of code first. A final neat feature of the debugger is that is it is accessible programmatically. You can quickly check the status, turn off or check various debugger flags all via a couple of Prolog predicates.
Windows SupportThe Windows support in Win-Prolog 4.1 is superb. From full Unicode encoding and OLE and DDE support to a large library of Windows routines and DLL support. Virtually all modern Windows technologies are accessible from Prolog.The Unicode support is new to 4.1 and it looks like LPA put some significant thought into how it should be implemented. The documentation goes into excellent detail how the characters are now stored in memory. The OLE support was also very impressive - an example program controlled Microsoft Word via its Automation object.
Hands-OnIn an attempt to understand quite how Windows programming and Prolog worked, I decided to try creating my own program. The program I created consisted of two list boxes that listed various family members. The user then selected a member from the left-hand list, selected a "Is-A" relationship and hit the "Relationship" button. The program would then highlight who related in such a fashion. The only relationships hardcoded in the program were parents and sex with some forced relationships like siblings and marriage to aid uncle/aunt calculations. Here is an example screenshot:
MessagingOne welcome feature of Prolog and the windows programming environment is just how easy it is to handle Windows messages. All you do is define the name of the predicate, then create all the necessary predicates with the parameters you want to handle. For example:% ... in startup code ... window_handler( familyTree, ft_handler ) % ... other code ... ft_handler( _, msg_close, _, cancel ). ft_handler((familyTree,1000), msg_button, _, _ ) :- % ... handler code ... .Notice how for the msg_close message, the handler returns a 'cancel' value. The second handler specifies the window and control and the message that is to be handled (msg_button). I found this a lot easier than C-based Windows handler and definitely easier than MFC and message-maps. So, Prolog is excellent for interfacing programming as well? Well, I wouldn't go that far. I'm not yet sold on the idea of programming a complete interface (let's say a database program like Microsoft Access) in Prolog. Creating owner-drawn controls or graphically intensive content could quickly become clunky. If the interface was dialog-based with little (or no) custom graphical content, then programming the interface in Prolog would probably be easier than programming it in C/C++ and integrating the two.
DocumentationA word must be said for the documentation LPA provides for Win-Prolog. That word is "amazing". Win-Prolog comes with 5 Adobe Acrobat files that details Prolog programming, a user manual, Windows programming guide, a reference manual and an some update notes. All documents are nicely done with hyperlinked contents and indices - allowing quick access to the content. Unfortunately, a standard Windows help file is not supplied so context-sensitive help is unavailable. I would love to be able to select a predicate in Prolog, hit F1 and get the information instantly. This aside, a user could not ask for more from the documentation. Well written, a lot of explanatory screenshots, example source and nicely formatted.
MiscellaneousIt should be noted that any program you create using the Personal or Programmer editions of Win-Prolog must run under the Win-Prolog environment. You will need the Developer edition (for £500 extra) to run your programs as stand-alone applications and gain a license to distribute them.Fortunately, due to these restraints, you can easily tie your program into Win-Prolog to augment its abilities. A perfect example of this is the "word completion" program. Once you compile the source you have access to a word-completion database (much like the AutoComplete in VB/VC6). A list of predicates will popup for the word you're typing when you hit F2. The speed of the compiler is also something to rant about. A program never took longer than 0.01 seconds to compile on my computer! This is a joy over the 10-15 seconds incremental compile or 1-2 minutes for a full build in C/C++ systems such as VC++. The compiler is also Edinburgh-standard compliant. After I first installed Win-Prolog, I took a piece of code I'd written on SWI-Prolog and tried to compile under Win-Prolog. To my absolute amazement, it worked perfectly. Having a compiler than conforms to some sort of standard is a must - this is definitely a plus for Win-Prolog in my books.
ConclusionWin-Prolog's Windows support is first-rate, supporting all the modern technologies. I'm not too sure how suited Prolog as a language is to graphically intensive programming, but as far as controls and messaging go, it has been implemented very well.Unfortunately, since Win-Prolog provides no sort of Wizards or additional helpers to write the handler code, finding the various constant values for Windows messaging and API calls can be frustrating. The documentation can help at times, but the lack of context-sensitivity makes it more labourious than it should be. Basically, a top-rate compiler wrapped by a mediocure interface.
Submitted: 03/06/2001 |
|
|||||||||||||||||||
All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -