Originally posted by kpedersen
View Post
Announcement
Collapse
No announcement yet.
Chris Lattner Formally Steps Down From Swift's Core Team
Collapse
X
-
Originally posted by Debunez View Post
That is actually not true. Swift is able to directly consume C API with no bindings needed.
https://developer.apple.com/document...tions_in_swift
However if you have a C header file containing MACROs, structs, function pointers, Swift cannot directly consume this. The languages are fundamentally different. The tooling can generate matching "things" for structs and function pointers but this is really just binding generation. The biggest issue is here:
C macros that are more complex than simple constant definitions have no counterpart in Swift.Last edited by kpedersen; 22 February 2022, 11:43 AM.
- Likes 2
Comment
-
Originally posted by kpedersen View Post
XCode does some amount of "importing" and generating of bindings:
https://developer.apple.com/document...tions_in_swift
However if you have a C header file containing MACROs, structs, function pointers, Swift cannot directly consume this. The languages are fundamentally different. The tooling can generate matching "things" for structs and function pointers but this is really just binding generation. The biggest issue is here:
Not entirely Swift's fault. I can't exactly state that "The biggest bug with Swift is that it is not C". However sometimes this does tend to feel to be the case.
Comment
-
Originally posted by Debunez View Post
My point still stands. You do not need *bindings* for C API's using Swift. Btw, I wrote all my swift code on Linux so Xcode is pretty much irrelevant. I was using xcb libraries directly in Swift. Just import and start typing. Where is the friction there?
Out of interest, what is the tool that generates the bindings? I thought this was done by the IDE (which was a bit annoying). Is it as simple as runningCode:swiftc <source>
OK, so it looks fairly powerful in terms of its binding generation for xcb. This is good to see. Do you envision that it can also wrap something quite high level like Gtk+ 2/3 including callbacks and things like that?
Comment
-
Originally posted by kpedersen View Post
It does look like you need bindings, but the tooling automatically generates them (kind of like SWIG, etc).
Out of interest, what is the tool that generates the bindings? I thought this was done by the IDE (which was a bit annoying). Is it as simple as runningCode:swiftc <source>
OK, so it looks fairly powerful in terms of its binding generation for xcb. This is good to see. Do you envision that it can also wrap something quite high level like Gtk+ 2/3 including callbacks and things like that?
But for simpler libraries, such as SDL or GLFW. Swift can use them as is (though some of the syntax will be a little clunky). I've tried writing Vulkan code in Swift in the past, but handling raw cstrings (for a lot of the layer and extension setup) is rough... Ultimately i ended up just going back to C as its my preferred language anyway. But I still have a place in my heart for Swift.
- Likes 1
Comment
-
I honestly don't see the point of Swift, especially since you basically have to use Objective C interop just to get a working app on iOS. Even something as simple as the return key being a submit on the last field of a form (e.g. a login form) is completely impossible with SwiftUI, and good luck finding out how to work around that, with Apple's extremely awkward and unhelpful documentation.
- Likes 1
Comment
-
It's interesting to read tidbits about Swift and the drama in its community. Well, the latter part is sad, I guess, but I can't completely decouple it from my feelings about Apple.
Anyway, my first thought, upon seeing the headline was "OMG, how did he even have time?". Chris seems like an incredibly busy individual, in his senior role at SiFive (VP Engineering) and now with his own firm, not to mention any involvement he still has with LLVM.
I still can't care. IMO, working with Apple isn't much different than the PRC. They'll tolerate you as long as you're useful, but you're ultimately disposable to them and have zero actual clout.
If you misread the dynamic, you get hurt. It's the kind of relationship you stay in only for as long as it serves your own interests. If you want to do something lofty, look elsewhere.Last edited by coder; 26 February 2022, 04:07 PM.
- Likes 1
Comment
Comment