PDA

View Full Version : Programming Noob Needs Help




Patmian212
Jun 10, 2005, 07:02 PM
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
Jun 10, 2005, 07:10 PM
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

Mitthrawnuruodo
Jun 10, 2005, 07:13 PM
Java (http://developer.apple.com/java/) and/or Python (http://www.python.org/) has a nice learning curve and can be used for most applications (pun intended ;)).

Cybernanga
Jun 10, 2005, 09:40 PM
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
Jun 10, 2005, 10:33 PM
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
Jun 10, 2005, 10:57 PM
Java (http://developer.apple.com/java/) and/or Python (http://www.python.org/) 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#.

Patmian212
Jun 11, 2005, 06:57 AM
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
Jun 11, 2005, 11:51 AM
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.

#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.

Patmian212
Jun 11, 2005, 05:56 PM
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
Jun 11, 2005, 06:34 PM
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 (http://www.teach-scheme.org/). You'll concentrate on programming, not on how to hack in a language.

Patmian212
Jun 11, 2005, 06:40 PM
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 (http://www.teach-scheme.org/). You'll concentrate on programming, not on how to hack in a language.
Thanks for the link, I'll check it out.

slooksterPSV
Jun 11, 2005, 07:13 PM
BASIC is Microsoft. C, C++, C#, Python, Java, etc. are universal.

cube
Jun 11, 2005, 07:49 PM
BASIC is Microsoft.

BASIC was invented in 1963 at Dartmouth College.

Patmian212
Jun 11, 2005, 07:54 PM
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

SodaPopMonster
Jun 11, 2005, 08:45 PM
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

HiRez
Jun 11, 2005, 09:28 PM
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:
[~/Documents/Java] $ javac HelloWorld.java
[~/Documents/Java] $ java -cp . HelloWorld
Hello, world!...or you could just do it in Xcode.

Patmian212
Jun 11, 2005, 09:46 PM
Assuming your file is named HelloWorld.java, launch Terminal:
[~/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?

Patmian212
Jun 11, 2005, 10:06 PM
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?

Cybernanga
Jun 11, 2005, 10:24 PM
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:

display dialog "Hello, World!"

than it is to learn and understand this:

[~/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 (http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.16.html) 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
Jun 12, 2005, 02:31 AM
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:import java.*;

Patmian212
Jun 12, 2005, 05:58 AM
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.

Patmian212
Jun 13, 2005, 01:25 AM
No one knows the answer to my compilation problem?

ChrisBrightwell
Jun 13, 2005, 02:43 AM
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:
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:cd ~/Desktop
javac HelloWorld.java
java HelloWorldThe 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
Jun 13, 2005, 02:56 AM
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.

#include <stdio.h> /*This is C Code*/
int main()
{
printf("Hello World\n");
return 0;
}


#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.

Patmian212
Jun 13, 2005, 03:58 PM
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?

HiRez
Jun 14, 2005, 05:27 PM
Also is creating a GUI hard?Creating a basic one is pretty easy, creating a good one (a rich one that serves the user instead of the programmer) is somewhat more difficult. Start with something easy, like a button in a window that prints some text when you click it.

Zion Grail
Jun 17, 2005, 03:13 AM
Xcode actually has an interface builder. Apple's website has tutorials on how to use it with Objective-C, but it can be used with Java also.

Here is a fantastic book on how to code in Java. Link (http://www.amazon.com/o/ASIN/0596009208/104-1776706-2826360?SubscriptionId=1WR8NR93GFXCZEE57C02/104-1776706-2826360)

I have more books on Java than on Assembler, C, C++, C#, Python, and everything else combined. Head First Java (the book at the end of the link) is, by far, the best. It doesn't matter what OS you're using for that book (as Java is platform-independent anyway).

Have fun!

slooksterPSV
Jun 17, 2005, 03:39 AM
Just for comparison, just to create a standard window in Windows C++ programming, it takes 72 lines of code. (I made my own functions that made it 38)

EDIT: And my emula-menu program, it has 1425 lines of code.

Patmian212
Jun 17, 2005, 07:15 AM
Just for comparison, just to create a standard window in Windows C++ programming, it takes 72 lines of code. (I made my own functions that made it 38)

EDIT: And my emula-menu program, it has 13,772 lines of code.


Jesus u wrote that many lines of code????????? How man mb is the program?

mattraehl
Jun 17, 2005, 08:16 AM
A good book for you might be Mac OS X for Java Geeks published by O'Reilly. The title is a little bit misleading, it's more like "Learning Java on Mac OS X." The only drawback being its a little bit dated (Jaguar).

When you are ready for real manly programming and want to learn C, and make nice native Cocoa apps, a great place to start is

http://www.cocoadevcentral.com/

slooksterPSV
Jun 17, 2005, 12:12 PM
Jesus u wrote that many lines of code????????? How man mb is the program?
Oops it was only 1,425 lines, and its only 456KB
I took out a lot of redundancy though, before I think it was over 5000

ChrisBrightwell
Jun 17, 2005, 01:31 PM
Jesus u wrote that many lines of code????????? How man mb is the program?
13,000 lines isn't that much code. The project at work has more than 290,000 lines of code. I've been on the project for 2.5 years, so it wouldn't be that far-fetched to think that I've written 20,000+ lines of code since I've been here.

Having said that, there's a LOT of functionality to still be implemented. :)

feakbeak
Jun 17, 2005, 01:50 PM
13,000 lines isn't that much code. The project at work has more than 290,000 lines of code. I've been on the project for 2.5 years, so it wouldn't be that far-fetched to think that I've written 20,000+ lines of code since I've been here.

Having said that, there's a LOT of functionality to still be implemented. :)13000 lines of code is not earth-shattering but it's a sizable amount. The dev shop that I work at currently has several hundred thousand lines of code between four projects. I recently got done with a sample application that will be distributed to our customers to show how to use our main COM automation interface. It's 4000 lines of code for a sample! I don't understand why I am asked to do the things I do sometimes... pays the bills though. Plus it was my first chance to work with C# - nice language for the most part. I do not like the fact that C# does not have optional arguments for functions - you don't need them, but I think it makes the code more elegant.

mwpeters8182
Jun 17, 2005, 02:04 PM
From personal experience, don't get ahead of yourself. Don't even THINK about doing any GUI progamming until you've got the basics down. Write some console programs that are actually useful, then move on to implementing those programs with a GUI.

MP

NtotheIzoo
Jun 17, 2005, 02:20 PM
13,000 lines isn't that much code. The project at work has more than 290,000 lines of code. I've been on the project for 2.5 years, so it wouldn't be that far-fetched to think that I've written 20,000+ lines of code since I've been here.

Having said that, there's a LOT of functionality to still be implemented. :)

I agree..in my software engineering class, two of us wrote a monopoly program...the graphics were opengl and the backend was c++...i would say we hit @ least 10000 lines...i think we had around 8-12 classes and such...it turned out ok...could have done better, but the two of us were the only ones programming in a 4 person group...a few all-niters...

slooksterPSV
Jun 18, 2005, 01:14 AM
From personal experience, don't get ahead of yourself. Don't even THINK about doing any GUI progamming until you've got the basics down. Write some console programs that are actually useful, then move on to implementing those programs with a GUI.

MP
True, very true. Once you understand the basics, like converting int to char or int to float or vice versa etc. Then you can understand more complex things (for example in Windows case, what an HKEY type is - I think its just int though). Always, when you learn how to, initialize variables, allot memory for them, and clean out what memory is already stored in them. For an example. Write a program that prints out a variable - in C or C++ do this:


//C++
#include <iostream.h>
using namespace std;
int main()
{
int x;
cout << x << endl << &x << endl;
cin.get(); //the &x tells you the address of x
return 0;
}


If anyone wants the source to my emula-menu program, just contact me. If you have a Windoze box and would like to try emula-menu, just download it from here: http://www.geocities.com/slookytek/utilities/emulamenu.zip

http://www.geocities.com/slookytek/emulamenu.JPG

There is a screen shot of it, if that doesn't show up click this link: http://www.geocities.com/slookytek/emulamenu.JPG

xwk88
Jun 18, 2005, 11:22 PM
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:
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:cd ~/Desktop
javac HelloWorld.java
java HelloWorldThe 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.

you don't have to import the String class in java that is already included in the java.lang which will never need to be imported. he's problem was that he typed string instead of String and system instead of System java is case sensitive and won't comile if you don't spell class names right.
;) :cool:

ChrisBrightwell
Jun 20, 2005, 11:03 AM
you don't have to import the String class in java that is already included in the java.lang which will never need to be imported. [...]
No, but explicitly importing it is part of my organization's coding standards. Besides, he asked how to use an import statement. What better way than by example?

I didn't realize java.lang.* was imported by default, though. Is that part of the Java specification or is it a "feature" of Sun's JDKs?