Packages vs COM vs Dlls

Question: “What are the advantages of using packages compared to Dll’s?”

A good overview of Packages (BPL) vs DLL’s is available on delphi.about.com

http://delphi.about.com/od/objectpascalide/a/bpl_vs_dll.htm

Packages (BPL)

The Delphi package architecture is often overlooked, however, it is in fact so powerful that the MS .Net platform copied it. In .Net the term is Assembly, but conceptually it is the same as Delphi’s Package.

Delphi Packages are specialized Dll’s that enable classes and interfaces to be packaged up into modules and easily used in many Delphi applications. Thus when sharing modules between Delphi applications, we recommend using packages.

With Delphi packages you build .bpl’s that ‘require’ other packages. Therefore myReportPackage1.dpk and myReportPackage2.dpk can both ‘require’ the ReportBuilder packages. The ReportBuilder packages will only be loaded once, they are dynamically linked rather than statically linked as in your .dll’s.

Delphi packages version are specific. For example, a package written in Delphi 2007 cannot be used by a Delphi 7 application.

COM

When using Delphi to build modules that can be used by different environments such as C++ and MS .NET consider using COM. In particular Delphi and MS .NET include excellent support for COM. COM enables any number of interfaces to compiled into a .DLL (or .Exe) and then used from any environment that supports COM.

DLL

Dll’s are a good solution for writing functions in Delphi that can be called from almost any programming environment.