Four Key Concepts of Computer Programming

Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

Four Key Concepts of Computer Programming

Rate This
  • Comments 18

Last week Rob Miles who is taller than I am, has more hair than I do and has an English accent all of which indicate he is probably a lot smarter than I am left a comment on one of my posts that lists his idea of the four key concepts in programming. He left to comment on Do We Need A New Teaching Programming Language BTW. The post and his full comment are worth the read. Rob’s list was:

  • Process data (assignment)
  • Make decisions (if)
  • Loop (do - while, for)
  • Use indexed storage (arrays)

Among other things he said:

If you can do these four things you can write every program that has ever existed. Sure, the code won't be pretty, but it will solve the problem. In my course we focus on algorithms at the start because this is where we actually create behaviours  [note classy British spelling which adds credibility] that solve problems.

In all seriousness, Rob is a great teacher who also writes some really good textbooks. He really knows his stuff. All of that not withstanding I kept trying to think of a fifth thing to add to his list.

I thought about input/output for a long time. But I/O is such a platform dependent sort of thing. It depends not only on the language but the operating system and even available hardware. Input via a key board is different from punch cards (remember those) and still more different from input via a Kinect sensor (let’s keep in mind that there is a future). As I recall the PASCAL standard did not specify requirements for input/output and left it to the developers for individual platforms. So that probably doesn’t fit.

I thought about variables but that is sort of covered by process data and indexed storage. Even internal data representation which I see as a key computer science concept is probably not as key for programming. I have successfully used programming languages that only stored integers and strings. Well maybe there was a Boolean but I forget. I managed to write some useful applications anyway. Some even dealing with money.

Recursion? How often do you really need recursion? And a lot of things that recursion is used for loops will do just fine for. So while one should learn recursion and a really good programmer should know how, and more importantly when, to use it I don’t think it fits the top four or five list.

Would you add something? Remove something? Overall what do you think of Rob’s list?

Note:  To subscribe to this blog please use http://feeds.feedburner.com/ComputerScienceTeacher as the RSS feed source. Thanks.


  • I disagree with Rob and gasstationwithoutpumps about exclusion of an abstraction mechanism. Without the concept of code reuse and variable scope, it's really difficult to develop algorithms that go beyond the basics. Part of learning computer science is gaining an understanding of generalization and partition of a problem. A fundamental part of designing a solution to a problem is breaking the problem down into sub-problems to solve. Without some sort of way to create layers of abstraction, your ability to solve complex (or you might even say interesting) problems is severely limited. I personally want my students to understand these concepts as soon as possible, right alongside iteration, decision, indexed storage and variable assignment/arithmetic. (This is one reason why I consider Scratch an excellent teaching tool in most respects, but do not think it can address the full spectrum of fundamental programming skills unless you use BYOB.)

    Look at it another way. The four operations that Rob listed coincide pretty neatly with basic functions of a microprocessor (and hence assembly language). Data processing is basically arithmetic and register operations. Decisions and looping are handled by branching and logic instructions. Indexed storage is done with the load/store unit. However, there is another concept built into all CPUs: subroutines and the stack. It’s there for a reason--because it’s just as fundamental as all the other operations.

    Of course, if we really wanted to get down to basics, we really ought to be programming a Universal Turing Machine. We don’t, outside of some specialized and limited contexts, because while everything computable can be reduced to a Turing Machine, it’s not an easy model to work in. Everything beyond that is abstraction, but obviously helpful. To some degree it’s arbitrary where we draw our own line that denotes essentials, but since some very smart people drew a clear line decades ago, in hardware, that seems like a sensible place to agree on.

  • How about Files? Without some form of storage when the code is not running many of our programs are not very useful. Databases could be another storage form.

  • I think what I really should have said is "You have to know how to use these things to solve problems before you go any further".

    I also should have added thing 0 "You need to know how to solve the problem before you can write a program" and thing 00 "You need to know what the problem is before you try to solve it." These are the other two points that I hammer really hard when teaching how to program.

    The main reason why software projects go awry has nothing to do with programming technique and everything to do with failure to determine what is really required. Abstraction, generalisation and partitioning are there to provide a means by which you can take the raw abilities of the hardware and make them properly able to solve real world problems in a managed way.

    Remember, I'm not actually saying these are the only things that you should teach, what I'm saying is that it is important people understand that these things are what computers really do and that everything else is built on top of these fundamentals.

  • The New Zealand Ministry of Education is working on these matter with the teachers and qualification for our year 11-13 students ages 15-18 years old

    www.tki.org.nz/.../dt1_46_int_8jul10.doc

    They have outlined that a computer program is

    A basic computer program is a program, written in a programming language, that: will include variables, assignment, predefined actions (e.g. predefined methods, functions, or procedures), expressions, sequence, selection and iteration control structures

    obtains and uses input, from a user, sensors, or other external source has been tested and works correctly.

    check out the link above, it may give you some ideas on where things are going

  • He has forgotton functions/modules/subroutines.   Breaking down problems into smaller parts is fundamental to programming.

  • Seems like a very narrow definition of what constitutes programming.

    So much for prolog and Turing machines. To heck with proof based systems like multi-dimensional programming.

  • As long as Data Types and Manipulation functions (+-*/etc)are included in 'Process Data', then the primary level is Process Data and Make Decisions.  All programs can be written with those.  Loops and Indexing are program folding techniques and are level 2.

    You can continue up the ladder

  • I think the point was that if you know how to do the following things (at all in any way shape or form)

    Process data (assignment)

    Make decisions (if)

    Loop (do - while, for)

    Use indexed storage (arrays)

    They can be used to solve almost any problem a programmer (I use the term very loosly here) can wrap his head around.(...and thir program will work) It may not be pretty, it's not something I would want to maintain, would be fairly useless to anyone else (least in the long run)

    As far as everything else goes... those are the skills needed to make code that can be read by others, to abstract the ideas so they are easily accessable and can be reused. It is the everything else that makes a programmer great programmer.

  • >I also should have added thing 0 "You need to know how to >solve the problem before you can write a program" and thing >00 "You need to know what the problem is before you try to >solve it."

    Those aren't programming concepts, but problem solving fundamentals in general for pretty much anything you do in life.

    Also you don't need "indexed" storage (arrays) per se, just some sort of dynamic storage allocation.

    As a practical consideration I think you do need another concept, whether you call it I/O or debugging or "feedback" or whatever.  The fact that I/O is hardware dependent is beside the point.  The programmer has to have some feedback from the system to verify the program is working, and to learn, practice, experiment and modify along the way.  I'd call that very fundamental.  Otherwise it would be like trying to learn to play the piano without being able to feel with your fingers or hear the sounds - theoretically possible if you're already a master, but essentially impossible if you're learning.  In fact if you're talking about teaching and learning programming, I'd put this thing (whatever you call it) first on the list.

  • To add to the I/O comment, imagine a computer program with no input and not output.  What exactly could that program accomplish?  How many such programs exist?  If you think about that, I think you'll realize I/O of some sort is pretty fundamental.  You can write a program without arrays, without loops, without decisions, and without I/O, but that's not really the point.

  • It is amazing how people get wrapped aroung the axle about a topic like this.  I have been teaching CS to HS kids for 20 years (give or take a decade) and I have to agree with Rob's list.  But I interperet I/O as part of process data and many of the other objections as part of his list in some way or other.  I see this list as the focus of a Programming I course and as such it pretty much covers most of the bases.  This does not mean these 4 are the only topics covered in the class.

  • These four concepts are key concepts, and really everything else is just higher level of abstraction. We need abstraction but it is not core concept. When one understand ifs, loops, arrays and variables, it is enough to write in any programming language is on earth, everything else goes into syntax differences, and on higher level using libraries, frameworks to not reinvent the wheel. So I totally agree.

  • While I agree that most everything can probably be categorized somewhere under these 4 broad categories, I also think that  the generalization leaves open the possibilities of large holes. When generalizations are used instead of details to specify completeness, there is a huge potential for incompleteness. I have interviewed "experienced" programmers who have learned all four of these concepts and done a lot of programming, but can't debug a problem because they don't understand memory models and stack frames. The devil is in the details.

  • There is a critical assumption underlying this entire thread. We are programming CPUs. These "Key Concepts" only apply to the hardware we are programming. Owen M hit the target with a glancing blow.

    The hardware, no matter how wonderful is seems to us, is NOT the way that the universe around us works. Described in the language of Mathematics, that universe is operating less like a CPU and more like a set of rules. Since this is a discussion about educational approaches, I think it's important to understand the framework in which we work.

    I tore into Apple II owner's manual (complete with circuit diagram and 6502 instruction set) at the same age my daughter is now. And we are still trapped in the simplistic view of computing that existed then. I wasted no time building a web of assigns, decides, loops and indexes. But my girl has the benefit of greater technology. She has an EASIER time solving problems with GHCi than with JS or LOGO. It's always a good time to remember the origins of CS.

    The aforementioned universe, which we often try to mimic with these Key Concepts, whirrs along. In a few decades, I really think we'll be programming a different kind of hardware. Megahertz will yield to mega-core, which will then yield to some other measure. Will today's students be ready? Does a positronic brain, a PAL-web or a [insert name here] have an instruction set? No, but the language of Mathematics will eventually return to prominence.

    Teaching variable assignment, if-then and loop structures is easy (given students with certain traits). And that is why we make them Key Concepts. And it has been easy to make machines that perform these tasks. Steps 0 and 00, “Understand the Problem” and “Express the Solution” are the Key Concepts in any discipline. And “let x = x + 1” doesn't make any sense in the real world.

  • The skilled programmers does not required the advanced concepts.May be it help in writing code much easier, modular and quicker

    It is sufficient to have these four basic concept understanding to write any code.I/O is again help in making things easier to display and feed the values.

    Even recursion is advanced concept,which helps in easier implementation.But the programmer with little intelligence and skill can break down the problem in such a way ,so that advanced concept are not necessary for computation.

Page 1 of 2 (18 items) 12