[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Best way to convert Delphi 6 code to C#

Posted on 2013-06-28
5
Medium Priority
?
2,577 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 1600 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 400 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 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