View Full Version : I'd like to get in to programming...
Fat John
07-25-2005, 06:16 PM
But I'm not sure how. I don't what language to start on, or how to install it (if that's what you do) on to my computer.
Any help would be appreciated.
SippyCup
07-26-2005, 01:32 AM
Starting with C++ isn't really a great idea, but it's your best bet if you don't want to spend a bajillion dollars on Visual Studio to start on Visual Basic. You can write C++ files in notepad, but you need what's called a compiler to create an executable file from your code. You would have to download one of those. Try searching for a C++ compiler on http://www.sourceforge.net. I don't know how difficult it might be to find one that will work in a Windows environment.
As for learning the language itself, there is an endless array of C++ textbooks out there. I used Deitel's Simply Series for VB .NET and I really liked them. I bought their C++ book for reference.
http://www.deitel.com/books/index.html
It comes with some stuff. I forgot what, but the site tells. They have a bunch of other C++ books too, you might want to check those out to see which one is best.
This stuff will start you out doing text-based programming.. basically learning about the language and crunching numbers. I've been programming with C++ for about a year and I've only done one graphical program (which was a numeric conversion program, and it wasn't easy).
By the way, I'm not sure if there's a standard, but I know C++ source files can be saved as *.C or *.cpp, but the books will probably tell you that.
SippyCup
07-26-2005, 01:38 AM
Actually, I did do a Tic Tac Toe game in Visual C++.. but that's part of Visual Studio, so it doesn't count.
AlienAssKicker
07-26-2005, 03:48 AM
Don't. Run away while you still can and pursue something more interesting!
http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif
Fat John
07-26-2005, 07:07 AM
SippyCup said:
Starting with C++ isn't really a great idea, but it's your best bet if you don't want to spend a bajillion dollars on Visual Studio to start on Visual Basic. You can write C++ files in notepad, but you need what's called a compiler to create an executable file from your code. You would have to download one of those. Try searching for a C++ compiler on http://www.sourceforge.net. I don't know how difficult it might be to find one that will work in a Windows environment.
As for learning the language itself, there is an endless array of C++ textbooks out there. I used Deitel's Simply Series for VB .NET and I really liked them. I bought their C++ book for reference.
http://www.deitel.com/books/index.html
It comes with some stuff. I forgot what, but the site tells. They have a bunch of other C++ books too, you might want to check those out to see which one is best.
This stuff will start you out doing text-based programming.. basically learning about the language and crunching numbers. I've been programming with C++ for about a year and I've only done one graphical program (which was a numeric conversion program, and it wasn't easy).
By the way, I'm not sure if there's a standard, but I know C++ source files can be saved as *.C or *.cpp, but the books will probably tell you that.
Thanks Sippy Cup. Buying online isn't really an option for me, so the closest thing to a free compiler I could find is this (http://sourceforge.net/projects/dev-cpp/), is it what I'm looking for?
EDIT - I really don't know what I'm looking for, there's some choice in compilers and I'm in over my head http://forums.3drealms.com/ubbthreads/images/graemlins/frown.gif. I've found a list here (http://www.thefreecountry.com/compilers/cpp.shtml), but I don't know which to get...
Dave-ros
07-26-2005, 09:00 AM
Getting into programming in this day and age can be much harder than it was back in my day. I could write BASIC programs on the Vic 20 and Amstrad CPC no problem - the worst you'd get would be a "Syntax error", not the entire thing refusing to run! Back then programming came built-in with the computer, complete with instructions, rather than being something you had to pay extra for...
</old codger>
So if you can get into C++ from a standing start, you're doing incredibly well http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif Maybe start with regular C and work your way up? C++ does some things much better - it's object-oriented, which means you can create for example an alien "object" that contains all that alien's coordinates, ammo count and routines to move and fire, instead of all these things being separate. But, best to start with C, then learn C++ to write your first best-selling game http://forums.3drealms.com/ubbthreads/images/graemlins/wink.gif
I'd go for the MinGW package, which comes with the GNU compiler. I used something like it before a friend illegally copied Visual Studio for me (don't tell MS!), and although it's DOS-based, it works!
Fat John
07-26-2005, 09:05 AM
Thanks Dave-Ros, downloading now.
Dave-ros
07-26-2005, 09:13 AM
No problem http://forums.3drealms.com/ubbthreads/images/graemlins/wink.gif When you're good enough with the basics to start writing games, I highly recommend the Allegro games programming library:
http://www.allegro.cc/
They have everything you need for graphics and sound etc, as well as a forum for all your questions. I myself used the package to write a bat'n'ball game called Duke Nukem: Balls of Fire http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif (Can't release it as it uses sound effects from Duke 3D!)
Anyway, best of luck!
MentalSentinel
07-26-2005, 09:18 AM
But, best to start with C, then learn C++ to write your first best-selling game
I've been told (by books, they speak to me!) that it's best not to learn C first if you want to become skilled easily in C++.. So I'd do that.
Fat John
07-26-2005, 09:55 AM
Having trouble getting the right files. I'm meant to "Download MinGW-NNN.exe, MSYS-NNN.exe, msysDTK-NNN.exe.". What does NNN mean?
And what's a library? http://forums.3drealms.com/ubbthreads/images/graemlins/redface.gif
Dave-ros
07-26-2005, 10:15 AM
Fat John said:
Having trouble getting the right files. I'm meant to "Download MinGW-NNN.exe, MSYS-NNN.exe, msysDTK-NNN.exe.". What does NNN mean?
And what's a library? http://forums.3drealms.com/ubbthreads/images/graemlins/redface.gif
Damn, I've had a look at the MinGW page, and I didn't know there were so many files! http://forums.3drealms.com/ubbthreads/images/graemlins/eek.gif I think NNN just refers to the most recent version number (so grab MinGW-4.1.1.exe). A library is just a collection of various files for various purposes, where the compiler can pluck out whatever it needs to compile your program once it's written.
Fat John
07-26-2005, 11:26 AM
Nearly there... I have all the stuff downloaded and installed. The problem is that the website isn't clear on how to actually compile a program:
The following is a code sample for a simple C++ program. Cut and paste it into a file named hello.cpp to try it out.
#include <iostream>
int main(int argc, char **argv)
{
std::cout << "Hello" << std::endl;
return (0);
}
What kind of file is it on about? I used notepad and saved it as hello.cpp, but it does naught http://forums.3drealms.com/ubbthreads/images/graemlins/frown.gif.
It then goes on to say -
For the C++ program, use the following to compile and link:
g++ -c hello.cpp
g++ -o hello hello.o
Which makes no sense to me.
Dave-ros
07-26-2005, 11:37 AM
Did you download and install MSYS? If so, run that and type it there (include the path to hello.cpp, e.g. c:\foobar\hello.cpp). That should work...
This is new to me as well, as I've been using Visual C++ to do this kind of thing, and it works right out the box. Tricky... well, keep trying! Will have a go at this myself and report how it goes.
edit: Okay, if you do the "all in one" step (g++ -o prog file.c) to create prog.exe from file.c, prog.exe will be created in C:\msys\1.0\home\(Your username)\, which is where you can activate it from. That's annoying... will look into a way to make it go somewhere more useful (and also search for file.c in a default location).
Maybe copy your compiled program to the root c: directory so it's easy to find, and then activate it through Command Prompt (type c:\hello.exe), as if you just double-click on the icon it'll appear as a DOS window very quickly and you won't even see it! Experiment with putting messages other than "hello" in there... it's great when you're a new programmer to see something appear on screen like this just because you told it to, a real sense of achievement!
edit 2: If you want a program that stays on screen, try compiling this one...
#include "stdio.h"
main()
{
while (1)
{
printf("Elvis is alive! ");
}
}
DudeMiester
07-26-2005, 02:01 PM
If you are at a college or university you can usually get a free copy of Visual Studio 2003 Acedmic Edition. For the longest time I just used a warez version, but now I have a legal copy and it was absolutly free! But yeah I would get VS 2003 or 2005 if it's out yet if you can, it's well worth it imho. Oh and you don't have to get the whole studio, you can just get the C++ version.
Oh and if you just want the VC++ 2003 optimising compiler, without the IDE (that means command line only) you can get it free from here:
http://msdn.microsoft.com/visualc/vctoolkit2003/
Fat John
07-26-2005, 02:36 PM
Since my previous post I have researched compilers a bit more I stumbled on to a free program called Dev-C++ by Bloodshed Software, and it's great for someone of my skill at programming. Thanks go to anyone who hasn't had any yet, and behold my creation in action...
dark_angel
07-27-2005, 12:22 AM
Fat John said:
But I'm not sure how. I don't what language to start on, or how to install it (if that's what you do) on to my computer.
Any help would be appreciated.
First of all you should ask yourself if you want to be a Web programmer or a GUI/windows programmer or a Game programmer than after you choose your destiny you can pick up the right tools and begin programming with the appropriate language.
but C# would be a good start.
DudeMiester
07-27-2005, 01:54 AM
Oh this is cool
http://www.codeblocks.org/
A free open source IDE compatible with the GCC (MingW/Linux GCC), MSVC++, Digital Mars, Borland C++ 5.5 and Open Watcom compilers. The IDE itself very modular and plugin oriented, not unlike FireFox. And with more work and plugins, it could supercede MSVC and Dev-CPP in terms of quality! Coupled with the free MSVC++ 2003 compiler I linked, you've got a damn good development platform, absolutly free!
Oh and if you want some seriously hardcore C++ to look at and study, I can send you my partitonable multi-threaded customisable garbage collector and smart pointer system. It's very efficient too, scanning about 750,000 allocated objects per second, potentially more if you customise the collector to the allocation patterns and data structures it's scanning. Oh and it has zero overhead if you're not using it, because it's not a global system, but local. So you have like a sub-main function, and it's only active and using memory during that function. It can also track any data, not just the classes designed for it. The advantage of designing your class for it, is that you can access extra information like the current collector/network it's assigned to or the current process/thread running the code, and you can take advatage of the smart pointers and memory management. The downside is of course, you can't use a class that's designed to work with the system outside of it.
lol, sorry for the rant, but it's taken a year to get to this point where everything works as it should with the most intuitive interface you could wish for.
Dave-ros
07-27-2005, 06:50 AM
DudeMiester, u r teh r0x0r!!!!!!1 http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif
This is just as good a program as Visual C++, but free (and legal)! I was going to suggest Fat John use my old friend DJGPP, with its DOS-based front-end RHide, as something which will show you where your errors are while compiling (MSYS isn't much good for that), but this is excellent!!!
Or it would be if I could figure out why it says "Command execution failed" and no other errors whenever I try to compile a simple program. It auto-detected MinGW no problem... any suggestions? http://forums.3drealms.com/ubbthreads/images/graemlins/confused.gif (Preparing to kick self if it's something ridiculously obvious)
edit: Seems to work better if I start a project first, but that seems extreme for a simple file to print "Elvis is alive!"... must be a path error, i.e. it's not looking in the right places for files...
Fat John
07-27-2005, 07:23 AM
DudeMiester said:
Oh and if you want some seriously hardcore C++ to look at and study, I can send you my partitonable multi-threaded customisable garbage collector and smart pointer system. It's very efficient too, scanning about 750,000 allocated objects per second, potentially more if you customise the collector to the allocation patterns and data structures it's scanning. Oh and it has zero overhead if you're not using it, because it's not a global system, but local. So you have like a sub-main function, and it's only active and using memory during that function. It can also track any data, not just the classes designed for it. The advantage of designing your class for it, is that you can access extra information like the current collector/network it's assigned to or the current process/thread running the code, and you can take advatage of the smart pointers and memory management. The downside is of course, you can't use a class that's designed to work with the system outside of it.
This paragraph makes me cry http://forums.3drealms.com/ubbthreads/images/graemlins/frown.gif
DudeMiester
07-27-2005, 02:42 PM
Well if after you learn the language, you will see how amazing it is, imho.
Destroyer
07-27-2005, 09:40 PM
learn C first.
MentalSentinel
07-28-2005, 07:23 AM
There's no reason to learn C first if you're going to learn C++. If you learn C first, you'll learn a lot of totally unnecessary stuff that can be done in C++ way easier.
Fat John
07-28-2005, 10:50 AM
C++ isn't as hard as I thought it would be learn, most problems come from having to put semi colons in certain places but not others (http://forums.3drealms.com/ubbthreads/images/graemlins/confused.gif), and the way the syntax is similar for a variety of different things (like creating functions and variables).
Dave-ros
07-28-2005, 11:03 AM
Fat John said:
C++ isn't as hard as I thought it would be learn, most problems come from having to put semi colons in certain places but not others (http://forums.3drealms.com/ubbthreads/images/graemlins/confused.gif), and the way the syntax is similar for a variety of different things (like creating functions and variables).
Yes, that is rather strange - you put a semi-colon after the closing brace following a class definition but not otherwise!
Also, I just found out today what causes that weird "undefined reference to WinMain@16" (WinMain@16) (don't click on that, it's not an e-mail address!) error when compiling programs. Dev-C++'s help file (currently incomplete if you're using v4.9.9.2) says it's "probably" because you don't have a main() or WinMain(), but I got it even when I definitely did! The way around it seemed to be:
void main()
{
// Your main procedure goes here!
}
END_OF_MAIN();
Just in case anyone else has been flummoxed by that - took ages to research it, it seems to happen for different reasons!
Fat John
07-28-2005, 01:03 PM
Dave-ros said:
Yes, that is rather strange - you put a semi-colon after the closing brace following a class definition but not otherwise!
What's a class definition?
Dave-ros
07-28-2005, 02:41 PM
Ooh, you'll find out! Sorry, I thought you'd gotten that far in learning it. It's a bit too involved to explain here, but basically a class (which is defined in a class definition http://forums.3drealms.com/ubbthreads/images/graemlins/wink.gif) is how you create objects, which are the basis of C++ (object-oriented language).
To explain an object, imagine you're creating a Space Invaders clone. Now each alien would be an object - self-contained, with its own X and Y coordinates, and routines to move, fire, check if it's been shot and display itself on the screen. In the main part of the program you'd just tell each alien object "oi, do your moving routine!" and let it take care of itself, rather than having to have the code for moving aliens in the main program.
Anyway, all these routines and variables are set up in the class definition, and then in the main body of the program you create individual alien objects from the class, tell 'em to move and fire, and then when they're shot by the player they get deleted. The main program doesn't even need to know what the data is in each object, they take care of themselves!
You'd have different classes for the aliens, the player's spaceship and the missiles fired by both. Even more advanced, you can have subclasses - a main alien class, and then maybe three subclasses for each type of alien, which all have the functionality of the alien class, but additional data/routines of their own...
Anyway, hope that wasn't overwhelming - you'll learn more in-depth stuff as you progress... work hard!
Tedades
07-28-2005, 03:08 PM
Programming is more then C++/VB/Java/Pascal, its more abstract.
If you know how to solve a problem in a programmers way, the only thing you have to learn it how to write it in a language.
Like learning japanese when you dont even have a native language.
But you do learn a language when you'r doing tutorials and all, so you'll be fine in the end. But sometimes a language restricts you from doing something what you want, and you wouldnt know untill you used a other language.
Fat John
07-28-2005, 03:15 PM
^That made sense Dave-Ros. The tutorial I'm on at the moment deals with pointers, and I made a program that creates customizeable blocks of numbers. Pointless, but good practice with loops...
#include <iostream>
using namespace std;
int main()
{
// variables:
int max_right;
int max_down;
int right_remaining;
int down_remaining;
int content;
int repeat = 0;
//loop here is for user to repeat this program
while (repeat == 0) {
// user input:
cout << "input max right\n";
cin >> max_right;
cin.ignore();
cout << "input max down\n";
cin >> max_down;
cin.ignore();
cout << "input content";
cin >> content;
cin.ignore();
// initialization:
right_remaining = max_right;
down_remaining = max_down;
// block generator
while (down_remaining > 0) {
while (right_remaining > 0) {
cout << content;
right_remaining = right_remaining - 1;
}
cout << "\n";
down_remaining = down_remaining - 1; right_remaining = max_right;}
cout << "To leave this program input 1, otherwise press enter";
cin >> repeat;
cin.ignore();}
}
Fat John
07-28-2005, 03:17 PM
Tedades said:
Programming is more then C++/VB/Java/Pascal, its more abstract.
If you know how to solve a problem in a programmers way, the only thing you have to learn it how to write it in a language.
I know that. I reckon my mind will let me be an adequete programmer, but I'm just doing this for fun.
Dave-ros
07-28-2005, 04:10 PM
Fat John said:
^That made sense Dave-Ros. The tutorial I'm on at the moment deals with pointers, and I made a program that creates customizeable blocks of numbers. Pointless, but good practice with loops...
I ran that myself, and I see what it's doing - you're learning well... don't see what it's got to do with pointers, or did you mean this was what you'd done before?
Anyway, a couple of minor improvements: firstly, instead of "x = x - 1", you can write "x--" (and similarly "x++" for adding 1); for bigger numbers, you can say e.g. "x+=2" to add 2. That's a nice space-saving trick in C++ (I think it's in C as well).
Secondly, you should perhaps write "while (repeat != 1)", since the condition to end the program is for the user to enter 1. Using my way, the loop will continue until repeat is 1, and entering something else will make it restart. Pressing Enter without entering anything doesn't seem to work, which is odd... must be a limitation of the language, rather than your programming skill!
Lastly, I'd tidy up the curly brackets and indentations, just for clarity - keep the opening and closing brackets of a while loop (or whatever) in line, and everything between them indented with Tab. Trust me, it makes it a lot easier to see when you've lost one somewhere, which will happen frequently! I know Dev-C++ likes to think it knows how many tabs you want to put in, but it's not perfect http://forums.3drealms.com/ubbthreads/images/graemlins/wink.gif
Oh, and it's "Dave-ros", with a lower-case "r" - it's a cross between "Dave" and "Davros" (the guy in my avatar) http://forums.3drealms.com/ubbthreads/images/graemlins/hhg.gif
Fat John
07-28-2005, 05:11 PM
Again, thanks.
DudeMiester
07-29-2005, 04:30 AM
I strongly recommend putting all '}' on a new line by themselves for clarity. Personally, I do the same for '{' too. Also, use proper indentation. You should be able to read code without considering the braces imho.
Also ';' is only used after declarations, definitions and individual commands, but not after code blocks (functions, if blocks, loop blocks, etc) and namespaces. You also don't need them if the "if", "for", etc code block/body only has one instruction, but you always have to use them when defining functions.
I'm not sure why you keep using "cin.ignore()", it's unneeded.
Lastly, as excellent C/C++ reference: http://msdn.microsoft.com/library/en-us/vclang/html/_vclang_home.asp
Fat John
07-29-2005, 08:14 AM
DudeMiester said:
I'm not sure why you keep using "cin.ignore()", it's unneeded.
The tutorials I'm using says that the enter key is also considered input, so ignore stops that input from causing problems.
DudeMiester
07-29-2005, 03:31 PM
lol, that would explain some things in my code! But I believe on the next call for input, it would skip the inital "enters" until it gets to data. But then it will leave an enter behind, so if you use cin.get(), like for a "Press The Any Key", it will read the left "enters" and not wait. That problem has plagued me for a while now, lol.
Rider
08-15-2005, 05:34 AM
I'd like to thank everyone in this thread.
I just wrote and compiled my very first C++ program ever thanks to the information contained herein. Methinks this thread should/could be stickied.
oh, and I found some understandable C++ tutorials HERE! (http://www.cprogramming.com/tutorial.html#c++tutorial)
you guys rule!
Fat John
08-15-2005, 10:50 AM
They're the tutorials that I'm using. You might want to register on Cprogramming's forums too.
I haven't gone through any more tutorials lately though, I kinda forgot http://forums.3drealms.com/ubbthreads/images/graemlins/redface.gif.
Dave-ros
08-15-2005, 11:55 AM
Rider said:
you guys rule!
<ISAAC HAYES>
You're daaaaaaaaaamn right.
</ISAAC HAYES>
Glad to be of service! http://forums.3drealms.com/ubbthreads/images/graemlins/grin.gif
Drazula
08-17-2005, 04:03 PM
Tedades said:
Programming is more then C++/VB/Java/Pascal, its more abstract.
If you know how to solve a problem in a programmers way, the only thing you have to learn it how to write it in a language.
Like learning japanese when you dont even have a native language.
Very well said. You cannot believe how many programming professionals, think that because they know a programming language, they are programmers/designers/architects. GADS!
Learn the principles (what is a compiler, what is the relationship between the code you write and the code that the CPU executes, etc.) and you will do great.
8IronBob
08-17-2005, 04:52 PM
Also choosing the right type of compiler and linker, etc... That's another thing to consider. You can't be too careful about which compiler will work best for your code. Even tho one may do rather well, then if you enter that same code and compile it with a different compiler, you'll get a ton of errors, so no two compilers have the same tastes for the C++ language (like Borland C++ vs. Visual C++, that sort of thing).
Destroyer
08-18-2005, 12:33 AM
Drazula said:
Tedades said:
Programming is more then C++/VB/Java/Pascal, its more abstract.
If you know how to solve a problem in a programmers way, the only thing you have to learn it how to write it in a language.
Like learning japanese when you dont even have a native language.
Very well said. You cannot believe how many programming professionals, think that because they know a programming language, they are programmers/designers/architects. GADS!
Learn the principles (what is a compiler, what is the relationship between the code you write and the code that the CPU executes, etc.) and you will do great.
totally agreed. you need to learn algorithm design and analysis, then programming is easy.
Tedades
08-18-2005, 05:50 AM
totally agreed. you need to learn algorithm design and analysis, then programming is easy.
I think its even more abstract, I'll give a example:
------------------------------
Problem:
You want to see if 2 numbers are the same.
Solution:
Compare them, and see if they are the same.
Implementation:
We don't how to do that yet, lets download a tutorial that will show me how its done.
------------------------------
Algorithm design is the next step, you'll have a actual abstract solution to the problem.
Like:
if the_first_number isn't the same as the_second_number then output NO.
if the_first_number is the same as the_second_number then output YES.
(//A regular programmer would use IF/ELSE, but this could be written by a non-programmer)
How you would translate that to a programming language is also a programmers problem, but that doesn't require actually thinking (just learning).
If you know the grammar you should only know the words to write it down, those can be found in a dictionary (works faster if you knew them already).
DrFunkenstien
08-22-2005, 07:48 PM
Hey,
just a word to fat john, ...
The folks here are right, C/C++ is a good language to learn.
But if you want to do graphics & windows forms you might want to try something a little easier to get you started.
In that case, Java is an *excellent* way to go. Java was the only way I would have every understood C++. Think of a much simpler, more cut down version of C++ that requires a little less code to get things done.
You can download the NetBeans Java IDE for free: http://www.netbeans.org/index.html
(But first download the J2 Platform: http://java.sun.com/j2se/1.5.0/download.jsp)
By the way -- Microshit has finally released VB for free -- at least in Beta. Go here: http://lab.msdn.microsoft.com/express/vbasic/default.aspx
vBulletin® v3.8.0 Release Candidate 1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.