Difficulties Programming

Sometimes I wonder why many first time programmers have difficulties with programming. For someone who has never taken any kind of programming, the process and attention to detail can be frustrating. Because I took programming during my grade school days, and had dabbled with GW Basic after I left grade school, I had few problems with first year programming at Brandon University in the early 90s. I essentially sailed through first-year programming class.

Since that first university course, I’ve come to realize, due to many trying programming circumstances I found myself in, what others may feel at times and how frustrating programming can be when something, some concept, doesn’t make a connection. It seems to me that a large part of the problem that beginning programmers have is related to the nuances of the language; omitting even the smallest detail or not being clear on a simple concept makes programming very challenging. Why, for example, do I keep getting a syntax error? My code seems correct, it looks very similar to the example code I checked it against, yet I keep getting the errors. After 15 or 30 or 60  minutes of testing, checking and rechecking, it dawns on me: I’ve left out the colon at the end of the if-then statement. This does happen.

I’m currently taking an introductory Python programming course online, Programming for Everybody, through the University of Michigan, with instructor Charles Severance. Recently I ran into another issue that may cause people frustration and dissuade them from continuing programming. I was writing a short program in Python which used division. However, no matter what I tried, the output of the program remained “incorrect”: it printed “0” every time. For example, when I divided 1 by 2, I should get 0.5.  However, the output was always 0. The problem, as it turns out, was due to the default position in python 2.7 which uses floor division and returns an integer quotient when dividing by two integers. “[Python 2.x] does division in the “C” sense: an integer divided by an integer yields an integer, rounding down if needed” (Bradley Froehle).

The problem was solved only when I converted either the dividend or the divisor to a “float”. (Or by adding a line of code, “from __future__ import division”,  which forced Python 2.x to use Python 3.x rules.) Here again, the nuance of the language and my misunderstanding of how Python 2.7 handled integer division caused problems. Had I clearly understand that or picked up that piece of information from the lectures or from the readings, I could have avoided the problem. Fortunately, Python 3.x defaults to decimal (float) answers when doing integer division, eliminating this issue for future programmers who will be using Python 3. But I learned this only after spending an hour trying and reading about the issue on the internet. For new programmers, this nuanced use of the language often causes frustration which leads them to give up on programming altogether. I’ve seen students with tears in their eyes due to their frustration, and it’s not a good feeling knowing that as a teacher, I didn’t do enough to teach, support and encourage students and guide them through some of these typical nuances.

Personally I have learned over the years that taking the time to become absolutely clear on the content, on the concepts, and on the syntax helped me or my students to overcome most hurdles. Even in university, I often needed to review my notes or textbook outside of class and work through problems one step at a time, making sure that I understood exactly how the examples work. Sometimes the pace of class is too fast to process all the information and quiet thinking time is required. I also found that notes or drawings really helped me to visualize the problem or the solution. Often working it out on paper visually brought as much satisfaction as writing the actual program itself, because programming is not just about the syntax of the language, but much more about the underlying solution to a particular problem. So,  potential future programmers need to keep in mind that paying attention to detail is important. They have to understand the nuances of the language. Often times, something may seem simple, but if one doesn’t clearly understand the concept, problems may occur.

My advice would be to take it slow and easy: work out solutions by hand when necessary, visualize it, pay attention to detail, and move on only after each concept and its application is clearly understood.

3 thoughts on “Difficulties Programming

  1. I have a feeling that what you’re describing doesn’t only apply to programming even though programming per se is more precise than other fields. I think this could apply to education in general, teaching Math, ELA or wherever. Knowing your ‘stuff’, the ins and outs, could prevent potential hurdles and empower you to address problems as they come up.

  2. This evetually retrains one’s mind to consider every implication of everything. It becomes an obsession which carries over into one’s social life. It improves critical thinking skills but mostly turns one into a pessimist. That’s why programmers aren’t fun at parties.

    • Interesting take on the programmers “mind”! I remember literally thinking some of my thoughts in the programming language I was immersing myself in years ago. It surely can impact your thinking…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s