Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will it take to add Objective-C support to the .NET common language runtime?

Is it possible for the .NET CLR to support Objective-C? Are there any reasons (either from a legal or implementational) standpoint why this wouldn't be possible?

In the spirit of cross-platform application development, it would be nice to be able to write and run Objective-C applications on Windows machines. At least I think it would.

like image 704
armahg Avatar asked Oct 29 '08 03:10

armahg


3 Answers

Objective-C is a strict superset of C. As such, it's got a lot of features, like pointers, that translate poorly onto .NET. Of course, it may be that -- in practice -- most Objective-C programs are written in such a way that they would also compile against a more tightly-defined version of the language specification that was more restrictive but could be translated into safe code.

Assuming this is the case, the method dispatch part of Objective-C is a natural fit for the dynamic capabilities of the DLR. I've actually considered creating such a port.

like image 163
Curt Hagenlocher Avatar answered Oct 16 '22 10:10

Curt Hagenlocher


If you mean being able to write .NET applications using the Objective-C syntax and being able to use the data structures from the Foundation frameworks (such as NSArray) this is trivial (albeit lengthy) to accomplish. It would be no different than adding support for any language.

However what makes Objective-C development great on the Mac isn't the syntax, it's the other API's that Apple provides like:

  • Core Data
  • Core Audio
  • Quartz
  • Core Animation

In addition to these APIs which would be much harder to implement, you also have to think about things like Bindings support and Key Value Observing which would be much much harder to implement in the CLR.

like image 45
lfalin Avatar answered Oct 16 '22 10:10

lfalin


There should be no problems hosting Objective-C on top of the CLR. You can probably implement the runtime on top of the DLR, or in the worst case implement your own. That is still significantly different from compiling any substantial Objective-C code bases for the CLR, since the vast majority of the Objective-C code you are likely to be interested in depends on Apple's frameworks.

In the end, you will either need reimplement them, or, bridge Objective-C over to the .NET frameworks, which would allow you to write Objective-C code, but it would not be using a framework compatible with any existing Objective-C code. You might want to take a look at Cocotron which is a cross compile environment that allows Mac developers to move some Objective-C applications to Windows. That should provide a reasonably good example of an Objective-C runtime for Windows, as well as potentially provide a few frameworks necessary to make a reasonable amount of Objective-C code usable once you bring up a compiler that can target .NET.

like image 3
Louis Gerbarg Avatar answered Oct 16 '22 10:10

Louis Gerbarg