tags:

views:

1566

answers:

37

I would like to know how you learned to program in order to teach future programmers.

Could recommend some books to teach programming,or some helpful tips?

Edit :

How to motivate students to continue learning?

+12  A: 

Practice it. I think that's the single most important thing to do in order to learn development. Was it Aristotle that said "We learn by doing" ?

And, if I may add a second recommendation, get used to change. Learn something (e.g. a programming language), and then introduce change (e.g.: learn a different programming language). This works on many levels. For instance, when you're reading a programming book, and you do its exercises, always try and do the exercise in more than one way.. or, when you learn new topics from later chapters, try and go back to earlier chapters and see if the new concepts could be applied to earlier exercises. Dealing with changes (in the technology, in the requirements, etc) is a major part of the software development experience.

FOR
"For the things we have to learn before we can do them, we learn by doing them." - Aristotle
Simucal
+10  A: 

Programming is best learned by doing, instead of by reading about it. Whatever book you choose, type in all of the example code and do all of the exercises. This will get you used to thinking in the programming language, and (more importantly) it will get you used to the error messages and debugging system in your compiler/IDE. You will make mistakes when you start writing real code, and it's much easier to get used to debugging when you have someone else's example in front of you.

Having said that, I recommend the following books for different languages. They're all good introductions to their respective languages, and to programming in general.

Head First Java

Head First Javascript

C++ Primer

Learning Perl

Bill the Lizard
+3  A: 

By not admitting I have learned it yet.

Serhat Özgel
+1  A: 

I did a mixture of first learning by doing (typing off scripts from a computer magazine), and later learning the basics (by reading and counseling students in their first programming course). So I recommend a two way approach:

  • Learn programming by programming
  • Learn programming by teaching how to program

(Not necessarily in that order). Especially the teaching had me question my knowledge and beliefs about programming. I was confronted with others who did not understand my argumentation, or did not agree with it. Humbling, but effective ;-)

Edit:

If you hand out programming tasks, make them interesting - something they may use in real life. The typical calculator programs let you cover all the operators, but having them program something they can use in outside your course (maybe something they are currently covering in math, e.g. linear regression, or a simple game they can show to their friends) will definitely be much more interesting.

Treb
+5  A: 

I learned initially on a Commodore 64 along with some Logo, where I could control a turtle as I was told. This was cool back in the '80s possibly but I think today it could be easily on things like Leapfrog or a game console in a way. There were some geometry puzzles that I enjoyed like how to get the turtle to draw a particular shape or design. As for the commodore 64, this included some basic use of print, but also programming up a multiple choice test without using a loop and having it be rather boring but I liked being able to write up a test.

If we are talking about children, then if they like games see if they can figure out a pattern of how a computer opponent plays or if they can write out instructions on how they play for someone to follow. Seeing a program in action was always the big cool point for me. "It's ALIVE!!!" would be the thought in my head and a sense of accomplishment on getting something right.

JB King
Answers like these are worth reading. Thanks JB King
Agusti-N
A: 

When i was 13 and had never seen a computer, i was invited over to a friend who had an Atari 600. That was one of the early 80s home computers with built in BASIC.

He said, "hey, let's program a game" and made me enter a whole page of nonsensical gibberish. That of course didn't accomplish anything other than my "friend" having fun at my expense.

Three months later i got a C64 and learned to program.

So, i say anger and defiance are the best motivators :P

Stroboskop
A: 

I had to do it. It was kind of the way kids play games, I programmed. Learned Basic from my first TRS-80 book, assembly from a z-80 book I bought, just a standard CPU reference book with pinouts, timing waveforms and all.

Virtually all really good programmers I've known had that drive at one point in their life. You couldn't keep them away from the computer, and they hardly needed anything--any book would do, any little project they could come up with would get finished.

If you are teaching someone like that, just shut the hell up and get out of their way. If they ask for a reference, get it for them (but they shouldn't need any with the internet at their fingertips.

If you are trying to teach someone who isn't like that, I'm not sure how to do so except find a project that they really want to do and help them do it. Maybe a website to track baseball stats if they are into baseball, or a simple game if that's what they are into.

Also, starting a task for someone else (a "job") from scratch is a really daunting task when you are starting out (remember?) Perhaps starting with some simple open source project and modifying it would be good.

Bill K
I agree completely that some people need to be left alone when they are learning how to program (I am one of them).
John Chuckran
+5  A: 

I sat down in front my my 2nd hand 286 when I was 12 with a copy of a C compiler and a couple of C programming books my grandfather let me borrow. Throw in about 6 years of late nights trying to understand other people's code, some CompuServe forums, countless Internet searches, and a handful of other languages.

So, in a nutshell, I taught myself by learning from other's work and reading megabytes of source code. I don't do well being taught- I have to learn it myself by failing. And I've failed.. A LOT.

jcoby
we never fail we simply find tons of ways of how not to do something, one day we find the "one of many ways" of doing something.
Alexandre Brisebois
that's a great way of putting it!
jcoby
Not many people are humble enough to accept a failure and still keep going. I think this is a very important character trait for programmers in general. to be able to say I've made a mistake, let me fix my mistake.
Alexandre Brisebois
I've failed over and over and over again in my life and that is why I succeed.Michael Jordan
Stefan
A: 

Just sat down one day and thought I would learn Pascal back 20 years ago, and picked up other languages on the way over the years, I learn best by example.

dswatik
A: 

Originally, Logo on an Apple. Moving that little turtle around the screen was a great way to introduce kids to programming and problem solving. I probably started using it in 2nd grade, if I recall correctly.

Sam Schutte
A: 

I was given some floppies with a C self-instruction course. I tried it for curiosity, I followed its examples and did the exercises until the end. Then, I bought and read Kernighan & Ritchie.

Anyway, I think you definitely cannot teach someone how to program. But he can learn from you, if he chooses to.

Federico Ramponi
A: 

Edit: Challenge them with ambitious (something they can do with a little research and trial and error) little projects. Have them win bonus points or exemptions from certain homework since they have proven to be able to understand and apply a certain concept.

The best way to motivate a someone is to have them set their own goals.

Help them find something they wish to achieve, be sure it is possible and not over ambitious. By breaking down a project into manageable milestones.

Working on something of interest pushes us to search, ask and persevere until we find some kind of break.

The simple fact of reaching ones goals is very gratifying.

Alexandre Brisebois
A: 

I started "programming" in BASIC a long, long time ago when my dad bought a ZX Spectrum 48K (by reading books), so in my opinion there is no real way to motivate people, either they like it or not.

João Augusto
A: 

Logo got me started in grade 2, then copying TRS-80 BASIC code out of a book, and trying to get it to work on GW-BASIC, then building web pages in high school and playing around with C++ and Java.

I think the biggest thing for keeping kids interested in programming is to use a language/system that lets them get quick feedback. This means easy input and output. Ideally some simple to use graphics. (BASIC had easy routines to manipulate pixels and draw lines). Something like MindStorms probably gives even better feedback, since you actually get to manipulate the physical world.

Eclipse
A: 

I learned php the same way I learned guitar, learning other people's stuff. I began using Wordpress, and then began wanting Wordpress to do more. So I searched through the code and became familiar with the structure of the language. I read the parts of php books that helped me write the functionality I wanted. After that, I went back and learned what the other parts of php could do. Mysql functionality, arrays, then functions. Still working out OOP...

kevtrout
+1  A: 

I learnt how to program when I discovered I could avoid tedious hours recalculating things (variables, factors) by just incorporating the heuristics into a program - and then have the computer in charge of executing the same thing several times in a speed and precision which is far from what I would be able to do - that was my motivation.

As to how to keep this motivation ongoing... I guess every day I read code or I discover a new language, I am actually discovering new answers to my basic questions (real life problems - such as - how do I summarize this - how do I draw this chart, why is that web page fancier than mine) so if you keep yourself loaded with questions and appreciate different ways to answer it you'll be motivate to learn more and more.

(Now I'm just discovering JQuery and how to make those fancy web interfaces... so that I won't ever have to resort to use crude html and javascript code)

rshimoda
Nice answer rshimoda, Thanks.
Agusti-N
+2  A: 

Self-taught, self-motivated. A science teacher showed me "INPUT", "PRINT", and arithmetic on an old IMSAI. I then immediately flailed, and he showed me again.

Everything else I figured out on my own or from books. I always knew the topic before taking the class in college. I've had projects marked down with the note "you don't know how to do this yet".

What's the best way to learn programming? By writing applications.

There are two kind of self-taught programmers out there. Those that write applications to Do Something (balance a check book, run a bunch of formulas, whatever -- most of these applications come from science and engineering), or Play Something -- games. I once had a doctor that wrote his own billing system, so he learned by writing billing systems for his practice.

I wrote games. Very bad games. And I typed in games from computer magazines, more bad games.

I spent more time typing in games and writing games than playing them.

Not having any real software is a great motivator to create your own.

All of this took time. A LOT of time. I was the guy breaking in to the school computer room on weekends when they closed it.

That's how you learn this stuff, you simply do it over and over and over.

You can't learn it in a vacuum. Pick something that interests you, and do it. Forget about "perfect", "best practice", etc. Just do it, and get it done. When it's done, then you can worry about "best practice". "Best practice", patterns, etc. make a lot more sense when you've hacked out pure garbage. You have a better understanding of the domain, you know how NOT to do it, and you know WHY you shouldn't do it that way (because you just did it and suffered in some way). That's invaluable experience. Fail often. You'll get it right in time.

Will Hartung
A: 

I subscribed to an awesome magazine targeted specifically at kids who wanted to learn to program (a sufficiently niche market that it unsurprisingly went out of business after only a few issues) - called "Let's Compute!".

The best thing about it was that it gave you a very simple program to copy out, explained what each part did, and then gave you some exercises - suggestions about what changes you could make. Over the course of several months of that you really began to understand what was going on.

I think the thing that made it so brilliant was the way they used cartoons and stuff to make it really appealing to kids.

andygeers
A: 

Good old trial and error.

Lots of trials, and even more errors. :)

Dan Walker
A: 

When I was 9 (in 1985) my parents bought me an Apple ][e. Given that it came with a BASIC interpreter and a decent manual coupled with my curiosity (and laziness) I started writing little programs to do my math homework. I then started modifying them to print out the steps so I could 'show my work'. This was great until my mother found out (it was cheating). Now I do it for a living. A big shout out to the 'rents for buying me a ][e - it changed my life.

cciotti
I feel very identified with your answer, Thanks cciotti
Agusti-N
+1  A: 

I took some classes in computer science in high school. Then I went to college and got my bachelors in computer science. Then I got my masters in it. Learning on your own is great, but to be thorough, schooling is also great. Everyone learns differently, and it doesn't make one person better than the other.

Dana
A: 

Sitting in the library with programming books as a kid. Writing code on paper. When we finally got a computer, I immediately started putting in all those programs I had written in the previous couple of years!

Brian Knoblauch
A: 

If you want to motivate students, help them to do something they will find useful. This is a LOT more difficult than it used to be. It USED to be possible to write a program from scratch and have it actually be useful. Now, it's far less effort to download a program that does the same thing. We tend to build on top of frameworks these days.

This is why games are so effective. My introduction to programming was a book on BASIC and how to program Olympics games. I still remember the hundreds of lines of code it took to make a little guy made up of a "O" for a head and a few lines for the body to make a silver medal dive complete with exclamation marks for splashes.

As for teaching them, use real world things they care about.

When teaching OOP, you could use the classic "Animal Kingdom" analogies. Or you could use something more real to them... like. People is the super-class and Musician are the subclass. A musician can play the guitar or sing or play drums, or all three. These are interfaces. Take a band or singer they care about and say, for example, Madonna is an object (of their affection) the implements "ISinger", "IIdol", "ISinger" whereas, "Baby Spice" is an object which implements "ISinger" IBandMember" etc.

You can expand it from there, by saying if you want a list of all the musicians in the world what's the best way to NOT exclude anyone?

Make a list of Musicians. Well, that's inheritance.

Atømix
A: 

Like JB King, I taught myself the basic concepts of programming on a Commodore 64. I bought it from a Sears store at a time when it cost me about a month's worth of rent, so I had some motivation to use it. :)

I grabbed some books, and worked through all the examples. By the time I entered school for a CS degree, I had written programs in C64 Basic, Pascal (the compiler was on a floppy disk, and I had to swap disks during compilation) and 6502 assembly language. I'd written some graphics programs using the peek/poke methodology, and inlined assembly, but mostly I stuck with text programming.

I still have fond memories of those years, and now wish I had not sold my C64 to fund textbooks!

Don Wakefield
A: 

My best teachers are the ones that did the programs right in front of us on the overhead projector, who needs a [black|white]board when you have eclipse/turbo C/python/[insert here your favorite platform].

My worst teachers are the ones that just enumerated the language keyword and APIs in the most borish tone possible, anybody can read the API/book/reference.

The parts when I learned fastest are when I did something really cool, usually this started up as an assignment of some kind and eneded up being in my own leasure time well after the assignment was due, the part I submitted was just a tag in the code trunk.

When learning something new I usually start with my own little scenario (sudoku solver now to learn GWT) and evolve the solution as I read more on the technology.

Coding without reading usually leads to a lot of running around but eventually the work gets done.

Reading without writing usually amounts to a lot of comprehension with very little retention.

Newtopian
A: 

Ah yes... a good book for teaching OOP is "Objects First BlueJ." It's built from the ground up around a compiler that makes things easy to learn.

Atømix
A: 

I always needed to be challenged to truly learn. One way of doing this is to have people expect something out of you that you're not sure how to do yet. I would tell a professor I wanted to get my project working with an LCD or something of that sort and then he'd get excited about it and I would feel obligated to perform. I always learnt more by having expectations higher than I currently felt I could handle.

As for getting others to learn/interested, I think it would be good to challenge them. Find something they have interest in and just tell them to do it and let them know you're there for questions they come across. Regardless of what they provide in the end it would be a great learning experience to produce something.

Sean
+1  A: 

I started around '92 when my dad bought a pc. I first learned GWBasic from a book I got from the library, can't remember which. I don't know why I started programming, but I never stopped. I started with small games, with falling " * " you'd have to avoid with your " ! ". I later adjusted and remade Nibbles in QBasic. In 1996 I started with C and C++. Writing graphical libraries and added my first 3D stuff in DOS demos. I later rewrote some parts of the libraries in assembler. From there I went to Visual C and did some DirectX and so. At school I had to learn Java too. Today I use C# with WPF, WCF and Silverlight most of the time.

I think the best way to learn how to program is to start with a language like VB, with lots of documentation and support online. Start making simple games with simple graphics. Games like Tic-Tac-Toe or LightsOut. Program with a friend, and discuss what and why you are taking a certain path. Show your code to people online and talk about that. And enjoy it. If you don't, you better find another hobby.

Sorskoot
A: 

Still, and always will be, learning

dove
A: 

I typed (copied) some of my first programs into a TI99/4A from the 99'er magazine I subscribed to. I also wrote programs on my own. Essentially for me in the beginning it was like using lincoln logs or other building blocks - you get to create something.

As for the learning part:

There are many factors involved - a lot of time has to be spent DOING it.
To become better usually means someone showing you concepts or otherwise having lessons learned form others.

Basically: One needs excellent resources to learn form and the attitude and time to work on it.

Early on (early college), a friend's father asked me for help with a scheduling problem - he was doing class scheduling by hand for his students in a school. I was stupid enough to agree to help and said if he didn't find something that existed that I would write a program for him.

It turns out that I signed up to solve an NP complete problem. It was a challenge for me as a freshman or sophomore in college but it gave me an appreciation for learning from other disciplines and an early appreciation of usability and requirements that I think is/was generally lacking in the academic world of computer science curriculum.

Tim
+1  A: 

As to how to keep students motivated, the best way I found is to have them work on something of practical value. For introductory students, using a language like Python makes this easier as you can teach about file input/output and have them write programs that convert files from one format into another format. In the CS0 class I teach, I use Python and wind up with them writing a simple XML parser (using the xml.sax module). They have to read in an XML file and convert it to HTML. For extra credit, they can accomplish the same thing using XSLT. Using a language like Python makes this possible even in a first semester course.

For more advanced students, having them work on a real project that the school will use is good experience. If you can get them paid to do this, that is even better. By giving them real-world experience it is easy to get the good students to work hard. In my more advanced programming class (covering PHP and MySQL), I tell the students that the ones who do well will be able to participate in a real project for the school. I think getting paid as well as getting real-world experience turn out to be good motivators.

Vern Takebayashi
+1  A: 

learn by doing

ManiacPsycho
A: 

I started with the scripting language for the UnrealEngine. Its called UnrealScript and it is/was a hybrid of Java and C++. I messed around with it and nothing really 'clicked'. Thankfully, when I started there was a very popular Wiki dedicated to UnrealScript and its engine and I got a lot of help from people who 'sat down' with me and went through some concepts and problems.

Some of it stuck but most of it didn't. I then took a look at Visual Basic. I had done some Visual Basic before this but it was all pretty much simply GUI stuff... drop a control onto a form and make a MsgBox appear when you click on it. I delved deeper into it, taking with me some of my knowledge from UnrealScript. When I got into it, it clicked.

Some time later I watched a Video Tutorial on how to make a 'customized' weapon with UnrealScript. After that everything just started to "click" and the Universe made sense.

So basically I learned to program mostly through self-teaching and someone showing me the basics as well as some advanced concepts. Once you get the basic concepts and learn a programming language intimately, you can pretty much take that knowledge and transfer it to any other language. Once you learn the syntax, there's no differences.

What motivated me to get into programming was solely the UnrealEngine. I wanted to create something "amazing" with a "wow" factor. When it 'clicked', I was motivated to learn about programming and other languages was the need to satisfy new long term goals: To develop an operating system, to develop a game engine and finally to develop a stand-alone game.

Going to school I found that not a lot of people wanted to learn code. In high school the only reason students took the Comp. Science class was because they had the idea that they would be allowed to surf the web for the entire year. After high school, it seemed that people were mostly learning how to program (those of which who didn't already know how) because their future goals or even just the course required it.

I believe some people just won't be motivated by programming. You can throw something shiny infront of them and they'll be more concerned with the fact that the shiny thing is made than how it was created. If you do find someone who is very motivated and interested in programming, I suggest you devise some 'cool' projects for them to learn from or get them to create a project plan on their own.

Dalin Seivewright
Good answer Dalin Seivewright - Thanks
Agusti-N
A: 

I learnt to program by fiddling. I had a programmer father, but he didn't know the language I was learning, so he just helped me with program suggestions and by pointing me to websites like koders and stack overflow. I used a book to learn the first fundamentals, and I learnt a bit at school, but I also used my IDE's help a lot too. I think the best way to teach people is to give them a book that teaches them a few basic commands, then challenge them to create programs. If you help them sort out their compiling problems, and just leave the expansion of their knowledge of commands to necessity, I'm sure they'll learn all right.

tiddlydum
A: 

How do you learn to dig a hole? At some point, you learn that a shovel makes the job much easier. It's the same with programming. You decide you want to do something and realize that automating that task is easier with a computer. So, first inspire a person to do something, then show them why it is better with a computer, finally, nurture that desire.

Josh
A: 

A local TV station ran a series of programming articles on their Teletext service. The examples were written in some kind of BASIC. I wrote the programs down on paper and went to our neighbors - they had a Commodore C64 back then.
There I translated my transcriptions Commodore BASIC V2, hoping that I didn't miss a line :)

weichsel
A: 

I wanted to make a simple application to give my girlfriend as a gift, and the only thing I knew were shell commands. Then, I downloaded Visual Basic Express 2008 and started using it. Voila, I happened to love writing code! =P

And of course I won't use GOTOs :D

Camilo Martin