Page 1 of 1

How is the objective-c backend supposed to work?

PostPosted: Wed Feb 09, 2011 2:00 pm
by gradha
All this time I've thought that Cobra was running on .Net/Mono because it would compile bytecode for these platforms. But there's no similar bytecode for the Objective-C, yet there are traces of it in the repository. How is this going to work? I mean, translation from one language to another is nothing new, but how are going to be implemented Cobra features not available on the Objectve-c side?

Re: How is the objective-c backend supposed to work?

PostPosted: Wed Feb 09, 2011 8:08 pm
by Charles
Any feature not directly available in Obj-C will have to be implemented with additional code generation that captures the semantics of that feature. Really this is no different than what a translator that generates assembly or machine code has to do.

Interestingly, there are already a lot of features in Obj-C that map to Cobra quite nicely such as garbage collection, classes, inheritance, protocols/interfaces, etc.

For each feature that does not map, you have to ask the question "What specific code generation is required to implement this?". So for example, Cobra on .NET/Mono supports first class contracts including semantics around inheritance. Additional code is generated to make that happen.

With Obj-C being a proper superset of C, we can also fall back to any C-level tricks that help us out (unions, pointers, etc.).

Was there a particular feature you were thinking of?

Btw Cobra generates C# rather than bytecode for various benefits, such as ensuring that Cobra programs have maximum compatibility in the .NET world.

HTH

Re: How is the objective-c backend supposed to work?

PostPosted: Thu Feb 10, 2011 1:01 am
by gradha
Didn't know Cobra produced C# source code. That may come in handy if I find somebody opposed to the language itself. Thanks for your answer.