Programming Noob Needs Help

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
Patmian212 said:
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
http://developer.apple.com/macosx/dashboard.html
 

Cybernanga

macrumors regular
Oct 27, 2004
201
0
Essex, United Kingdom
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
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
Cybernanga said:
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
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.
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,255
117
Nowheresville
Mitthrawnuruodo said:
Java and/or Python has a nice learning curve and can be used for most applications (pun intended ;)).
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#.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,255
117
Nowheresville
Patmian212 said:
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
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.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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?
 

cube

macrumors P6
May 10, 2004
16,453
4,463
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.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
cube said:
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.
Thanks for the link, I'll check it out.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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
 

HiRez

macrumors 603
Jan 6, 2004
5,805
1,700
Western US
Patmian212 said:
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.
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.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
HiRez said:
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.
How do I compile in xcode?
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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?
 

Attachments

Cybernanga

macrumors regular
Oct 27, 2004
201
0
Essex, United Kingdom
superbovine said:
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.
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)
 

HiRez

macrumors 603
Jan 6, 2004
5,805
1,700
Western US
Patmian212 said:
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?
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.*;
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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.
 

ChrisBrightwell

macrumors 68020
Apr 5, 2004
2,294
0
Huntsville, AL
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.
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,255
117
Nowheresville
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.
 

7254278

macrumors 68020
Original poster
Apr 11, 2004
2,365
0
NYC
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?