<p>I've seen several posts that outline the difficulties creating bindings for the mobile platforms (i.e. android or iOS), some of them claiming that's not even feasible(i.e. you would end-up writing some kind of non-go code) so I'm wondering if frameworks binding is on any roadmap or it's just something that we shouldn't expect. Is it more a technical issue or a kind of grunt work issue? I imagine it should be possible to just "generate" these bindings.
The release of Apple Swift as open source could actually help to write a binding generator, right?</p>
<p>I'm aware that Go has mobile support[0] but that seems to be the case only for games(i.e. no cocoa or android API support).</p>
<p>[0] <a href="https://github.com/golang/mobile" rel="nofollow">https://github.com/golang/mobile</a></p>
<hr/>**评论:**<br/><br/>koffiezet: <pre><p>I'm not sure how Obj-C/Swift bindings work, but I would think they should be similar to C/C++? No idea though...</p>
<p>I'm not sure how you envision autogenerating stuff like that, it's more complex than you'd think. There is stuff like <a href="http://www.swig.org/" rel="nofollow">swig</a> to generate C/C++ library wrappers, but even then you still need to do quite some manual preparations to get things working, and I don't think it can do Go->Objective-C...</p>
<p>So it's probably down to some serious grunt work, having someone willing to do this stuff.</p>
<p>Also mind that a blind 1:1 binding might not be what you want, or might even be possible due to differences in concepts in the languages.</p></pre>kjk: <pre><p>Don't expect good Cocoa bindings for Go. It's possible to do but the mismatch between how Cocoa/Objective-C sees the world and how Go sees the world means that bindings will be slow, tedious to write and awkward to use.</p>
<p>Consider calling a simple Cocoa function like [NSButton setTitle:"foo"]. In Go, strings are binary blobs (possibly in utf8, but that's not enforced, so you really don't know the encoding). In Cocoa, strings are UTF 16. In a hypothetical Go binding, if you do button.setTitle("foo"), "foo" has to be converted from byte string to UTF16, which is expensive (compared to function call) and you need to write a wrapper that does this conversion for every function that takes NSString as an arg. That's a lot of wrappers.</p>
<p>This is only one example of Cocoa and Go mismatch. Cocoa is an object-oriented, dynamic runtime. Swift was explicitly designed for Objective-C/Cocoa interop. Go wasn't.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传