Totally new to programming, need some help
I'm a web designer and am looking to get into programming. I have zero experience with programming. I think the best place to start is with C (open to suggestions) and last night purchased the K&R book on C. I almost exclusively use a Mac (OS X 10.4 - Tiger) and would like to learn my programming skills on it. The problem is I don't know where to start. I want to start with the classic "hello, world" program, but as I said, I have zero programming experience and am not sure what to do first. I don't know what application to write it in. I don't know how to compile it or what application to use or where to get one for my mac. The list goes on. Any insight would be greatly appreciated! I would also be interested in any resources for learning C or programming on Mac for a total novice like me. Thanks in advance, I look forward to your suggestions!




Python! Python!
Don't start with C. You quickly become bogged down in pointers, types and other minutia associated with working with a low level language.
If you want to do something useful and see results quickly, start with Python. With Python, you can get up to speed quickly and start making scripts that really do things. Using the pyobjc package (http://pyobjc.sourceforge.net/) on the mac, you can make beautiful apps with full access to Cocoa. In Leopard with XCode 3, Python is a first class programming language, so its even easier. PyObjc works well with Tiger, you just have to install more stuff on your own.
Dive Into Python (http://www.diveintopython.org/) is often referred to as a good book to start with. Its available online for free or you can buy a copy. I'd suggest returning the K&R book on C, reading Dive into Python, and maybe spending the cash on upgrading to Leopard.
Check out Xcode
As a grad student programming many simulations, I have come to use the K&R book as a frequent reference and have found it to be nothing short of excellent. If you will only be using a Mac for your programs, you might want to check out objective-C. There is a great series of tutorials on objective-C on this website. The book Cocoa Programming for Mac OS X by Hillegass is one of the best, if not the best, books on objective-C and using Xcode for development. Xcode is likely one of the best tools to edit, compile, and debug code on OS X and it is included as part of the development tools on the OS X installation DVD.
Cheers.
RE: Totally new to programming, need some help
hi-
If you mean you want to extend your HTML designing into web app programming then you should download Eclipse and run a Hello program (in java) (there is an intro front end for this in Eclipse).
If you mean you are tired of the web and want to do desktop programming then you should install Xcode and make a new Project (Cocoa Application) which I think is already setup to do a Hello World in the main file (or it is easy enough to do).
See Xcode or Eclipse Example programs (don't learn totally from a book, that is too linear).
Xcode
This is a no-brainer: install Xcode, as suggested by another poster. For a simple C tool, you can also start a "Foundation Tool" project, this will start a project template with a structure similar to what you will find described in K&R.
I also just want to say that it is normal you get stuck at what seems a very simple and basic step. It is like learning how to walk, you must first figure out what is a feet, and where yours are. I would recommand the Aaron Hillegass book for this, though, the 3rd edition just came out.
Another vote for Python
For a person just learning to program, I second heartily the suggestion of using Python. Mac OS X has Python already installed, ready to go. There are many good free editors that provide excellent editing of Python source code with full syntax coloring... 2 examples are Smultron and TextWrangler. Python also provides an excellent interactive environment for exploration. I suggest starting with the Python Tutorial at http://docs.python.org/tut/tut.html. There are also many good books on Python, some of the available for free download - Google is your friend and will find them for you. Two books that I liked for learning Python are Learning Python, 3rd Edition by Mark Lutz and Core Python Programming (2nd Edition) (Core Series) by Wesley Chun - both available with substantial discount at Amazon.com. Good luck! I hope you enjoy your new adventure!
Thanks
Thank you to everyone's suggestions so far! I have a lot to look at this weekend. I'm planning on starting with something that is less automated than Xcode so that I can appreciate what's going on under the hood when I eventually do begin working with Xcode. I also got the Cocoa book by Hillegass from Amazon the other day and will be using that as well. The Python recommendations are interesting and I will have to look into that more, I don't know too much about it right now. Thank you to the comments about first starting out. I realize that this is the biggest hurdle and that once I clear it, I will be well on my way. Thanks again for all your suggestions and I welcome any additional ones!
Is Python fast compared to Obj C ?
A lot of folks seem to be quite excited about Python. But is this a fast language compared to Obj C or C? Can you interface Python with XGrid? I'm a little bit concerned that Python may not be a good choice for a simulations, or am I wrong?
Python Performance
Python is very good for scientific simulations. As a scripting language, it isn't as fast as a compiled language like C or Obj-C, but most simulations are not spent in the python code itself, but in scientific libraries (eg BLAS, LAPACK, FFTW), and these are native.
Many people use Python for scientific programming. Take a look at the following to get an idea of the broad range of scientific modules available:
http://scipy.org/
http://www.enthought.com/products/epd.php
Drew
---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org
Python
Python does have the advantage that it's cross platform, so for example if you're developing code on the Mac that you want to eventually run on a Linux server you'll have little if any trouble with Python. Objective C does seem interesting however, but if you want to go that route I'd recommend you get familiar with normal C first.
Ruby
I would take a look at Ruby. You'll find it's very similar to Python, but without the whitespace-sensitivity, which some people dislike. I don't think there is as good an XCode integration as with Python, but for a learning language, you'll be far less frustrated with Ruby or Python than with C, C++, Objective-C, Java, etc.
More reference
I totally adhere to the idea of starting to learn a "core" programming language (by core language, I mean something where you learn about pointers and memory adressing, basic data structures, and the like). The C language is by far one of the most interesting from this point of view (if one avoid the Obfuscated challenges). There are a number of good tutorial on the web.
Next, Python provides a coherent environment, especially for prototyping, or as already mentionned, for numerical simulation. It inherits most of the advantages of Perl, C, and probably Java, though it can be a little bit awkward to the beginner. Alan Gauld hold good ressources on his website.
Dive into python is a also a good starting point. I would recommend the on-line book How to think like a computer scientist. Learning with Python because it provides a nice introduction to Object-Oriented coding, and is targeted to other languages (Java and C++) as well, thus facilitating a common understanding of OO languages.
About editors, as I come from the Linux world, I'm using Emacs (more precisely, the Aquamacs fork) which provides all that is necessary to start programming. However, learning to use Emacs is another story...
Christophe Lalanne
Ruby/Ruby on Rails
Ruby is one of the nicest programming languages I have tried, if what you are interested on is going from web designer to web developer Ruby on Rails (RoR) is the way to go, it is a Agile Web Development Framework that takes no time to master. Many people say that you can start developing using RoR without knowing Ruby, that you can grasp it in the way, but in my opinion it is very important to know quite well Ruby before Ruby on Rails.
To do development on the Mac using Ruby there is a new book by the Pragmatic Programmers (www.pragprog.com) that talks about Ruby and Cocoa called: RubyCocoa.
Best wishes
HdR
Learning to program? Maybe wait on the Hillegass book
The Hillegass book is excellent (I am reading it right now myself), but it does assume a certain level of experience with programming in general, so it might be a bit too much at this stage.
If you are learning to program, you need to first understand language-independent basic concepts such as flow control, basic data structures, program structure, etc. In this respect, I have read good things about this book:
Learn to Program, by Chris Pine
It uses Ruby as a first language, which I think is a fine choice. Python is also good. C (or even Objective-C) as a first language... not so sure, it will twist your mind forever.
Once you understand the basic idea of programming, in any language, picking up new languages is relatively easy.
Above all, don't be afraid to experiment, try, break and fix things, and have fun. Programming is a lot of fun.
First off, that K&R C book
First off, that K&R C book is way outdated... We're now using ISO/ANSI/C99 C (1999 version of the language), which, among other things defines the 64-bit (minimum) "long long" data type. Mac OS X Xcode tools includes the GNU C/C++ compiler, which, consequently is ISO/ANSI/C99 compliant (well, striving to be, each release is closer to compliance, and is the most compliant compiler available today)
My recommendation is to start off with C, and completely ignore Objective-C (this'll make Steve Jobbs mad). The only group that's using Objective-C is Mac OS X developers, everyone else is using C/C++ (including Mac OS X developers). The Carbon library in Mac OS X allows you to use C function calls to create and draw in windows, and get user input from the graphical interface.
So look into Carbon development, not Cocoa.
I wrote a guide back in 2005/2004 to teach teens (specifically boy scout aged kids) how to write computer programs. The compiler commands are the same as those you'd use under Linux, MSYS/MinGW, or the Mac OS X Terminal (provided Xcode tools are installed).
You can find it at: http://coderguide.com/Guides:C/C_Crash_Course (undergoing a rewrite and add to the coderguide wiki). It doesn't cover the more advanced topics yet, and covering Carbon is way down the list of things to do, but it'll get you started enough to understand and use a book on Carbon programming.
---
www.stellimare.com -- for custom PCs
www.coderguide.com -- for programming help
Meanderings
First, as already stated, programming can be a lot of fun and very rewarding. It is also an aesthetic experience which may eventually guide your choice of preferred language.
Second, you will experience frustration like you have never before known. At first this will seem awful but you will eventually learn that that's part of the process and will find great satisfaction at the "end of frustration" as you crack a problem (and the next frustration awaits you).
Third, Python is slow for numerical simulations. I respect and understand the argument that it uses fast, non-Python code for some of its calculations but this argument applies also to Matlab, Octave, Mathematica, etc. and anyone who has used them knows that there are bottlenecks and you'll pull your hair out trying to program around them, then fail. This won't matter until you find yourself waiting 10 hours for a calculation to end. Use these languages for quick one-off short calculations; otherwise, use a compiled language and link to a good library like the GNU Scientific Library.
Finally, C and its derivatives are the most perverse and cruel hoaxes ever foisted on mankind. But you will use them because everybody does it. If you have a low aesthetic threshold and you enjoy spending lots of time debugging code and then have it still contain bugs, then you will love C. Personally, I use Ada with the excellent gcc-based GNAT. Look at www.macada.org and sign on to the mailing list.
Hope this isn't too much flame bait but it comes from my perspective from living outside the box.
Jerry
2¢
K&R C is still a great reference for clean programming, but usually not something you want to start with. Unless you're anal retentive & want strict ANSI 89 for maximum cross-platforming.
I'm slightly hesitant (but don't disagree) with people learning programming in Obj-C. I went the standard route of Turtle Programming/BASIC/scripting lang. then onto C then C++. Now I've been dabbling with Obj-C.
As a learning methodology, starting with C and Carbon will probably cover more ground. But if you want to get something up & running quick, Obj-C will give you more "bang for your buck" especially early on.
If you want heavy lifting in a scripting language, I would advise towards Python rather than Ruby. For ease of programming I'd probably lean towards Ruby.
So basically I'd say:
"Drier, but less overhead"
C and Python
"Syntax friendly, but more overhead"
Obj-C and Ruby
Cheers.
As a beginning student, it
As a beginning student, it is unlikely you'll be writing anything very soon that actually taxes the processor, which is insanely fast.* That being the case, the right solution for you might be something that is familiar to you that provides rudimentary programmability, such as Visual Basic in Excel or MATLAB. That should let you get your work done without getting mired into too many details. Only once you grow beyond the capabilities of that sort of tool and you are forced to use something more powerful is it worthwhile to undertake a real exercise in programming.
Before proceeding, this stuff needs to come with a warning label attached:
COMPUTERS ARE DANGEROUS TO YOUR SCIENTIFIC HEALTH!
They will soak up all your time, and distract you from the real work at hand by burying you in programming minutia. You may even decide you like it better than benchwork, which will probably kill your career in science entirely.
Back to the highly unimportant non-science trivia, C is a great language to write operating systems, and pretty good for HPC, provided you know what you're doing. If you don't, and expect the dev tools to do the hard work for you then FORTRAN is a better bet for HPC. C offers detailed fine grained control over everything, exceeded only by assembly. However, for many/most common purposes, C may be too much control and too many details to manage.
The main difference between Objective C/Cocoa and C is that the former comes with a window/GUI toolkit that makes getting Apps with windows and buttons and other controls up and running very quick and easy. You basically draw your interface with Interface Builder, connect some wires, and your app is running, partially functional already. Carbon is by no means comparable. Having done a bit of both, I can safely say that Carbon is maybe an order of magnitude more work to make decent GUI apps with. I personally wouldn't waste time with Carbon at this point. C apps more commonly just run as command line apps at the terminal. The back end computation that makes your app unique is the same, no matter what you use.
Python is a nifty alternative that can grow nicely. When the interpreter starts to fail to run quickly enough due to load, you can extend your python with widgets that you write in C to handle the heavy lifting.
The hardest thing about learning a new language is learning the grammar and punctuation. You'll have this automated agent pointing out flaws in your code, refusing to cooperate or hint what you should really be doing. The best way around this problem is to find a buddy who knows what he is doing to straighten you out every time you do something silly. The second best way is to find a pile of sample code and attempt to mimic it.
Apple's developer documentation is here:
http://developer.apple.com
There is vastly more there than any beginning developer can hope to comprehend or understand the extent of. Eventually some curtains will part, and a few light bulbs will go on, and it will start to make sense.
Best Regards,
Ian Ollmann
*It is a little known fact that professional software developers work very hard to sabotage CPU performance. Typically they don't even know they are doing it themselves! It is quite common to leave 90%+ on the table.