caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: Ocaml, Objective-c, and XCode
@ 2010-02-12 21:29 dynasticon
  0 siblings, 0 replies; 2+ messages in thread
From: dynasticon @ 2010-02-12 21:29 UTC (permalink / raw)
  To: caml-list; +Cc: dynasticon

Andrew Webb <andrew.webb@gmail.com> writes:

> I have a few questions relating to using Ocaml with objective-c for
> anyone who programs on a Mac.

We've been working with OCaml/ObjC/Cocoa on the iPhone for a while.  We
also have a small subset working on the Mac and have built Mac apps with
it.

> I am aware that there aren't any real bindings between ocaml and
> objective-c/cocoa, so I am investigating rolling my own.

This is what we did.  There was some work on an OCaml/Cocoa bridge, but
it doesn't appear to be finished, and doesn't look like an active
project.  The home page is here:

    http://code.google.com/p/objective-c-caml-bridge

> 1) Does anyone have experience in interfacing ocaml and objc? Is it
> difficult?

The things that make it easier than it could be are:

(a) There is good documentation on interfacing OCaml and C, and ObjC is
    a clean superset of C.  So the language tools all work together
    quite well.

(b) The OO subsystem of OCaml is a pretty good match for the Cocoa
    design.  With some work, you can use OCaml objects to represent
    Cocoa objects, and vice versa.

The hard parts are:

(a) Cocoa is a very large system, too large for a small number of people
    to build an interface by hand.  A mechanical interface generator
    would be best, but is also a big project.

(b) There's a mismatch between the ObjC reference counting and OCaml GC.

For our work, we just add bits to our interface as we need them.  Memory
management issues are tricky but only need to be solved once in the
lowest layer.  We don't have any experience with the ObjC GC; this might
make things a little trickier.

One thing to note is that we like OCaml because it's very flexible and
expressive.  If you mechanically translate all Cocoa objects and structs
into their obvious OCaml corollaries, you lose a lot of the advantage of
using OCaml.  For example, we map Cocoa NSPoint values into OCaml
2-tuples, not into OCaml records.  And we often use OCaml lists (with
the correct base type) to represent NSArray objects.  Because of this,
we don't think a direct mechanical translation of Cocoa into OCaml is
going to work.  But a mechanical translation with sufficient overrides
probably would.

> 2) Does anyone have a small example project that does mix these two
> languages? I have looked at unison, but it is too big for me to get my
> head around. I am thinking more on the scale of the ubiquitous
> Currency Converter...

I don't know of anything.

> 3) Does anyone who is mixing these languages use Xcode to do so? If
> so, what steps do you need to go through to set that up?

To be honest, we don't currently use Xcode in any non-trivial way.  We
just use its built-in knowledge about packaging up applications.  There
was a project to integrate OCaml into Xcode, but again it doesn't look
like an active project.  The home page is here:

    http://maxao.free.fr/xcode-ocaml-plugin

Jeff Scofield
Seattle


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Ocaml, Objective-c, and XCode
@ 2010-02-11  1:28 Andrew Webb
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Webb @ 2010-02-11  1:28 UTC (permalink / raw)
  To: caml-list

Hi there,

I have a few questions relating to using Ocaml with objective-c for anyone who programs on a Mac. I am aware that there aren't any real bindings between ocaml and objective-c/cocoa, so I am investigating rolling my own. So:

1) Does anyone have experience in interfacing ocaml and objc? Is it difficult?
2) Does anyone have a small example project that does mix these two languages? I have looked at unison, but it is too big for me to get my head around. I am thinking more on the scale of the ubiquitous Currency Converter...
3) Does anyone who is mixing these languages use Xcode to do so? If so, what steps do you need to go through to set that up?

A big thanks to anyone who can answer (some of) these questions. I am trying to decide whether to use haskell or ocaml for my next cocoa application, as these are the two languages I am most comfortable. I have recently found an excellent description of how to do this using haskell (http://tscheff.blogspot.com/2010/02/currync-converter-using-haskell-with.html) and was wondering if there were such resources for ocaml.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-12 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-12 21:29 Ocaml, Objective-c, and XCode dynasticon
  -- strict thread matches above, loose matches on Subject: below --
2010-02-11  1:28 Andrew Webb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).