Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Has anyone attempted using Objective-C for game development outside of iOS gaming? It'd be interesting using it as an OO language substitute for C++.


I’m sure there’s been Mac games written in Objective-C, but there are certainly no cross-platform games written in it because vital bits of Objective-C aren’t actually part of Objective-C; instead, they’re part of the Foundation framework in OS X and iOS. You can compile Objective-C on whatever platform you like through GCC but you’re going to have to write your own memory management, allocation, etc among other things in order to do so. That said, you might be able to write a cross-platform game through open source Foundation/AppKit implementations like GNUStep and Cocotron, but keep in mind that they implement a version of Foundation that’s several versions behind now.

The next closest thing is probably Swift alongside Apple’s FOSS reimplementation of Foundation for Swift, though I don’t know how well Swift works for development with OpenGL and such.


Yes, I used Obj-C to port a game from iOS to Android. Mac and Windows versions coming soon, also in Obj-C! I use Clang, GNUstep and my own rewrite of UIKit.

Possibly this is just Stockholm syndrome, but the more I use Obj-C, the more I like it. It uses reference counting, so memory overhead is low and consistent, and running time is consistent. It's not fast, true, but in my case most of the running time is spent in OpenGL anyway. Plain C is always there at your fingertips for crucial inner loops. Newer features like properties and for-each loops make it fairly pleasant to use. The standard Foundation library is pretty well-designed.

The one thing it's possibly missing is generics (Apple added that feature recently but I haven't tried it yet). Without generics, it feels a bit like a reference-counted Go -- that slight scripting language feel but with native speed.

The one big downside... On non-Apple platforms, the tooling is very patchy, and new features can take a while to arrive. If Apple is really serious about open-sourcing Swift, that could help a lot. I imagine there'll be more interest in new shiny Swift than crufty old Obj-C, but Obj-C is still a nice little language.

[Edit: capitalization of GNUstep :)]


No. It has the speed of smalltalk and the type safety of C.


That's a nice soundbite, but not really fair.

Modern Smalltalk-style languages can be fast. Look at Javascript! And in Obj-C, you can drop down to plain C when you need the speed.

It's possible to get your types mixed up when using non-generic collections, and that will throw an exception at runtime. No different from Go or Python.

In terms of memory safety, it's a step up from C if you use ARC, as all your object lifetimes are managed automatically. You can still get memory corruption if you're careless with arrays, but it's not really an issue with objects.


Oolite a clone of Elite : http://www.oolite.org/


There isn't much reason to. Without the Apple libraries and XCode support Objective-C isn't anything special.


Well, I do know non-iOS devs whose dislike of C++ have caused them to speak in favor of ObjC, but I suppose they would simply use C with structs in that case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: