Migrating from Delphi 5 to XE

Randy Rich
Randy Rich used Ask the Experts™
on
I need to move several applications written in Delphi 5 up to be compatible with Windows 7 and 64 bit system.  I'm contemplating migrating up to Delphi XE.  I also use Infopower, Direct Oracle Access, Crystal Reports components.  I connect to an Oracle database.  Has anyone migrated applications along the same path and can you tell me of any things I need to watch out for?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Emmanuel PASQUIERFreelance Project Manager
Top Expert 2010

Commented:
I still regularly use Delphi 5 as for some projects I really have to stick with it (plugins for application written with it, so no choice at all)

At the same time I used Delphi 7 for many years as my main dev plateform, and only recently decided to switch to Delphi XE (I was not convinced by intermediary versions like Delphi 2005, 2007 - And 2009, 2010 where a big step. I'll say why in a moment).

But one has to admin that Delphi XE is great.

So, abuot the jump from D5 to XE : it is like a move from Win95 to Vista directly. Most of your applications using standard components will work again with just a few touches and compilation, but some time you'll hit trouble.

First step : the 3rd party components. You'll have to decide which you want to keep, and the ones you'll have to change. Because a lot of standard new components exist now for XE that weren't there at D5 time or that the author didn't want to make compatible with such an old dog. And some are really worth the change.
- make a list of all the 3rd party components you use
- see if the author still exist, and which Delphi version is the last one supported.

if Delphi XE is supported , GREAT ! keep it !

otherwise, 3 possibilities (IF YOU HAVE CODE, OTHERWISE SKIP DIRECTLY TO LOOKING FOR ALTERNATE) :
- Delphi 2009/2010 : That should be just fine, and will only need maybe a few renaming of packages to avoid such bpl names like "WhateverLibrary_2009.bpl" which is awkward (but work perfectly)
The main problem (Unicode) is already fixed with such D2009 compatible packages
- Delphi 7-2007 : Most of the components will be Ok, as D7 (maybe even D6) introduced the major changes in component designs that are still used in newer Delphi (with some extensions of course) so if those libraries are not susceptible to Unicode problems, just rename packages if necessary and compile ! Working ? Great ! Not Working ? either you are a good delphi programmer and depending on the problem you might be able to fix it, or the compiler throw pages of errors and warning and you might consider looking for newest alternate solutions.
- Delphi 5 and below : try recompile, if they are not complex lib that might just work. most of the time, it won't and I will recommend forgetting it. It will be a pain already to make those work if you have to fight agains components designs AND unicode, but you will be condemned to maintain those alone for the time to come, without the author.

Now, about the most famous problem when switching to 2009 and above : Unicode !!!
All strings in delphi are now considered UNICODE (16 bits per char) and not ANSI (8 bit per char). And that impacts everything in the VCL. So if your code uses lots of PChar, you'll have trouble.
That particular problem can be difficult to overcome in some cases, but there are plenty How-To to get started by googling a bit, or here in ExEx.

Freelance Project Manager
Top Expert 2010
Commented:
Second step : your applications themselves.

Most of the time, once you have installed the library packages for XE, you'll have probably a few components to replace with newest ones (different lib). That will probably involve use of a good text editor (like UltraEdit) with strong Search/Replace functions.
For the component set, I have taken the time to restrict myself  to only a handful of libraries, such as JCL/JVCL (JEDI, open-source, well maintained, and very extensive). I cleaned a few of my toolbox, and made the necessary changes in my applications, to simplify the need of maintaining too much old ones (and clearing some room in the IDE component palette)

All the components you have been able to upgrade will pose no problems in your app code - IF they have been coded properly, there is always a chance that they compile but on some extreme runtime case they fail miserably. That has not been the case very often in my experience. The most difficult part being that they compile.

Then of course, your applications will maybe suffer from the same kind of problems as the components libraries. But you'll have only the Unicode problem, and mainly only if you use PChar. So a search in all files will put you directly to the portion of code that need prudent thinking and maybe fixing.
All other differences between D5 and XE will be a whole load of issues you had before that are fixed now, and maybe the difficulty to get back again to D5 if your project has been *converted* to XE. And of course a lot of new language features that you'll have to learn, and bad things you where used to do that you can do much simpler now. So it is a bit of the joy that you experience when learning a new language, but with the feeling it's not that different, just better.

In the end, you are probably facing a big time full of problems of any size. But know that I'm very happy that I have taken the time to do it. Delphi 5 is way too old to be productive nowadays.
Randy RichPresident

Author

Commented:
When you ran the delphi 5 and 7 simultaneously, did you run them on the same box?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Geert GOracle dba
Top Expert 2009

Commented:
you can run all delphi versions on the same machine
but ... they got better at that since d6

d5 to d6
> variants unit (you'll have to the variants unit to almost all units)
> split into designtime and runtime packages

d6 to d7
> fastnet components to indy

if you have created any wizards/design time enhancements on delphi
> check www.gexperts.org > nice tool to have

d7 to d2007
> ok, not to many changes

d2009 and up
> unicode
new type varString

in one sentence ... lots of work :)

Emmanuel PASQUIERFreelance Project Manager
Top Expert 2010

Commented:
if you mean same machine, yes. Absolutely NO problems running both, even on the same project.

That is not the case with XE, as it changes automatically the .DFM files of the forms you open to add some default values for properties that were not there in D5 => problems opening them again with D5/D7
Geert GOracle dba
Top Expert 2009

Commented:
oh yeah, lol we bumped into the win7 <> lower os version too
it changed all sizes of components on your form when using themes

so much for backward compatibility

you will need a good backup of every d5 project :)
Randy RichPresident

Author

Commented:
Very quick and thorough response.  I feel much more prepared for the update.  Thanks
Randy RichPresident

Author

Commented:
Can you tell me where Delphi XE is concerning 64 bit?
Emmanuel PASQUIERFreelance Project Manager
Top Expert 2010

Commented:
nowhere near I'm afraid.

maybe better luck with next Delphi version, due this year if they are not late. I've heard It should have both x64 and support for other platforms (like MAC OS)
look there (french, sorry, maybe you can translate with your browser) :
http://delphi.developpez.com/actu/20281/Delphi-en-phase-de-devenir-multiplateforme-l-EDI-d-Embarcadero-reste-limite-a-Windows-mais-compilera-pour-Linux-et-MacOS/

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial