digitalmars.D - Porting C# code
- Brien (2/2) Jan 06 2010 I'd like to port a large amount of C# code over to D.
- BCS (6/10) Jan 06 2010 I've got a tool that will handle some of the porting but it has a number...
- Brien (10/10) Jan 07 2010 Hi BCS,
- Steven Schveighoffer (4/21) Jan 07 2010 Note there is a D compiler for .NET, which may allow you to avoid portin...
- Brien (1/5) Jan 07 2010 I saw that, but my goal is to get off of .NET. I'm assuming I will be a...
- Steven Schveighoffer (4/13) Jan 07 2010 It depends on what you are doing. If you rely heavily on the GC, .NET's...
- Brien (3/5) Jan 07 2010 For performance reasons, I've taken great pains to avoid steady state me...
- BCS (8/30) Jan 07 2010 I took the cheap solution of a state machine and per-line regex.
- Brien (3/6) Jan 07 2010 Ok, that's good to know. I assumed because D billed itself as a "system...
- Don (4/11) Jan 07 2010 D is trying to be exactly that. We don't have the infrastructure yet,
- Brien (6/13) Jan 07 2010 Cool.
- Lutger (10/23) Jan 07 2010 Wouldn't it be more efficient for you and the code to implement the
- Lutger (4/46) Jan 07 2010 There's also this tool for porting C#, but I don't know anything about
- BCS (3/42) Jan 07 2010 IIRC managed<->un-managed calls are insanely expensive. If you do this,p...
- Brien (2/4) Jan 08 2010 I can confirm that. The thunk layer is pretty heavy weight and tends to...
- Iivari Mokelainen (9/56) Jan 08 2010 Every managed->unmanaged call is checked somehow, and there was an
- Brien (5/15) Jan 08 2010 Pinvoke is no good for functions that are fast and invoked a lot.
- BCS (5/18) Jan 07 2010 (Ignoraing IDE/tool chain issues) Yes, D.
Hello Brien,Are there any tools that can help me do this?I've got a tool that will handle some of the porting but it has a number of limitations. For one, it only handles a very limited set of .NET (exactly Zero GUI, mosly only bits of the File I/O, regex and other "back end" kind of stuff) and it has some somewhat arbitrary formatting limitations. It would take me a bit but I could prob'ly dig out the code.
Jan 06 2010
Hi BCS, I'd really appreciate it. I'm looking to port over a network server application so the GUI stuff shouldn't be a problem. I've also kept my source Did you write your own parser or base it on ANTLR or some other parsing/compiling library? I wonder if it is possible to fully automate the conversion process- if you public class Foo { public /* shared */ int bar; } which could get translated as a shared variable. port to D where I would be able to use native techniques on critical areas of the code. -Brien
Jan 07 2010
On Thu, 07 Jan 2010 09:23:47 -0500, Brien <reply tolist.com> wrote:Hi BCS, I'd really appreciate it. I'm looking to port over a network server application so the GUI stuff shouldn't be a problem. I've also kept my Did you write your own parser or base it on ANTLR or some other parsing/compiling library? I wonder if it is possible to fully automate the conversion process- if public class Foo { public /* shared */ int bar; } which could get translated as a shared variable. optimized port to D where I would be able to use native techniques on critical areas of the code.Note there is a D compiler for .NET, which may allow you to avoid porting parts of it. I've never used it, but it has been announced here somewhere. -Steve
Jan 07 2010
Note there is a D compiler for .NET, which may allow you to avoid porting parts of it. I've never used it, but it has been announced here somewhere. -SteveI saw that, but my goal is to get off of .NET. I'm assuming I will be able to get better performance out of optimized D running on Linux versus optimized .NET on Windows or Mono. Is that a safe assumption?
Jan 07 2010
On Thu, 07 Jan 2010 09:53:32 -0500, Brien <reply tolist.com> wrote:It depends on what you are doing. If you rely heavily on the GC, .NET's GC is much more mature than D's, and probably performs better. -SteveNote there is a D compiler for .NET, which may allow you to avoid porting parts of it. I've never used it, but it has been announced here somewhere. -SteveI saw that, but my goal is to get off of .NET. I'm assuming I will be able to get better performance out of optimized D running on Linux versus optimized .NET on Windows or Mono. Is that a safe assumption?
Jan 07 2010
Steven Schveighoffer Wrote:It depends on what you are doing. If you rely heavily on the GC, .NET's GC is much more mature than D's, and probably performs better.For performance reasons, I've taken great pains to avoid steady state memory allocations. I've got a lot of mid-life crisis type allocations so I'm forced to avoid the GC which would spend all day doing Gen2 collections. I'm looking at D as a way to gain a speed boost and allow me to get off of Windows for my production runtime.
Jan 07 2010
Hello Brien,Hi BCS, I'd really appreciate it. I'm looking to port over a network server application so the GUI stuff shouldn't be a problem. I've also keptDid you write your own parser or base it on ANTLR or some other parsing/compiling library?I took the cheap solution of a state machine and per-line regex.I wonder if it is possible to fully automate the conversion process- public class Foo { public /* shared */ int bar; } which could get translated as a shared variable.The output is D 1.0optimized port to D where I would be able to use native techniques on critical areas of the code.That might be viable but the system was never intended for speed (its intent was as a way to escape needing Mono on a non Windows system) so you would I'll look into digging it out.
Jan 07 2010
BCS Wrote:That might be viable but the system was never intended for speed (its intent was as a way to escape needing Mono on a non Windows system) so you wouldOk, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount. I'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlier syntax and developer
Jan 07 2010
Brien wrote:BCS Wrote:He's talking about his converter program, not about D!That might be viable but the system was never intended for speed (its intent was as a way to escape needing Mono on a non Windows system) so you wouldOk, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.I'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlier syntax and developerD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 07 2010
Don Wrote:Oops, sorry about the misinterpretation.Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.He's talking about his converter program, not about D!Cool. That being the case, I'm not sure I can give up my addiction to Jetbrains about library support- I can reimplement whatever I need, just the language itself. Also, is the threading support and memory model of D1.0 solid and performant? I'm a little unclear about how synchronization is achieved. I see the synchronized keyword and I've seen some references to using mutexes, but I don't really have a clear picture. ThanksI'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlier syntax and developerD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 07 2010
On 01/07/2010 10:50 PM, Brien wrote:Don Wrote:Wouldn't it be more efficient for you and the code to implement the easily do extern(C) so it's not much work, much less probably than massaging an automated port. If you go with D1 take a look at the ldc compiler and the tango documentation for class libraries (these should contain a fair bit of information): www.dsource.org/projects/tango www.dsource.org/projects/ldcOops, sorry about the misinterpretation.Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.He's talking about his converter program, not about D!Cool. That being the case, I'm not sure I can give up my addiction to Jetbrains about library support- I can reimplement whatever I need, just the language itself. Also, is the threading support and memory model of D1.0 solid and performant? I'm a little unclear about how synchronization is achieved. I see the synchronized keyword and I've seen some references to using mutexes, but I don't really have a clear picture. ThanksI'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlier syntax and developerD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 07 2010
On 01/07/2010 11:59 PM, Lutger wrote:On 01/07/2010 10:50 PM, Brien wrote:it. Seems like it hasn't been updated for 2 years: http://www.dsource.org/projects/nanuDon Wrote:Wouldn't it be more efficient for you and the code to implement the easily do extern(C) so it's not much work, much less probably than massaging an automated port. If you go with D1 take a look at the ldc compiler and the tango documentation for class libraries (these should contain a fair bit of information): www.dsource.org/projects/tango www.dsource.org/projects/ldcOops, sorry about the misinterpretation.Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.He's talking about his converter program, not about D!Cool. That being the case, I'm not sure I can give up my addiction to Jetbrains Resharper. Do you think a fully automated translation from tools? I'm not too worried about library support- I can reimplement whatever I need, just the language itself. Also, is the threading support and memory model of D1.0 solid and performant? I'm a little unclear about how synchronization is achieved. I see the synchronized keyword and I've seen some references to using mutexes, but I don't really have a clear picture. ThanksI'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlierD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 07 2010
Hello Lutger,On 01/07/2010 10:50 PM, Brien wrote:IIRC managed<->un-managed calls are insanely expensive. If you do this,profile the Snot out of it to be sure you actually get a gain out of it.Don Wrote:Wouldn't it be more efficient for you and the code to implement the easily do extern(C) so it's not much work, much less probably than massaging an automated port.Oops, sorry about the misinterpretation.Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.He's talking about his converter program, not about D!Cool. That being the case, I'm not sure I can give up my addiction to Jetbrains Resharper. Do you think a fully automated translation from tools? I'm not too worried about library support- I can reimplement whatever I need, just the language itself. Also, is the threading support and memory model of D1.0 solid and performant? I'm a little unclear about how synchronization is achieved. I see the synchronized keyword and I've seen some references to using mutexes, but I don't really have a clear picture. ThanksI'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with theD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 07 2010
BCS Wrote:IIRC managed<->un-managed calls are insanely expensive. If you do this,profile the Snot out of it to be sure you actually get a gain out of it.I can confirm that. The thunk layer is pretty heavy weight and tends to code gen doesn't seem to deal with that very efficiently. And lastly, it does really poorly optimizing value type structs so the builtin features that could theoretically get you closer to the metal don't in reality.
Jan 08 2010
BCS wrote:Hello Lutger,Every managed->unmanaged call is checked somehow, and there was an attribute which lets you do pinvoke calls extremely fast but unsafe. printf perfomance was pretty much the same as in C++ with that attribute. Its used internally to do OS calls very fast, iirc it was undocumented. Try some disassemblers on .net framework, mainly parts that do OS calls. Good Luck - dataOn 01/07/2010 10:50 PM, Brien wrote:IIRC managed<->un-managed calls are insanely expensive. If you do this,profile the Snot out of it to be sure you actually get a gain out of it.Don Wrote:Wouldn't it be more efficient for you and the code to implement the easily do extern(C) so it's not much work, much less probably than massaging an automated port.Oops, sorry about the misinterpretation.Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount.He's talking about his converter program, not about D!Cool. That being the case, I'm not sure I can give up my addiction to Jetbrains Resharper. Do you think a fully automated translation from tools? I'm not too worried about library support- I can reimplement whatever I need, just the language itself. Also, is the threading support and memory model of D1.0 solid and performant? I'm a little unclear about how synchronization is achieved. I see the synchronized keyword and I've seen some references to using mutexes, but I don't really have a clear picture. ThanksI'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with theD is trying to be exactly that. We don't have the infrastructure yet, though. So the productivity gains are a bit theoretical at present...
Jan 08 2010
Iivari Mokelainen Wrote:Every managed->unmanaged call is checked somehow, and there was an attribute which lets you do pinvoke calls extremely fast but unsafe. printf perfomance was pretty much the same as in C++ with that attribute. Its used internally to do OS calls very fast, iirc it was undocumented. Try some disassemblers on .net framework, mainly parts that do OS calls. Good Luck - dataPinvoke is no good for functions that are fast and invoked a lot. Here's some good proof http://community.opennetcf.com/articles/cf/archive/2008/01/31/performance-implications-of-crossing-the-p-invoke-boundary.aspx -Brien
Jan 08 2010
Hello Brien,BCS Wrote:(Ignoraing IDE/tool chain issues) Yes, D. won't be getting some of the available speed advantages that D can give you. You end up with the union of the problems and the intersect of the advantages.That might be viable but the system was never intended for speed (its intent was as a way to escape needing Mono on a non Windows system)Ok, that's good to know. I assumed because D billed itself as a "systems" programming language that performance would be paramount. I'm sure I'm the millionth person to ask this, but- is there a language out there that is bare metal like C/C++ with the friendlier
Jan 07 2010