tags:

views:

668

answers:

5

Hi

I have a large application written in Delphi. I want to renew it, starting with the user interface. I thought about using the new QT. During the process of renewing it, I want to change to C++ as the programming language. Is there a way to gradually rewrite the application (starting with the UI) to change to C++?

Thank you for your help.

+2  A: 

Convert your Delphi application to dll-s. You should figure out some reasonable API and expose it in dll. Then use that dll-s from C++ application.

There is also possibility to create COM+ objects, but they are windows specific technology (because of QT, I presume you intend to create multi platform application).

zendar
+5  A: 

It's probably easier to go the other way - rewrite the business logic in C++ and call it from Delphi via C interfaces. This is particularly so as one of Delphi's key strengths is working with GUIs.

anon
+8  A: 

The best course of action highly depends on the C++ development environment.

If it is C++ Builder you have two possibilities:

  • Use runtime packages instead of normal DLLs. This will spare you much headaches when it comes to string marshalling and mapping class hierarchies to flat DLL functions.

  • Use mixed code. You can mix Delphi/Pascal code with C++ code in the same project. (Only one language in a single module/unit though)

If it is any other C++ compiler:

  • Go the way you proposed with DLLs. You have to create some kind of layer/facade to map your classes' functionality to flat DLL functions.

  • If you want to go the plain DLL way even though you are using C++ Builder you can try using a shared memory manager like ShareMem (comes with Delphi) or FastMM (SourceForge) to allow passing of strings instead of PChars.

  • Create .objs instead of .dcus so both compilers work with the same output format. Then link them directly into you C++ program. This is essentially the same as with creating a DLL, but it's static. You will spot certain kinds of errors at compile time rather than runtime.

DR
I'm not happy with it, but I guess that's just the way it is. Thank you everybody for your insights.
Tobias Langner
+2  A: 

In general, while there are hetero-language options, I always found that freezing the older version, and rewriting a next major version in the new language was more time-efficient in the end.

But I went the other way around. (increasing C++ percentage that I ultimately backported to Delphi)

Marco van de Voort
A: 

I understand you, because I'm a delphi developer too and I want to migrate too my code to QT framework, that is in c++. I want to reach the cross platform goal: so I discarded the dll solution to keep the original source code, because it force me to hold delphi IDE in standby. I don't wanna go back to write/fix/improve the delphi code again.. I wanna evolve! The only choice I see is to rewrite delphi code in c++ and recompile it with QT creator (in detail, it will be recompiled with g++ mingw compiler invoked by QT creator.)

Rewriting your code will offer you the chance of refactor your classes to going "QTed" compliant. The gui will be totally rewritten too, because VCL is event driven, QT instead is signal driven, but I think that you already know this.

Remember: keeping your delphi code intact and building it into a dll library or compiling it into objs, will force you to keep up delphi source maintenance.