March 01, 2001
arch 2001 - Pick a Language, Any Language
Some peoples' favorite language is whatever their customers will pay them the most to program in. And others beg to differ as our readers, writers and contributing editors debate a gamut of past and present development approaches.Last Halloween we invited Software Development's contributing editors, editorial advisors and writers to send us their software horror stories. Reader response for our compilation of scary development vignettes in the October issue was overwhelmingly positive, so we decided to return to the well with questions focused on languages and algorithms. Here is a selection of the responses we received to the questions "what is your favorite language or algorithm?" and "what makes it special, useful, or elegant?"
Positive Results The 8085 addressed only 64K of memory, and we had used just about all of it. It had no floating-point hardware, and we were only using integer operations until we received a request to add a couple of decimals to the percentages given in reporting. This would have been a nightmare, but I remembered an algorithm from grammar schoollong-hand division. It's all integer math and will produce as many decimal places as you please. We were so tight on memory that I had the cursor positioned on the terminal before the computation and popped each digit out as an ASCII byte as it was computed. After working the full range of languages, from writing boot ROMs in assembly, using business languages like FORTRAN and COBOL, system and application development languages like Pascal, C and C++, Internet languages like Java, and various scripting languages, I have to say my favorite is actually VB/VBA, because the projects where those languages are appropriate typically yield positive results quickly. I'm tired of doing plumbing and tired of large-scale systems with their longer development times and lower success rates. Andy Barnhart
Roll Your Own After that, I read my compiler error messages with more respect. Compiler design and compiler tools are a lesson in large system design. In the early days of high level languages, building a compiler was an enormous undertaking. Now an undergraduate student can build one during a one-term course. If you've never learned about compiler design, I recommend you pick up a book or take a course. The tools and design techniques do not fit neatly into a functional or object-oriented structure, but they work extremely well together to simplify the overall design and speed up development. Hugh Bawtree
Smalltalk You can string messages together because a message always returns an object; the default is the nil object, as you see with the "if statement" code in Figure 1. I first invoke the firstName getter operation on the customer object to obtain a string object, the value "Scott" in this case; then I send it the '=' message with the parameter "Bubba," which would return a boolean object (with the value of false) which in turn is sent the message ifTrue: ifFalse:. The ifTrue: ifFalse: message takes two code blocks as parameters, a code block being a collection of one or more Smalltalk statements (one or more method invocations on objects). Smalltalk is a little strange at first because you need to actually think in terms of objects, not the quasi-object thinking that you do when coding Java or C++. As I said before, in Smalltalk you truly only have objects to work with, and the only thing you can do is send them messages. Smalltalk has been around since the late 1970s, although it came into its own in the early to mid-1990s, just in time to be squashed by Java. Oh well, chalk that up to imperfect market forces. However, don't get me wrong, companies such as IBM (www.ibm.com) and Cincom (www.cincom.com) are still selling Smalltalk worldwide and open efforts such as Sqeak (squeak.org) are gaining popularity within the object-oriented software engineering community. If you are interested in learning more about Smalltalk, the Smalltalk Industry Council (www.stic.org) is a good place to start. Scott W. Ambler
Smalltalkers of the World Unite! Martin Fowler
MVC Although MVC has its roots in Smalltalk, it's really more of a way of partitioning the design of interactive software than either an algorithm or language construct. The goal of MVC is to divide the functionality of an application into three logical categories: the "model" that contains the internal workings of the program (the algorithms), the "view" or visual display that shows the user the state of the model, and the "controller," which is how the user changes the state or provides input. Even by today's standards, MVC is still an influential concept. According to Erich Gamma in Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley, 1995), "looking at the design patterns inside MVC should help you see what we mean by the term pattern." Doug Rosenberg and Kendall Scott (Use Case Driven Object Modeling with UML, Addison-Wesley, 1999), likewise acknowledge how closely Model-View-Controller maps to their innovative Boundary-Entity-Control approach to analysis and design. Roger Smith
The C++ STL What struck me most was its sheer concentrated power. It sorted, did permutations, generated sequences of elements for testing and so much more. Yet all the code fit in a small directory (there being obvious comparisons with large bodies of code that just manage to generate GUI components). And its integrityat the core, the STL code re-invoked itself, making use of functions available for use from user-level code, unlike most system-level code, which reserves "special" mechanisms for its own internal use. When working with assembler code long ago, I'd realized that opportunities existed for re-implementing parts of an algorithmfor example, finding only the integer dividend instead of both dividend and remainder when dividing might yield extra efficiency under certain circumstancesbut I had never before seen "modular algorithms," such as partition made available as a subalgorithm of quicksort. However, what really won my heart was the STL's resonance with standard C and C++ coding idioms. The copy algorithm, for example, was almost exactly the one-line loop of strcpy through which most beginners are introduced to the dangerously compressed elegance of C and C++, with pointers extended to iterators. The STL did postpone the promulgation of the ANSI C++ Standard, at the same time as some momentum was lost due to Java's emergence as a competing focal point, due to maintaining the integrity of the C++ standard by re-architecting the whole under its influence; string became a template class, the iostreams facilities too, and exotic extensible mechanisms for locales were crafted. I still get dizzy when I think of trying to implement the extensions to templates that were added to support what are now the ANSI C++ standard template algorithms and container classes: partial specialization, for instance. (So much for the C++, C and Unix school exemplifying a tradeoff favoring implementation simplicity over user capability!) However, the ability to use templates to compile a solution as directly tailored and efficient as possible for your particular application in its particular environment remains a unique feature of the C++ language. Today, the full promise of the STL is still being delivered on, with, for example, the Generic Graph Library (www.lsc.nd.edu/research/ggcl); I've long used the code for graphs as my standard "litmus test" of data structures implementations. Just as the STL uses the concept of iterators to bridge containers and algorithms, so the GGL uses the concepts of vertex, edge, visitor and decorator to bridge graph structures and graph algorithms. Finally, the structure of the GGL feels like it can bear the complexity required. The architecture of the STL in the standard C++ library also has succeededwhere a thousand sterile papers never couldin expanding the horizons of C and C++ programmers to include the beauty of abstract type systems and a more applicative style. Christine Bouamalay
Show Me the Money! Many of my colleagues would recoil in horror at my mercenarial attitude towards programming languages. What kind of programmer goes around selling his skills to the highest bidder? A programmer who has a family, a mortgage, car payments, wants to retire above the poverty line and enjoys the occasional hockey game. A programming language is just another tool. Actually, this mercenarial attitude protects the customer's interests. If the customer is willing to pay me a premium to work with a language, then that customer must perceive an advantage to using that language. Many programmers who only argue the academic merits of their favorite language overlook other factors that influence the choice of a programming language. Many engineering firms still have large portfolios of Fortran code because Fortran does its job extremely well. Many companies want to minimize the number of languages and tools they support. And many companies need to be able to easily hire talent, therefore choosing their tools and languages based on the skills of people readily available. OK, really now, what is my favorite programming language? None of them. While IT is a great industry to earn a living in, the tools leave a lot to be desired. Case in point: While I've made a ton of money designing and programming systems in C++, Bjarne Stroustrup must have been hauling in big cases of that strong Danish beer to all the C++ standards committee meetings. Steve Adolph
Duct Tape Perl's light side: gazillions of existing system administration tools, ready for you to download and adapt to your needs. In addition, Perl serves as the lingua franca of system administrators, much as all aviators understand English. The dark side: While Perl doesn't completely deserve the "Write Once, Read Never" label hung on it by its detractors, there is no gainsaying the fact that understanding Perl code requires an eye for detail. Although Perl is no COBOL, it is readable if you take your time. In spite of this, three out of four administrators recommend Perl for whatever ails your system. Warren Keuffel
The Logical Choice The algorithms to create and exploit binary space-partitioning trees are simple, practical, and with behavior that is profoundly nonintuitive. Given a complex geometry, pick any face and extend it into a plane, sort the rest of the geometry into that which is "in front of" or "in back of" that plane, splitting intersecting faces. Recurse on the two resulting sets. The result is well, Castle Wolfenstein 3D, which was to the graphics in competing PC games what Star Wars was to Logan's Run. The follow-up to Wolfenstein was a little diversion called Doom, and the BSP (binary space partitioning) has been the core data structure of video game graphics ever since. So the next time you frag some low-ping buster who is camping over a regen point, give thanks to the magic of hierarchically partitioned convex subspaces. Larry O'Brien
Attack of the Valkyrie In college, it was Pascal. Niklaus Wirth's pretty little teaching language had just a rudimentary I/O library, so I sat in the lab with the other nerds, edit-compile-testing. Time to leave, I had a date. One more compile. Surely it can read in a string, for crying out loud! Wait, one more compile. And another. And another the only sound in the room was clicking keys. The sound stopped as the door slammed open. Framed in it was a Valkyrie-female, beautiful and certainly warlike. The nerds stared, openmouthed. A girl? Above the door, I noticed, was a clock-I was now 95 minutes late. She smiled sweetly. The other guys felt their blood warming. I felt mine freezing. "Rick? Rick Wayne! So great to see you. Hey, here's my number. When you get a minute ... call me!" A swirl of skirts, the slip of paper drifted to the desktop. The door slammed again. Good thing I managed to catch her, otherwise I doubt she would have married me. Years later, it was C. Pointer bugs. References to deallocated memory. Array overruns. I was so cranky, my superiors gave me my own officemore as a workforce-safety measure than a perk. The pressure was on to get the release disks cutthat night, in factand I was the very last obstacle. Edit, compile, test. Crash. Dang. Edit! Compile! Test! Crash. Argh! EDIT! COMPILE! TEST! Crash. PUNCH FILING CABINET! EDIT! COMPILE! Update resumé. Next it was C++. Better. My demeanor improved to the point that I was given an office near the director. But I was spending way too much time on silly things, like debugging memory problems (still) and trying to get incompatible libraries to link. Then I downloaded JDK 1.0.2, which changed my working life forever. Sure, it was dog-slow, and they kept changing the class library. But I never had to deallocate an objectwhen there were no more references, the system garbage-collected it for me. And no pointers. And array overrun protection. A real class library. Woo-hoo! And, miracle of miracles, when I did manage to screw up, I was presented with a nice exception trace, including line numbers, instead of, oh, say, having the machine reboot. I was hooked, and never went back. Today, I can even share an office. Paul and I sit back-to-back, and he has no fear. But ever since he inherited that legacy Pascal project, I've been nervously looking over my shoulder Rick Wayne
A Mongrel Language Admittedly, C++ is a difficult language to master. In fact, it's a difficult language just to learn. But everything really worthwhile requires some sacrifice, and maybe some blood and tears. And, if my program should have a bug (this doesn't happen very often, of course), I can get all the way down to the chip level and really mess with the processor's mind. Can't do that with Java, can you? I admit I come from an earlier day of programming. It was an era when a program actually ran on a real machine, not a virtual machine. And we didn't have all these "sissy" tools like symbolic debuggers we just learned to read machine code. More than once I debugged a third-party DLL without any source code, and found the problem. But, eschewing all further levity, I do have a special fondness for this mongrel language. It reminds me of a Cincinnati chili with all these great ingredients combined to achieve an end greater than just a fast meal. C++ is more than just a programming language. It's a way of doing programming, and I lament that so many using "the other language" haven't experienced the privilege of spending time with this superior programming tool. Gary Evans
| ||||||||||