Cross-platform functional language for Objective-C

EDIT: Having spent several hours learning this, I don’t think I’m going to find anything that actually will ultimately save me compared to the amount of time and effort to find the right language, suitable bindings, and keeping this environment in the face changes on all of these platforms. I accept the answer that seems most realistic because it would be the best idea for most people. The opinion I use from these conversations and the others that I have is that the only sure way is to use a functional language that can work without external bindings, or one that has bindings supported by a commercial entity such as F #. This is too much work and too little demand, and the state of what is available in the wild reflects this. I hope he changes one day.

I would like to start using a functional language in my software in addition to Objective-C, which is my main language (C can be functional as a binding?). Must be cross-platform, which means Windows, Linux, OSX (x86) and iOS (ARM). What should I use and how can I achieve this?

I plan to migrate to LLVM server and Clang soon for my Objective-C, if that matters.

I do not have any “investment in knowledge” in any functional language, although I have tricked them several times. I study it from scratch, so I want to learn something non-essential, if possible

  • The solution should be real , there is a lot of preliminary or prototype work, but ..
  • I am using target C, and I really need Cocoa bindings; because a lot of my data uses Cocoa types, so otherwise everything will be useless. Also, Objective-C messaging would prevent me from creating glue code between static C functions and my Objective-C instance objects (this is what Objective-C method calls do inline ..)
  • The solution must be safe for static binding (iOS requirement)

Here are examples of what I would like to do:

  • Process byte language, e.g. network protocol
    • Input: bytes and length and instance of the <call> Objective-C method
    • Exit: return to the Objective-C method call, send it cocoa -container arguments
  • Make decisions about the best "move" in a board game
    • Input: cocoa -saved state data, call Objective-C call
    • Exit: maybe change the state data, maybe call an arbitrary Objective-C method, and then return to the Objective-C method call, send it cocoa -container arguments
+4
source share
5 answers

Gambit or Chicken Scheme is probably the best choice - they compile with C.

+2
source

As Daniel Bünzli mentions, we have the OCaml app for the iPhone, which is sold right now in the iPhone app store. (This is a card game called Cassino, if you want to find it.) Apple abandoned its language restrictions in September 2010, and we did not encounter any resistance at all (although, of course, we are a very small player).

I have compiled some examples for writing iOS applications in OCaml, which you can find on our website:

http://psellos.com/ocaml/example-app-portland.html
http://psellos.com/ocaml/example-app-slide24.html

You did not mention if you want the GUI code to be cross-platform. This is a very complicated problem. Our code uses thin wrappers to access native Cocoa touch libraries that will not work on Linux or Windows. They work (at least a subset) on OS X. In the tutorial examples, you can see some custom (greatly simplified) Cocoa Touch wrappers.

OCaml certainly works well on all the systems you mention. It seems like a pretty good choice for me (somewhat biased OCaml enthusiast).

+5
source

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 binding exception. See here for more details:

http://caml.inria.fr/ocaml/license.en.html

Some have already made applications in OCaml, which are available in the application store, you do not need to pay 3000 €. Follow these instructions:

http://web.yl.is.su-tokyo.ac.jp/~tosh/ocaml-on-iphone/index.html

http://psellos.com/ocaml/compile-to-iphone.html

+4
source

I really don't know what “Functional Language for Objective-C or C” means, but GHC (Haskell) is licensed by BSD and has good F FFI. In addition, the iPhone had a lot of work for the GHC.

+3
source

Source: https://habr.com/ru/post/1340566/


All Articles