Showing posts with label PROGRAMMING. Show all posts
Showing posts with label PROGRAMMING. Show all posts

Thursday, 27 September 2012

Mini-Review: Head First Java, 2nd ed. by Kathy Sierra and Bert Bates

Head First Java by Kathy Sierra and Bert Bates, cover image.
Head First Java, 2nd Edition
Head First Java is a great book for describing many of the confusing aspects of the Java language. It is easy to read, written in a light style, and it uses lots of graphics to break up long runs of text. Many of the graphics in the book illustrate key concepts of Java.

Not For Raw Beginners, But Close to It

For an experienced programmer new to Java, it can be used to learn enough about Java to get a strong basis in the language. It covers a lot of the language, enough to get someone from just starting out to the point where they're capable of carrying on learning with the official documentation or books on specific programming subjects within Java. It starts out at a point that will probably not be basic enough for non-programmers to start learning, but if the non-programmer has a mentor, or another book specifically intended for non-programmers, it will make an excellent supplement.

Trying Out LiveCDs

I'm still looking for a Linux or FreeBSD LiveCD for my high school computer class. I've had some success, but there's more to do. The idea is to have an OS disk that we'd run off of during class with the tools we need all there, ready to go.

No Room, No Room!

The computers in our lab at school have very limited disk space. Windows XP is installed on them, along with programs needed for other classes. That doesn't leave much room for graphics programs and development systems that I'd like to use for my classes, both the middle school and high school classes. So I thought I could use LiveCDs to solve the problem. Only the student's data files would need to be stored on the hard disk.

Wednesday, 26 September 2012

Why I Taught Programming with Java

I teach a high school computer class, and this last year we spent a semester learning programming. Picking the computer language we'd use was a lot tougher than I expected it to be. I looked at a lot of languages, and a lot of implementations of those languages. I ended up using Java.

I wanted a language that the students could use on their own, outside of class, to do real things. The language also had to be supported on multiple platforms, with the same syntax and libraries/classes on at least the major desktop OSes. It also had to be free, in the sense that there'd be no license fees for the school

On top of that, I wanted it to be fun, something that would let the students play with graphics and sound. Console-mode text just didn't cut it.

Now, in this day and age you wouldn't think it's expecting too much to have a programming language support features like graphics and sound, right? Apparently the language developers think it is. They rely on hooks to proprietary APIs, mostly, meaning that the code to open a window on platform A is completely different than that on platform B.

I'm not talking implementing keywords for controlling specular reflections and bitplane operations, here. I'm just looking for windows and some basic drawing primitives in the way of graphics. For sound, the ability to play a tone or a simple audio file would be plenty.

I was hoping to use a language with a clean, simple syntax like ruby or python. But I didn't find an implementation of either that met my needs. Jython came close, but the hurdle of jumping the Java API barrier to get the graphics and sound undid all the good that the core python would do--it would be easier to just teach Java from the outset.

I also considered going with Berkeley Logo. I like Logo a lot, basically it's LISP with some of the historically-established keywords cleaned up. I may use it this upcoming year with my middle school class. But for my high schoolers, I wanted something with more of a real world presence. Something they could keep moving forward with without having to change horses. Honestly, an open LISP implementation with platform-independent graphics and sound capabilities would fit the bill. One look at Y Combinator is all it takes to see that LISP is alive in the real world. I looked at some LISP implementations, I'll be looking at some more, but in the time I had I didn't find something that did what I was looking for.

Less Than Perfect
There were still some snags with Java, though. Installing the SDK on the school's Windows systems was a pain. The extra step of changing the command path was annoying for me, and for my students who went to install it on their home systems it became an insurmountable obstacle in about half the cases. OK, to tech-heads this probably seems like foolishness. Some may say that if they're stopped by this they have no business programming. I don't see it that way, and I don't take kindly to folks who think unnecessary complications in installing and using software ought to be used as a worthiness test for beginners. Beginners are beginners, and they ought to be able to focus on the one thing they're working on learning at any one time.

And, face it, as Windows users they're not used to install procedures any more complex than spinning a disk and clicking on a button. It's a shame users of all platforms couldn't have it that good.

As the aficionados of the scripting languages point out, Java's syntax isn't a simple and straightforward as it could be. To new programmers its insistence on certain forms of capitalization make it seem pretty fussy, for example, and dots meaning one thing in an import statement and another with invoking methods and members is more class time lost.

I used a Java textbook for non-programmers in an attempt to make my life a bit easier. I wasn't entirely satisfied with the any of the available Java programming books I was able to review before we got started with Java in class. As basic Computer Science books, I think they were fine. As introductions to casual programming, there were none that fit the bill. I'll try to do mini-reviews of the books I looked at and used in some future post. But my main concern was that the fun stuff--graphics and sound--was all left till late in the books. I had expected to find something that presents some basics like a JFrame and paintComponent early on, then plays with flow control constructs and such by using graphics within them. Unfortunately, I didn't find any such Java books for non-programmers (or for programmers but basic enough that I could make up the difference.)

Looking Forward

I'm planning on spending a semester on programming again in this upcoming school year. I haven't decided if I'm going to stick with Java, though the default will be doing so. If I do stick with Java, I may create a LiveCD of some sort with the SDK and a basic IDE on it, and distribute it to the class. This could get rid of some problems I had last year, like dealing with some of Window's programmer-hostile features in class while neglecting the students on other OSes, as well as installation of the SDK on the computers in the school's lab (the non-Mac OS ones, that is.) It'll also mean that the student can take the CD home and have the same development environment there as in class.

I'm also still looking at other options. Because I still think it's worthwhile to have some graphics and sound in an introductory class, and because I still want the students to be producing portable programs, I'm concentrating on the language implementations that compile to Java bytecode. If I find a language that doesn't have some of Java's gotchas for beginners, it won't be any worst to install its compiler (except that I'll have to add it to the OS X systems as well as the others, unlike the Java SDK.)

Groovy is one possibility I've found so far. JavaFX may be another. Whatever language I choose, I may still go with using a LiveCD of a BSD, Linux, or maybe even OpenSolaris depending on what I can find that works well with the lab's computers and is likely to work well with most students' home systems.

I can tell you this, though. As "bad" as it was, it's times like this that I really, really miss those old 8-bit computers with BASIC on them.

An Infinite Number of Cats on an Infinite Number of Keyboards and the Works of John Carmack

If we place an infinite number of cats on an infinite number of keyboards how long will it take them to reproduce the works of John Carmack?*

How long before the cats have reproduced Doom and Quake? Will some lively Russian Blue turn out Spear of Destiny in just a few short years?

With the time it will take the cats to get their programming tools in order, the cats have zero chance of even managing Commander Keen. I like cats, but faced with the uphill battle of going from non-programmer to programmer I'd say the cats are toast. Heck, I'd give them over a century to get as far as "Hello, World!" from K&R C.

What chance does that give a human non-programmer? Assuming they manipulate a mouse and keyboard with more control than a cat, not quiteso bad.

10% Inspiration, 270% Perspiration


The most important characteristic is perseverance. Perseverance in the face of confusing messages, obscure software failures, oblique semantics, and I'm not even talking about the programmer's own programs! I'm talking about getting the development tools installed. Once they start doing their own programs they'll need even more sticktoitiveness.

The Cat's Advantage


The cat's advantage is that it does not allow its mood to be affected by strange error messages. It also does not allow a long list of errors to faze it. Humans on keyboards tend to take these personally, however, as if the computer is commenting on their personal grooming or appearance. "Undeclared identifier error in line 46. And is that your feet or did a fish die under the table?"

Cats are unflappable. There are no errors. Either they meant to do that, or it never happened.