News for hackers. Stuff that matters.
Re:Winding down the Swift 3 release by pjmlp on Monday May 16, 2016 @06:13PM (#11710058)
> Swift is a successor to both the C and Objective-C languages.

Source: https://developer.apple.com/swift/

Re:Winding down the Swift 3 release by nardi on Monday May 16, 2016 @06:42PM (#11710211)
Objective-C requires a runtime, and the Darwin kernel is not implemented in Objective-C.

Also, Swift, unlike Objective-C, is not a superset of C.

Re:Winding down the Swift 3 release by pjmlp on Tuesday May 17, 2016 @01:06AM (#11711459)
Interesting that you decided to ignore the fact that Apple also mentions C, which is what the Darwin kernel is implemented on, isn't so?

Which also happens to have a runtime, crt0.o.

Re:Winding down the Swift 3 release by the_why_of_y on Tuesday May 17, 2016 @07:29AM (#11712670)
C has a runtime, used in a "hosted" implementation (your typical *NIX user-space program) - but it's optional, and there is the alternative "freestanding" implementation that doesn't need to have a runtime or standard library, and this is generally used to implement kernels.

http://www.iso-9899.info/n1570.html#4.p6

Re:Winding down the Swift 3 release by pjmlp on Tuesday May 17, 2016 @11:13AM (#11714314)
Doesn't invalidate the fact that Swift could eventually be used in similar scenarios.

Usually in these scenarios I believe it just requires a company to bully developers to accept it and an eventual generation change.

If tomorrow Apple decides, for whatever reason, that new kext or IOKit modules are to be written in Swift, then whoever cares about their Apple OS customers will just comply with it.

Re:Winding down the Swift 3 release by whistler on Tuesday May 17, 2016 @02:08PM (#11715876)
It is possible but the Swift stdlib does rely on a minimal set of libc functions including malloc()/free() and the usual str* and mem* functions. Some of the other functionality can be removed eg the math and floating point but even implementing malloc() in Swift would be hard because any data structures that get used eg Arrays will themselves rely on malloc(), and even if you wrote it using UnsafeMutablePointer it would not be much different to a C implentation. Also the globalinit functions that get called at startup themselves rely on malloc() so it ends up being circular.

However if you are willing to accept some functionality will be written in C it is possible to run Swift directly on bare metal.

Re:Winding down the Swift 3 release by pjmlp on Tuesday May 17, 2016 @02:42PM (#11716165)
> However if you are willing to accept some functionality will be written in C it is possible to run Swift directly on bare metal.

I would rather use Assembly or compiler intrinsics instead, just like many C alternatives, some much older like NEWP, do.

Also many of the C library calls are impossible to implement in pure ANSI C without language extensions or Assembly, malloc() and free() being two of them.

Re:Winding down the Swift 3 release by nardi on Tuesday May 17, 2016 @12:29PM (#11714945)
What I think you're missing is that using a runtime is impossible in an OS kernel, unless the runtime doesn't use any OS features. You at least need to bootstrap enough of an OS before you can use the runtime. It's not the same thing as kexts or IOKit modules.
Re:Winding down the Swift 3 release by pjmlp on Tuesday May 17, 2016 @02:06PM (#11715865)
It is so impossible that history of computing is full of such examples, but the C community likes to re-write history so thay younger generations don't feel the need to dive into ACM papers about how the world was outside AT&T walls.
Re:Winding down the Swift 3 release by nardi on Tuesday May 17, 2016 @05:42PM (#11717717)
Sincerely: I would love to learn about one or more of these. Do you have any links to papers?
Re:Winding down the Swift 3 release by the_why_of_y on Tuesday May 17, 2016 @12:38PM (#11715034)
Could be, I wouldn't rule it out, but if so I've got serious doubts that it would be the full Swift language - the Objective-C style "dynamic" dispatch seems rather inappropriate for kernel space.
Re:Winding down the Swift 3 release by whistler on Wednesday May 18, 2016 @04:22AM (#11720503)
I agree that dynamic dispatch is not suitable for a kernel however if you compile Swift on a linux host then there is no ObjC runtime support anyway so its not an issue. However I would still see it as the full Swift language