Beginner Programmer - Good Stages

Discussion in 'Mac Programming' started by sebpayne, Dec 19, 2005.

  1. macrumors member

    Joined:
    Nov 28, 2005
    #1
    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
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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.
     
  3. macrumors 68000

    Josh

    Joined:
    Mar 4, 2004
    Location:
    State College, PA
    #3
    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.
     
  4. macrumors member

    Joined:
    Nov 23, 2005
    #4
    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.
     
  5. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    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
     
  6. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #6
    PS. Cocoa isn't a language, its a collection of frameworks...
     
  7. macrumors 68000

    atari1356

    Joined:
    Feb 27, 2004
    #7
    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.)
     
  8. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #8
    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.
     
  9. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #9
    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.
     
  10. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #10
    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).
    PHP:
    #include <iostream.h> //include standard C++ libraries

    class MyClass //create a class called MyClass
    {
    private: 
    //make anything listed below private members
    int c1Valuec2Value//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 a1int a2chara3) : 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
    {
     
    MyClassxclass//create a pointer to MyClass called xclass
     
    xclass = new MyClass(1015"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
     
  11. macrumors 65816

    Joined:
    Jan 6, 2004
    #11
    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.
     
  12. macrumors 68000

    iEdd

    Joined:
    Aug 8, 2005
    Location:
    Australia
    #12
    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.
     
  13. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #13
    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.
     
  14. macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #14
    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.
     
  15. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #15
    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.
     
  16. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #16
    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:
    Code:
    #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.
     
  17. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #17
    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:
    Code:
    for (int i = 0; i < 10; i++) { ... }
    Even Java can do this! It's a small thing, perhaps, but useful and I want it. :)
     
  18. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #18
    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.
     
  19. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #19
    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 of
    Code:
    int i = 0;
    for (i = 0; i < 10, i++) { ... }
    which you have to do now, you could just write
    Code:
    for (int i = 0; i < 10, i++) { ... }
     
  20. macrumors 6502a

    #20
    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.
     
  21. macrumors 6502

    Coheebuzz

    Joined:
    Oct 10, 2005
    Location:
    Nicosia, Cyprus
    #21
    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!
     
  22. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #22
    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:
    Code:
    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;
    }
    
     
  23. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #23
    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.
    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 ;)
     
  24. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #24
    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)'
     
  25. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #25
    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 :/
     

Share This Page