What Ever Happened To This Idea?


Orion4874

Mega GP Mania
Joined
May 17, 2009
Messages
1,426
Age
50
Location
North Brunswick, New Jersey
There was a suggestion to starting a "how to guide to coding" subforum as discussed in this thread,


I thought that was a great idea and should still be done, anyone else agree? I know that means asking all the experienced devs to contribute and take away more time from them but if it even encourages someone to sart learning then it's definately worth it.


Who knows, if enough info is written maybe an ebook could be published with the proceeds going towards dev funds and manufacturing. Call it, "The Open-Source Lovers Guide To Introductory Programming" or something along those lines, with all credit going to the devs from GP32X/OpenPandora communities. Would also be good publicity IMO.


Anyway, this may be wishful thinking but it's just a thought.
 
I'm all for it (although I can't help with advanced topics). What do you need help with?


Beginner's Guide to Programming [tentative]


0. Preprogramming


Preprogramming is the act of planning an program before you begin coding. A major preprogramming tool is the flowchart. Thinking through a problem before you start can help avoid running into walls. We learned Nassi Shneiderman charts where I went to school. There are also those ANSI flowcharts, but I've only read them in auditing and AIS problems. When we learned charting, we started by charting everyday tasks, like making cookies. I like how this reads, but we learned a simplified set of the structures. If you read it and find it's ok, just go with it. The way we learned it, everything is broken down, piece by piece (aka stepwise refinement) to three basic actions: sequence-do this and move down; decision-perform a check and move accordingly; and loop-perform a check and perform this group of actions until the necessary state is present. Decisions often are "if" statements (basic, usually yes-no) or "switch" statements (the presence of several options). Loops (at least in C++) are broken down into "while"(basic, if a condition exists, you enter the loop and upon reaching the end, go back to check the while condition), "for"(a specific form of "while" where a control variable is used to determine how many times the loop should iterate) and "do"(like a "while" except you check at the end of the loop. I never use it. I convert my "do" loops to "while loops" and I've always gotten away with it. Just sayin').


Besides the three basic actions, it's important to know about subroutines. After all, that sheet of paper you're using is only so long, so it would be nice to be able to break the program into smaller chunks in order to keep it all on one page. If you cook, you might have run across one of those recipes that ask you to pull up another recipe. You might be making homemade macaroni and cheese and the recipe references a recipe for making a white sauce. So, not only are they making the mac & cheese recipe easier to understand (there are less steps you have to read at one time), they are also isolating the steps of the white sauce recipe to allow it to be applied to other recipes (idk, maybe alfredo or something). This is really a horrible example, but that's why I don't get paid to do this stuff. Hopefully you understand it. If not, post/PM.


1. Choose a language


Each programming language is built around certain concepts. This gives them strengths and weaknesses. A quick example: scripting languages vs. system programming languages. Scripting languages are generally higher level than system programming languages. A high level language performs more actions per line of code than a low level language. The advantage of high level is that less lines of code need to be written, which can decrease development time. But an advantage of a lower level language is efficiency. Picking a popular language is a good idea because more people can support/collaborate with you. Read through this thread for help choosing the language. (I should probably read through it myself if I'm recommending it, but it is late, and I am le tired). Anyway, it should at least steer you toward languages that work on the Pandora.


2. Learn the Language


Find resources and tutorials to help you learn the language, but more importantly, the programming concepts. This is because many concepts transfer between languages.


AWESOME C/C++ RESOURCE!!


AWESOME PYTHON/PYGAME RESOURCE!!


Notes:


-It might be a good idea to find a friend to learn along with you. Then, you would have someone going through the same trials you are going through. Bounce ideas off each other, keep each other motivated, and so on.


-Google is your friend. When in doubt, search Google (or any other search engine). I've talked to a lot of beginner programmers who never consider performing a quick web search.


-You're going to do a lot of typing. You don't have to be great at it, but the faster you can type, the less time it will take to code. This is mostly a public service announcement for the "hunt and peck" typers.


This next section will assume an interest in C++

Before I begin, I'll just say that I don't know where you're at as far as skill on computers. I might miss a step, and I cannot immediately correct a mistake if you happen to make one. So, if you're having any trouble with this, please PM me. Also, I realized when I was right about finished, that I totally ignored OS X users. If this affects you, pretend you use Linux, and PM me any problems.


The first step of using C++ is installing the compiler. I use MinGW in Windows, and gcc in Linux.


For Windows:


It might be a good idea to read this introduction to MinGW.


Then, follow the instructions here.


For Linux:


Open up a terminal. If this is your first time doing this, welcome (it's dark in there, isn't it?)


type



Code:
g++ -v
and press Enter. Hopefully, it gives you a block of text describing the compiler version. If it gives you a message along the lines of "not found," you'll have to install the compiler. Consult the documentation for your distribution. Or just perform a search of "[distribution name] gcc". I'm sure it will pop up. Follow the instructions there (it will probably be an installation similar to others on your distribution).



Ok, hopefully that step went ok. That's probably the hardest part of this spoiler section. Let's move on to a quick program.



Let's keep things neat. It's a good idea to make at least one folder for your programs. Call it whatever you want. "Programs" is a nice name. As you make more complicated programs, you should give them dedicated folders. But simple programs can be put in the same directory as long as it isn't too unorganized.



Ok, open up your favorite text editor. If you need one, I would recommend Notepad++ for Windows, geany as a minimal Linux IDE, gedit for Gnome, or kate for KDE. But try them all out. If you're in a hurry, you can even use wordpad or notepad. Just as long as "Office" isn't anywhere in the name. Here's the code:



Code:
#include <iostream>

using namespace std;


int main()

{

   cout << "Hello World" << endl;

   return 0;

}

Save it as "hello.cpp" in your programs folder.



A quick note: C++ generally doesn't care about white space. You don't need to match indentation or anything like that.



First line: #include <iostream>

This pulls in the Input/Output Stream library. This gives the program access to "cout," which will allow us to write to the screen.



Second line: using namespace std;

This line makes the program assume that we are in the namespace "std". Now, we don't have to reference std every time we want to use something within it. Don't worry, we'll get there. Notice the semicolon. Statements use semicolons to end. I think it's hard at first to recognize when to use semicolons and when not to use semicolons.



Third line: int main()

main is the main function of every C/C++ program. This is where the program begins to run. The "int" at the beginning of the line says this function returns a number. We'll see this later. The left curly bracket on the next line tells us the function has begun. The right curly bracket at the end tells us the function has ended. Do not get parentheses and curly brackets confused. You'll get an error, and it will be just about impossible to see (I know someone who did this).



Fifth line: cout << "Hello World" << endl;

This line tells the program to print the string "Hello World" to the screen. Imagine that cout is the screen, then follow the arrows. You can also see that "endl" gets passed to cout. This stands for "endline." It's the equivalent of hitting Enter in a text area.



return 0;

This statement tells the function (main) to finish and passes a 0 up (in this case, to the operating system). This will get explained more when functions are discussed.



Ok, let's compile it. Open the Terminal/Command Prompt (under accessories in the start menu in Windows). Navigate to the necessary directory. To enter a folder, type



Code:
cd [directoryname]



To exit a folder, type



Code:
cd ..





Alright, assuming we're in the right directory, you type



Code:
g++ hello.cpp

Hopefully you don't get any errors. If you do, PM me. If you get an error that g++ cannot be found, and you are sure you installed it, you might have a path problem (this would most likely be a Windows problem). I won't clutter this with the solution if no one has the problem.


Assuming the program compiled, you get to run it. From the same folder, type "./a.out" if you're using Linux or "a.exe" if you're using Windows. "Hello World" should print onto the screen. If it doesn't (and you're using Windows) check the directory for a text file called "std.out". MinGW might be configured to print it there. You can open it in notepad.


Note: at some points in this document, especially around quotes, improper punctuation or capitalization was used to avoid confusion.


This is just a stub, but it can get bigger with questions or suggestions so please post your thought or PM me. Documenting your question could help someone else trying to learn. Even a comment to say it helped would be appreciated.
 
Last edited by a moderator:
if i get time i was going to do a set of videos, walking through the entire porting process for something simple, no idea when i'll get the time though XD


another idea i've had for a while is sit down with a live stream running while doing general dev type stuff (nothing in particular) and field questions from interested peoples
 
One thing I'd want to see is the steps needed to set up a proper dev environment on your comp(toolchain, sdk and whatever else that is needed). I've seen alot of threads were people have trouble just getting past that point. It's pretty discouraging when you read how much of a pain it can be just to get started!
 
I tried to stay away from that because it's language dependent. I could look up some topics, if you'd like. As far as toolchains, they sound like a PITA. It might be easier to set up the build environment on the Pandora and run things through there. It's supposed to be a full Linux machine, after all. It might compile slower, but that won't come into play as much if you do some/most of the testing on a faster computer.


For C++, I prefer a minimal code editor (geany on Linux, Notepad++ on Windows) along with gcc for compiling. Qt Creator seemed to be coming out right as I was making the switch to SDL.


Have you made a decision on a language yet? Also, what OS/distro are you currently using?
 
Last edited by a moderator:
Well, I was thinking Python as it seems to be one of the most newb friendly languages. I mainly use my Windows7 machine but I do have an older computer with Mint installed. I did that basically to mess around with in preparation of recieving my Pandora since I have liitle to no experience with Linux.
 
Last edited by a moderator:
I'm afraid I don't use Python. But I'm under the impression that it's interpreted, which means you shouldn't need to worry about cross-compiling AFAIK. Have you looked at this thread?
 
Last edited by a moderator:
I'm afraid I don't use Python. But I'm under the impression that it's interpreted, which means you shouldn't need to worry about cross-compiling AFAIK. Have you looked at this thread?
Wow, no I missed that thread. There's some great info there, thanks for that! :D


Well, let me ask you this, I want to be able to program my own little games but also what to be able to port games to different consoles. In this regard it doesn't sound like Python would help me much. What's the best material to study for that? I'm going to stick with Python to get the basics down but where would one go from there to learn how to cross-compile in your opinion?
 
Last edited by a moderator:
I don't have any experience with cross-compiling. However, I would think it would also depend on the language as well as the console. To my knowledge, iPhone/iPod apps need to be written in Objective-C using Apple's SDK and then released through their marketplace, or something like that. That's assuming the device isn't jailbroken. If it is, I have no idea. As far as other smartphones, I would look at the vendor's website. Or see if Qt is supported. But as far as developing for the Dreamcast, run a search through google, I guess.


What consoles are you looking at developing software for?
 
I don't have much interest in developing for any smartphones or Apple products. I want to stick with the GPH/Pandora consoles, Dingoo etc. The open consoles these communities revolve around basically.
 
The Pandora is going to be my introduction to console programming, so I really can't help you. I suppose you could check out the developer subforums for each console located on the GP32X forums.
 
Last edited by a moderator:
Back
Top