Objective-C 的跨平台函数式语言
编辑:在花了几个小时研究这个之后,与寻找合适的语言、合适的绑定和维护所需的时间和精力相比,我认为我不会找到任何真正能节省时间的东西面对所有这些平台上的变化,这种环境。我接受看起来最现实的答案,因为这对大多数人来说是最好的主意。我从这些对话和其他对话中得出的观点是,唯一真正的前进方向是使用无需外部绑定即可运行的函数式语言,或者使用由商业实体(例如 F#)维护的绑定的语言。工作量太大,需求太少,野外可用资源的状况反映了这一点。我希望有一天它会改变。
我想开始在我的软件中使用一种函数式语言,除了我的主要语言 Objective-C(C 可能可以作为绑定?)。必须是跨平台的,即 Windows、Linux、OSX (x86) 和 iOS (ARM)。我应该使用什么以及如何实现这一目标?
我计划很快为我的 Objective-C 切换到 LLVM 后端和 Clang,如果这有什么区别的话。
尽管我用过一些函数式语言,但我没有对任何函数式语言进行任何“知识投资”。我正在从头开始学习一个,所以如果可能的话,我想学习一些非神秘的东西
- 解决方案必须是真实的,已经完成了很多初步或原型工作但是..
- 我正在使用objective C并且我确实需要 Cocoa 绑定;因为我的大量数据都使用 Cocoa 类型,否则事情会变得一团糟。此外,objective-c 消息传递将阻止我需要在静态 C 函数和 Objective-C 对象实例之间创建粘合代码(这已经是 Objective-c 方法调用正在执行的内置操作......)
- 该解决方案必须是许可证安全的用于静态链接(iOS 要求)
以下是我想要做的示例:
- 处理字节语言,例如网络协议
- 输入:字节和长度以及“调用”objective-c 方法实例
- 输出:返回调用 Objective-C 方法实例,向其发送 cocoa-container 参数
- 做出关于棋盘游戏中最佳“移动”的决定
- 输入:cocoa 包含的状态数据,“调用”objective-c 方法实例
- 输出:可能改变状态数据,可能调用任意 Objective-C 方法,然后返回调用 Objective-C 方法实例,向其发送 cocoa-container 参数
EDIT: After spending several hours researching this, I don't think I'm going to find anything that will actually end up saving me time compared to the amount of time and effort of finding suitable language, suitable bindings, and maintaining that environment in the face of change on all these platforms. I'm accepting the answer that seems most realistic because it would be the best idea for most people. The opinion I'm drawing from these conversations and others I'm having is that the only true way forward is to either use a Functional language that can operate without external bindings, or something that has bindings maintained by a commercial entity such as F#. It's too much work and too little demand and the state of what's available in the wild reflects that. I hope it changes one day.
I'd like to start using a functional language in my software, in addition to Objective-C which is my primary language (C may be workable as the binding?). Must be cross-platform, meaning Windows, Linux, OSX (x86), and iOS (ARM). What should I use and how can I achieve this?
I'm planning to switch to LLVM backend and Clang for my Objective-C soon, if this makes any difference.
I don't have any "knowledge investment" in any functional language, although I've screwed around with a few. I'm learning one from scratch so I want to learn something non-arcane if possible
- The solution must be real, there's a lot of preliminary or prototype work done but..
- I'm using objective C and I really do need Cocoa bindings; because a large amount of my data is using Cocoa types so things would be a mess otherwise. Also objective-c messaging would prevent me from needing to create glue code between static C functions and my Objective-C object instances (which is already what objective-c method calls are doing built-in..)
- The solution must be license-safe for statically linking (iOS requirement)
Here are examples of what I would like to do:
- Process a language of bytes, for instance a network protocol
- Input: bytes and length and 'calling' objective-c method instance
- Output: return to calling objective-c method instance, send it cocoa-container arguments
- Make decisions about the best "move" in a board game
- Input: cocoa-contained state data, 'calling' objective-c method instance
- Output: possibly alter state data, possibly call an arbitrary objective-c method, and then return to calling objective-c method instance, send it cocoa-container arguments
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
正如 Daniel Bünzli 提到的,我们有一个 OCaml iPhone 应用程序,目前在 iPhone 应用程序商店中出售。 (这是一款名为 Cassino 的纸牌游戏,如果你想找的话。) Apple 在 2010 年 9 月取消了语言限制,我们没有遇到他们的任何阻力(当然我们是一个非常小的玩家)。
我整理了一些在 OCaml 中编写 iOS 应用程序的教程示例,您可以在我们的网站上找到这些示例:
http ://psellos.com/ocaml/example-app-portland.html
http://psellos.com/ocaml/example-app-slide24.html
你没有提到你是否希望 GUI 代码是跨平台的。那是一个多
更难的问题。我们的代码使用瘦包装器来访问本机 Cocoa Touch 库,该库无法在 Linux 或 Windows 上运行。它们在 OS X 上确实可以工作(至少是一个子集)。您可以在教程示例中看到一些自定义(非常简化的)Cocoa Touch 包装器。
OCaml 当然可以在您提到的所有系统上运行良好。对于我(一个有点偏向的 OCaml 爱好者)来说,这似乎是一个相当不错的选择。
As Daniel Bünzli mentions, we have an OCaml iPhone app that's for sale right now in the iPhone app store. (It's a card game named Cassino, if you want to look for it.) Apple dropped their language restrictions in September 2010, and we encountered no resistance from them whatsoever (though of course we are a very small player).
I put together some tutorial examples for writing iOS apps in OCaml that you can find at our website:
http://psellos.com/ocaml/example-app-portland.html
http://psellos.com/ocaml/example-app-slide24.html
You don't mention whether you want GUI code to be cross platform. That's a much
harder problem. Our code uses thin wrappers to access the native Cocoa Touch libraries, which aren't going to work on Linux or Windows. They do work (at least a subset) on OS X. You can see some custom (much simplified) Cocoa Touch wrappers in the tutorial examples.
OCaml certainly works well on all the systems you mention. It seems like a pretty good choice to me (a somewhat biased OCaml enthusiast).
OCaml 不是 GPL。编译器本身根据 Q 公共许可证分发,标准库根据 LGPL 分发,但有静态链接例外。请参阅此处了解更多详细信息:
http://caml.inria.fr/ocaml/license.en .html
有些已经在 OCaml 中完成了应用程序,这些应用程序可以在应用程序商店中找到,您不需要支付 3000 欧元。请按照以下说明操作:
http:// web.yl.is.su-tokyo.ac.jp/~tosh/ocaml-on-iphone/index.html
http://psellos.com/ocaml/compile-to-iphone.html
OCaml is not GPL'd. The compiler itself is distributed under the Q Public License and the standard library is distributed under the LGPL with a static linking exception. See here for more details :
http://caml.inria.fr/ocaml/license.en.html
Some have already done apps in OCaml which are available on the app store, you don't need to pay 3000€. Follow these instructions :
http://web.yl.is.s.u-tokyo.ac.jp/~tosh/ocaml-on-iphone/index.html
http://psellos.com/ocaml/compile-to-iphone.html
我真的不知道“Objective-C 或 C 的函数式语言”是什么意思,但 GHC (Haskell) 是 BSD 许可的,并且有一个很好的 C FFI。 iPhone 上的 GHC 也做了很多工作。
I don't really know what a "Functional Language for Objective-C or C" means, but GHC (Haskell) is BSD licensed, and has a nice C FFI. There has also been a lot of work for GHC on iPhone.
Gambit 或 Chicken Scheme 可能是您最好的选择——它们编译为 C。
Gambit or Chicken Scheme are probably your best bet — they compile to C.
Xamarin 支持 F# 截至 2014 年中期,情况相当不错。
Xamarin's support for F# is pretty good as of mid 2014.