Articles - Choosing a ZIP Library for Delphi
Most of software developers sometimes need to compress data for their projects. ZIP format (PKWARE Inc.) is more frequently used in the world for making archives. The main advantage of ZIP format is its wide range of supported platforms and its worldwide usage for a long times. Another reason to use ZIP is rather fast compression algorithm called Deflate. It provides rather good compression rate on text files and files with regular structure. Unfortunately Deflate cannot achieve high compression rate on large pictures, especially scanned images, binary data and most of other data that has no long repeating sequences of symbols. Also ZIP cannot compete in compression rate with more strong algorithms like BZIP, PPM, RAR, ACE. Nevertheless ZIP is usually much faster that makes it a good choice for software developer.
There are many different libraries supporting ZIP for Delphi. I have tested most of them and made some investigations of their functionality, performance, support and other important factors for my company (Premium Systems, Ltd). My company has some corporate rules for choosing third-party tools to be used in its projects. At first, we never use any products without preliminary testing by personal of our company. We do not believe in any advertising, articles in popular magazines, web sites, newsgroups, conferences and so on. We had too many problems with well promoted products in past and do not want to have them in the future. Also we always compare many different products of the same purposes to find the best suitable solution for us. Unfortunately I cannot publish all of materials collected by me due to our corporate rules, however everyone can easily check my results by writing his own test program. It is not a very hard task for experienced programmer. ;-) You will have spent much more time converting your programs from one library to another when you will face real problems that can be solved only by switching to another product.
As Deflate algorithm used in ZIP is rather fast, the performance is one of key factors for any ZIP library. Obviously there is no need to compare them by compression rate as all of them has the same algorithm (Deflate), so compression rate varies in a very short range (< 1%) depending on implementation and speed optimizations. The second factor is a functionality that is very different in various products. Another important factor for developer who chooses the ZIP library is price and license types, as well as support and a frequency of new releases. Let’s look at the modern ZIP libraries available for Delphi more closely:
- Performance. There are two main factors determining the performance of a ZIP library: the Deflate implementation and performance of the archive modification routines. Deflate implementation speed generally depends on the source code language and its speed optimizations. The products with Deflate written in Pascal like Kevin Boylan’s VCLZIP, Microchip Data Systems ZipTV and Turbopower Abbrevia are slower by 15%-20% compared to the products with Deflate written in C that uses either ZLIB (AidAim ZipForge) or InfoZip dll (DelphiZip, etc.). Well, most of us know that Pascal compilers have no such powerful optimization tools like C ones. As for archive modification it generally depends on the programmer interface of the library. ZIP format has most of headers at the end of the ZIP file, so any update operation requires full or partial rewriting of the ZIP file. If library does not support operations with any set of files by single update operation you will have to rewrite the whole (or part) of ZIP file much more times. The most flexible approach to the solving of this problem is used in AidAim ZipForge, which has a transaction system that allows to make any add, update or delete operations with any set of files within a single transaction, so the ZIP file will be rewritten only once on committing the transaction. All other libraries has no transaction support, so if you will update your archive frequently they will loose in speed essentially, as rewriting of a large ZIP file takes too much time, and they will do it more times than ZipForge.
- Functionality. The main features of a good ZIP library are: multi-disk spanning support (that allows to store archive on multiple volumes like floppy disks or CDs), splitting support (that allows to divide an archive to multiple files for transmitting via network, for example) and ZIP64 support (that allows to store files larger than 4 Gb in the ZIP archive and provides larger maximum size of the archive – 2^64 bytes in a ZIP64 versus 2^32 bytes in a previous ZIP formats). The most of libraries supports multi-disk spanning, splitting is supported in ZipForge and VCLZIP, and ZIP64 is supported only in ZipForge at this moment.
- Prices and licenses. DelphiZip is totally free, ZipForge is free for personal use (and rather low prices for companies) and Abbrevia is under LesserGPL or Mozilla 1.1. ZipTV prices starts from $300.
- Support and frequency of new releases. The most frequently updated product is a ZipForge (9 public releases for 8 months), has also excellent support – it looks as AidAim is a solid company with responsive technical support team. VCLZIP has also good support, but this product is updated more seldom – most probably due to it is developed and supported by its author, Kevin Boylan. The Abbrevia is open source now, so I do not think that there will be any new releases or bug fixes in the nearest future. DelphiZip is a version 1 for some years, there is no any support (at least I was unable to contact with its authors during the whole week). So if you need to switch to new versions of Delphi as soon as they will be available you should use ZipForge (AidAim Software is a Borland Technology Partner) or VCLZIP (but its Delphi 7 version was released later than ZipForge that comes with Delphi 7 Companion CD).
- Ease-of-use and documentation. This is a very subjective factor. My vote is for ZipForge. Abbrevia has rather full documentation, but I have faced with some serious bugs at earlier stage of my work with it (Abbrevia 3.00, trial version). Also there are no simple demos there. The VCLZIP has too complicated programmer interface that makes it hard in use by novices. DelphiZip has no documentation and demos.
- Compiled code size and presence of an external libraries. The smaller code has DelphiZip, but it requires an external dynamic library (.dll) that makes distribution a little harder. ZipForge is rather compact and has no external libraries. VCLZIP has average code size. Abbrevia and ZipTV are too bulky, requires too many Delphi and own custom units.
- Source code availability. As I have said earlier, Abbrevia is now open source, so more probably you will have to fix the bugs yourself. VCLZIP and ZipForge has source code version that costs under $100. DelhiZip uses InfoZip open source library in .dll form that is rather large and cannot be compiled under Delphi, as it requires C compiler. ZipTV has source code version that costs $700.
I will not give you any final recommendations, most of mentioned above products have different strong and weak sides. Our company usually avoids using open source products and products that updates too seldom or have no support. So we use ZipForge now and very happy with it.
P.S. This is an overview article, so possibly some products were missed here, such as ActiveX controls that we consider to be useless in Delphi environment. All materials mentioned in this article were collected by me without any help from the products’ authors.
Premium Systems, Ltd.