Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
i v n i n seeks n e t o

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


           

c# to objective c auto translator

in google translate
  (+1, -2)
(+1, -2)
  [vote for,
against]

Just like from french to chinese. (and the result will just as unreadable, but useful)
pashute, May 08 2012

[link]






       Translating the language is probably fairly straightforward (I assume—I'm not familiar with C#). Translating the respective APIs (i.e., .NET to Cocoa) would be nearly impossible. You'd need to write some sort of abstraction layer for both APIs, and even then you could only translate code that targets that abstraction layer. And at that point, why bother translating the language? You might as well just write an ObjC .NET interface, or a C# Cocoa interface.   

       I guess if you dropped the "useful" requirement, it might work.
ytk, May 08 2012
  

       This is just a compiler, with a C# frontend, and an ObjC backend. Without knowing of any specific examples I won't go as far as to call it baked, but all the parts that make it up are well and truly baked, and plumbing them together wouldn't be a major challenge.   

       As [ytk] points out, if you want to call the result "useful", all the pain will be in dealing with the APIs / standard libraries.   

       (Another route you could take might be to translate .NET VM bytecode into ObjC - this lets you use the existing C# tools to do all the tricky parsing / validation etc of the C# source, and probably some optimisations too, leaving you with known-good input and a much easier task.)
Wrongfellow, May 08 2012
  

       Doesn't C# compile to bytecode (.NET)? If so simply decompile the .Net to objective C. (Shouldn't be too difficult to write a ObjC from bytecode)
Dub, May 08 2012
  

       Usually if its doable somebody already did it.   

       No links?
pashute, Jun 05 2012
  

       [ [ NSForeignLanguageStatement statementWithString: @"<STATEMENT>" fromLanguage: [NSForeignLanguage languageFromString: @"C#"] ] evaluateAsLanguage:[ [NSObjectiveCLanguage alloc] init] gently:YES];   

       There. All you need to do now is implement the NSObjectiveCLanguage, NSForeignLanguage, and NSForeignLanguageStatement classes, and problem solved.   

       (For any innocent bystanders: Yes, Objective-C is really that hideous in real life. That's one reason I gave it up in favor of Ruby.)
ytk, Jun 05 2012
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle