Live data from Hacker News

Apple announces full Swift rewrite of the Foundation framework (2022)

infoq.com

401–402 of 402 posts

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#401
post #395

Earlier quoted context omitted.

What you’re doing in this medium post is call the objc runtime from swift and take advantage from swift objc bridging. This does not work if the class you’re trying to swizzle is a pure swift class. For a reason : swift is mostly static dispatch, whereas objc is pure dynamic dispatch (taking its root from smalltalk). This means code that tried to swizzle foundation types, assuming foundation is developped in objc, wi…

If Foundation is to retain binary compatibility with Obj-C, then it will by necessity still be using the Obj-C runtime, with Foundation types still extending NSObject, and thus swizzling should still work as before. The alternative would be for Apple to break compatibility with old Obj-C apps, instead shipping a compatibility version of Foundation.framework which old apps would continue to link against. But it sounds…

Yet using the objc runtime defeats the purpose of being easier to port to other platforms.

Re: Apple announces full Swift rewrite of the Foundation framework (2022)

#402

Earlier quoted context omitted.

You’re making the wrong assumption! I have read the article before I asked, and still have no idea what it is! Saying it provides these abstraction NSObject, NSString, NSArray tells me nothing! The article is clearly written towards readers familiar with Apple ecosystem.

Objective-C is an object-oriented programming language that is essentially a super-set of C. In fact the earliest implementation of Objective C, if I recall correctly, translated Objective-C code to C. The only built in types in Objective-C are the C types, like int, char and so on. The "Foundation" is a set of classes that implement many useful types that all inherit from a superclass called NSObject. The "NS" prefi…

GCC still compiles Objective-C as if it is translated on-the-fly to C. Unfortunately, there is no way to get translated source :-( because it happens on AST-like level.
Post reply on HN