Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it considered bad practice to write c code in objective-c / cocoa framework?

Tags:

objective-c

I am writing some Objective-C code which will be publicly available. The code mainly consists of well known algorithms which would benefit from optimization. I am planning on writing most of the code in C to reduce the overhead on creating objects and garbage collection. Is this considered bad practice?

like image 984
Nippysaurus Avatar asked Nov 30 '10 01:11

Nippysaurus


1 Answers

No it's not. This is done quite frequently actually.

Generally one does this when one needs time critical code to run quicker (everything else equal, calling a C function is quicker than an Objective-C method).

However, it may also be nicer in some other cases to write C functions instead.

Remember though that Objective-C is a superset of C. Everything C can do, Objective-C can do, and it should not be considered bad to do anything C can do. There may be cases where doing some things is discouraged, but anyway.

like image 118
jer Avatar answered Sep 18 '22 02:09

jer