PDA

View Full Version : Beginner Programmer - Good Stages




sebpayne
Dec 19, 2005, 06:02 AM
I'm new to programming (apart from CSS and HTML) and using the tutorials on the internet, I am thinking of developing my skills by:

1. Learn AppleScript
2. Learn Cocoa

I tried a Cocoa tutorial on Apple Developer Connection but it failed (don't know why) but the AppleScript one worked and I guess it would be good to have knowledge of both languages. If you were totally new to programming, where is a good place to start?

REALbasic looked good but I can't afford £280 for a license for it so I'm going to stick to free tools.

Thanks

Seb



robbieduncan
Dec 19, 2005, 06:24 AM
It depends on your goals. If you want to become a good programmer in general learn the theory! If you want to become a Mac programmer learn C the Objective-C/Cocoa. AppleScript is pretty much unique in terms of syntax so will not really help you much in terms of moving to other languages/platforms so I'd view it as optional.

Josh
Dec 19, 2005, 07:03 AM
I'd say start with C or C++.

Learning an easier language like C will help you learn C++, Java, etc a lot more quickly.

The syntax is different in different languages, but the general concept is there. Once you learn one, picking others up is a lot easier.

Jordan72
Dec 19, 2005, 11:05 AM
Applescript is for programming how programs can be used together to produce results. I.e., lets say you wanted to always know when news about a particular subject was being broadcasted on the web. You could make a program in AppleScript to cause Safari to launch and use several searach engines for your subject. The links found then would be coppied to a text document created by AppleWorks. After Safari had performed the daily search, it could shut down. If links are found, you could cause it to set an event for your iCal, which brings up a message saying you have links. This could all be done through using AppleScript programming. AppleScript's practical benefit is pretty much limited these kind of tasks: Automating existing applicatons for a customized use.

Cocoa is used to build applications like Safari, Applworks and iCal. You wouldn't use Applescript to make Chess or some software a local company hired you to make (except, maybe a small project). You would most likely use Cocoa.

Once you know what kind of software you intend to learn to build, you'll know where to start. If you choose to learn Cocoa, it's better to start with Objective-C, because that is what Cocoa is written with. There is really only one beginners book: Programming in Objective-C by Kochan. It also teaches you the C you need to get going.

robbieduncan
Dec 19, 2005, 12:23 PM
Jordan is mostly correct about AppleScript but there is AppleScript Studio which allows for building Applications with AppleScript. It uses a bridge into Cocoa iirc. It does have the downside of being called ASS. It's amazing that you don't see more programs advertising : "Built With ASS" :D

jeremy.king
Dec 19, 2005, 12:32 PM
PS. Cocoa isn't a language, its a collection of frameworks...

atari1356
Dec 19, 2005, 02:11 PM
If your goal is to be able to create Mac applications, I'd first learn some C programming basics.

Then read "Programming in Objective-C" by Stephen Kochan. It's a good introduction to Objective-C, and covers a bit of the Cocoa frameworks as well.

After that, you can read one (or more) of the books covering Cocoa.

(I've been learning off and on for a few years now... it's not easy, and can be intimidating. One thing I think that might help is to have some goals in mind - come up with an idea for a small application that you want to create, and work on it as you learn new things. It helps you stay motivated if you feel like you're accomplishing something as you go along.)

HiRez
Dec 19, 2005, 09:16 PM
I have found that for myself, keeping myself exposed to different languages is a good idea. It might present you with different ways of thinking about problems, plus seeing a number of languages makes it easier to learn a new one when the time comes. And the time will come. Of course you will probably concentrate on a single language, but keep dabbling in others along the way.

Soulstorm
Dec 20, 2005, 12:18 AM
if you want to program for OS X, C variants are the way to go.

For Cocoa, you will need Obj-C, for Carbon you need C++ or C.

Applescript is an easy way to handle Application specific sub-routines, but the limitation for Applescript and Applescript studio application is that you must constrain yourself to use things that other applications use. You never have the chance to create something entirely for yourself.

My opinion is to start with C++ because with this, you will never have to learn C (since C++ is a superset of C), and later, you will have an easy time moving to Cocoa by learning Obj-C.

slooksterPSV
Dec 30, 2005, 01:15 PM
My 2¢:
Learn C then C++ - learn about Polymorphism (SP?), Inheritance, and the like. This is a must in all OOP (Object-oriented programming) languages. And I'll throw an example cause I like to :D . Once you've learned C or C++ depending on what you want to develop, learn that API - for example for gaming I've been learning SDL and have made a Tetris program via a tutorial. I've known C and C++ for about 4 years, but never made a game with it not until yesterday. Now I'm enhancing on the game. Here's the link to that btw http://www.aaroncox.net/tutorials/ and SDL tutorials are kind of rare on the internet right now. Alright, here is some simple code that deals with classes (what basically defines OOP).

#include <iostream.h> //include standard C++ libraries

class MyClass //create a class called MyClass
{
private: //make anything listed below private members
int c1Value, c2Value; //declared two integer values
char *nmValue; //declare a character pointer (good for strings)

public:
//now I'm going to create a constructor for MyClass
MyClass(int a1, int a2, char* a3) : c1Value(a1), c2Value(a2), nmValue(a3)
{
}
//now a destructor
~MyClass()
{
}

int returnMultiply() //return int value via function called returnMultiply
{
return c1Value*c2Value; //returns c1Value*c2Value
}

};

int main() //main start of a program
{
MyClass* xclass; //create a pointer to MyClass called xclass
xclass = new MyClass(10, 15, "My New Window"); //allocate new memory for xclass via new MyClass(variable, variable, variable)
std::cout << xclass->returnMultiply() << endl; //print out into a command or terminal window the value of class->returnMultiply();
return 0; //exit program normally
}


Now I know most of this you won't understand right away. Learning Javascript may help with learning these key features. Umm... yeah, not sure what else to say but good luck. - Oh all this program does right now is return the output: 150

darkwing
Dec 30, 2005, 01:27 PM
My opinion is to start with C++ because with this, you will never have to learn C (since C++ is a superset of C), and later, you will have an easy time moving to Cocoa by learning Obj-C.

C++ is not a strict superset of C, you know. There is C code that won't compile with a c++ compiler.

The difference between learning C and C++ first is whether or not you want to start off learning OOP. I know many people who "know" C++ but don't even begin to understand OOP.

iEdd
Dec 30, 2005, 04:43 PM
I am a beginner and I have had quite a bit of experience with the language NQC (Not quite C), which has similar syntax functions of the true C language. NQC is mainly used for powerfully programming LEGO® MINDSTORMS™. After a few years of doing nothing, I started learning Java from just after christmas, then went back and looked at NQC again and their are many, many similarities. NQC is much easier though :p As many have recommended, a beginner who wants to learn a *real* language, should start with C or Java, then move onto C++, objective C or C# if they do windows stuff. Or so I was told.

Catfish_Man
Dec 30, 2005, 07:30 PM
C++ is a highly annoying language. I recommend C#, Objective-C, or Java if you need an object oriented C-derived language to work with.

savar
Dec 30, 2005, 08:31 PM
I'm new to programming (apart from CSS and HTML) and using the tutorials on the internet, I am thinking of developing my skills by:

1. Learn AppleScript
2. Learn Cocoa

Just learn Java. Its a popular language that is relatively easy for novices and its used all over the place. Buy a book or better yet take a class.

Soulstorm
Jan 2, 2006, 04:01 AM
C++ is not a strict superset of C, you know. There is C code that won't compile with a c++ compiler.

The difference between learning C and C++ first is whether or not you want to start off learning OOP. I know many people who "know" C++ but don't even begin to understand OOP.
I know that. But at first it was created as such, didn't it? Anyway, the point is indeed wether you want to learn Object Oriented Programming or not. Personnaly, I think that OOP is the one way to go. C has limitations in structures, that I don't like. I found OOP disturbing at first, but later, I couldn't imagine myself not using it.

The only thing that I still find difficult is pointers and references. Although I understand their usefullness, I have trouble using them with objects... On the other hand, I still haven't been involved with C++ for 5 months yet.

slooksterPSV
Jan 2, 2006, 01:17 PM
I know that. But at first it was created as such, didn't it? Anyway, the point is indeed wether you want to learn Object Oriented Programming or not. Personnaly, I think that OOP is the one way to go. C has limitations in structures, that I don't like. I found OOP disturbing at first, but later, I couldn't imagine myself not using it.

The only thing that I still find difficult is pointers and references. Although I understand their usefullness, I have trouble using them with objects... On the other hand, I still haven't been involved with C++ for 5 months yet.
CC, it is strict and has limitations, the one major thing I don't like about it, is you have to define all of your variables before any real code, at least with some compilers if I defined int way down the line, it would give me errors and that. With C++ you can define any type of data anywhere. So let's say I had a program like this:

#include <stdio.h> //c header

bool render();
int GetErrorCode();

int g_Error = 0;

int main()
{
printf("This is a statement\n");
if(!render())
{
int x = GetErrorCode();
return x;
}
return 0;
}

bool render()
{
return true;
}

int GetErrorCode()
{
g_Error = 100;
return g_Error;
}

That would generate errors cause int x has to be defined at the top level of main.

HiRez
Jan 2, 2006, 01:50 PM
I am waiting for them to provide inline variable declarations to Objective-C (or to the gcc compiler anyway), so I can do stuff like:for (int i = 0; i < 10; i++) { ... }Even Java can do this! It's a small thing, perhaps, but useful and I want it. :)

slooksterPSV
Jan 2, 2006, 04:16 PM
I am waiting for them to provide inline variable declarations to Objective-C (or to the gcc compiler anyway), so I can do stuff like:for (int i = 0; i < 10; i++) { ... }Even Java can do this! It's a small thing, perhaps, but useful and I want it. :)
Objective-C you can't do inline!? I don't know Obj-C, but thats sad if it can't. When I made my OpenGL class (SFC_GL.h) when I used a PC, I called the functions as inline _return_type_ function_name(...)
{
//define here
}

cause I heard it makes your programs faster.

HiRez
Jan 2, 2006, 09:28 PM
Objective-C you can't do inline!? I don't know Obj-C, but thats sad if it can't. When I made my OpenGL class (SFC_GL.h) when I used a PC, I called the functions as inline _return_type_ function_name(...)That's function inlining, which is a compiler optimization, and I believe you can specify inline functions in Xcode's C/Objective-C, but that's a completely different thing than I was talking about. I'm talking about declaring variables inside program statements. So instead ofint i = 0;
for (i = 0; i < 10, i++) { ... }which you have to do now, you could just writefor (int i = 0; i < 10, i++) { ... }

AlmostThere
Jan 3, 2006, 06:08 AM
add -std=c99 to your compiler flags.

That said, I don't know the position of Objective-C wrt to C99 (1999 'Standard' for the C language) maybe someone who knows can reply.

For the OP
Please ask yourself why you want to learn to program, then you will get better advice. Learning because you want to learn more about computers in one thing (go for any C type language), but learning if you have a specific programme you want to write is another (I suggest Python with no other information, knowing what you want to program is important here).

If you fall into the latter group and learn the wrong language, you will be in for a very frustrating experience.

Coheebuzz
Jan 3, 2006, 10:33 AM
I am in the same position as sebpayne, am just starting to get my feet wet with low level languages and my first attempts have failed!
My only experience with programming has been/is with HyperTalk, Lingo and ActionScript. A few months ago i decided to try RealBasic and i really really liked it, very easy to learn and you can start producing *multiplatform* apps in no time! However i quickly struck its limitations so now am certain that Objective-C is the way to go because there are already build-in classes into OSX that i can use to build what i have in mind.

Also, does it really help to begin with C or C++ and then move towards Objective C? I don't want to become a programming guru, am a g designer and i just want to know enough so that i can work out solutions by myself. I mean what can Carbon do better than Cocoa in everyday examples? Sure carbon is more mature than Cocoa in terms of available classes but new stuff are added all the time.

I keep hearing good things about Kochan's book so i just bought it, i should have it by Friday! I hope his tuts are better than Apple's!

slooksterPSV
Jan 3, 2006, 05:01 PM
That's function inlining, which is a compiler optimization, and I believe you can specify inline functions in Xcode's C/Objective-C, but that's a completely different thing than I was talking about. I'm talking about declaring variables inside program statements. So instead ofint i = 0;
for (i = 0; i < 10, i++) { ... }which you have to do now, you could just writefor (int i = 0; i < 10, i++) { ... }
Oh that's just as bad, if not worse. No that's worse. I like being able to do that cause then if I want to call the same variable for a different for loop its in a different score. Good thing you can optimize with inline in Obj-C. *hugs C and C++ and SDL*. What about putting something like this:

void ab() //I don't know Obj-C so I'll do it in C/C++ Standard
{
cout << "Hello world" << endl;
int x = 1; //this specifically, can you declare variables any where?
cout << x << endl;
int y = 2; //this too
cout << x * y * y * y << endl;
}

caveman_uk
Jan 4, 2006, 03:19 AM
My only experience with programming has been/is with HyperTalk, Lingo and ActionScript. A few months ago i decided to try RealBasic and i really really liked it, very easy to learn and you can start producing *multiplatform* apps in no time! However i quickly struck its limitations so now am certain that Objective-C is the way to go because there are already build-in classes into OSX that i can use to build what i have in mind.
Realbasic is nice and easy but I quickly got tired of it's limitations. Primarily it's lack of scalability and it's bugs and the fact that you end up paying every year for the damn thing.

Also, does it really help to begin with C or C++ and then move towards Objective C? I don't want to become a programming guru, am a g designer and i just want to know enough so that i can work out solutions by myself. I mean what can Carbon do better than Cocoa in everyday examples? Sure carbon is more mature than Cocoa in terms of available classes but new stuff are added all the time.

I'd advise using objective-c/cocoa when you can and carbon when you can't. It's a lot easier to write an app in obj-c/cocoa than it is in carbon. There are some things that you can't do yet in cocoa (IIRC spotlight, core image, authorization for example) but you can include carbon code in a cocoa app. You'll find that there are lots of folks out there writing Cocoa wrappers around the nasty bits of the carbon API (because Apple hasn't got round to it).

If you plan on doing objective-C then don't bother with learning C++. It's a lot harder and most of it you won't need. Learning C would be a good idea but you don't need to be a real C guru for Cocoa. A basic understanding will probably do. So long as you understand variables, loops, conditionals etc you should be fine.

I'm not sure how you'd learn this but I think it's more important to quickly grasp how to design apps using objects than to be a real **** hot C programmer. Also make sure you read and understand the retain - release mechanism. If you get it wrong, objects vanish when you least expect (because you should have retained them) or you leak memory (because you didn't release something you should've).

Finally, In cocoa it seems that there's tons of methods to learn and loads of classes but there are patterns to the naming of them and the documentation is pretty good. When you first start out you do tend to spend a LOT of time looking at the documentation for every line of code looking for the right method! That stage should pass with a few hundred lines of code under your belt ;)

caveman_uk
Jan 4, 2006, 03:21 AM
void ab() //I don't know Obj-C so I'll do it in C/C++ Standard
{
cout << "Hello world" << endl;
int x = 1; //this specifically, can you declare variables any where?
cout << x << endl;
int y = 2; //this too
cout << x * y * y * y << endl;
}

Yes you can declare variables just when you need them...this isn't pascal;) You just can't declare a variable in a 'for ( blah; blah; blah)'

Catfish_Man
Jan 4, 2006, 11:25 AM
add -std=c99 to your compiler flags.

That said, I don't know the position of Objective-C wrt to C99 (1999 'Standard' for the C language) maybe someone who knows can reply.


Objective-C is fine with C99, there's even a checkbox in Xcode for it. I think it's madness that it's not on by default :/

slooksterPSV: so wait... you inlined ALL your methods? Do you know what that actually does?

caveman_uk: Spotlight has Cocoa API, and there are methods for converting NSImages to CIImages and back. You're right about authorization services though... such a pain :/

slooksterPSV
Jan 4, 2006, 08:04 PM
Yes you can declare variables just when you need them...this isn't pascal;) You just can't declare a variable in a 'for ( blah; blah; blah)'
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.

HiRez
Jan 5, 2006, 02:33 AM
But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
You can name your own variables and methods almost anything you want, however the setter/getter methods for variables should follow a certain syntax if you want to use them with Cocoa Bindings. The Cocoa APIs tend to be verbose in their method signatures, but that can be seen as a strength as well. Try going back to a piece of code you haven't looked at after 6 or 12 months. Would you rather try to figure out "arrayWithString" or "strarr"?

gekko513
Jan 5, 2006, 02:44 AM
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
Then you haven't been working much with large programs. The more I work with and maintain large programs the more I recognise the need to use variable and method names that are as describing as possible. Readable Objective C methods with named parameters are a definite advantage when working with unfamiliar code.

Code completion can solve most of the problems with the tediousness of using verbose symbol names, but I'm not quite satisfied with Xcodes code completion. I like Netbeans better.

I agree that not being able to declare the loop variable within the for loop itself is the most annoying thing about Objective C. It drives me crazy. :mad:

caveman_uk
Jan 5, 2006, 03:04 AM
Oh ok, that still sucks. But Objective-C (as I've heard) is very very very very picky basically. And Apple, when designing code, doesn't want you to use, x or m_CenterX or anything like that, but to use things like: CenterOfFrog or CenterOfFrogEntity or something like that, which IMO is just too many more characters to type and try and fix problems with.
It's a pain if you do have to type it but that's why you have code completion turned on;)

I think longer, more descriptive names adds to code readability and that can only be a good thing (I was taught that it was a good thing 20 years ago and I doubt opinion has changed much). Objective-C itself couldn't give a monkey's what you call things but the implementation of Cocoa expects certain things. For example if you're using key-value coding Cocoa expects that the setter for a variable is called 'setVariableName' and the getter is called 'variableName'.

So go ahead and call your variables x1 and q but if anyone ever has to change your code in the future I think their defense lawyer has a mitigating factor when that coder hunts you down in revenge...