Making beginner-level programming exercises more interesting and more motivating
I've learned a little C++ (very little), am starting to get familiar with the command line, but am getting tired of writing programs that are like math problems. What I'd really like is to have a look at some code and try to edit it and learn at the same time. Here's my question...
I've got several Linux boxes. Let's say I wanted to have a look at the source code of a very simple program, say, kwordquiz, which is a very simple flashcard program, part of the KDE edutainment or educational programs. I like kwordquiz, however, there are a few things that I'd like to change, for example, the default height of the lines of the editor, etc. Where, on a Linux system, is its source code? I'm on Fedora and Mandriva mainly, more on Mandriva. I can't find an /src directory. Where, for example, would the kwordquiz source code be? ... or the source code of any another program for that matter? While I'm on the subject, does anybody know of a more interesting, more motivating way of learning programming skills (in general)? Bash scripts are interesting. It'd be cool to play around with them to customize the appearance and behaviour of my computer. I'm tired of programs which just launch a terminal and calculate the sum of numbers. How about something with colours and an interface or simple games? ... absolutely anything that makes it all interesting and motivating. I don't even care what programming language it is, however, knowing that I've gained some familiarity with C++ and bash, perhaps that might be a good place to start. Can anyone send me a few links? Many thanks. |
According to your profile, you've used Slackware. The source for everything built into a Slackware release is on their release CD's.
Maybe other distributions work the same way. |
In Debian based systems, there's a great way of getting the source code:
Code:
apt-get source <package> Just try to create some simple games. Otherwise it depends on you. Just try to program what you want to program (starting with not too complex projects of course) and learn along the way. |
Quote:
Quote:
|
Well if it's just that you want to learn programming, but don't care about which language it is (which means you have no idea what you're eventually going to program, at all), it probably isn't motivating. First you should come up with an idea (what to do, what to make better?), then sketch it to get the bones, then think about it more precisely and when you have an image of the complete thing, start writing it into the form of a program (oh, and after you know what you're doing you may think what's the best tool to make it).
Programming is basically more or less mathematics, with or without numbers. Computers work with numbers, after all, not colours nor interfaces. Interface programming (unless you use IDE, and maybe even then) can be tricky if you start off there, wanting to program Doom again. First it would be good to know some mathematics, how to deal with things - and how to represent them. Reading ready source code which is often sanitized, thick, sparsely commented, not meant for learning can be exhaustive for a beginner. It was for me, at least. Maybe you should start off with something easier than a ready KDE graphical app? As boring as it sounds, the easiest programs that teach you the beginning are "merely" command-line math apps. Knowing how lists work, how to deal with numbers and variables is the stone you build the rest on. I agree that games are a good way to learn programming. But don't jump to 3d games right away, start off with something extremely easy - like a number game for example. Then gradually try to do more complex things. Eventually you'll notice you've done quite a lot of "math" :) |
If you want to stick w/ C++ I would try following some 2D SDL tutorials. While SDL is very powerful, it is fairly easy to graps the basics if you are a beginner. You should be able to create some fairly useful little games in not too much time.
If you wanted to learn some OpenGL, you can try to follow the NeHe tutorials: http://nehe.gamedev.net/ When I first started programming, much of that stuff was over my head, but it was good to basically copy paste, then try to modify. |
Wow! Lots of response to my questions... Many thanks to everybody...
I think I led some of you on the wrong track... I realize that programming is lines of code, maths, etc., and I do like that! Really!! It's the end product that I'd like to be graphical or at least a little more interesting. Very basic question: How do I get something that has a more attractive presentation than a terminal emulator to open up when I launch a program? Okay, I could create number games, but how, for example, might I get a wrong answer to be in blinking bold red characters and a sound to come on when the user enters the right answer? How might I create moving objects that can be manipulated with the arrow keys or the mouse? I have learned some of the basics of programing (variables, etc.), and perhaps all of this is a little above me (or perhaps it isn't!)... How can I start doing something of this sort... What I really need is some good links, some good sites that fill the gap between the beginner programmer and someone who can actually write real programs. Maybe there aren't very many out there. There are tons of sites for beginners, but I haven't been able to find sites corresponding to what I'm looking for... Another idea: perhaps a list of programs (or mini-programs) whose source code are pretty basic and brief that I could toy with. The thing is, I have no idea what programs have code that is relatively easy to grasp (if any). [KIA]aze, Thanks for the tip about apt-get. Does anybody know how to do the same thing from other distros (yum, urpmi, etc.)? wjevans_7d1@yahoo.com, Thanks for the tip about the Slackware DVD. I had a look at the kwordquiz source code files. Cool! There are lots of them and I don't know how they work together to create a basic program... (Yet another question)... But it's motivating to know that I can check it all out and try to understand something! I couldn't find the Mandriva src directory, perhaps it isn't on their DVD. |
I think the best way to learn is to try to figure out how to do things yourself and when you get stuck look it up on the internet or ask questions here or comp.lang.c++.moderated. Slackware is great for programming because of Qt Designer/documentation, GTK documentation, and info:libc. If you are interested in a program, looking at the source is a great way to learn how others do things. I've spent a lot of time browsing kernel sources, program sources, and the STL headers. The reason I've been programming for 16 years and have only had one formal course is because tutorials and classes tend to make things entirely too complicated and they end up holding you back; they tend to cater to the least intelligent (in that area, that is) portion of their audience with little regard for those who want to burn straight through and get to the good stuff.
I say learn enough to be dangerous from tutorials, then experiment for several decades. You will figure out what you need to learn along the way if you stay interested in it that long. ta0kira |
Programs that are not too complicated?
Well, I think the the small games that come by default in Debian and Ubuntu are a good start. Simple interfaces like GDebi might also be good. I only discovered the apt-get source trick recently. But now at least I don't have to search for the tar.gz everytime. :) I learned a lot from the "tuxtype" code (especially a nice trick for debugging) and this weekend I started modifying the source code of metal blob solid to move Bob around freely to find out where to go (ice levels are frustrating). I got the supertux code for the same reason but haven't done anything with it yet (there's a level editor for it that might also do, but where's the fun in that? ^^). Oh, and if someone knows simple programs implementing MySQL, SQLlite or Boost.regex, I'm interested. :) And you wanted links? Here: What to start with if you want to make games http://www.gamedev.net/ http://www.anjuta.org/documents/C/anjuta-tutorial/ I don't know what exactly you're looking for, so this is a quick mix of links I remembered. ^^ Things to google for: *for games: SDL OpenGL PyGame *for GUIs GTK+ Qt WXwidgets |
Thanks [KIA]aze !
Yeah, I've had a look at the source code for kwordquiz and, of course, there are lots of source files. I now realize that I have to go on a little further in my basic programming exercises to better understand how these files work together and to learn more about libraries. I'll be patient with the mathematical type programming exercises for a few more weeks and check out what you've sent me at the same time... I do have a more general question, actually, a few questions. Now, I don't know if these questions are easy to answer or if all I need to do is continue studying on a daily basis to eventually learn how to do this, but if I could to some of this fairly soon, it would certainly motivate me. Here are my questions: - How does one know what is where in a source code directory (there are so many source code files and other files in there!); e.g., the kwordquiz source code directory or any other similar directory. Is there a site that explains the conventions used to quickly understand the mapping out of these files? How about the extensions? .cpp is C++, etc. but how about the rest? - This might be really easy or quite difficult, I have no idea. Let's say I wanted to do a simple hello world program in C++, but I wanted to make my own interface and include a background image. Is this easy to do? ... or do I just need to be patient... and I'll get to it eventually in lesson 28 of my C++ tutorial (lol)...? - Lastly, little extras like the previous question might motivate me, that is, using what I already know and adding a few elements to make the final product a little more appealing, a little more pleasant to look at and to use... (Again, I don't know if this is possible...) Thanks again for your last reply. I'll go over the links you sent me more carefully when I get back, I've got a few errands to run... Many thanks. |
Quote:
.c,.C= C source file .cpp,.CPP=C++ source file .h=C or C++ header .hpp=C++ header (generally for classes, is paired with a .cpp with the same basename) .cxx,.hxx=I think I saw them once, probably also C++ source/header files *How to find out where what is: If it's well documented and the folder/file names are obvious, no problem. If it isn't well documented by the creators, use grep. :) Code:
grep [-r] <pattern> <file> I recommend Kate as an editor. It has an inbuilt terminal and "find in files" function (GUI frontend to grep). :) Other well-known editors are Vim and Emacs/Xemacs, but they take more time to master. You can of course also use an IDE (see below). Quote:
The only possibility I see of creating colored/blinking text in a console would be to use escape sequences. It is easy to do in shellscripts and would therefore be possible by using system calls in a C/C++ program. I think it's also possible with printf(), but I have never tried it. (will have to do that...) To create an interface, the easiest way is to learn a GUI toolkit like Qt, GTK+ or WXwidgets. If you want to draw the interface yourself, use a graphic library like SDL. Google for a tutorial on those libraries/toolkits and learn. Quote:
Here are some things that might help you: GUI builders: http://www.linuxquestions.org/questi...d.php?t=557967 Formatting (make code look good): Try astyle. :) Help on compiling and small list of IDEs I just copy/pasted from one of my posts on the Ubuntu forums: Quote:
|
Thanks [KIA]aze !
Thanks for all of the advice, your suggestions, tips and links. I think I've got enough information now... which will keep me busy for at least a few weeks. Thanks so much. P.S. - And thanks to everyone for their general advice and comments too ! |
Quote:
|
Here's a couple of slightly lateral suggestions.
1. try and find something you want doing for yourself eg a game or Cd management system. 2. Try and solve real probs on sites like this that other people have posted. There's a lot of prog help wanted sites like this, and even if you don't come up with a complete soln, you'll learn a lot by trying and by reading other peoples solutions/tips. These pretty much apply to any IT skill. |
Printing colored text on a colored background with a special style with just printf?
Found it: http://linuxgazette.net/issue65/padala.html This should be easier than learning how to use other libraries first. Now I learned something new too along the way. :) |
All times are GMT -5. The time now is 10:52 AM. |