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

February, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    FizzBuzz–A Programming Question


    Projects or exercises that lend themselves to many different “correct” solutions are just about the best sorts of learning experiences I can imagine. They really open the possibilities for discussion and from discussion – questions, answers, explanations – comes real learning. Recently Dennis Shaw, a student at Old Dominion University and a Microsoft Student Partner, told me about the FizzBizz exercise. (see Using FizzBuzz to Find Developers who Grok Coding for where it comes from) This is exactly that sort of multiple solution but not that difficult sort of exercise I love. Briefly stated the exercise is:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

    So there you have it. It involves using some sort of conditional of course. Nested or unnested? It can be done either way. Which way is best? Do you check for multiples of three first or five? Do you check to see if the number ISN’T one of those cases  first or if it IS one of those cases? Or rather than If statements is there a different way completely? Perhaps a select/case structure? Does creating functions/methods complicate of simplify the result? If students know multiple programming languages is there one that is better for this than another (think especially about functional languages v. procedural languages). Are there special operators (like perhaps the ternary operator in C#, C/C++ and Java) that might make the code “tighter?” Is there a trade off between complication and understanding? Oh and of course, does your solution actually work?

    Justify your answers. (Don’t you just just love the teacher-ness of “justify your answer?” Smile)  I can see asking students to write up an explanation of how their solution works and why they did it that way as a means for forcing examination of the solution. And as a side benefit a lot of students can benefit from yet another writing exercise. Code that can’t be explained isn’t properly understood and that causes problems in the long run. A piece of code should not be “magic” to the person who wrote it.

    There are many solutions on the Internet to the FizzBuzz question. So yes, some student might go searching for one and even try to use it. The “justify your solution” question means that they still have to understand and explain how it works and why they like it. I can’t see a student saying “I like this solution because I found it on the Internet and it works.” Well, I hope they wouldn’t try that. But if they do, grade them on how well they explain the benefits of using borrowed code and if they credited the original source properly. And of course they should also be able to explain why this solution is better than others they might have found. Surely they were not so lazy as to hand in the first solution they found?

    BTW a couple of related posts of mine are Teaching, Learning and the Job Interview and Characteristics of a Good Programming Project

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Are Programming Languages Really Languages


    Every so often someone suggests, sometimes in jest and some times in all seriousness, that programming languages “count” as a language for meeting graduation or degree requirements. According to Ian Bogost, who is not happy about it, some schools are actually doing this and others are close to it. (Computers are Systems, not Languages)

    Is this a good idea? I think it largely depends on what you see as the value in learning a language other than your own native language. As someone who struggled his whole academic career with languages (first year French twice, First year German three times) I’m not so sure that language learning the way we do it in US is much good. Very few really become fluent enough to have more than the most casual of conversations (any one have evidence to the contrary?)  One reason I often heard for learning a foreign language (the politically correct term is world language I think) is that it gives one a better understanding of the culture of the countries where it is spoken. I guess that is true to some extent. Although with our “flat world” is it as necessary as it was a generation or two ago? Arguable. Isn’t the world of computers a culture though? Perhaps learning to program helps people, especially in the humanities, some insights into that “other” culture?

    Another reason I have heard is so that one can read research and other works in the original language. Perhaps that made a lot of sense when French and German were the principal languages of some areas of study. But today people write in far too many languages to make focusing on one make for a solid argument – well unless that language is English. An awful lot is written first in English even by people whose first language is not English. On the other hand there may be some value in being able to read code in the “original” language. It’s a theory. And fortunately computer languages are often enough alike that learning one or two is enough to have a reading familiarity with others.

    Does learning a different language help one understand their own language better? That seems a stronger argument than some others. There is no close corollary to this with programming languages with the possible exception of COBOL. Smile 

    So am I arguing that programming languages should take the place of natural languages as general education requirements. Not really. I’m sort of asking why we have learning natural languages as a requirement. Sacrilege of course but why not? I do think that more people should take some programing or other real computer science course though. It is part of being a fully educated person in the 21st century.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    What Does Watson Mean?


    Researchers at and working with IBM have created a computer and software that played and beat the best human players of the TV game show Jeopardy. This is an event that raised a lot of questions. For computer scientists it raises question along the lines of “how does it work?” and “How is this work applicable to other domains?”  For the wider audience, but also critically important for computer scientist,  there are also questions about what does this mean for artificial intelligence? Are computers catching up or even passing humans in intelligence? Is Watson smart? A genius? Is Watson actually thinking? Should be be afraid of the machines from the Terminator movies moving a step closer to reality? Ah, probably not.

    I read a book by Ken Jennings (Brainiac: Adventures in the Curious, Competitive, Compulsive World of Trivia Buffs) which talks about Jeopardy and similar quiz games and the people who compete in them. It doesn’t take a genius to do well at these games. It does take some skill at understanding the questions and a good recall for huge amounts of data. But its not about doing great things with the data or making complicated decisions. Watson does things with a lot of work that people tend to do without thinking about them. Which brings up another point. It took 4 years, 25-30 people and millions of dollars to create a machine what people can do with a few minutes (or less) on instructions. The resulting computer/software can only play one game – Jeopardy.  It would talk a lot of work to change Watson to play other games. People are much more versatile.  Watson is not going to be making decisions based on its database anytime soon.

    The big skill of Watson (for a computer) is to understand the natural language questions and then do a data search based on the results. People are still better at that. The Watson miscue on the Final Jeopardy question when Watson identified Toronto as a US city (more or less) while both humans correctly answered Chicago is a demonstration of that.  So the computer is not yet that smart – not scary smart anyway.

    What is thinking anyway? Is it just parsing a statement and doing a data search? I think not. I think it is more about things like making more choices based on insufficient data – making a jump of faith if you will. It is about how you use the data once it has been retrieved. Right now Watson is just a sort of search engine that is a lot better than average at parsing natural language questions. This makes is great for retrieving data but raw data is only as useful as the people making decisions based on it.  I’m sure some look at a lot of computerized systems and saying “those machines are making decisions based on data” and they’d be right. To a point. The computers are making decisions based also on rules and guidelines that people have developed and programmed into the machines. They are not making the decision on, for example, what tolerances are ok for a manufacturing process. Or on what makes a flaw minor or major. 

    Thinking involves some level of creativity as well. I don’t see Watson having any creativity either. So it’s a great project. I think it advances the art of natural language processing and data mining. I am not so sure that we can say this is a super smart machine compared to humans. We’ve got a ways to go for that. What do you think? Are their other questions to ask and answer? I wonder what Watson would reply if asked questions about itself.

    BTW I like this balanced view on CNBC.

Page 1 of 7 (20 items) 12345»