Solved

Best way to convert Delphi 6 code to C#

Posted on 2013-06-28
5
2,361 Views
Last Modified: 2013-07-01
As the title says, I'm looking to convert as much Delphi code to C# as possible.  

I realize there are some tools that will convert whole projects.  I'm thinking this may not be the best way.  Maybe file by file or function by function.  I don't need the designer code converted although having the control names identical to the new C# designer would probably be helpful.

Control names aside, what is considered to be the best solution for people needing such conversions?

Thanks!
0
Comment
Question by:John500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 400 total points
ID: 39285842
The best solution, no matter what language you come from, is to rewrite the application.

Conversions between 2 different .NET languages, say VB.NET to C# can give usable results, because they fundamentally use the same system and the same paradigms. It's only a question of converting the syntax.

However, when you come from a completely different environment, simply adjusting the syntax is not enough. Even trying to convert from VB6 to VB.NET is never a good solution, although the syntax used is the same.

If you look at it closely, Delphi (Pascal) and C# do not do much in themselves. The work is mainly done in classes that they use. The classes in Delphi are not the same as those in C#. And this is where conversions cannot do a good job. A button in Delphi is not the same as a button in C#. They do not have the same properties and methods. Although some can be simply mapped by the converter, many exist in one environment and not in the other one. Same thing for the file I/O classes and the database access classes.

Same thing for all the classes that your application uses.

After the converter has done its job, you are stuck with a lot of code that could not be converted. And the code that could be is not efficient. In order for the application to work as closely as it was doing before, the converters often need to generate a dozen lines of code to reproduce in .NET something that was done in one line in the old environment. Usually, when you code straight in .NET, it's the reverse.

The generated code is thus incomplete, is a mess, a nightmare to debug, and a very bad way to learn how to do things in the framework.

As a .NET trainer, I have witnessed many tries at converting older applications to .NET, from different languages and environments, and almost all of those fell flat, sometimes after days or weeks trying to make the thing works. In most cases, after losing much time, the conversion project is scrapped, and the application either left in its old format or rewritten from scratch.

The very few conversions that do eventually reach production are usually buggy and/or unstable, and are always a pain to maintain.
0
 
LVL 11

Assisted Solution

by:lenordiste
lenordiste earned 100 total points
ID: 39286684
I agree with jamesburger, a rewrite is probably the best way to go!

Also, you while it is tempting to convert this project file by file and function by function, this process will probably yield an "old application written with a new language". Best approach is to document what you need from this application and write it anew. This will help get rid of legacy code or features which may not even be useful anymore! The worst thing is to spend time coding/thinking about how to rewrite a piece of code while the goal is to arrive at the same result, and not the how. The time you'll save going this route will probably leave you with some free time to tweak it further or add new wanted features.
0
 

Author Comment

by:John500
ID: 39286726
Well, thanks to both of you.  I didn't know whether such a tool would at least give me some insight but I can see now it wouldn't be good.

We're talking about a Form Application that has six tabs numerous text boxes, a menustrip, tool strip etc.  The folks that asked me to convert it say it should take about a month.  I don't know.  

Just started working at this place.  I was hoping to utilize some code reuse because they have already converted numerous similar applications.  Nobody gives code away these days except here... or I keep getting the wrong jobs.
0
 
LVL 40
ID: 39286767
You can think of code reuse if the applications where designed as forms in a .exe and most of the functional code in dlls.

You could then rewrite the forms in .NET and simply connect to the old dlls. This works pretty well if the dlls were designed properly.

But if the applications were big .exe that contains everything, a conversion is not something I would consider.
0
 

Author Comment

by:John500
ID: 39289977
Thanks again!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question