Book and Product Reviews

Picture of aegisjournal

aegisjournal

Table of Contents

From the AEGIS e-Journal, Volume 10 Number 12, December 2007

Dyalog APL, Version 11 Dylog Limited http://www.dyalog.com/ +44(0)1256 338461 In his wayward youth this editor was an APL programmer. At that time, before even large companies could afford their own computers, APL was the leading programming language. Indeed, the first portable-ish computer from IBM had APL built into it. APL had one big virtue: It was very fast to program because it uses less code than do other computer languages. As an example of the small amount of code involved, imagine you are an average programmer, and your boss asks you to write a program to do simple arithmetic averages. How do you calculate an average? This isn’t a trick question: You add up the numbers and divide by the number of numbers. In APL operations can be performed across a bunch of numbers using the forward slash symbol (/) which means that if you wanted to add up the numbers 1 2 3 you would type in +/1 2 3 ÆGIS, December 2007 12 hit return, and the computer would print the number 6. To show the number of numbers, APL uses the Greek letter rho (ρ). In theory, then, to get the average of 1 2 3 you would type in +/1 2 3÷ρ1 2 3 and the computer would return 2. In practice this is not the best way to do it, as APL has no rules of precedence: Instead, it works strictly left to right, so, if written as above, it would add up each of the individual numbers divided by the number of numbers. That is to say that it would add up 1÷3 and 2÷3 and 3÷3. While this is not a big deal with three numbers, it is a lot of extra processing with ten thousand numbers. To get around this we put parentheses around the numbers to be added up, which gives us (+/1 2 3)÷ρ1 2 3 which does one addition and one division. We obviously don’t want to keep typing individual number, so we use variables, which are assigned using a left pointing arrow. So now our computation would look be nums←1 2 3 (+/nums)÷ρnums The only problem with this is that APL works on multi-dimensional arrays, and the / really works on the first dimension. Since we want the average of all the numbers, independent of the shape of the array, we use a comma to ravel an array to a vector. Which means or calculation now becomes nums←,1 2 3 (+/nums)÷ρnums For readability we would probably use a separator character, which is a diamond, and assign the number and do the calculation on a single line nums←,1 2 3 ◊ (+/nums)÷ρnums So how do we turn this into a program that will take in a bunch of numbers and pass a result that can be used by other programs? The del character tells the computer that we are going into self-improvement mode and creating a new function. So our almost-complete program might say ∇ r←avg nums [1] nums←,nums ◊ (+/nums)÷ρnums ∇ The variable r was chosen arbitrarily. Why is the program only almost- complete? Because it is imprudent to write any program that lacks comments ÆGIS, December 2007 13 telling what it is you are doing. Or at least think you are doing. APL uses a little filament (as if from a lightbulb) before the comment to allow you to illuminate your code. So our real program might (at the very least) say ∇ r←avg nums [1] ⍝Purpose: Simple arithmetic average, shape independent. [2] nums←,nums ◊ (+/nums)÷ρnums ⍝Ravel numbers to a vector, add them up, and divide by the number of numbers. ∇ Congratulations: You are now an APL programmer! How would this compare with a program in other languages? Ask someone on your programming staff to show you the code for the program they have written to do simple arithmetic averages: You will be horrified. As it turns out, APL is not only fast to write, but it also runs fast. It was not uncommon to see someone develop a prototype in APL in a short period of time, then spend a huge amount of time and money converting it to what they thought of as a real programming language, only to find that the APL prototype ran almost as fast, and sometimes faster. And the application could be maintained more easily in APL because there was so much less code. APL largely disappeared for three reasons. First, by the beginning of the 1980s corporations were able to afford computers. They wanted to buy the commercial version of APL that they had been using for timesharing, but the timesharing companies, not recognizing that the paradigm had shifted, didn’t want to sell it. By the time they came to their senses, their clients had largely gone in-house with other languages. Second, when the young Microsoft tried to buy an APL interpreter, the timesharing vendors wouldn’t sell it, so Microsoft chose Basic as their programming platform. Third, while APL’s development efficiency was good for a timesharing environment, it was a disadvantage in the corporate environment. As the VP of a large insurance company put it, “I have 600 COBOL programmers working for me, which makes me a very senior member of the management team. If I did this work in APL I’d have 40 people working for me and be a division leader.” Since managers are often rewarded on headcount and budget managed, APL was an inappropriate career move for a cost center. After assuming that APL had been pretty much dead, out of the blue this editor mysteriously received three inquiries about doing APL programming ÆGIS, December 2007 14 work. This lead us to believe it was time to look at APL in its current incarnation, and see how it had changed in the last decade or so. We looked at Dylog APL, and were very impressed: This is definitely not your mother’s APL! All the fundamentals were there, and worked as flawlessly and efficiently as you would expect from an industrial-strength programming language. A lot had been added that was not in APL when we were programming. We will ignore here new primitive functions (the single symbols) because we think they will be of more interest to programmers than to managers. What is of interest is that APL now includes GUI facilities that did not exist in our past, tools to integrate to anything else on your network, and even a .Net interface. What does this mean in practical terms? It means that you can have access to all the data in a modern network environment and slash your programming effort. While we frankly don’t envision APL regaining the position it once had – it still faces the defect of needing far fewer programmers than if you work in Basic, C, COBOL, or any other programming language – it remains a viable, state of the art, and effective programming environment. If you find yourself having computer project responsibility, but not enough time or money, Dyalog APL is well worthy of your consideration. 7. Subscription/Unsubscription/Copyright Information •• ÆGIS is supported and maintained by voluntary efforts. This publication is owned, published, and copyright © 2007 by The LUBRINCO Group Ltd, Inc. and Financial Examinations and Evaluations, Inc. It is edited jointly by Richard Isaacs (RBIsaacs@lubrinco.com), L. Burke Files (LBFiles@feeinc.com), and Terry Philips (TPhillips@aegisjournal.com). LUBRINCO provides services in three high-threat areas, too specialized to be dealt-with in-house, that can adversely affect domestic and international bottom lines. • Identification, valuation, and protection of intellectual assets and critical information. • American businesses lose $300 billion in revenues annually to competitive intelligence, economic espionage, inappropriate disclosure, and information theft. ÆGIS, December 2007 15 • LUBRINCO provides private sector consulting access to OPSEC, the government-standard process for identification, valuation, and protection of intellectual property and critical information. • Implementing an OPSEC program is likely to increase revenues for an at-risk operating group by $75 million. • International asset location and due diligence. o Location of concealed assets in fraud, theft, and divorce. o Financial fraud, anti-money laundering, and anti-corruption program development and training. o Due diligence to prevent fraud and loss in China, Central and Eastern Europe, Central Asia, the offshore financial centers, Latin America, and the Caribbean. • Protection of management, staff, and families. o In the high-threat environments of Latin America, Africa, the Mid- East, and Southeast Asia. o When traveling and living overseas. o When transporting items of substantial value. LUBRINCO identifies and quantifies threats and vulnerabilities, and their associated risk, then manages the vulnerabilities so you can transfer or live with the residual risk. We prevent disastrous financial loss to your company, and physical harm to you, your family, and your staff. For information on LUBRINCO and its services, or for the archive of all past issues of ÆGIS in PDF format, please go to http://www.aegisjournal.com/. Subscription to ÆGIS is available for $15 per year in North America and $20 per year outside of North America. To sign up for a complimentary subscription to ÆGIS or the ÆGIS PDF notification list, send an email to subscribe@aegisjournal.com. To subscribe to our AvantGo channel, go to http://avantgo.com/channels/_add_channel.pl?cha_id=1773 To be removed from the subscription list, send an e-mail to unsubscribe@aegisjournal.com. If you know of anyone else who should be receiving ÆGIS, please send their e-mail address to subscribe@aegisjournal.com. ÆGIS, December 2007 16 If there is a topic that you would like to know more about, send it to editor@aegisjournal.com and the editors will consider it as the topic for an article in an upcoming issue. If you would like to submit an article for publication in ÆGIS, send it as an attachment to an e-mail to editor@aegisjournal.com. Submission of an article certifies that (a) all information in the article is in the public record, or (b) that you are authorized to release any personal or corporate proprietary information contained in the article, and (c) that none of the article has previously been copyrighted. The submission of materials for publication in ÆGIS constitutes a license to LUBRINCO, and/or Financial Examinations and Evaluations, Inc, their assigns, associates, or affiliates, to abridge and/or edit said submission, and to copyright and publish/republish any submitted materials in whatever written and/or electronic form they may choose. If you would like to go beyond normal fair-use in reproducing articles from this issue of ÆGIS, you may do so freely as long as appropriate source, copyright, accreditation, and link to the ÆGIS Web site is included. This should be in the form

Article Title, from the December 2007 ÆGIS (© 2007 LUBRINCO and FE&E), to be found at http://www.aegisjournal.com/. ÆGIS is a forum for the exchange of information, ideas, operating styles, theories, and related topics for corporate managers who make decisions about threats typically outside the expertise available in-house, yet which have the potential to affect their company’s domestic and international bottom lines. Nothing appearing in ÆGIS should be construed as legal advice. The information provided is “general information,” not “specific advice.” The solution to any problem is highly dependent upon the precise facts involved. Thus, before making any reliance upon anything said here, you should consult with an appropriately skilled professional. Opinions expressed by contributors are not necessarily endorsed by the publisher, and may be presented to encourage a dialogue among subscribers. The publisher and any re-publisher cannot be held responsible for any loss incurred as a result of the application of any information published in ÆGIS. Please be safe, and be smart.

Share This Post

You might also enjoy reading

Author

Table of Contents