Author Topic: Objective C Portability  (Read 10772 times)

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Objective C Portability
« on: December 17, 2011, 08:43:51 PM »
How portable is Objective C?  Or, can the iOS devices run regular C? I am going to use C for my roguelike, but I also wanted a port to most every OS there is, including iOS (and maybe Android?) I suppose the best way to answer my questions is to make a list of every system each can run on, ie:

C ---------------------- Obj. C
Windows                 iOS
Unix                         OSX
etc                           etc
{O.o}
 |)__)
   ” ”   o RLY?

ido

  • Rogueliker
  • ***
  • Posts: 618
  • Karma: +0/-0
    • View Profile
    • Tame Tick
Re: Objective C Portability
« Reply #1 on: December 18, 2011, 11:42:32 AM »
You can compile c for ios, and there are objc compilers for linux and windows (gcc for example supports objc). So assuming you're only targeting fairly mainstream hardware both of them support pretty much everything.
« Last Edit: December 18, 2011, 11:44:06 AM by ido »

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #2 on: December 18, 2011, 05:09:45 PM »
Ok, thanks Ido
{O.o}
 |)__)
   ” ”   o RLY?

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #3 on: December 19, 2011, 03:13:46 AM »
On another Objective C related question, are there any roguelike libraries for Objective C, or do I even need one?
{O.o}
 |)__)
   ” ”   o RLY?

eclectocrat

  • Rogueliker
  • ***
  • Posts: 81
  • Karma: +0/-0
  • Most of your personality is unconscious.
    • View Profile
    • Mysterious Castle
    • Email
Re: Objective C Portability
« Reply #4 on: December 19, 2011, 06:00:28 AM »
I don't know of any portable Objective-C libraries at all (OpenStep has not worked well for me...)

The good news is that Objective-C is a strict superset of C, so you can use any C library without recompiling.
Your best bet is to pick a good framework like SDL or something, write a roguelike engine that will draw whatever you want wherever you want it and then proceed from there.

Objective-C is a very nice language IMHO, quite readable, but most people only know it as Cocoa/NextStep.

ido

  • Rogueliker
  • ***
  • Posts: 618
  • Karma: +0/-0
    • View Profile
    • Tame Tick
Re: Objective C Portability
« Reply #5 on: December 19, 2011, 03:07:11 PM »
Your best bet is to pick a good framework like SDL or something, write a roguelike engine that will draw whatever you want wherever you want it and then proceed from there.

LibTCOD is also available in c, is a lot higher level than SDL (not to mention already has a lot of rl-specific stuff built-in) and can probably save Pueo a lot of work.

-Ido.

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #6 on: December 19, 2011, 05:26:51 PM »
Your best bet is to pick a good framework like SDL or something, write a roguelike engine that will draw whatever you want wherever you want it and then proceed from there.

LibTCOD is also available in c, is a lot higher level than SDL (not to mention already has a lot of rl-specific stuff built-in) and can probably save Pueo a lot of work.

-Ido.

Ah, so since Objective C is basically C + Small-talk, I can still use libtcod, since it is a C library?
{O.o}
 |)__)
   ” ”   o RLY?

eclectocrat

  • Rogueliker
  • ***
  • Posts: 81
  • Karma: +0/-0
  • Most of your personality is unconscious.
    • View Profile
    • Mysterious Castle
    • Email
Re: Objective C Portability
« Reply #7 on: December 20, 2011, 02:56:22 PM »
Yeah, and although I don't have much experience with LibTCOD, a lot of competent people recommend it, so it sounds like a good bet.

Leaf

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #8 on: December 21, 2011, 10:59:41 AM »
Warning: Personal opinions lie ahead, and y'all know how opinions are...  I apologize in advance for any of this that turns into an early-morning pre-coffee geekrant.  :3

I like objc.  I think it's a good OO extension to C that lacks the mess of certain other C-derived OO languages.

I think if you want massive portability, it's not the best choice, though.  Yes, it will compile on many platforms, but you're going to end up linking with a bunch of native C libraries on each platform for cross-platform graphics, sound, etc, and having to not only manually manage the heap allocation associated with those libraries, but also manage the differing build process on all the platforms you want to support.

(Here's that pre-coffee geekrant. :P )  My opinion is: it's almost 2012, not 1980.  Automatic garbage collection is a wonderful thing, despite what some might say. ;P  The only reason to be managing your own heap allocation these days is if you're doing teeth-on-the-hardware OS-level stuff or targeting tiny embedded systems that don't have room for a rich execution environment.  I don't know how I didn't pull out all my hair back in the C-in-Unix day when we had to explicitly free() stuff, trying to track down those couple of obtuse memory leaks that /always/ found their way in somewhere....

(Edit: Unless you like doing your own heap management, I guess.  Diffrn't strokes and all that, I suppose, but I find that I get a lot more done per unit time without it.)

Anyway, I think if you want to write portable software, you're better off using an inherently portable language like Python, Java, or C#.  It is unfortunate that Apple has chosen a licensing scheme that makes using such languages on their handheld platform difficult. :<

I chose Java meself, explicitly because there are some tools in development at Google for compiling java apps down to native arm code that can be distributed on the Apple store and installed without rooting the machine.  The tools are still a bit too immature to mess with at the moment, imo, but I am hoping that they'll be pretty decent by the time I get this particular project complete enough to start thinking about porting it to something other than Swing and Droid.
« Last Edit: December 21, 2011, 11:13:02 AM by Leaf »

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #9 on: December 21, 2011, 05:28:41 PM »
@Leaf:
Thanks for the info, and I know we all have those geekrant moments :) Yes, I am a little sad that iOS has to be written in Obj C to really work, but I also appreciate you giving me a heads-up on some of the problems I might face.
{O.o}
 |)__)
   ” ”   o RLY?

Leaf

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Objective C Portability
« Reply #10 on: December 21, 2011, 10:42:33 PM »
I do apologize for being a little ranty in that last post. :P

I think when it all comes down to it, you should use whatever you'll have the most fun with and if it's not portable, then oh well.  The more fun it is, the more likely you are to finish it.  And if you finish it, even if it ends up less good than you want, and even if it only runs on one platform, I still expect you'll have accomplished more than 90% of us. XD

Myself included.  I haven't actually /finished/ a free-time game programming project since the Apple 2 days. :3  They sure are fun to write and then abandon when ya get to the boring parts, though..... :3