• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Java or C++ for cross-platform Cocoa/.NET?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java or C++ for cross-platform Cocoa/.NET?


  • Subject: Re: Java or C++ for cross-platform Cocoa/.NET?
  • From: Jonathan Dodds <email@hidden>
  • Date: Mon, 7 Jun 2004 18:42:43 -0400

Managed C++ (MC++) is a set of non-standard extensions to C++ that allow for the creation of and interaction with objects in the .NET managed heap. MC++ is not portable.

You might lean heavily on the preprocessor to have code that can compile as either MC++ or C++. For non-.NET compiles you could #define away things like __gc. You'll also need to deal with type differences. For example, you can't use std::string in managed code; you must use the CLR String type. Basically you would be using the preprocessor to generate two different sources. That could get ugly. (And note that there are big changes to MC++ syntax that are coming with Visual Studio 2005.)

You could write the platform-independent code in straight standard C++ and take advantage of the standard C and C++ libraries. As you can with C++ and Objective-C, you can mix C++ and MC++. As with Obj-C++ there are certain restrictions because of differences in the object models. The unmanaged C++ code would not be subject to the garbage collector. That may not be a disadvantage unless there is a reason to be pure .NET.

If it is really important to keep the .NET and unmanaged code separate, you could wrap your platform-independent code in a COM object and then use COM-interop to call it from .NET.

I haven't used J# so I can't comment on it.

On Jun 7, 2004, at 9:58 AM, David Feldman wrote:

I've posted bit now regarding a cross-platform app I'm working on. It will be Cocoa on the Mac and .NET on Windows. The Windows UI will be written in C#. But I'm now realizing that I have two seemingly reasonable choices for the platform-independent code: C++ (as Managed-C++ compatible as possible) or Java (as J#-compatible as possible).

Anyway, I'm not entirely sure what the benefits would be one way or the other and was wondering if anyone else had thoughts on the matter. Both Java and C++ are natively supported by Cocoa. Java seems tempting because I'm guessing J# is closer to Java than Managed C++ is to regular C++. On the other hand, C++ has a certain comfort factor, and can be freely mixed with Objective-C.

A follow-up question as well: If I do go with Java over C++, does it make sense to keep the Cocoa UI in Obj-C? What are the pros and cons (aside from the fact that I'm comfortable in Obj-C)? What's the best way to mix Java and Obj-C in a single Cocoa project?

Thanks,
--Dave

----------------------------------------------------------------------- ---
David A. Feldman
User Interface Designer
http://InterfaceThis.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Java or C++ for cross-platform Cocoa/.NET?
      • From: David Feldman <email@hidden>
References: 
 >Java or C++ for cross-platform Cocoa/.NET? (From: David Feldman <email@hidden>)

  • Prev by Date: Re: Newbie Alert: NSMovieView with control won't update when movie changes.
  • Next by Date: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
  • Previous by thread: Java or C++ for cross-platform Cocoa/.NET?
  • Next by thread: Re: Java or C++ for cross-platform Cocoa/.NET?
  • Index(es):
    • Date
    • Thread