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.
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.
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With