5 ms·
what is more interesting is his other project to make an application in pure C: https://github.com/richardjrossiii/CBasediOSApp https://github.com/richardjrossi
by FraKtus 9y ago
what is more interesting is his other project to make an application in pure C: https://github.com/richardjrossiii/CBasediOSApp https://github.com/richardjrossiii/CBasediOSApp.
When you are doing cross-platform, you may be more at ease with a few lines of C for some utilities call if you don't want to learn objective C.
- 52-6F-62 9y agoWhoa that looks so much simpler to me than ObjC. Of course I'm being a little naive because I haven't looked for moment at what those headers contain or how the API works, but just the same—that C version looks clean. I wonder what developing a more complex application would look like.
- delinka 9y agoI don't think it looks "simpler" than ObjC. He's still making the ObjC method calls, but with even more verbosity. I'd abstract all that away into macros or function calls ... but then you're right back to ObjC.
- tzahola 9y agoHe just de-sugared [foo bar] into objc_msgSend(foo, sel_getUid(“bar”))
- 0x0 9y agoAnd probably lost a ton of compiler assisted type checking in the process. I hope nobody considers doing anything remotely like this for any reason beyond learning a little about the low-level Objective-C machinery.
- tzahola 9y agoIt’s definitely NOT cross-platform. He’s just calling the objective-c runtime from C.
- drb91 9y agoMaybe I'm reading wrong, but I read it more that if the Objective-C interface is small, i.e. the bulk of your app is cross-platform C, you could easily use C to interact with the runtime.
- vlovich123 9y agoSo why not just write the Objective-C part in C rather than calling the underlying machinery directly. It's a neat project to learn the internals, but I wouldn't ever structure a real app this way.
- curyous 9y agoIf you write part of it in C, then you can reuse that code on another platform.
- 0x0 9y agoObjective-C is a superset of C though, so you might as well write the platform specific stuff in an .m file rather than messing around with the .c API for Objective-C. :)
- vlovich123 9y agoYes, part of it should be in C. Even if the Objective-C calls were portable (last time I checked GNUStep was pretty much dead) the APIs it calls into aren't. Seems to me like there's more value to just write the Objective-C parts in a .m file normally & call into the shared C/C++ code.
- duskwuff 9y ago> So why not just write the Objective-C part in C rather than calling the underlying machinery directly. Because the "underlying machinery" isn't documented by Apple. It may not even be a stable interface!
- 9y ago
- wolfspider 9y agoThis is how SDL2 works for Cocoa it also is written in pure-C in some areas where there would normally be Mach files
- gurkendoktor 9y agoThe Cocoa implementation of SDL 2 uses plain Objective-C to access Apple's APIs: https://github.com/spurious/SDL-mirror/tree/master/src/video/cocoa https://github.com/spurious/SDL-mirror/tree/master/src/video... I couldn't find a call to objc_msgSend in other (.c) files using GitHub's code search. Objective-C and C/C++ are perfectly interoperable, there's rarely a reason to use the verbose and error-prone C API to call into Objective-C. The .m file extension is not related to Mach: https://stackoverflow.com/a/652266 https://stackoverflow.com/a/652266