Hacker News new | ask | show | jobs
by jlongster 5192 days ago
Every new language/environment has the problem of needing interfaces into the lower-level system. If this takes off, you can expect the people to build the FFIs and share them.

If not, usually it's not too difficult to only wrap the calls that you need. There are also methods for automatically generating FFIs, although that only works with certain APIs.

Cocoa is definitely accessible from C. Objective-C is just a superset of C, so if you compile all the generated C files as Obj-C you can write any Cocoa code you want.

1 comments

I think you have it backwards what subsets and supersede are. The subset (C) by definition does not have everything in the superset (Objective-C), and one of the crucial features missing is Objective-C's object model and message passing. This is not intractable (BridgeSupport and the runtime API should be sufficient), but it will definitely be more work than writing Objective-C directly.
That's what I said, Objective-C is a superset of C. C is a subset of Obj-C.

You can simply do this (the actual FFI call might be wrong, it's been a while):

(c-lambda (ptr) void "[___arg1 sendThisMessage:1];")

You can literally code Obj-C straight into it.