You are hereForums / General Discussion / Charlie's amazing forum of Knowledge! / Guest Speaker Lesson #2 -- Programming and you

Guest Speaker Lesson #2 -- Programming and you


1 reply [Last post]
Griff
User offline. Last seen 16 weeks 6 hours ago. Offline
Joined: 11/07/2005
Points: 1274

Hey all,
After reading the posts in Charlies forum I've decided that the bored kids at school (work.) Need more subjects, snakes and theoretical physics are great, but bored kids (adults) need more variety. As the title sugests I'm going to talk a little about programming, I'm going talk a little about what computer science is and isn't, and then even give you everything you would need to know to write your own program.
The most important thing that I think people looking to have a career in computer science should know is what they are buying with their time and money at college. A programmer is not necessarily a computer scientist. Computer scientists learn how to program, so for the most part computer scientists can be programmers, but the education they receive is almost entirely focused on mathematics and problem solving. If you decide to get a degree in computer science you'll find that you'll really only study programming languages for the first year and after that it is all concepts, probably without any actual code involved what so ever. A lot of people start computer science and get turned away by the late night debugging sessions. You learn programming languages so that you have a practical way to formalize problems that you can use them to study computer science.
A few stores before I move on. After your mandatory "learn current sexy language" courses you'll never be required to use a specific language again. In fact in a lot of cases you will not even need to produce machine readable code, a mathematical proof, or logical list of steps will be sufficient. There are a few different main categories of languages, but once you know one in a category you can typically pick up another in a few hours of study.
Many computer scientists become programmers (someone who earns their living or spends their free time programming), however, a compute science degree also allows you to become a software engineer (someone who designs software), a software manager, or [b]any job that requires problem solving[/b]. Having a computer science degree means that you have learned a little (perhaps a lot) about computers and computer languages, but also that you know how to solve problems and that you know how to compare and evaluate methods.

Now that I've finished the guidance counselor portion of the post I'll move on to why you may have clicked on the link, asserting your will over that pesky silicon monster you're sitting in front of. The traditional way to introduce people to programming is to have them write and compile (convert what you write into something that the computer can read) a program. I'm going to introduce one that is particularly new programmer friendly and does the compiling when you actually run the program.
The first step is to setup your machine to allow you program. In recent years Microsoft has systematically removed this functionality from our computers so if your using windows it can be quite a pain. If your using linux or OS X, congratulations you have already finished this step and can get straight to mind bending part. Microsoft, and other companies that produce software that lets you program your computer like to charge you thousands of dollars for the privilege. We, however, are poor so we are going to use a free solution.
Take a little break and go download the [url=http://www.perl.com/download.csp]perl interpreter[/url].
If your using windows now open up notepad ([url=http://www.textpad.com]or download this great free editor[/url]). Do not use an editor like word or wordpad. Simply type the following into a new file (lets call it myfile.txt):

print "Hello World!";

Then save the file to an easy to remember and type directory directory, like c:\myProg\. Your next step is to enter the command line and go to the directory that you saved the file and type [i]perl myfile.txt[/i]. If it complains that there isn't a command named perl, then you will need to write out the whole location of perl, probably, c:/Program Files/Perl/perl or some such nonsense. If everything goes alright it should print 'Hello World' to the screen.

More than likely even with that one line we have run into a problem. Did you remember the semi colon (;) at the end of the line? Did you close your quotes? Did you misspell print? Perl should attempt to give you message (often cryptic) that is intended to help you identify the problem.

So what have you done? What happened to that compile thing that I mentioned? You did that when you typed [i]perl myfile.txt[/i], perl is what is called an interpreted language, it is compiled in the background.

Some might feel that this program is lame, well, yeah it is, but that isn't the point. You have to start somewhere. You are now able to display text to the user (this is HUGE!), and you were able to create a working program (world altering and stuff!). You also probably learned a little about debugging.

If there is any interest I can continue with more perl lessons. (or c, java, javascript, python, pascal, sql, or pretty much any other language that isn't VB, I don't program for windows and this is a language that only runs there.) The next lesson would be titled "Variables and You" and would include your first example of a useful program.

"This is where apple pie goes when it dies."

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Charlie
Charlie's picture
User offline. Last seen 6 days 10 hours ago. Offline
Joined: 02/02/2005
Points: 3743

Ahhhhh....this just brings back memories of programming in "C" for the various MUDs I used to play....

Oh the nostalgia!

___________________

Official Gamer Hooligan

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.