Programming Noob Needs Help

Discussion in 'Mac Programming' started by Patmian212, Jun 10, 2005.

  1. Patmian212 macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #1
    Hey All,
    I did a search on the forums but didnt find exactly what I was looking for so maybe you guys can help.
    I want to start a new hobby, programming. I know NOTHING about programming, I am only fluent in HTML. I want to make stuff like widgets, simple games, basically some simple programs to get started, preferably with GUI not command line interface programs. What is a simple language to learn and get started with? What programs will I need? Any good tutorials(not books)?
    Feel free to add in things I missed.
    Thanks
    Fred
     
  2. superbovine macrumors 68030

    superbovine

    Joined:
    Nov 7, 2003
    #2
    http://developer.apple.com/macosx/dashboard.html
     
  3. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #3
    Java and/or Python has a nice learning curve and can be used for most applications (pun intended ;)).
     
  4. Cybernanga macrumors regular

    Joined:
    Oct 27, 2004
    Location:
    Essex, United Kingdom
    #4
    AppleScript is the most english like language I've ever come across. It's amazingly powerfull, and if you use X-Code for your AppleScript you can make complete full feature applications.

    Yeah, I know many people will tell you that AppleScript is not a propper programming language, but it's easy to learn and understand, and give you good basis from which to start learning another language, as you will learn about variables, loops and other programmy things.

    PM me if you want some help/pointers with AppleScript
     
  5. superbovine macrumors 68030

    superbovine

    Joined:
    Nov 7, 2003
    #5
    think about the non-english speaking people who learning programming languages with little no, or no knowledge of english. do you know hard it is for them read a compiler error in english for someone who has little understand of the language, much less an error message from a compiler. What i am saying is, just because the language is the most like english, people all over the world over come that problem without evening knowing the with much harder to learn programming languages.
     
  6. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #6
    Python is one of the easiest programming languages for Mac IMO. FORTRAN isn't too bad, not the best though. Um... later on learn C or C++ or C#.
     
  7. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #7
    I have xcode 2.1, is that all I need, also how do I run the program after, is it just like a webpage where I refresh the compiler or do I need another program?
    Anyone know any good tutorial?
    Thanks
    Patmian
     
  8. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #8
    With XCode, it depends on how you make it. It may make it as a Terminal Application. Otherwise it would make it as a Apple App with a GUI Interface.

    PHP:
    #include <iostream.h>
    using namespace std;
    int main()
    {
     
    cout << "First program that runs in terminal" << endl;
    }
    This is C++ - #include includes files that are used for functions, calls, etc.
    using namespace std; - that means that it will be using a namespace called std so that you don't have to call cout like this std::cout ...
    int main - the starting function for all C, C++, C# programs - others have a same variant of starting - Pascal is like START: or something like that
    { } - the scope, or how far int main goes
    cout - displays whatever is in "" or variables of just their name

    Expand on this you guys, as i have to go to work.
     
  9. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #9
    Guys, I just thought of something, I want to start from the bottom up to get a better understanding of programming, I want to learn BASIC, then Python. Can xcode do basic? Also what type of programs can BASIC create?
     
  10. cube macrumors G4

    Joined:
    May 10, 2004
    #10
    Basic isn't any better to start with. Is what people used to start with 20 years ago because that's what came with their home computers.

    Do yourself a favor and go here. You'll concentrate on programming, not on how to hack in a language.
     
  11. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #11
    Thanks for the link, I'll check it out.
     
  12. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #12
    BASIC is Microsoft. C, C++, C#, Python, Java, etc. are universal.
     
  13. cube macrumors G4

    Joined:
    May 10, 2004
    #13
    BASIC was invented in 1963 at Dartmouth College.
     
  14. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #14
    Guys I wrote my first java app, the Hello World app, I wrote it in BBedit, now how do I compile it and run it? I downloaded, J2SE 5.0 but I cant figure out how to compile it.
    Help would be appreciated
    patmian212
     
  15. SodaPopMonster macrumors regular

    Joined:
    Jan 13, 2005
    Location:
    Houston, TX
    #15
    I remember seeing a visual-based programing interface on macupdate somewhere-I'll try to find it again.

    edit: here it is-I haven't downloaded it yet, so I don't know whether it is good or not, it seems to be based on graphing http://www.macupdate.com/info.php/id/16945
     
  16. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #16
    Assuming your file is named HelloWorld.java, launch Terminal:
    Code:
    [~/Documents/Java] $ javac HelloWorld.java 
    [~/Documents/Java] $ java -cp . HelloWorld
    Hello, world!
    ...or you could just do it in Xcode.
     
  17. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #17
    How do I compile in xcode?
     
  18. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #18
    OK I put my java code in xcode and I got 3 errors, I dont know what I did wrong, from looking at the screenshot could someone expain it to me.
    Also where do I type the code in xcode, I just erased the manifest file and typed there, is that right?
     

    Attached Files:

  19. Cybernanga macrumors regular

    Joined:
    Oct 27, 2004
    Location:
    Essex, United Kingdom
    #19
    Aha, SuperBovine, we meet once again!

    I read Patmian212's post, and his english seems perfectly fluent to me. I mentioned AppleScript because it is easy to learn and understand because it has very english like syntax.

    it's much easier to learn and understand this:

    Code:
    display dialog "Hello, World!"
    than it is to learn and understand this:

    Code:
    [~/Documents/Java] $ javac HelloWorld.java 
    [~/Documents/Java] $ java -cp . HelloWorld
    Hello, world!
    I used english as an example, as the original posted seems to have fluent english and so do I. However, if you read here you'll see that AppleScript has support for additional human dialects, meaning you could write AppleScripts with French, Spanish or other syntax if you wanted

    Even though Apple officially discontinued support for other dialects in OS 8.5, I still come accross the occasional French AppleScripts now and then that have obviously been written on OS X, so I assume there are probably some people keeping this funtionality alive, even if it's not officially supported by Apple. (Oh, and I mention French because I can understand it, there are probably other languages still supported, but I would know because I haven't been looking for them)
     
  20. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #20
    First you start a new project of type Java Tool (if you don't need an interface, as you don't in your HelloWorld example). Then create a new file for your HelloWorld class source code (the name of the file must match the name of the class inside it). So the file should be called "HelloWorld.java" in this case.

    The errors are because you must, at the top of your source files, import any Java built-in classes you will be using, such as String. For something simple you can get away with:
    Code:
    import java.*;
     
  21. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #21
    Hirez sorry import class? I dont understand. Also if I use BBedit, how can I compile? I have J2SE 5.0 but I cant figure out how to compile. BBedit seems much friendlier then Xcode but thats just me I guess.
     
  22. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #22
    No one knows the answer to my compilation problem?
     
  23. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #23
    The problem is that you're trying to instantiate a java.lang.String object (look at the parameters in main()) and you're not including the java.lang.String class.

    Open your text editor of choice (I use TextWrangler) and try this:
    Code:
    import java.lang.String;
    
    class HelloWorld
    {
        public static void main(String args[])
        {
            System.out.println("Hello, world!");
        }
    }
    Save that as "HelloWorld.java" (no quotes) to your desktop. Notice that the "HelloWorld" class declaration matches the pre-extention "HelloWorld" in the filename. This is case sensitive and they MUST match.

    Next, open Terminal.app (Applications / Utilities / Terminal.app) and type in these commands:
    Code:
    cd ~/Desktop
    javac HelloWorld.java
    java HelloWorld
    The first command, cd ~/Desktop, should be self-explanatory. The second, javac HelloWorld.java, calls the java compiler to compile your .java file into a .class file.

    The final command, java HelloWorld, tells the Java runtime executable (aka JVM) to load HelloWorld.class, find the main() method, and run it.

    If this is over your head, I strongly suggest picking up one of the "... for Dummies" books and going from there. Learning a language and powerful and complex as C or Java w/out a book or something is really painful.

    Good luck.
     
  24. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #24
    Use TextWrangler, its free and it will format the code for you.

    I don't personally know Java, even though I have a Java Certification book, but I'll help you out as much as I can - I'm going to go grab it and read through it.

    EDIT: In C and C++ that Java source would look like this, respectively.
    PHP:
    #include <stdio.h> /*This is C Code*/
    int main()
    {
       
    printf("Hello World\n");
       return 
    0;
    }
    PHP:
    #include <iostream.h> //C++ Code
    /*Alternatively we could put [using namespace std;] so we don't have to type std::*/
    int main()
    {
       
    std::cout << "Hello World\n" /*if we use   using namespace std;   we don't need std:: */
       
    return 0;
    }
    Let's break down the code piece by piece again:
    #include - This will include files for basic functions, standard language, etc. Just like you use import .... for the usage of String
    int main() { } - This is a function, common to class HelloWorld in your java app, but classes are very different, very structured and organized for data
    { } - these are scope operators, you use these to define the start and end of a function - functionname(args){ //start scope } //end scope
    std::cout << or cout << "text"; - prints the line of text, just like Systemln.out in the java program, and all ending calls with have a ; after them. So: int a; int b; printf('la la la'); char* x, b, c = 0; etc.
    return 0; - return 0 if program executed ok or x if error.

    I made a program called Emula-menu for Windows, if you would like to see the source code of that, I would gladly hand it out to anyone. Also, I can make a few C++ programs that are universal just so you can see the code or that.
     
  25. Patmian212 thread starter macrumors 68020

    Patmian212

    Joined:
    Apr 11, 2004
    Location:
    NYC
    #25
    Thanks for the help, I got "Hello World" running. I am currently taking more tutorials, so does everyone agree that java is a good way to go? Also is creating a GUI hard?
     

Share This Page