|
|
#1 |
|
C and Objective-C relationships
I started my App development career learning Objective-C, having no background in programming whatsoever. It has been 12 months since I started learning code and I am now curious about learning another language.
A friend mentioned that learning C would enhance my understand of Objective-C, so I got my hands on this book. http://www.amazon.co.uk/C-Programmin.../dp/0131103628 I have progressed 33% of the way through this book to find that the similarities are so similar that I might as well not bother reading the rest of it. It would be good to get a thread going on other developers thoughts on C, in the context of how it might benefit an Objective-C developer of iOS Apps.
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC |
|
|
|
0
|
|
|
#2 |
|
Objective-C is an add on to C.
All the non-object oriented Obj-C code you write (including, likely much of the code in your methods) is plain C. It's not just similar - it IS C. Plain C will be useful to you if you ever do any low level work with hardware, or write code for another platform, possibly where Objective-C does not exist.
__________________
MBP (early 2011) - Core i7 2720 2.2ghz, Hires Glossy, 16GB, Seagate Momentus XT 750GB Mac Mini (mid 2007) - Core2 Duo 1.8, 2gb, 320gb 7200 rpm iPhone 4S, iPad 4 |
|
|
|
0
|
|
|
#3 |
|
K&R may not have been the best choice of books. Just my humble opinion.
You might have been better served by one of the phone book sized books that provides tons of example of more specific things. B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
|
|
|
0
|
|
|
#4 |
|
What would you have suggested as an alternative?
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC |
|
|
|
0
|
|
|
#5 |
|
I edited my post. I can't think of a specific example right now with my pre-coffee brain, but K&R is a thin book where a lot of the actual work is left as an exercise to the user. Thus, if you already know some programming of any kind it doesn't really add anything to your arsenal beyond the language reference. You do it the way you already know it.
B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
|
|
|
0
|
|
|
#6 |
|
Good point @balamW
I suppose it might be worth learning Python or something completely different, to enhance my skills as a 'problem solver'
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC |
|
|
|
0
|
|
|
#7 |
|
I wouldn't forgo that entire book... I did the same thing as you, learning Obj-C before C, except I knew Obj-C was an extension of C and so I thought I knew all there was to know about C.
But it turns out that on account of learning Obj-C first, I didn't learn about some of the plain old C ways of doing things. For example: A struct is basically a class full of instance variables and no methods. Do you know how to use them? NSRange and NSRect are examples of structs that Apple uses that you might have used before. Do you know how to use a c-array? They look like this Code:
int array[3];
array[0] = 2;
array[1] = 3;
array[2] = 10;
printf("%i", array[1]);
Do you know how to allocate memory? Can you use switch statements? I would just look through this and read any chapters that you don't think you understand just so you can make sure you know all there is to know about C. http://c.learncodethehardway.org/book/ Also note that ALL VALID C CODE IS ALSO VALID OBJ-C CODE. If you know how to do something in C and Obj-C, and doing it the C way won't take significantly more time or lines to write, do it the C way. Your code will be more portable (more platforms understand C than Obj-C,) and chances are it'll execute faster. Other languages you can learn: C++ java C++ is mostly just an extension of C, although occasionally the authors decided to take out features of C that they felt were insecure. Honestly, I don't like C++... I feel like the main new features that it has and other languages don't just lead to more confusing code. IE, they allow you to redefine operators in the language. So typing Code:
"string1" + "string2" Code:
"string1" - "string2" Java is inspired by C++ but they managed to weed out a lot of the stupid ideas from C++... unfortunately, they didn't get all of them, because a terrible concept introduced in C++, known as exceptions, still exists in Java (and I actually think Java's standard classes utilizes them more.) The basic concept of an exception is that, rather than have errors when you try to compile buggy code, or return error codes, it's much better to crash or slow down the application. The person who introduced the concept in C++ is on my time traveling hit list.
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed. Like it on Facebook! |
|
|
|
0
|
|
|
#8 | |
|
Quote:
I'd suggest a C-based book on a specific topic that is either related to what you are working on or in a completely different area. (games? databases? ...) Learning new languages is great, but doesn't always translate to putting new arrows in the quiver. B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme |
||
|
|
0
|
|
|
#9 |
|
How about SQL to be able to use databases ? Of course there are libs around but some solid SQL is good in many cases. Things like stored procedures, trigger ...
Maybe PHP for server-side stuff. And JavaScript also can be handy to know, too. If you can Objective-C the classical C is too close and concepts like ARC are great compared to nasty old malloc/free. Last edited by ChristianJapan; Jan 13, 2013 at 08:34 AM. Reason: Remove some 'some' |
|
|
|
0
|
|
|
#10 |
|
Good point. I want to explore animations and user interface design from a coding perspective, so I think I will read in those areas.
@ArtOfWarfare from what you have said here I feel pretty confident that I know enough about C. ---------- Ye, I've just figured out how to set up APNS using SQL and PHP. Will explore that in more detail. ---------- Easyapns.com was really helpful |
|
|
|
0
|
|
|
#11 | ||
|
Quote:
I'm also not totally convinced that C will be that much faster for most purposes than Objective-C once compiled, particularly since Apple has done so much work to make sure that Objective-C is a first-class player in Clang/LLVC. That being said, this is a matter of personal choice, so don't take my word for it. Go with what works best for you. Quote:
In my case, I learned C in college, then promptly forgot about it after changing from a CS to an English Lit major (one of the worst decisions in my life, but I'm slowly recovering). When I decided I wanted to earnestly pick up iOS dev, I had to relearn a lot of stuff, but in retrospect it wasn't as tough as I thought it would be - just practice enough, and it becomes second nature, just like with anything else. All that being said, if I have the choice, I'd still rather write in Objective-C than straight C, as much of a n00b as that might make me.
__________________
Garrett Albright - The Tokyo Drupal guy! |
|||
|
|
0
|
|
|
#12 | ||
|
Quote:
Sure, it makes it easier to do stupid/confusing things, but balanced by making it much easier to do smart/sensible things. Powerful tools are dangerous when wielded by the confused. If a language is going to allow unrestricted manipulation of pointers, then risk of redefining the subtraction operator is minor. ---------- Quote:
|
|||
|
|
1
|
|
|
#13 |
|
A good programmer usually knows more than one programming language, and learning the C language core of the Objective C superset can give a coder far greater understanding into how their device's processor actually runs stuff, how to debug their apps in more detail, and the possibility of some options for improving the performance of their code.
K&R is a great historical document. It doesn't include some of the newer C99 (and later) constructs used in modern coding, but can give you great insight into the core of the C language that everything else (including Objective C) was built on top of. |
|
|
|
0
|
|
|
#14 | |
|
Quote:
Just because you can do things like overload the basic arithmetic operators doesn't mean you should, even in the languages that allow you to do so.
__________________
Garrett Albright - The Tokyo Drupal guy! |
||
|
|
0
|
|
|
#15 | |
|
Quote:
The issue is whether the language should let you. Some people seem to think that, just because they can't think of a good use, the option shouldn't be available to anyone. |
||
|
|
0
|
|
|
#16 |
|
Coincidentally, an iBooks book was recently released on this topic: All the C You Need to Know (the "you," implicitly, being an Objective-C developer), by Bill Dudney. The price looks a bit high relative to its length, though it does take advantage of the iBooks platform with some interactivity tricks and such. Has anyone given this a look yet and can give a quick review?
__________________
Garrett Albright - The Tokyo Drupal guy! |
|
|
|
0
|
|
|
#17 | |
|
Quote:
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC |
||
|
|
0
|
![]() |
|
| Tags |
| learning, objective-c |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 05:23 AM.







I support the 
Linear Mode
