Is Swift Bridge Possible?

classic Classic list List threaded Threaded
10 messages Options
hz
Reply | Threaded
Open this post in threaded view
|

Is Swift Bridge Possible?

hz
hi, All,

Given the lack of runtime support of Swift, is it safe to say it’s impossible now to implement a Swift-Lua bridge for production (feature set similar to Wax or LuaCocoa)?

Best Regards,
/hz
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

William Sumner

On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:

hi, All,

Given the lack of runtime support of Swift, is it safe to say it’s impossible now to implement a Swift-Lua bridge for production (feature set similar to Wax or LuaCocoa)?

Best Regards,
/hz


Preston
hz
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

hz
Checked that, seems no support for defining class from Lua side. Right?




On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:

hi, All,

Given the lack of runtime support of Swift, is it safe to say it’s impossible now to implement a Swift-Lua bridge for production (feature set similar to Wax or LuaCocoa)?

Best Regards,
/hz


Preston
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

Andrew Starks-2
On Thu, Jan 26, 2017 at 11:20 AM, fiosoftware <[hidden email]> wrote:

> Checked that, seems no support for defining class from Lua side. Right?
>
>
>
>
> On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:
>
> hi, All,
>
> Given the lack of runtime support of Swift, is it safe to say it’s
> impossible now to implement a Swift-Lua bridge for production (feature set
> similar to Wax or LuaCocoa)?
>
> Best Regards,
> /hz
>
>
> See https://github.com/sdegutis/lua4swift.
>
> Preston

What is a Lua class?

Which is to say, in order for the binding to support Lua classes, it
would need to pick one way to represent them and then create a bridge.
Given that class-like behavior in Lua can be done in many ways, that
is probably beyond the scope of a binding, even though the ability to
marshal classes from either side would be valuable.
--
Andrew Starks

Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

Chris Jones
Hey

I think flosoftware probably meant defining a Swift class from Lua, as one could do with, say, LuaCocoa.

I'm not an expert on Swift, but it's not currently a particularly dynamic language, so it may not actually be possible to define entirely new classes at runtime. Its creator, Chris Lattner, spoke about this on the atp.fm podcast recently and said that dynamicism is planned for Swift.

Cheers,
Chris

On 26 January 2017 at 17:35, Andrew Starks <[hidden email]> wrote:
On Thu, Jan 26, 2017 at 11:20 AM, fiosoftware <[hidden email]> wrote:
> Checked that, seems no support for defining class from Lua side. Right?
>
>
>
>
> On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:
>
> hi, All,
>
> Given the lack of runtime support of Swift, is it safe to say it’s
> impossible now to implement a Swift-Lua bridge for production (feature set
> similar to Wax or LuaCocoa)?
>
> Best Regards,
> /hz
>
>
> See https://github.com/sdegutis/lua4swift.
>
> Preston

What is a Lua class?

Which is to say, in order for the binding to support Lua classes, it
would need to pick one way to represent them and then create a bridge.
Given that class-like behavior in Lua can be done in many ways, that
is probably beyond the scope of a binding, even though the ability to
marshal classes from either side would be valuable.
--
Andrew Starks




--
Cheers,

Chris
hz
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

hz
Hi,

Yes. I mean something similar to:

waxClass {MyClass, SwiftFoo, protocols = {...}}

/hz



Hey

I think flosoftware probably meant defining a Swift class from Lua, as one could do with, say, LuaCocoa.

I'm not an expert on Swift, but it's not currently a particularly dynamic language, so it may not actually be possible to define entirely new classes at runtime. Its creator, Chris Lattner, spoke about this on the atp.fm podcast recently and said that dynamicism is planned for Swift.

Cheers,
Chris

On 26 January 2017 at 17:35, Andrew Starks <[hidden email]> wrote:
On Thu, Jan 26, 2017 at 11:20 AM, fiosoftware <[hidden email]> wrote:
> Checked that, seems no support for defining class from Lua side. Right?
>
>
>
>
> On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:
>
> hi, All,
>
> Given the lack of runtime support of Swift, is it safe to say it’s
> impossible now to implement a Swift-Lua bridge for production (feature set
> similar to Wax or LuaCocoa)?
>
> Best Regards,
> /hz
>
>
> See https://github.com/sdegutis/lua4swift.
>
> Preston

What is a Lua class?

Which is to say, in order for the binding to support Lua classes, it
would need to pick one way to represent them and then create a bridge.
Given that class-like behavior in Lua can be done in many ways, that
is probably beyond the scope of a binding, even though the ability to
marshal classes from either side would be valuable.
--
Andrew Starks




--
Cheers,

Chris
hz
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

hz
In reply to this post by Chris Jones
There are some internally defined runtime methods here:


But they're 
1. not public method 
2. not well defined as objc runtime
3. hard/impossible to expose



Hey

I think flosoftware probably meant defining a Swift class from Lua, as one could do with, say, LuaCocoa.

I'm not an expert on Swift, but it's not currently a particularly dynamic language, so it may not actually be possible to define entirely new classes at runtime. Its creator, Chris Lattner, spoke about this on the atp.fm podcast recently and said that dynamicism is planned for Swift.

Cheers,
Chris

On 26 January 2017 at 17:35, Andrew Starks <[hidden email]> wrote:
On Thu, Jan 26, 2017 at 11:20 AM, fiosoftware <[hidden email]> wrote:
> Checked that, seems no support for defining class from Lua side. Right?
>
>
>
>
> On Jan 26, 2017, at 9:24 AM, hz <[hidden email]> wrote:
>
> hi, All,
>
> Given the lack of runtime support of Swift, is it safe to say it’s
> impossible now to implement a Swift-Lua bridge for production (feature set
> similar to Wax or LuaCocoa)?
>
> Best Regards,
> /hz
>
>
> See https://github.com/sdegutis/lua4swift.
>
> Preston

What is a Lua class?

Which is to say, in order for the binding to support Lua classes, it
would need to pick one way to represent them and then create a bridge.
Given that class-like behavior in Lua can be done in many ways, that
is probably beyond the scope of a binding, even though the ability to
marshal classes from either side would be valuable.
--
Andrew Starks




--
Cheers,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

Eric Wing
In reply to this post by hz
Hi, I’m the author of LuaCocoa. I thought I would chime in.

So Swift is currently a very compile-time oriented language. I haven’t
done a deep dive into pushing on the dynamic side of Swift yet
(because it is still a little wild-wild-west on even just the
traditional C/static-side interoperability where I am spending my
time), but my overall impression is that building a bridge like
LuaCocoa out of Swift isn’t going to be viable (assuming no ‘cheating’
by calling the Objective-C runtime).

Within the Cocoa community, some prominent veterans have raised
concerns about the lack of dynamic features in Swift because there are
certain features and patterns in Cocoa that are easy to implement in
Obj-C, but very hard in Swift.  The Swift development team has
responded (on the Swift mailing list) that they are interested in
solving these problems, but are not there yet. It is a combination of
trying to implement these features that makes sense for the Swift
language as a whole, as well as priorities. The people who need
dynamic features are mostly framework authors, and actually a niche
within that group. And since Swift doesn’t even have a stable ABI yet,
there aren’t a lot of framework authors, so you might imagine that
priorities are focused on other things.


If you wanted to do a Swift-Lua bridge today, I would imagine you
would have to do it like the C++ bridges of today, i.e. relying on
code generation and generics to create the bridging at compile time.


-Eric

Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

Roman Tsisyk
In reply to this post by hz
>Thursday, January 26, 2017 7:24 PM +03:00 from hz <[hidden email]>:
>
>hi, All,
>
>Given the lack of runtime support of Swift, is it safe to say it’s impossible now to implement a Swift-Lua bridge for production (feature set similar to Wax or LuaCocoa)?
>
>Best Regards,
>/hz

You might be interested to see Swift support in Tarantool:

https://github.com/tris-foundation/tarantool

--
WBR,
  Roman Tsisyk <[hidden email]>
  http://tarantool.org/ - an efficient in-memory data store and a Lua application server
hz
Reply | Threaded
Open this post in threaded view
|

Re: Is Swift Bridge Possible?

hz
In reply to this post by Eric Wing
hi, Eric,

Thanks for the detailed explanation.

I had written a C++ - Lua binder once for an RPG game, after using Wax and LuaCocoa for iOS and Mac projects, never want to go back to use that template oriented bridge.

/hz

>
>
> Hi, I’m the author of LuaCocoa. I thought I would chime in.
>
> So Swift is currently a very compile-time oriented language. I haven’t
> done a deep dive into pushing on the dynamic side of Swift yet
> (because it is still a little wild-wild-west on even just the
> traditional C/static-side interoperability where I am spending my
> time), but my overall impression is that building a bridge like
> LuaCocoa out of Swift isn’t going to be viable (assuming no ‘cheating’
> by calling the Objective-C runtime).
>
> Within the Cocoa community, some prominent veterans have raised
> concerns about the lack of dynamic features in Swift because there are
> certain features and patterns in Cocoa that are easy to implement in
> Obj-C, but very hard in Swift.  The Swift development team has
> responded (on the Swift mailing list) that they are interested in
> solving these problems, but are not there yet. It is a combination of
> trying to implement these features that makes sense for the Swift
> language as a whole, as well as priorities. The people who need
> dynamic features are mostly framework authors, and actually a niche
> within that group. And since Swift doesn’t even have a stable ABI yet,
> there aren’t a lot of framework authors, so you might imagine that
> priorities are focused on other things.
>
>
> If you wanted to do a Swift-Lua bridge today, I would imagine you
> would have to do it like the C++ bridges of today, i.e. relying on
> code generation and generics to create the bridging at compile time.
>
>
> -Eric
>