3 ms·
That’s why we’ve been warned for years to not call them directly from C I guess! Mike Ash has such amazing content always.
by dep_b 7y ago
That’s why we’ve been warned for years to not call them directly from C I guess! Mike Ash has such amazing content always.
- saagarjha 7y agoI don’t see why you can’t call objc_msgSend directly if you cast it correctly.
- dep_b 7y agoYou _can_ call it as you could call it before as well only there's a pretty big chance your existing code will break because of this change.
- braindeath 7y agoNo that’s not right. The implementation is not changing. The prototype is changing to break code that was poorly formed in the first place. If you had cast to the correct type in your code as you always should have, this change shouldn’t break anything. As far as code breaking changes go, the impact should be low. How many times in a code base should you need to call msg send? And the risk of problems is low. Only if your code was silently relying on float corruption would you notice a change. Anybody making six figures should be able to analyze such a thing without too much whining.
- dep_b 7y agoWell I'm not sure either who would rely on extensive calling of this function but why would you call it "whining"? Apart from the fact that earning six figures still isn't the norm for most Objective-C developers. > The prototype is changing to break code that was poorly formed in the first place. I guess calling it directly would even be poor form by itself so who knows.
- braindeath 7y ago> I guess calling it directly would even be poor form by itself so who knows. The point being that there are limited cases where it is justifiable. For example, a VM or language interop would likely be justified. Those types of cases mean the absolute number of call sites should be small though. In other words, the problem is somewhat self-limiting. Probably, in appropriate use, the function would be called extensively, but likely not from many sites. > Apart from the fact that earning six figures still isn't the norm for most Objective-C developers. I have no horse in this race.. I don't work in the industry for years. This was also a somewhat tongue-in-cheek remark that I think you are reading too deeply into. The real point is, software engineers are generally paid well relative to median incomes and have a cushy job. On the scale of pain, this doesn't seem like a big deal - not even a Python 2 to 3 transition. BLS average salary for software engineers is $103k, not including bonuses and stock, etc. I would think the average engineer that would justifiably use msg send directly is being paid greater than the BLS average - which includes all the enterprise LOB app slaves that don't do incredibly well.
- vbezhenar 7y agoHow are you supposed to call Objective C code from C then?
- 0x0 7y agoCall it from an extern C function in an .m file?
- vbezhenar 7y agoNot very practical, if you need to use a lot of APIs. One of advantage of Objective C is that it's easy to interop with C.
- pjmlp 7y agoYou are seeing the other way around. That advantage is to migrate C code into Objective-C, just like C++ and TypeScript have done as well. In fact, NeXTSTEP and its derived OSes have very little pure C code, beyond BSD/XNU kernel and the POSIX APIs.
- monocasa 7y agoYou'd be surprised. The new APFS.Framework appears to be all C for instance.
- pjmlp 7y agoEven then you're supposed to actually use the higher level filesystem framework APIs from Objective-C and Swift. https://developer.apple.com/documentation/foundation/file_system/about_apple_file_system https://developer.apple.com/documentation/foundation/file_sy...
- monocasa 7y agoI mean, yeah, you're not "supposed to" use it; it's a private framework. Also, the only reason why someone like me would know if it's in C or not is that I need one of the aspects of that library that can't be expressed in the high level APIs. My point is that there's tons of non legacy C code, in the OS outside of the kernel and posix subsystems on *OS.
- mpweiher 7y agoYou can still call objc_msgSend() from C. Just need to cast it correctly.