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

macsrockmysocks

macrumors regular
Original poster
Feb 21, 2006
233
0
I know that this forum isn't really about "this", but I want to learn some type of computer language. I am 14 and an Honors High School student. I do not know which language would most suit me though. I have a Mac, so I considered Cocoaa and Objective-C. What ddo you guys think?
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,661
1,468
Bergen, Norway
I would start off with a nice scripting language, like Python and/or PHP, the latter is nice for making websites (maybe even with some XML and/or MySQL thrown in), and in PHP5 you can even get started on the next step: Object Oriented Programming.

Learn some basic Java, which is probably the most educational OOP language out there, and once you have a good understanding of that you're ready for anything.

Some simple C programming could also be handy before getting into Object-C, I would think.

Every language has it's pros and cons and only by trying quite a few you can find the one that suits you and your programming projects best.
 

macsrockmysocks

macrumors regular
Original poster
Feb 21, 2006
233
0
Mitthrawnuruodo said:
I would start off with a nice scripting language, like Python and/or PHP, the latter is nice for making websites (maybe even with some XML and/or MySQL thrown in), and in PHP5 you can even get started on the next step: Object Oriented Programming.

Learn some basic Java, which is probably the most educational OOP language out there, and once you have a good understanding of that you're ready for anything.

Some simple C programming could also be handy before getting into Object-C, I would think.

Every language has it's pros and cons and only by trying quite a few you can find the one that suits you and your programming projects best.

Ok, I think I am going to do the basic Java, then C, then Cocoa(Objective-C). Do you know any books for absolute beginners?
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
Python is great, but recently I've been checking out Ruby, which has much of Python's goodness but IMO is potentially much more useful because of Rails. You can't go wrong learning ANSI C as it is the foundation for many modern languages and is still useful itself.

Java...meh. I used to really like Java a lot, and spent a lot of time with it, but after getting into Python and Ruby, Java seems a bit archaic and extremely bloated. It's got some advantages, but it can just take so much work to get things up that it's painful. In other words, you may find yourself spending most of your time building "scaffolding" on which to get your app running, rather than concentrating on the task at hand. Objective-C has some of this problem too, although things like Interface Builder, CoreData, and Cocoa Bindings bring some relief. For web apps, Struts is the API from Hell, and JSP+Servets suck by comparison with modern lithe solutions such as PHP and Ruby on Rails. Still, Java is not a bad language to learn programming on. One advantage Java has, other than being (mostly) cross-platform, is that there are literally a ton of books written about it, and a sea of free references and tutorials available online.
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,661
1,468
Bergen, Norway
I didn't actually read the book when I took Java in college, just spend much time solving the (small but frequent) assignments we got...

I would start at Sun's Java site. Lot's of downloads, code examples and tutorials, and it's (mostly) free... :)

The only books I've actually used a lot are the Java and C/C++ Programmers Reference books. And they can be very handy for beginners and pros alike...
 

therevolution

macrumors 6502
May 12, 2003
468
0
macsrockmysocks said:
Ok, I think I am going to do the basic Java, then C, then Cocoa(Objective-C). Do you know any books for absolute beginners?
Yikes. While doing all those things would certainly be educational, it's overkill if you just want to find out what programming is all about and if it's something you'd like to pursue further.

Do you have a certain project in mind you'd like to do? If so, perhaps we can make a better suggestion for you. You don't have to pick Obj-C just because you have a Mac. On the other hand, if Cocoa apps are what you want to do, then Obj-C is the way to go. You probably don't need to bother with learning Java first, though.

If you want something simply to help you get a feel for programming, I'd go with Python. Here's a list of Python tutorials for total beginners such as yourself.
 

balamw

Moderator emeritus
Aug 16, 2005
19,365
979
New England
macsrockmysocks said:
Ok, I think I am going to do the basic Java, then C, then Cocoa(Objective-C). Do you know any books for absolute beginners?
As mitth pointed our each language has its own strengths and weaknesses. It would help to know what kind of programs you intend to write, and where you think you might go into later in life...

Personally I tend to "Click" with all of the O'Reilly books I've used. For the beginner the "Learning XXX" titles are often a good resource. e.g. Learning Python

B
 

Monkaaay

macrumors 6502
Jun 19, 2006
258
0
Richmond, VA
I think you should check out Objective-C. It's a pretty simple extension to C that includes objects. With Cocoa you have a nice framework to start with too. I think working with these two technologies would give you a good start.
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
Monkaaay said:
I think you should check out Objective-C. It's a pretty simple extension to C that includes objects. With Cocoa you have a nice framework to start with too. I think working with these two technologies would give you a good start.
I second learning Objective-C then learning Cocoa.

Objective C is really really easy, Cocoa is awesome, fun, and easy.

I recommend: Steve Kochan's Programming in Objective-C
For Cocoa I highly recommend: Aaron Hillegass' Cocoa Programming for Mac OS X
For HTML ( a simple scripting language) - learn it off of: http://www.pageresource.com/
 

kodiak

macrumors newbie
Mar 21, 2005
29
0
(trying not to go off topic :))

when doing cocoa bits, does every one use straight objective-c, or use objective-c++?

i already know c, c++ etc, want to play with cocoa...
most examples i see use plain objective-c,
so is objective c++ only used when trying to utilise existing c++ libraries?


as for original poster... if you wanna learn how to program, rather than script .. then use java, its easier than c/c++ - teaches most of the concepts (expect perhaps good memory mangement) but has great tools and multi platform - i guess the reason colleges have moved to it.

so leads another question for the existing programmers... anyone use the java cocoa interface? any good?
 

ham_man

macrumors 68020
Jan 21, 2005
2,265
0
Learn how to program with C, learn the concepts of OOP with Ruby, and then move on to Obj-C/Cocoa... :)
 

GeeYouEye

macrumors 68000
Dec 9, 2001
1,669
10
State of Denial
First learn C, then Smalltalk. Then imagine a fusion between them. That's Objective-C and Cocoa, which you should learn next. Then Java (for WebObjects, which is the best web app stack out there - beats Struts to death with a strut, bashes Rails over the head with a rail... okay, enough of that). Then, when you're ready for something really fun, Io.
 

Gil Bates

macrumors newbie
Jun 16, 2006
18
0
Frozen Wasteland
kodiak said:
i already know c, c++ etc, want to play with cocoa...
most examples i see use plain objective-c,
so is objective c++ only used when trying to utilise existing c++ libraries?

You can mix Objective-C and C++ no problem. There are things you can do easier in C++ than Objective-C, and vice versa. I only use Objective-C in the Mac specific area to make porting to the "other" platform easier.

To the OP, if you are planning to major CS in college, you may want to try Java. I heard it is what they teach first. But if you want to write Mac applications, Objective-C/Cocoa is the best.
 

ham_man

macrumors 68020
Jan 21, 2005
2,265
0
Gil Bates said:
To the OP, if you are planning to major CS in college, you may want to try Java. I heard it is what they teach first. But if you want to write Mac applications, Objective-C/Cocoa is the best.
Learning any OOPL and then learning another is like learning Spanish then learning Italian. They are both alike, but there are some minor phrasing and syntax differences. In the end its the same framework and structure, just a different way to go about writing it...
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
Here's a couple programs - they do the same thing:

PHP:
/*Using the [ php ] tag for MacRumors color codes the code
Code coloring helps you to understand what and where your variables are
Ignore everything above this line*/

#include <stdio.h> // include the standard input/output header

int main(int argc, char* argv[]) // starting point of any C/C++/Objective-C program
{
  printf("Hello world!\n");
  return 0;
}
Output
Code:
Hello world!
The above is C. Let's disect it:
#include <stdio.h> --links that header file to your program, this will allow you to use specific functions such as printf, scanf, sprintf, etc.

int main(int argc, char* argv[]) --this is the starting point of any C/C++/Objective-C program, int main is a function that takes two arguments, int argc, and char* argv[]. If you use this on the command line and you type something after the executable name (let's say its myfirstprogram) so if you type: myfirstprogram this program -- argc would have the number 3 stored in it. myfristprogram = 1, this = 2, program = 3 and char* argv[] would contain those arguments in an array. -- basically ignore all that about int argc and char* argv[] for now.

All functions that you are specifying what they do have curly braces around them, so inside the function int main(int argc, char* argv[]) you specify what it's going to do between { and }.

printf("Hello world!\n"); -- this will print out text out if you run it in a terminal or command line window. It will print out:
Hello world!
_
_ denotes the cursor. \n tells printf to go to a new line. So \n\n\n would go to the next line 3 times.

return 0; -- tells you everything executed fine and that there were no errors. if you get 1 or -1 or something above or below 0 then there was an error with your program.

You'll notice that lines that do something (like print output, return variables, declare variables, declaring functions that haven't been defined) all have semi-colons after them ( ; ). This is to tell the compiler when that function ends what its doing. Now this is different with different functions, for example if you are using variables, you can do a new line... ehh.. here's two examples:

NSLog(@"He"
"ll"
"o w"
"or"
"l"
"d!\n");

[myFraction number1:23
number2:44
string:mad:"The fraction is: "];

oh the stuff between /* */ are comments and are ignored by the compiler same with //
Programmers use these to document there programs so they know what is going on.

PHP:
//This is a C++ program now
#include <iostream>

using namespace std; 
//use the standard namespace std so we don't have
//to type in std::cout

int main(int argc, char* argv[]
{
  cout << "Hello world!" << endl;

  //now let's say we didn't specify using namespace std;
  //we'd have to type this in to get Hello world!
  // std::cout << "Hello world!" << std::endl;
 
 return 0; // let our app know it ended fine
}

The above is C++ read through the comments to see what it does.

PHP:
#import <Foundation/Foundation.h> 

//Yes names are case sensitive
//and notice we #import the files we need, we don't #include them
//#import is better so it doesn't have to compile code included from
//those files again

int main(int argc, char* argv[])
{
  NSLog(@"Hello world!\n");
  return 0;
}

Output:
Code:
2006-07-13 15:09:48.915 a.out[7822] Hello world!

Oi this post is long, if someone wants to explain more, go for it. The Objective-C program uses a part of the Foundation framework, but its not the first objective-c program I made in the one book, the first objective-c program used <stdio.h> (using #import)..

Anyways I've probably scared you from programming huh? there's a lot, and a lot to explain, just be prepared
 

weg

macrumors 6502a
Mar 29, 2004
888
0
nj
macsrockmysocks said:
Ok, I think I am going to do the basic Java, then C, then Cocoa(Objective-C). Do you know any books for absolute beginners?
Thinking in Java would be for free (though I've to admit that I never read this book). Try to learn several different languages, you're still young and you can always specialize in one language later... A good book on the concepts of Object Oriented Programming is Bertrand Meyer's book on that topic, and if you want to go for something different you can have a look at Ocaml, there's a good user's manual and a free book online. Python is also a nice language to start with. It has some object oriented as well as functional elements, and like functional programming languages, it's pretty easy to write your first small applications (since there's an interactive development environment). If you want to learn a .NET language I'd have a look at F# (can be run on the Mac or on Linux using Mono). As a beginner, I'd stay away from C++ and C#, since these languages contain way too many features and allow you to write programs in a very bad style. Once you've understood the concepts they will be easy to learn (uhm, well.. not that I know anybody who has fully mastered C++).
 

macsrockmysocks

macrumors regular
Original poster
Feb 21, 2006
233
0
Alright guys, I decided to do Python first just because it looked easy. And it is! It is very easy to understand. Thanks guys.
 

guzhogi

macrumors 68040
Aug 31, 2003
3,766
1,885
Wherever my feet take me…
It also depends on what you want to do. If you want to make Mac only apps, go w/ objective-c. Cocoa is just a framework, not it's own programming labguage. If you want to do Windows-only, learn .Net. But C/C++ is probably crucial since many apps in several different OSes use these, along with Java. PHP is good for websites, along w/ HTML. Note: HTML is a markup language, not a programming language. Those languages are probably a good place to start basic programming. Also, C, C++, Java and Javascript are all fairly similar. Once you know one, it's generally easy to go between them.

There are butt loads of other languages out there, like Lisp, Scheme, Prolog, Perl, BASIC, Fortran, etc. As said earlier, each language has its pros and cons and are better suited for each thing.

If you really like programming, several universities of computer science majors. I majored in Computer Science at Illinois Wesleyan University which is a liberal arts university so I probably did not get as much training as I would have gotten if I has gone to MIT. But hey, do whatever's right for you.
 

yg17

macrumors Pentium
Aug 1, 2004
15,028
3,003
St. Louis, MO
I first taught myself PHP, and now consider myself to be very good at it, and I've never touched a book thanks to tutorials online, and the PHP documentation which is extremely helpful. I then learned C++ and Java in college which were easy, but once you know 1 programming language, learning another is a lot easier. I never got too deep into C++ and Java, because I switched majors from computer science (programming) to IT, which is more of a general computer major.

I know 3 languages (4 if you want to count Javascript, although I'm not a pro at that, I still have to look things up every now and then), and still prefer PHP. I find it a bit easier to use, and I know more PHP than C++ and Java combined, so I can write a pretty advanced PHP program, but my C++ and Java skills limit me to useless command line programs. Plus, since I've done a little bit of website design (nothing professional, just crap with friends and a personal site that didn't last too long due to my laziness), knowing PHP just made sense.

Unfortunately, PHP is virtually useless in the business world. For some reason, large corporations won't touch PHP with a 10 foot pole and would rather work with things like ColdFusion and M$ ASP for reasons I'll never understand.
 

cmmcintosh

macrumors newbie
Jun 22, 2006
7
0
yg17 i wouldn't say C++ was easy, When ever you first learn pointers it gets complex and confusing.

slooksterPSV what does the function NSlog() do? i have never seen that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.