Any way to convert C++ source code to C# or VB?

Discussion of chess software programming and technical issues.

Moderator: Ras

JohnW
Posts: 408
Joined: Thu Nov 22, 2012 12:20 am
Location: New Hampshire

Any way to convert C++ source code to C# or VB?

Post by JohnW »

Anyone know of a way to take the open source code of a chess engine written in C++ and convert it to C# or even VB? I am just not well versed in C\C++ stuff. Thanks..
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: Any way to convert C++ source code to C# or VB?

Post by Greg Strong »

JohnW wrote:Anyone know of a way to take the open source code of a chess engine written in C++ and convert it to C# or even VB? I am just not well versed in C\C++ stuff. Thanks..
Short answer: No.

Long answer: This would be an almost completely manual process and an extreme pain in the butt. I did this to port the Cutechess-cli code to ChessV. It was definitely time-consuming.

Why not start with an open-source C# chess engine?
User avatar
hgm
Posts: 28472
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Any way to convert C++ source code to C# or VB?

Post by hgm »

I once tried the reverse: convert a Visual Basic program to C (Steve Evan's ShogiVar). Existing converters did not seem to work on it. So I wrote my own edit script to do most of the conversion automatically, and then I had to finish it by hand. It was a lot of work.
tttony
Posts: 278
Joined: Sun Apr 24, 2011 12:33 am

Re: Any way to convert C++ source code to C# or VB?

Post by tttony »

A google search sent to this site: https://www.tangiblesoftwaresolutions.c ... tails.html

the free version has limitation, I've not tested
Dann Corbit
Posts: 12845
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Any way to convert C++ source code to C# or VB?

Post by Dann Corbit »

I have played around with some of their tools and even bought one of them.

Don't imagine that it will create a working solution (unless the problem is really trivial to start with, in which case you would not be looking at a converter).

What it will do is write out a code base that does not do the job, but is close enough so that you can examine the code and understand the task better.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Any way to convert C++ source code to C# or VB?

Post by Evert »

There are compilers that target an intermediate language, so theoretically this could be done.

Unfortunately for you, most of those actually "compile" the program into C code, which then gets fed into a C compiler. There is very little incentive to write a program that converts C++ into C# or VB (the reverse I could see).

The other downside to a program like that is that it normally outputs code that is intended to be processed by another computer program. Making the code easy to follow for a human being is not a priority.

Now, C++ code can become nearly unreadable, but reasonably written code you should be able to follow. Things like variable declaration, function calls, loops and conditional statements don't differ that much between languages.