J3 - J Grows Up!
Vector 13:1, page 48
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 48
The following was posted to the newsgroup comp.lang.apl:
As many readers of comp.lang.apl know a new version of J has been released. As a J3 beta-tester and longtime J’uggler (J user) I’ve had an opportunity to beat up on the new system. Here’s a brief summary of what J3 has to offer.
Let’s get straight to the main point. With version 3, J has come of age. If you have new projects, particularly on Windows systems, take a good look at J. Here is a sample of what you will find:
Better Documentation¶
Iverson Software has often been criticized for producing documentation that requires serious study. Fortunately, J3 continues this noble tradition.
J3 comes with three main documents (distributed as Windows *.hlp files and as printed manuals). They are: The Dictionary, A User Manual and J Phrases. The dictionary has changed very little from previous editions. It’s still the deep classic we’ve all read and cherish. Changes and editions have been added and the formatting of the document has improved but the dictionary is still "The Dictionary." The User manual is very similar to J2’s manual. New sections have been added and many changes have been made to reflect the facilities in the new system.
I found the J Phrase book the most interesting. For old, and I mean old, APL’ers that remember the FinnAPL Idiom booklet printed way back in the early 80’s the J Phrase book will seem familiar. The phrase book is a collection of over 1,000 tacit J definitions. Many phrases are direct translations of FinnAPL idioms but many are pure J and can not be easily expressed in APL. This is a fabulous resource that any serious J programmer should not be without. As a plus the phrase source code is distributed with J3.
Performance Improvements¶
Prior to release 3, J often came up short on standard APL benchmarks. Scalar (atomic) function processing has been reworked and J is now as fast, and often faster, than most APL systems on scalar integer and floating point algorithms. The improvements are in the (3 to 5 times faster) range for scalar functions.
The speed boost runs through the entire system. For example 32-bit ODBC is faster in J3 than APL+Win. The power conjunction, (not available in APL systems), is also much faster. Performance is no longer a valid reason for not using J.
Language Enhancements¶
New "Level" words L. and L: have been added to J.
L.reports the maximum nesting level of a noun. It’s similar to APL2’s depth primitive.L:the "level" conjunction applies its left argument at the levels specified by its right argument.
The L: conjunction makes it easy to do APL2-style pervasive scalar function processing in J. L:’s fine level control also makes it possible to do all sorts of "at depth" operations that are not easily coded in APL2.
n. m. u. v. argument designators have been added to make it easier to define explicit adverbs and conjunctions in J.
The grade primitives /: \: have been extended to all arrays. This is a very welcome extension. Don’t groan, but J now makes the grade!
OLE automation¶
The professional editions of J support OLE server automation. You can run a full version of J as an EXE server or you can run a stripped down version as an in process DLL server. It’s now possible, and indeed easy, to farm out array calculations to J from any Windows application that can serve as an OLE automation controller. Right now the list of OLE controllers is short: Excel 7, VB 4.0, MS C/C++, but this is such a significant technology that within a year every serious Windows tool will support OLE automation.
Personally, OLE automation support in J3 has changed the way I program and how I attack problems. It’s now easy to doll up a user interface with the dumb blondes of software "Powerless Blunder" and "Visionless Bs" yet do the real data processing with J under the hood and out of sight.
Improved Debugging Facilities¶
A new set of 13!:n debugging verbs have been added. It’s now possible to examine the state of the execution stack under J program control and to set "latent" debugging sentences that execute upon debugger breaks.
The new debugging facilities make it easy to write all sorts of "tacit" tools, like code profilers, space monitors, nice tracers, et cetera.
J3 debugging is still command-line and programmer-oriented which frankly is a blessing.
32-bit ODBC¶
The data driver 14!:n verbs have been reworked in the professional 95/NT version to provide 32-bit ODBC. A new column-oriented fetch primitive has also been added.
When using "good" 32-bit ODBC database drivers the new ODBC sub-system is much faster, and able to handle much larger data objects than 16-bit ODBC. 16-bit ODBC limited J to BLOBS of 64K. Now it’s up to a respectable 2 Gigs.
New Window Driver¶
The J3 window driver 11!:0 has been completely reworked to support new 95/NT controls and to provide better event processing. The new driver is not compatible with J2 and scripts using the old driver will have to be changed. One change that I particularly like is treating all Window driver errors as J domain errors.
The form editor has also been improved to take advantage of new controls and to exploit J locales to improve the modularity of J GUI code.
Improved utility scripts¶
The standard scripts distributed with J have been revised to take advantage of improvements in the language and window driver.
I have used J for years to solve problems. It’s always been a good ad-hoc problem solving tool. J3 is now a good system-component tool. I’m no longer going to be shy about including J as a part of client systems. In fact I plan to focus a large part of my programming efforts in the next year on exploiting J’s powers via OLE/DLL in 32-bit Delphi and VB environments.
A Review of J3¶
My previous Release of J was 2.01. I bought it mostly because I was just curious how the development system with its GUI support would look like. I had mixed feelings about the GUI engine I found there, the so-called "window driver". I liked the level of abstraction and simplicity and in particular the approach to access the window driver via a clean, text-based protocol instead of an API. However, I never liked to do the tedious house-keeping necessary for the proper dispatching of events, not in any other window system and not in J, either.
My interest in the GUI facilities only became revived when I saw a short demonstration of the interface builder which was part of the Professional Edition. It made it not only easy to lay out the forms, it also took care of the association of events and the corresponding J code. This was exactly what I had missed. But since I am usually not running Microsoft Windows — I only bought it for running J- I did not bother to acquire the Professional Edition back then.
I was therefore very pleased to learn that this form editor would also be distributed with the Release 3 Freeware version. I initially got that to have a closer look at the form editor, but in the end I was pleased by a lot more things than just that. This review relates to the Professional Edition of Release 3.
GUI development¶
After installing J (it’s a breeze) I went directly to chapter 7 in the User Manual which introduces the form editor. This chapter is a very well written tutorial which guides you through the development of a small application from beginning to end. It really pays to sit in front of the computer and to follow it step by step. I got so carried away that it was well past midnight when I switched off the computer.
It is not just that you now have an interactive tool that helps to lay out your forms and takes care of all the coordinates involved. Two other things that are not so prominently visible at first sight but nonetheless just as significant have been changed, too.
The system comes now with a default event handler that does all the hard work for you. The association between events and J code under that scheme is not any more through case tables but implicitly by name. If your form f has a button called foo, a verb called f_foo_button will automatically be found and invoked as a handler for it. (In fact, there is some search scheme to locate a handler.)
The other new thing is that all controls are now regarded as maintainers for some value. The value of an edit control is the text, the value of a checkbox is a boolean, and so on. The new set command is used to change those values under program control. Reading the values is even easier. The default wdhandler will atomically extract all information from the event structure and assign them to ordinary J variables. At the same time, many wd commands have been simplified to return the result directly. The overall effect is that there is no need any more to use wddata.
Good use of locales is made to prevent a cluttered namespace. It helps here that J locales are very simply structured. You don’t have any trouble to access the data from several controls at the same time. As a UNIX hacker I am just familiar with the X Window System and its various offsprings. Tk/Tcl there and J’s wd are now very comparable with respect to coding style and ease of use. Tk has a slightly more sophisticated widget set, but J is clearly more mature than Tcl as a frame language and better suited to manage an entire application.
In terms of features, the current developments of Microsoft Windows seem to be closely tracked. J’s window driver has new controls inherited from the Windows95 and NT environment, in case you happen to run that. As long as portability is not an issue for you, you can now make use of some new native Windows95 controls. Progress, status and trackbars, and spin buttons are the simpler new features, but tabbed panes, the RTF text control, and toolbars can have a big influence on the look and feel of your application.
While this strong support is all good news for Windows users, there is however still no port of the window driver for the X11 system available yet. I am still holding my breath for it and am hoping that more and more dependency on MS-Windows goodies will not prohibit that goal sometime. It would be very nice to write portable applications and GUIs in J.
Documentation¶
The two books Introduction and Dictionary and User Manual are by and large the same as in Release 2. Of course, they have been extended to cover the new facilities and the language and the system. As before, beginners will appreciate the usage examples that accompany the terse Dictionary entries since Release 2.
The documentation kit now also contains the new Phrases book. Don’t be fooled by the tabular layout that is mostly used. Phrases is much more than just a large collection of idioms ordered by topic.
It also serves as an introduction to several programming pragmatics related to tacit programming which is used throughout the book. I personally find that many typical programmer’s questions are addressed here which I felt uncovered in the earlier Programming in J. Introductory notes and many simple examples guide you in a very gentle pace through the flexibility and facets of a basic concept before it is used in combinations with other elements. For example, more than two pages are dedicated to simple uses of v&n which prepare you to recognize such mini-groups quickly in larger contexts. Another page demonstrates just the various indexing capabilities of { and corresponding APL expressions using the bracket notation.
About half of the book consists of side-by-side listings of J phrases and their descriptions, e.g. 0 1&#: and "whole and fractional parts of y".
Language changes¶
As always, it is advisable to have a look at the status.doc file and read the related entries in the Dictionary anew.
There are neither radical nor incompatible changes in the language this time. It appears that most of the work done was concentrated on performance enhancements, the smoothing out of some finer nooks and crannies and on new facilities for J as a development system.
The language itself has been quite stable and the only modifications you might have to apply to your existing code would be changes related to the window driver which are well worth such a inconvenience. Since the new default handler is just a utility routine in J and the older hand-coded wait; loops can still be made, you should be able to continue with the old scheme and just a few changes here and there. But all in all, you should benefit from converting to the new scheme of associating events and code.