开发者

Feasible to switch to objective-c on these platforms and situation?

开发者 https://www.devze.com 2023-02-12 10:46 出处:网络
I\'ve written most of a game engine using C++ that runs on OSX and iOS (Xcode 3.5 so, GCC), Linux (GCC), and Windows (Vis Studio 2010).It uses stl vector for collections of objects.It implements messa

I've written most of a game engine using C++ that runs on OSX and iOS (Xcode 3.5 so, GCC), Linux (GCC), and Windows (Vis Studio 2010). It uses stl vector for collections of objects. It implements message passing. The engine is using OpenGL on the iOS platform and will eventually use OpenGL on all platforms and potentially DirectX on windows.

I really don't like C++, although I have a very strong understanding of it. I'm a C programmer and after an introduction to Objective-C a year ago, I realized it's ideal for how I work开发者_开发百科 and think. So it would be a huge advantage for me to switch to Objective-C. Unfortunately, the beautiful world of OSX/Cocoa isn't the reality of Windows or Linux.. or is it?

I am sure a Cocoa/Apple/NeXT evangelist will provide me with a masterpiece of an answer here

Edit:

Looks like Cocotron and GNUstep are 2 options, with GNUstep being more mature but seeming to have more baggage such as requiring a runtime.

I need a solution that can fit these requirements:

  • Able to compile, run, debug Objective-C on all platforms
  • Able to use the Cocoa API calls on all platforms (ie NSString, NSNumber..)
  • Endusers should be able to install and run my app without installing anything extra, or at a minimum my installer should be able to easily and non-pervasively install anything (such as a runtime) GNUstep requires runtime, Cocotron does not
  • Explains what issues I may hit. For example, will I be able to use the provided Cocoa stuff for parsing XML? What about CFSocket? What about CG? Where does the solution end and I go in to the realm of OS-specific libraries that aren't ported?

Ideal:

  • Can support closures (blocks) on all platforms so that I can use GCD and libdispatch as it becomes available, even if it boils down to less efficient situation on non-native platforms
  • An API to allow Core Data type data management (I'm dreaming here), even if it boils down to less efficient situation on non-native platforms
  • A forward-looking solution that will maybe use LLVM since that seems to be the way things are moving

Do NOT Require:

  • GUI functionality such as drawing NSView etc
  • IDE functionality except on OSX
  • Objective-C 2.0
  • Objective-C++
  • Garbage Collection
  • Ease of my setup: that is, it's OK if this is a pain for me to set up and configure to get working, as long as the working solution fits my needs and allows me to write code that will be easy (portable as per requirements above) and doesn't push any of that pain on to my users.


Cocotron is absolutely phenomenal software that has suited my every need so far. While the documentation is poor and it's hard to understand and get working, it's extremely worthwhile and very awesome.

The LLVM/blocks/libdispatch doesn't seem like quite a reality yet, although it may be, but I think certainly at the switch to Xcode 4 it will all be very real. It really boils down to minGW working with LLVM.

There is even an implementation of Core Data.. wow


Objective-C is available on any platform that GCC is available on, granted it isn't the same GCC Objective-C compiler that Apple uses. Cocoa and all the OSX/iOS goodness that goes along with it, isn't, this is the main reason that Objective-C doesn't have a lot of uptake on non-OSX platforms, no really robust library like Cocoa that is cross-platform. GNUstep is an Open Source standard library that is Cocoa like but that has been going on for over 10 years and still isn't complete, and it is based on OpenStep which is so far removed from Cocoa that it isn't relevant. There is also something called Cocotron which is more recent but still looks incomplete. Xcode is probably the only good Objective-C IDE. I am sure there is probably some obscure Eclipse plug-in project somewhere on the internet, but it will never rival Xcode. I doubt that anything is going to give you OSX like GUI applications cross platform, your best bet would be to write Objective-C bindings around QT for cross platform GUIs, but that would require the GCC compiler to be able to compile Objective-C++.


clang + blocks (closures) are now available on linux using libdispatch

sudo apt-get install libblocksruntime-dev

clang test.c -fblocks -lBlocksRuntime -o test

0

精彩评论

暂无评论...
验证码 换一张
取 消