I am eventually wanting to program in Objective-C to write programs for OS X and possibly the iPhone. I do not have any direct experience with C and I come from a web programming background. I am much more familiar with java syntax than C and Objective C.
I am just looking for suggestions on how to get started. It looks like I need to just start with C (I do not yet have a Mac computer powerful enough for programming, so it would be nice to start with C on the Windows platform anyway (information about programming environments would be helpful too, I am used to eclipse)). I am just looking for book recommendations, online tutorials or any other pointers to keep in mind. Keep in mind though that my end goal is to work with Objective-C, so is there anything I need to keep in mind when learning C, anything to watch out for, etc. Thanks for any input.
Update: The reason I am thinking I need to learn C first is that most of the tutorials that I have come across so far for Objective-C assume you already understand C syntax, which I do not fully. Are there better tutorials out there for me?
I don't entirely agree with unwind who says "C and Objective-C are different languages". Objective-C is a strict superset of C.
Of course he knows that - his point was that you don't need to completely master C before progressing onto Objective-C. I'll second that (and hopefully have clarified it).
But I do think it's worth getting some basics with C first, as most introductory texts on Objective-C will assume a basic knowledge.
I don't have any recommendations on that myself, but probably most internet based tutorials will be sufficient for that purpose (remember, you're not trying to master it at this stage). If you want to take it seriously, then "The C Programming Language" by K&R is the classic text.
When you you can do some basic hello world programs in C, and understand the type system, pointers and stuff - then pick up a copy of "Cocoa Programming for Mac OS X", by Aaron Hillegass. This is a book about Cocoa that covers Objective-C along the way, but it one of the best presented coverages of the language. It will assume you are coding on a Mac (it's in the context of Cocoa after all). You may be able to follow the pure language stuff using GCC on Windows, but I wouldn't recommend it.
If you're going to be working on a Mac eventually, then best to do it at this stage, IMHO. You say you don't have a Mac "powerful enough for programming", but anything that can run OS X would be fine to get your started.
If you know java, obj-c will be easy for you (java was influenced a lot by obj-c.) Apple has great documentation, you can start here. I don't think you need to learn C before learning obj-c (sorry Joel).
You can use obj-c on windows if you get gcc. Also check out cocotron:
The Cocotron is an open source project
which aims to implement a
cross-platform Objective-C API similar
to that described by Apple Inc.'s
Cocoa documentation. This includes the
AppKit, Foundation, Objective-C
runtime and support APIs such as
CoreGraphics and CoreFoundation.
With all the buzz about iPhone development, there are now dozens of obj-c books. Not sure how good they are, but a classic that I would suggest is Cocoa Programming from Mac OSX by Aaron Hillegass.
Programming in Objective-C by Stephen Kochan is what you want. It assumes no programming experience but doesn't hold you back if you do and introduces the whole thing, C with the Objective-C superset, as a complete package. I read the first half of Kochan (the second half gets into Cocoa) and now I'm working on Cocoa Programming for Mac OS X (3rd Edition) by Aaron Hillegass and reading Kochan was a massive help. Those two are a "one-two punch" that will get you going in no time.
Have a C and Objective-C reference handy as Apple's docs of C in XCode pretty much sucks from what I've seen so far. K&R's C text is like the Encyclopedia Brittanica of C and, just like a set of encyclopedias, isn't for everyone. I've just been Googling for references and generally find what I need on the web since C is so ubiquitous.
You'll burn through a couple of books before you find the set that best fits you, but you simply can't go wrong with Kochan and Hillegass for Objective-C and Cocoa. By the time you finiah the first couple chapters of Hillegass, you'll want to (and be able to) start writing some stuff on your own.
There is a recent blog-entry at Tuaw:
http://www.tuaw.com/2009/01/15/starting-out-with-objective-c/
4 guides about getting started with Objective-C, which helped me quite a lot when I started developing in Xcode. You should take a look at this:
http://cocoadevcentral.com/
http://developer.apple.com/iphone/index.action
http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/
http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/mobilehig/Introduction/Introduction.html#//apple_ref/doc/uid/TP40006556-CH1-SW1
I'd say that it's better to learn C first. be sure to approach it like what it is: a structured machine language.
when you feel comfortable on it (no need to really master it), go on to Objective C, where you'll rediscover several things familiar from Java, but knowing the C infrastructure will make more apparent when they're similar but not equivalent.
it's very important not to learn a language using what you already know as a 'metaphor' for the new. always try to pretend you didn't know anything before.
I don't know what you mean by a Mac powerful enough to do programming on (any Mac should do), but get yourself something at least marginally useful as a development system soon. (You may well have the development system on one of the CDs that came with your Mac, or alternatively you can download it from Apple.)
The sooner you get Xcode working, the sooner you'll be comfortable with it.
I have recently started to learn programming for the Iphone and tried many differenet books until i found these helped me the most (I would also strongly recomenned getting a mac since the Xcode is the way to go when coding for Iphone):
Apress: Learn C on the Mac (To
get the initial C going)
Apress: Learn Objective-C on the Mac
(Learn Objective-C based on your
understanding of C)
Apress: Learn Cocoa for the mac
(learn apples way of building
applications, greatly helps when
going over to Iphone however you can
go straight to the iphone if you
like)
Apress: Beginning Iphone
development... (The final book,
and essential tool)
To note all these books have the same author and thus the traceability is great! The books have crossreferences between each other that really helps.
Agreeing with others, I found Cocoa Programming for Mac OSX - Hillegass
a great intro to Objective-C, the Cocoa framework and whole Apple way of doing things.
You can run Objective-C on any Linux or Windows box too although of course you won't have access to all the Apple libraries eg. NS (afaik). These frameworks are really the whole point of Objective-C, and the real reason it still exists given C++ and C# came later and are more or less languages designed around themselves (as opposed to Objective-C which is a strict superset of C).
Apart from pointers, I think you can get by without learning all the intricacies and close-to-the-metal aspects of C, although any and all C you can digest always helps.
Related
I have been playing a MUD game now off and on for over a year. I have scoured the internet looking for the best computer language to learn to develop my own. So far, I have come up with nothing but C. Is C the best language to learn for this application, or is there something better?
I know SMAUG was written in C, but that was years ago. I am new to programming in general and have some experience with Python. I have been playing Aardwolf, which allows it users (after a certain level) to create their own area's. The user does this using Lua. This was interesting to me, because Lua is a "scripting" language. So this begs another question - Do you build the game's format in C (or something else) but create the world with a script?
Also, this would be a game with only my friends, so a direct connection would be required since I would not be hosting it online. So, once again, I would like to dive into this world and use this as a pet project to also help me learn a programming language... but which one would be the best that would also allow me to scale it uo in the funture
P.S. - Any open source code out there that I can look at and study?
So, once again, I would like to dive into this world and use this as a pet project to also help me learn a programming language... but which one would be the best that would also allow me to scale it uo in the future
Most MUD codebases tend to be in C, but this is mainly for historical reasons. MUDs were fairly popular a while back, and at the time, C was by far the best language for portability which was supported by most hosting options out there.
That being said, a MUD is really fairly simple, in many ways. You could easily write a MUD in any language, provided it supports sockets and text parsing. Using a language with a good string parsing and high level socket support would actually be far simpler than some of the classic MUD code bases.
There are a ton of available MUD engines available online : a quick look at MudConnector will give you a ton info of available servers, software and code bases.
As for your programming language of choice, if you intend on only making it available to you and your friends, Python would be fine - I made one entirely in Lua a few years ago and it was a breeze. It's a great learning experience !
perhaps you should look for a MUDOS
http://www.mudos.org/
What could some of you recommend for using when learning C and programming with C?
I have thought of the following options. (On OSX)
Aquamacs
TextMate and the Terminal
XCode
I want to learn more than just the IDE so that I grasp the concept as I will be learning about compilers etc.
I tried Aquamacs when learning Erlang but it was more of a hassle than I enjoyed.
Is there a lot extra to learn when using an Emacs environment?
What is most beneficial for understanding how things work. ( C )
Are there any other tools or possible options worth looking into?
Thanks
If what you want to learn is C Programming Language in Mac OS X I would go with XCode. It has a very good GDB integration, and its learning curve is smoother that EMACS' or just writing your own Makefiles.
If you want to learn about C, in my opinion, you should use the most basic editor available, compile using the terminal with gcc. And that's it.
Once you'll understand the language, picking one IDE over an other will be a no brainer.
But no IDE will really teach you anything about C.
There's also BBEdit on OSX. (I've used it briefly in the OS8 days.) As far as learning C goes, there are a number of books that you can try. I'd pop down to whatever chain bookstore is closest and browse the Programming section.
I'd also invest in a good algorithm book.
If you want to use Emacs as an IDE, you will need to write Makefile in order to be able to compile from within Emacs. Writing Makefile could help you understand the compiler options, object code, linking and such.
So to use Emacs as IDE for learning C, you should be using C-mode, know about M-x compile and using gdb under Emacs(M-x gdb). To look up man pages for library functions, M-x man and supply it (3 printf, for example to read the man page of C I/O function printf) the section number and function name.
I am not sure if using Emacs+Makefile this way is most beneficial in helping you teach how to compile, link, build etc, but it sure does help in learning those ideas.
If you're not comfortable using a more advanced editor like vim or emacs, then I would suggest using TextMate or something similar. This would let you concentrate on the code you're writing rather than struggling to learn how to use the editor.
Using a full blown IDE like XCode will also allow you to pretty much ignore the build system while you're still learning the language itself. Once you get comfortable with C, learning things like make or cmake would be less overwhelming.
Then after that, maybe you can go back to check out vim or emacs and see what a more complex editor can do for you, if anything.
I have learnt C and Assembly(IA32) on Linux and I will also be learning a few more languages this year.
I want to make my fundamentals strong and for that I need some tips from you guys as in, where will I find programs for practice? so that I solve them and get more and more experience.
Any good web links that would help a novice programmer to improve and be confident about the language he/she is learning.
I try looking up for questions on websites but they are either too difficult or not meant for beginners.I want some source which would help me to be more clear fundamentally and conceptually.
Thankyou.
You could start by coding some of the simpler Project Euler problems in C, and then translate them to assembly. The problems get progressively more challenging as you go.
This page has an on-line version of The Art of Assembly Language Programming by Randall Hyde, but without the laboratory exercises. However it still includes a lot of code snippets, and Randy takes a high-level approach to assembly programming using macros which will be familiar to a C programmer. (I worked with Randy nearly 30 years ago doing assembly language programming on the Apple II).
It depends on how "novice" you are, but I'll be suggesting the UVa Online Judge.
One thing you can do (recommended to me by an experienced programmer) is read really good code. The Linux kernel is written in C. You can go to http://www.oldlinux.org/ to study with the first version, which would probably be easier than the current one. Beyond that, I would recommend finding an open source project for C that interests you. Working on a real-world project that interests you is going to be the best way to grow your skills.
I have programmed in c and I know about data structures and algorithms, but It has been a while since I programmed in c. I forgot things like how function pointers and some advanced stuff in c work. I want to try graphics programming using sdl. my question is how much of c should I know (for example should I know function pointers) before getting into this. Or in other words will I be stuck if I dont remember a lot?
I think basic knowledge of C should be enough. Look for some SDL tutorials and follow them closely, you will refresh your knowledge of C and at the same time learn how to use SDL. It might go a little slower at first, but you will get into it.
Try for example: SDL Tutorials
Or: GPWiki SDL tutorials
Or: Lazy foo
The first one offers also C tuts. As for functions pointers, you might need them later, when you get to the more advanced stuff. With the basics, you will see everything in tutorial source code and believe me it is easy to understand.
If you like books, try: Focus on SDL
Dont know if there are better ones.
I see PeterK posted lots of good stuff, but I figured I'd throw my two cents in as well. When I started using SDL (3-4 months ago), I had a little experience in Java and no experience in c/c++. Using LazyFoo's tutorials (http://lazyfoo.net/), I was able to get up to speed very easily. I would recommend it to anyone who wants to learn SDL.
I was recently diagnosed with a cascading dissociative disorder that causes retrograde amnesia in addition to an existing case of possible anterograde amnesia. Many people have tried to remind me of how great a programmer I was before -- Right now I get the concepts and the idioms, but I want to teach myself whether I know or not. I think I can overcome the amnesia problems in part with it.
My question for you, stackoverflow, is this: I recently found Clojure and it... it feels good to use, even in just copying down the examples from whatever webpage I can find. My goals in learning a functional programming language are to create a simple webserver, an irc AI bot of some variety, and a couchdb-like database system, all of which lightweight and specifically for education. What flaws does Clojure have? Is there a better functional programming language to use right now for education /and/ application?
I think Clojure is a very nice language. If I should point to any defect it is that it's very new, and even though the language seems very mature and production ready, the tools and frameworks around it aren't. So if you are going to make, for instance, a web-app, don't expect to fire three commands and have a "Your first web app is running, now read this documentation to create your models"-page on your browser.
There aren't that many libraries written in Clojure yet either, but that's not a huge problem if you consider that you can use almost anything written in Java.
Haskell currently has a large following and a growing base of libraries and applications. It's also used for education and research. I find it a very nice language to use.
Haskell, Erlang and Clojure are all good choices. I would personally recommend Clojure, you might be able to do some interesting database stuff with the Software Transational Memory system that is part of Clojure.
You list CouchDB in your question, and it's written in Erlang, which is meant to be a pretty engrossing language once you get into it.
I have no personal experience with Clojure, but i really recommend F#. It's quite a powerful language in the style of OCaml. I really like it because it's debugging tools and IDE are second to none, and you can take advantage of practically every library on the (huge) .NET platform.