4

Background:

I've been using Delphi since version 2, and since moving up to around v5/v6, I've never upgraded to get newer features - but instead to get around bugs in the IDE/compiler. Today, I opened up a personal project that I've been working on occasionally for the past year and it wouldn't compile (having not been changed at all since last time). Eventually it compiled but wouldn't run.........

I've been using C# / visual studio quite a lot for work and quick'n'dirty projects and the only problems I've come across with C#/VS are limitations of the C# language itself.

The question:

Is there some way that I can edit my Delphi projects within Visual Studio and run/debug them from there, instead of having to use the Delphi IDE/debugger with all its numerous bugs? I really don't want to have to upgrade Delphi again purely to get around Borland's heisenbugs.

I saw some LGPL'd project to get Delphi into visual studio but it seemed to be dead as of 2007. Likewise, I've seen Delphi .NET in visual studio, but some of my scientific code is heavily ASM optimised (SSE/FMA).

Alternatively, is there a decent (and free/cheap) Delphi=>C++ / Delphi=>C# translator program around? If I can just have my Delphi code translated to a Visual Studio language (give or take the occasional bit of ASM), that would probably suffice.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Mark K Cowan
  • 1,755
  • 1
  • 20
  • 28
  • There is Oxidizer: http://code.remobjects.com/p/oxidizer/ Delphi Prism isn't free though. – Jens Mühlenhoff Jul 10 '12 at 13:33
  • When I first started using Linux, I wrote a program that translated Delphi 3 code (nb. no forms/resources) to gcc-compatible C and compiled it... Following the information at [link](http://stackoverflow.com/questions/4283072/how-to-create-a-new-language-for-use-in-visual-studio), I'll dig out that old program and use it as a starting point for an Object Pascal in Visual Studio language service... – Mark K Cowan Jul 10 '12 at 13:42
  • @Mark That's impressive. And this converter handled all valid Delphi 3 syntax did it? So long as your code is trivial, then you may get somewhere. Your code doesn't sound remotely like that. – David Heffernan Jul 10 '12 at 13:44
  • @DavidHeffernan It handled all d3 code that I had, plus some of the RTL. I've no idea whether it was "complete", as I couldn't find a Delphi standard/specification anywhere. For example, there are lots of interesting little bits of syntax that most experienced Delphi people have never seen such as the alternative square-brackets (. .) that can be used in place of [ ]. If my converter still compiles, I'll try to add generics to it and any other features that I'd been screaming at Borland for since ~d3... – Mark K Cowan Jul 10 '12 at 14:31
  • I've also developed a big Delphi framework which takes advantage of all the metadata in Delphi programs - allowing automatic parallelisation, dynamic loading and unloading of code while a program is running, XML serialization and an "object explorer" that can be loaded within a program to explore objects and view their properties. Looking very far ahead, I'd hope to make metadata more "reflection-orientated" instead of "form-streaming-orientated", and build my thread management and run-time code patching into the translator to produce a Delphi-like language rather than simply cloning Delphi. – Mark K Cowan Jul 10 '12 at 14:32
  • @MarkKCowan So how did you map polymorphism of classes onto C? – David Heffernan Jul 10 '12 at 14:34
  • In addition to the link in my first reply-comment, [this looks useful too](http://www.codeproject.com/Articles/33250/Writing-Your-First-Visual-Studio-Language-Service) – Mark K Cowan Jul 10 '12 at 14:35
  • Objects and classes were represented as structs. Interfaces weren't supported at all. Virtual methods were represented as function pointers within the class struct. Virtual and dynamic were treated as identical. Realistically, I didn't do it _too differently_ to how the compiler does it, the biggest difference being that I produced yet more human-code rather than going straight to machine code. – Mark K Cowan Jul 10 '12 at 15:00
  • `If we assume some virtual method that I won't explicitly name, using: TBase.VBM (Virtual base method) TNext.OM (Overridden method) TBase.VBM would be translated to a new TBase__VBM, which would call ((TBase_Class*)(*Self))->VBM TNext.OM would be translated to TNext_OM, which would do a similar call as above, but with a TNext_Class cast (TNext_Class is a TBase_Class struct with extra fields afterwards). A call to "inherited" would look at the struct pointed to by ((TAnyClass*)(*Self))->ClassParent, typecasting it appropriately and calling the virtual method.` – Mark K Cowan Jul 10 '12 at 15:04
  • I didn't want to write a full compiler/optimiser - the translator's purpose was to produce something that gcc could use. I still did all the actual development in Pascal. The C code was never supposed to fall under human eyes, think of it more as an "obj" file or a "dcu". A line-number translation file was also produced, mapping C line numbers to the original source (where applicable). On gcc compilation errors and program errors, a quick lookup told me where in the Pascal source the problem was (when there was no corresponding pascal line, I got what Borland call an "Internal Error") – Mark K Cowan Jul 10 '12 at 15:23
  • 4
    If you want to move away from Delphi I think Delphi Prism - Hydra may be what you are looking for. Your proposed solutions (converters, VS for developing Delphi code, etc.) seem way too *Rube-Goldbergesque* to me. – Leonardo Herrera Jul 10 '12 at 19:18
  • 5
    I think this question has some merit, but only if we exclude all the presumptions regarding .net trans-compilation. Asking for a plugin which allows the borland or FPC compiler to be used from visual studio, which is a language agnostic IDE, is not "unconstructive", but quite in vouge. A lot of people love object pascal but have a love/hate relationship with the Delphi IDE (or lazarus) and would like alternatives. There have in fact been plugin projects allowing delphi to be used with VS (see: https://delphi4visualstudio.codeplex.com/) so it's not completely off the bat – Jon Lennart Aasenden Nov 24 '14 at 07:24

0 Answers0