views:

1412

answers:

16

If someone wants to learn programming starting from scratch, in which order should I recommend to learn which programming concepts? Should he start with data-structures or algorithms. When obejct-oriented-programming should be introduced? Should he take a look at functional programming? Should he learn about pointers and heaps, even if I recommend in the end a language with automatic memory-management?

+3  A: 

"Beginning Programming" from Wrox Press mentions different languages, then talks about editors and compilers before any other concept. Then it gets into the idea of statements, and "paragraphs" of code, before getting into functions, then data (variables).

When I teach complete newbies, I start with the idea of variables, move into assignment, then conditionals, then loops. The concept of "statement" naturally falls out, and the concept of "block" comes along with conditionals. Only then will I start on functions, both calling and then creating.

Jeremy Smyth
+2  A: 

Althoug it never happens this way, it's not entirely a joke :

  1. Hello World
  2. Commenting and documentation
  3. Design by contract
  4. Unit Testing
  5. Backing up and Version Control

  6. All the rest

UPDATE :

A true tragedy it is, that unit testing and commenting and the like are seen seperate from programming!! It is the reason so much bad code is around us. Indeed, a good language should incorporates stuff like commenting (javadoc, sandcastle) and even design by contract (eifel, spec#)

Peter
In my comment the message I was trying to convey was not that unit testing or commenting is not a part of programming, it was that those things are done when developing software, and not important for someone who was yet to grasp the basics of the language.
CiscoIPPhone
I can understand your opinion. But don't you think it would be a good idea in any language to learn adding comments immediately for example? The reason lots of people have bad programming habbits is they didn't start out learning it right away I believe.
Peter
I think it's acceptable to teach someone how to make a comment after 'hello world'. But I think learning when to use comments and how to use them would be a bit advanced at that stage.
CiscoIPPhone
+10  A: 

Start a complete beginner with much, much more basic concepts:

  1. Tiny program examples, to introduce
  2. Logic, fundamental structured programming concepts: sequential operations, branching, looping
  3. User (keyboard) input, then very simple file I/O
  4. Data types: integers vs. floats, characters, strings
  5. Records: collections of data, including arrays; write records to a file
  6. Dynamics: memory allocation or object (record) instantiation, based on unpredictable events like user input

Once a beginner understands basic logic and branching, grouping & typing of data, file I/O, and the concept of dynamic memory use, then they're potentially ready to start on serious data structures (lists, trees, hashes) and algorithms (sorts, hashing, graph traversal). Organizing code into functions comes somewhere in the #4-#6 range.

John Pirie
A: 

I am teaching my 12 year old son programming in c#. I would not necessarily have chosen c# but the book I found is the best I have seen. It allows me to have an outline and story to work from. To get to the point, it starts with viewing the customer needs, writing requirements, then UI, then coding, then test. The 2005 book is very beginner. The 2008 book is more focussed on writing code. http://www.johnsmiley.com/main/mybooks.htm

annonymous
+1  A: 

Here is my list:

  1. Hello World
  2. Backing up and Version Control
  3. Unit Testing
  4. All the rest

Reasoning: You should be able to code something very small because the rest doesn't make sense without this.

Next is how to manage your code in a VCS. This should come early so it becomes a natural part of your workflow.

Before you start to learn "poor man's unit testing" (write code, run it, eyeball the result, fix it, repeat), you can spend the time to learn the real thing for the same price.

Anything else is just icing on the cake and can be deferred until you need it.

Aaron Digulla
This seems like learning software engineering, not programming.I don't think there is much point in this much rigour for a beginner. A beginner should understand what programming is about before writing unit tests (how could they even write unit tests if all they can do is 'Hello World'?), using source control or backing up.
CiscoIPPhone
+1 Hey of course I agree, your answer than again is a copy of mine :-)
Peter
@Cisco: TDD is more simple when you start with it instead of when you have to forget about the old, comfy "Oh, I can just hack in the code and fix the bugs later ... someday"
Aaron Digulla
@Peter: I posted my own versions since I wasn't happy with your order of things.
Aaron Digulla
+3  A: 

I don't think you really need to look much father than the chapter headings of K&R (The C Programming Language), With maybe some adjustment for modern practice.

  1. Types, Operators and Expressions
  2. Control Flow
  3. Functions and Program Structure
  4. Pointers and Arrays
  5. Structures
  6. Input and Output

Nowadays Structures would probably be 'Structures and Objects' and Pointers and Arrays would place less emphasis on pointers, but it's still a remarkably valid set of fundamentals and the order in which to approach them.

Cruachan
+1  A: 

I recommend first learning generally a little more about how computers work, how the memory works, etc. It shouldn't take to much time if the person is already familiar with the basics. If this is not possible then a basic explanation of the memory concept.

After that, the person should try to get a feel of programming by learning as much as necessary to be able to build his own modified version of a "Hello World application", compile it and run it. The "Hello World" is very basic in every programming language and can be quickly explained, understood and picked up. At first, the person should be able to find a way to interact with the programming languge syntax and basic construction of a working program without much writing and memorizing.

Object oriented programming should, in my opinion, be introduced after the person has had a sense of the language and basic algorithm and array construction. It should be soon after loops and functions, after the person is comfortable with the previous knowledge.

Pointers and heap often confuse people so they should be mentioned and then reviewed later on before getting serious into memory. A bit by bit the person should feel good about programming and wanting to move on.

Secko
agreed. OOP should be taught much later..
jinsungy
Or not. A somewhat clear and concise introduction to OOP by relating to real-world examples can, in my opinion, serve as a very potent introduction to programming, as it is less abstract to the student than plain math-styled programming approach. Anyway, that helped in my case, at the very least :P
MrZombie
People are not the same!For me it's like saying that laws of physics can relate to things in the "real world". But, physics = real world;
Secko
So there's no better approach for this, some people will be better off with some methods, while others will require different ones. I'm sure glad I got the real-world examples, because I doubt my teachers would have adapted content to fit the needs of each and every other fellow students.
MrZombie
I also forgot to mention that pseudo code construction is important.
Secko
A: 

Many of the suggestions so far are excellent.

I'd advise starting with something simple that lets them see visible results quickly. As ugly as Basic is as a language; it let us do that back when people learned it in QBasic, on Commodores or Apples, etc. Python, perhaps with Pygame, can probably do that today.

The order of instruction in K&R also seems wise. After they've gotten through that, then I might start them on functional and perhaps object-oriented programming.

Michael E
+2  A: 

My approach would be to slowly immerse in the programming world through real-life examples.

Introducing objects and inheritance using means of transportations, for one, helped me understand quickly. Properties are logical from there on, and variables can be easy to connect to.

As in: Bob has a car. Bob's vehicle has four wheels. Carl has a motorbike. Carl's vehicle has two wheels. Carl gets rid of his motorbike and decides to use Bob's car too.

Such examples helped me start. Then, when there is solid comprehension of the general concepts of programming, go on with language-specific stuff.

[edit for addition] In an order of personal preference, I would go with simple comparisons first, along with typing, then loop structures, basic understanding of the mechanics of events (as in "things happen when stuff interacts with objects"). Starting there, you should have some curiosity in other stuff, and maybe the tools needed to go a little further without hitting your head repeatedly on a brick wall. As a student, that's how I learned, and that helped me alot when learning new languages.

MrZombie
A: 

My steps:

  1. Boolean algebra
  2. Algorithms (using Data structures, Numerical Maths)
  3. C/C++ (use this language to write programs)
  4. After this you choose any language you want and start learning it.
Kaz
I think it'd be much more helpful to have done something in code before you look at algorithms formally...
David Johnstone
Thats true, one must have hands-on in a programming language before understanding algorithms.
Kaz
+2  A: 

I'd recommend starting him with a language such as python. This is one of the easier languages to learn.

I think teaching him a functional language to start with would be a big mistake. After he has a solid understanding of imperative languages and is ready for a new way of looking at writing programs, introduce something like Haskell.

Zack
+3  A: 

The temptation here is to go to one of two extremes:

  • The newcomer is lost, terrified, huddled in a corner next to a cursor and the word "printf". They are in a dangerous environment and a C++ compiler will eat them if they put a foot wrong. Make everything soft and fluffy and sit them down in front of Python or Ruby or something like that.

  • The newcomer is a perfect, 100% attention-giving nerd who will not hesitate to give three days of his life understanding the concept of a class or a function (or a unit test) before touching the keyboard. Give him a copy of C#, a 700-page textbook and a coke and leave them to it.

Neither of these extremes are much good but I guess it is about judging their character. Some people -- even some of us techies -- need instant success, like caffeine, whereas others of us will go for hours for just a single number to read correctly. It depends on the person.

(I know we are bored of it depends answers... but it's the truth!)

Oh and find that writeup that went around (anyone have it?) about will-a-person-make-a-good-programmer. Quite apart from their litmus test, it has educational value of its own.

Chris Burt-Brown
A: 

Well,

I started with Borland C++ and quite often fellt like this was'nt the worst choice for my 'fist language'. Actually I think the 'older' languages are a good starting point since they are not as overloaded as some of the newer ones appear to be.

Don't get me wrong, C++ is way not simple - but it's a good starter anyways. I think.

Best,

        KB22
KB22
A: 

Most beginners become lost and lose their focus quickly. I find it helps to work with them towards a concrete goal, such as displaying data on a webpage, or a desktop app that can talk to google. Although they won't fully understand everything it keeps them focused and excited.

JonnyD
+1  A: 

These responses are good but, honestly, they are all missing one small point. Because the OP was asking about "someone" learning, I think the place to start is with the "someone." Learning is always best when the student sees the information as relevant, and relates it to something already familiar. It's also best when s/he sees it building toward a desired end point, i.e., working towards learning how to program something personally interesting. So, I would ask what sorts of things the person is interested in doing?

I'm only a hobbyist. There are lots and lots of things I still need to learn; watch for posts from me in the coming weeks and you'll see what I mean :-) However, I'm experienced enough to have dabbled in languages as different as Python and Delphi. I love each one, but find them to be best for different kinds of tasks. I wouldn't go so far as to say one is "better" for all beginners than the other.

Just my .02.

Al C
A: 

My List:

  1. Simple output ("hello world")
  2. variables, simple data types
  3. flow control (if/else, loops)
  4. basic i/o (users, files)
  5. arrays, strings, other more 'advanced' data types
  6. functions
  7. objects
  8. recursion
  9. data structures
  10. design patterns
  11. regular expressions
GSto