Monday, February 22, 2010

Computer Science a Top-Paying Undergraduate Degree

According to NACE, Computer Science ranks number four in top paying undergraduate degrees. The top three are engineering degrees. Google "top jobs" and see how often computer science jobs are in the top.

Given this, and the fact that technology is critical to almost any popular job and entertainment option, why aren't more young people interested in computer science? Why are people waiting until they enter the workplace before realizing how important technology is?

Tuesday, November 17, 2009

Lazy programmers

I recently accessed the on-line customer service for the Des Moines Register. Part of that process has you register your account number. Here's the message I got on the field to enter your account number:
(You can find your account number on your invoice or call customer service at 1-877-424-0225. You must drop all beginning zeros and include the 'DM'. For example DM00012345 becomes DM12345.)
Exactly how difficult would it be to write an algorithm that would add the DM if I forgot? Or drop the leading zeros?

The DM Register is hardly alone. Many sites ask you to enter your credit card number, but without spaces. Stripping spaces takes only 1 to 2 lines of code, depending on the language you are using. If I want to enter spaces with my credit card number, don't let that stand in the way of my spending money at your web site.

Sunday, August 30, 2009

HP Counterfeit Ink

Just when I thought my HP Photosmart C7280 Printer could not be any more annoying, it has picked up a new "feature."

What were a few of the original annoying features?
  • Continuously running 6 different processes.
  • Throwing up a dialog box to every computer in the house when it is low on ink, out of paper, or even if it has been turned on.
  • Originally it had 'critical updates' 2-3 times a week it needed to download. I figured out how to turn that off thankfully.
  • 1/2 the computers in the house cause a blank sheet to print between each actual page we want printed.
The 'new' feature: accusing me of using counterfeit ink. It is already a waste when studies have shown printers to report cartridges empty long before they actually are. But now I can't use my nearly full cartridge after only a month, because printer is suddenly convinced it is not a 'real' HP cartridge. At first it kept giving me nasty messages about voiding my warranty. Now it just refuses to use it at all.

Bad Hewlett-Packard.

Thursday, July 9, 2009

Searching and Sorting algorithms

I'm teaching second semester programming this summer. This is the class where classic algorithms such as binary search and QuickSort are introduced. These algorithms have a certain beauty about them that I really enjoy.

The book I'm using is Java Software Structures. This book is a solid CS2 textbook that covers searching and sorting in the order one would expect. I did not find the book to be outstanding, just a solid contender. I think the book would be outstanding if these issues were addressed:
  • The book uses generics, iterators, and other advanced features of Java without adequate coverage in the text. There is some coverage, but not enough. Many students coming out of a CS1 course won't be prepped enough to use them.
  • Code for searching and sorting is only given using generics. This forces students to solve 2 problems, what is the algorithm doing, and what's going on with the generics. I'd prefer the code first be introduced using an integer array, or even pseudo-code. If the code using generics was shown right after an integer array example, it would help emphasize what generics add.
  • I'd like to see some recursive algorithms, like binary search, be shown in non-recursive form. Otherwise students might think that the recursive algorithm is the only way to do it.
  • I'd like to see better images of the searching and sorting in progress.

Past that, not a bad book.

Tuesday, June 23, 2009

8-bit microcontoller programming

I'm once again learning how to do simple embedded programming. I'm using the DEMO9S08AW60E board from Freescale. Unfortunately I'm solving the same problems I ran into last summer I worked on this.

So just in case someone (like me) runs into these problems, I'll blog about them so that the solution can be found via Google.

1. CodeWarrior for Microcontrollers doesn't work with 64-bit Microsoft Vista. It won't even install. Its been that way for several years, no fix coming. Even more annoying, the installer just fails with a cryptic message. Nothing that would indicate that the problem is 64-bit Vista incompatibility.

2. Any time my program tries to run an analog to digital conversion (ADC), the program hangs. I'm not sure why, but I traced the issue to this line in the ADC bean's initialization function:

setReg8(ADC1CFG, 0x7A); /* Set prescaler bits */


Once that runs, I can't do a conversion. The line is auto-generated by the 'processor expert' that comes with CodeWarrior. Every time the processor expert generates the code, I have to comment out this line. I'm not sure yet whatthe 'prescalar bits' are supposed to be set to. I figure when I take the time to understand that, I can code around the issue.

3. Since doing a ADC uses an interrupt, it doesn't work to place the code inside a different interrupt. Measurements have to be done in the main loop.

Now I can blink LEDs and read a 2-axis accelerometer. My not-very-exciting program can change the rate the lights blink depending on how the board is tilted. Next step is to see if the custom printed board a student built last year can be programmed. That board is set up for interfacing robotic servos.

Saturday, June 13, 2009

Python and scope

I think this rule with scope in Python is not intuitive. Take a look at the following program:

1 x = 1
2
3 def main():
4 print x
5
6 main()

x is in scope within main(), and the program runs correctly. Now look at this program:

1 x = 1
2
3 def main():
4 print x
5 x = 1
6
7 main()

This program fails, it can't print x because the value for x has not been set before printing it in line 4.

Why? x is set in line 1, correct? True. But that x is not in scope.

By setting x=1 in the main function, we get a brand new variable called x, which is only in the main function. There are 2 variables, both named x. One for the main file script, and one for the main function. And since x has not been set in the main function, print x does not work.