0

How to maintain code in multiple languages (such as .NET and VCL) ?

For example, TMS FlexCel has both .NET and VCL editions. And so does Eldos SecureBlackbox.

SOUser
  • 3,802
  • 5
  • 33
  • 63
  • 2
    Different projects for each language? – Sir Rufo Apr 13 '14 at 12:15
  • @SirRufo As far as the given examples are concerned, what you say might not be true. – SOUser Apr 13 '14 at 13:17
  • If its `Oxygene` then you might use compiler defines. You can then maintain FPC, Oxygene, Delphi and even Mobile Studio – user3060326 Apr 13 '14 at 13:22
  • @user3060326 Can Oxygene compile into Delphi / FreePascal ? I thought Oxygene compiles into .NET / JAVA / Object-C. – SOUser Apr 13 '14 at 13:26
  • @XichenLi I said you can use compiler defines and compile the code in whatever compiler. – user3060326 Apr 13 '14 at 13:26
  • @user3060326 I cannot find what you suggest using google (Make Oxygene compile into Delphi / FreePascal). Do you mind giving a reference link ? – SOUser Apr 13 '14 at 13:28
  • 1
    @user3060326 Oh! Sorry that I misunderstand you! Your point is a good one! – SOUser Apr 13 '14 at 13:33
  • 1
    [Indy](http://www.indyproject.org) targets VCL, FireMonkey, FreePascal, and Delphi.NET with a single codebase. The trick is to use 1) a common language (Pascal), 2) language-specific projects, 3) IFDEFs around compiler-specific code, and 4) abstractions around platform-specific code. – Remy Lebeau Apr 13 '14 at 17:14
  • @remy try targeting winforms and VCL. Or single codebase with different languages. – David Heffernan Apr 13 '14 at 20:54
  • hire a developer who's proficient in all of them! – Sam Apr 13 '14 at 22:25
  • @DavidHeffernan: as Indy is mostly non-visual, it does not target WinForms. However, Indy does have some design-time editors, and one of them does support both VCL and WinForms. And obviously it is not possible for a single codebase to support different languages. – Remy Lebeau Apr 14 '14 at 00:38
  • 1
    @user3060326 This SO post is related to your suggestion and interesting. http://stackoverflow.com/questions/16806810 – SOUser Apr 14 '14 at 12:47

1 Answers1

1

The naive answer to how to compile a single codebase in multiple languages is that it is not possible. So I guess that's not quite what you are asking.

For the examples that you give the developers probably have two different codebases that happen to be packaged up into products with the same name and offer very similar functionality.

In the question you mention .net and VCL as examples of languages but these are frameworks rather than languages. However, the products you mention that are available for these different frameworks will likely be two distinct codebases. VCL libraries and .net libraries would use different code bases even if the same languages were available for both frameworks. That much has to be the case because the frameworks are quite different.

For non-visual libraries then it would be possible to share code easily enough. Put common code in a library and then offer multiple language specific wrappers just at the published interface.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I seem to read somewhere that TMS FlexCel .NET is produced from VCL version via their home-brew MONO. I cannot find the link right now though. – SOUser Apr 13 '14 at 14:36
  • So you are looking to build your own home-brew code translation? – Sir Rufo Apr 13 '14 at 20:53