Dr. Dobb's Journal September 2000
Smart Iterators
Dear DDJ,
I'm writing regarding Al Stevens' March 2000 column. Al writes: "A truly smart iterator would include assertions every time the program dereferences an object through the iterator or changes the value of the iterator itself. The assertions will ensure that the iterator points into a container of the class and type for which iterator is declared. Otherwise the iterator will throw an exception."
I'd like to point out an implementation of Al's idea. In LinAlg, a linear algebra classlib, a Matrix is a collection. You can build a number of views into a collection (for a particular row, a particular column, a subblock of a matrix, and so on). Some views are transient, others are more permanent. An example of a permanent view is an LAStream, which acts pretty much as an STL iterator, as well as iostream. You can fetch the current element of the stream, modify it (if the stream is an Out stream), and advance the stream. If the stream is at the EOF, fetching an element leads to a nasty message (and the program quitting in disgust). When a nontransient view is created, it asserts a "shared lock" on a collection. Some Matrix operations like resizing or destruction require an "exclusive lock." If they fail to obtain it, they crash the program. This makes it impossible to pull the rug from under any outstanding view. Unlike Al's idea, the "lock" is checked only at the creation of a view and by an exclusive operation -- rather than on every usage of a created view. The "locking" operations are very lightweight, and inlined by the compiler (I checked): http://pobox.com/~oleg/ftp/ LinAlg.README.txt; http://pobox.com/ ~oleg/ftp/packages/LinAlg.h; http://pobox .com/~oleg/ftp/packages/LAStreams.h; and you can download the package from http:// pobox.com/~oleg/ftp/packages.htm. It compiles on many platforms.
Oleg Kiselyov
oleg@pobox.com
Database Debates
Dear DDJ,
As an IT professional for 24 years, with the last 14 years as a database developer, I read Tim Kientzle's article "Database Engines: MySQL Versus Oracle" (DDJ, July 2000) with some interest.
In 1994, I conducted a benchmark to choose a DBMS to run in a client/server environment for Furnas Centrais Eletricas, the company I was working in Brazil. The winner was Ingres. It is a very good database -- simple, reliable, scalable, and easy to administer. We used Ingres 6.4, although Computer Associates' current release is Ingres II. One important feature is connectivity. My client used the Ingres gateways and put its legacy data in the new era. During the process of choosing the DBMS, it took the Oracle technicians two days to get the database up and running, while CA technicians spent two to three hours. You can find information about Ingress at http://www.cai.com/, and information on the project I worked on at http:// www.cai .com/clientspotlights/information/ingres_ furnas.htm. Oracle may have market share, but that doesn't make it the best DBMS.
Paulo Barros
Paulo.Barros@mmoh.com
Tim responds: Thanks for your note Paulo. I agree that ease of administration is a much-overlooked feature, and is one of the reasons I keep coming back to MySQL, despite some of its obvious weaknesses. My own experiences installing and administering Oracle have not been particularly pleasant. Like a lot of older software, Oracle has tried to graft on administration tools to simplify things, but the result is that you have even more pieces to figure out.
I'm certainly aware of Ingres, but don't have any hands-on experience with it. Ingres was originally the fruit of a University of California at Berkeley research program, and was later commercialized. That same research program later produced Postgres, which has been enhanced into the open-source PostgreSQL. I've been considering PostgreSQL for some new projects, and so far, it looks pretty good.
Dear DDJ,
Of course, the main thrust of Tim Kientzle's July 2000 DDJ article was MySQL and Oracle, but several other DBMS were mentioned in passing. I think DDJ readers should also know of the existence of PostgreSQL. This is a DBMS that is open source and freely available under a version of BSD copyright. Like Oracle, PostgreSQL supports transactions and commit/roll-back. In some ways it is more advanced than Oracle. It deserves an article in DDJ. Look at http://www .postgresql.org/ for more information.
Paul Condon
pecondon@quiknet.com
Dear DDJ,
While a database guru might read Tim Kientzle's article "Database Engines: MySQL Versus Oracle" (DDJ, July 2000) with relish, I noticed a few issues that might confuse a database novice. Most importantly:
Don't forget, there are usually other APIs and configuration involved outside of the SQL seen from the front-end application. Dataset integrity is most important to most companies. This is achieved through support for redundancy and parallelism at many levels. I was left with the feeling that Oracle is expensive and its installation and configuration is a nightmare. This begs the question -- Why do so many companies use it? My list:
Tony Duarte
Tony_Duarte@justInternals.com
Margination
Dear DDJ,
This letter is written with regards to William Fishburne's article "Margination and Project Gutenberg" (DDJ, May 2000). The statement that "there is no word processor in the marketplace (free or commercial) that meets these interesting requirements" is uninformed. My text editor of choice, Kedit (from Mansfield Software) has had basic "word processing" features in it since the early '80s. Suppose you want to format your paragraphs as follows: ragged right edge, maximum line length of 65 characters, indent the first line 5 characters, and put two spaces after each period. You do this in Kedit by setting the two state variables: set format nojustify blank double and set margins 1 65 +5. Paragraphs are also easily reformatted at any time simply by pressing Ctrl-F.
Howard Gantz
William responds: Howard, I love the Kedit editor, too, and used it many years ago. I went to the Mansfield web site in hopes that your assertion (that it could handle the margination requirements mentioned in my article) were true. I could not find anything that indicated this would be the case. Unless I misunderstand your example, you have set a MAXIMUM line length, not an OPTIMUM line length (which could be exceeded). This is the problem I was attempting to overcome by writing the programs I did. I still have not found any word processor which allows you to assign an OPTIMUM line length instead of a HARD MAXIMUM line length. If I have misunderstood Kedit, or any other word processor, please let me know. I strive to do thorough research and would be terribly embarrassed to have missed an editor with the capabilities mentioned in the article. I would also like to say that I have received a large number of suggestions for optimizing the applications I developed and have truly enjoyed the many e-mail and even some phone discussions I have had! I have found the DDJ readers to be a largely supportive group of very talented programmers.
Dear DDJ,
Having seen so many organizations write so much drivel that came directly from the high-tech lobbyists brochures, it's refreshing to read your article. Your courage is appreciated. I'm surprised the Silicon Valley companies haven't burned you in effigy.
There is one misstatement in your column that is often cited by the industry lobbyists, and unfortunately you include it here--that most H-1Bs are foreign graduates of U.S. universities is totally without foundation. Please double-check your facts.
A second item in your column that I must also disagree with is the premise that programming skills in legacy computer languages need a Y2K-like crisis to bring back those dinosaur skills. (A play on words from your description of COBOL programmers.) It is my experience from 18 years of working with programmers that a good programmer is a good programmer, regardless of the language he is using. If a person was a good COBOL programmer, he can also become an adept Visual Basic programmer, Oracle, PowerBuilder, SQL, HTML, Java, and so on, programmer, given a minimum of retraining. The truth is that companies will cite a need in a new language and bring in an H-1B, not because of his extensive experience in the new desired language, but because the older American worker costs more and this is a good excuse to get rid of him.
Please do not use my name. The company I work for has many H-1B's and I would be the next casualty if my name is used.
Name Withheld By Request
DDJ