Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I am about 2/3 done reading "Learning C on the Mac". Another 2 to 3 weeks I should be finished at my current pace. Should I play with C before moving on, or move right into Objective-C? I am tempted to skip over Objective-C for now and start off with Cocoa. The console is fine and boring and I want to taste some GUI.

I have been looking at making a GUI with C but searching the internet for this information seems limited. Maybe that is a waste of my time?

What do you think is the right move?

-Lars
 
I am about 2/3 done reading "Learning C on the Mac". Another 2 to 3 weeks I should be finished at my current pace. Should I play with C before moving on, or move right into Objective-C? I am tempted to skip over Objective-C for now and start off with Cocoa. The console is fine and boring and I want to taste some GUI.

You can't "skip over Objective-C for now and start off with Cocoa". Cocoa is a framework not a language, further more it is a framework written in Objective-C. Therefore if you want to use it you need to learn Objective-C first.

I have been looking at making a GUI with C but searching the internet for this information seems limited. Maybe that is a waste of my time?

There are quite a few GUI toolkits written in C. Gtk+ is probably the biggest one. If you are feeling brave (mad? stupid?) you could try using the X Windows API directly although that is somewhat arcane from what I have seen.

Carbon is still there too although for anything other than a learning exercise you should use the Objective-C Cocoa stuff.
 
I am about 2/3 done reading "Learning C on the Mac". Another 2 to 3 weeks I should be finished at my current pace. Should I play with C before moving on, or move right into Objective-C? I am tempted to skip over Objective-C for now and start off with Cocoa.
You can't skip learning the language(obj-c) and go right to the framework based on this language (i.e. Cocoa). At least the bare minimum that fits in 10-something pages about things like object declarations, parameters and messages syntax.

I have been looking at making a GUI with C but searching the internet for this information seems limited. Maybe that is a waste of my time?
C itself has no means to create GUI, it's achieved using frameworks. Most of GUI frameworks are based not on pure C but on C++.
 
Do you know what data structures are? Any of the ideas behind object oriented programming? Design Patterns? Computer languages are generally easy to pick up. Learning the language programmers speak to each other is harder but will make learning computer languages easier. And when you're trying to learn a framework, knowing the patterns that were used to develop it will make it much easier to understand.
 
You might want to look at Cocoa Programming for Mac OS X by Aaron Hillegass. It assumes a knowledge of c/c++ and teaches you the basics of obj-c and cocoa simultaneously. I was like you and wanted to get away from command line apps so I picked up this book about 4 years ago. It gave me a good understanding of the basics of obj-c while teaching Cocoa. I then went on to Programming in Objective-C by kochan to get a deeper understanding of obj-c. I believe Hillegass's book is now in its 3rd edition vs the 2nd when I read it and kochan now has Programming in Objective-C 2.0.
 
I think you should make some C programs, from design to completion. Finishing a book is like finishing school: it's the beginning of your education in the real world.

Design, then write, debug, test, and complete at least 5 simple but non-trivial C command-line tools. They should run with no memory leaks or other obvious faults, and include test-cases and adequate user documentation.

For some ideas on what "simple but non-trivial" might be, look through the Unix commands. Find ones that have between 5 and 10 options or switches, and which process both command-line args and stdin/stdout.
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/

The standard commands are in Section 1. Sysadmin commands are in Section 8.

Some commands have relatively few options, yet are deeply complex, like 'awk'. I wouldn't call awk simple. Not even the conceptually simpler 'bc' is necessarily simpler to write. However, a simplified version of a calculating language like 'bc' is both simple enough to be comprehensible and complex enough to be a challenge to finish. So that leaves 4 more programs to think of.
 
Thanks for your replies.

Chown33 - That is what I thought, like graduating school. I wanted to test it out before I move forward. I think I will try your idea of a few small sample projects.

gnuguy - This sounds like the best of both worlds to start, then go back and really get the insight of Objective-C with yet another book :)

Are there any good resources / books out there that are not programming books, but books that covers how to plan a project, good coding tecniquies, test and distribute the final product? That stuff is a way's off but I still think about it.

-Lars
 
What should be next in my education after C?

Assembly language.

Maybe 6502 code running in an Apple II emulator. Woz did a lot of 6502 coding... in raw machine code even.

Being able to read ARM assembly is actually quite useful when debugging iPhone apps.

All this high level and OOP stuff is just layers upon layers of pretend abstraction that just hides the real magic happening in the hardware.
 
Assembly language.

I started programming on a Commodore 64 in the 80s and did lots of programming in 6510 (like the 6502) assembly. That experience took all the magic away, in that I learned exactly how the computer did things.

When I got my first PC, after programming in gwbasic for a while, I started programming in assembly on the PC, and again I learnt a lot about the details of exactly how the PC did things. Learning C after assembly was really easy because I got see straight away what C was doing.

Now when I stop and think about what my Mac's actually doing, I'm in awe. It really is amazing at what these geniuses at Apple can do with what really is just an extremely fast calculator.

If anyone hasn't programmed on metal, I really would suggest trying it out. But modern platforms are a bit complex these days. Like firewood suggests, starts out in an emulator of an 80s computer; which one depends on what books/resources you can get your hands on. Or perhaps run something like bochs and freedos to create a simple enough environment.
 
I guess I would not advise assembly at this stage, though I do think it is very instructive eventually. One way or the other, definitely pick a RISC ISA to learn. MIPS, PPC, ARM... Stick to 32-bit variants (or less if applicable). CISC like x86 (even though x86 is now an intermediate language that is broken down into RISCy micro-ops to actually run these days) as your first ASM venture is a road to pain. I know some book trimmed x86 to a "y86" that might be bite-sized, but a real ISA that is grokable would probably be better.

-Lee
 
Assembly language.

Maybe 6502 code running in an Apple II emulator. Woz did a lot of 6502 coding... in raw machine code even.

I've made similar suggestions for beginners wanting to learn how a computer really works.

Not much simpler than the 6502.

Of course running an 80 era computer simulator also requires learning a new platform as well. But if someone is willing to do it I'd recommend an 8-bit Atari emulator running the Synapse Software "SynAsm". It has a built in editor, assembler and debugger. All of which is available on-line for free, including hardware manuals!
 
Just checking. Are all of you recommending 6502 old enough to have programmed on them when they were current? (I am and did). Be curious to hear if some of you are too young to remember those days, but still recommend 6502.

B
 
My 2 Cents

Just to chime in -

If you already understand C pretty well, you can try to jump to Hillegass next, using Objective C tutorial's to supplement. Then if you really get stuck, you can always go back for help.

This is what I did - I found Kochan's (Obj. C) bored me to tears and went ahead and skipped to Hillegass' (which I'm now 3/4 through). So long as you keep at it, you'll get it; it's really just a matter of time.

Christopher
 
haha. Funny you should say that. I did start with his book to and did not like it, it was also boring and I downloaded the videos to help me. I decided to step back into C which I am glad I did. I breezed though the first 9 chapters in the C book but now it got difficult with list pointers and passing structs in Functions.

My over all goal is to have an app that will drive stepper motors and servos with feedback encoders from an app on the Mac or ipad. That is why I am glad I am learning C.

Thanks for the Hillegass idea, I was thinking that too.

-Lars
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.