是否可以用C语言编写核心逻辑来为浏览器、android和iphone进行开发?
通过谷歌搜索,这似乎可以在使用 NDK 的 iOS、Android 以及使用 Java Web Start 或 Java Applet 的浏览器中实现。我知道 iOS 和 Android 的 GUI 必须使用 Objective-C 和 Java 来完成。如果这可能的话,当您开始考虑调试支持时,它有多实用?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Objective-C 运行时可以通过 访问C api,因此可以使用纯C++为iOS和Cocoa编写代码。
对于 Web 开发,据我所知,目前没有任何东西可以让您部署用 C++ 编写的代码。这是因为 C++ 通常被编译为本机代码,这很难沙箱化,并且意味着存在安全漏洞。将来,可能可以使用 Native Client 运行此类代码。目前它仍在开发中,但作为 Chromium 的实验性扩展,它已经部分发挥作用。
对于 Android,您的代码必须始终在 Dalvik JVM 中运行,但您可以使用 Android NDK。
The Objective-C runtime can be accessed through a C api, so it is possible to write code for iOS and Cocoa using pure C++.
For web development, there is nothing that I know of that is currently available that allows you to deploy code written in C++. This is because C++ is usually compiled into native code, which is very difficult to sandbox and which would imply a security hole. In the future, it may be possible to run such code with Native Client. At the moment it is still in development, but it is already partially functional as an experimental extension to Chromium.
For Android, your code must always run in the Dalvik JVM, but you can incorporate C++ that has been compiled into native code by using the Android NDK.
我不能代表浏览器发言,但我在 iOS 上开发 C++ 已经快几年了。 Fieldrunners 和 Autodesk Tinkerbox< /a> (这两个都是我工作的)是 C++。 GUI 也是定制的 C++。只有少量的 Objective-C,因此 C++ 代码可以与 iOS 交互。 Android 版本的 Fieldrunners 还使用 C++ 代码库和少量 Java,同样作为粘合代码。
I can't speak for the browser, but I've been doing C++ on iOS for almost a couple years now. Both Fieldrunners and Autodesk Tinkerbox (both of which I work on) are C++. The GUI is also custom C++. There is only a tiny amount of Objective-C so that the C++ code can interface with iOS. The Android version of Fieldrunners also uses the C++ codebase with just a tiny amount of Java, again as glue code.