#52WeeksOfCode Week 30 – The R Project

Week: 30

Language: The R Project

IDE(s): R

History (official):

(From the R Project “What is R?” page)

R is an integrated suite of software facilities for data manipulation, calculation and graphical display. It includes

 

  • an effective data handling and storage facility,
  • a suite of operators for calculations on arrays, in particular matrices,
  • a large, coherent, integrated collection of intermediate tools for data analysis,
  • graphical facilities for data analysis and display either on-screen or on hardcopy, and

 

  • a well-developed, simple and effective programming language which includes conditionals, loops, user-defined recursive functions and input and output facilities.

 

Once again, this is what you get when programmers write your sales materials – nothing but facts.

Boring, tediously informative facts.

History (real):

In the Olden Days (™), if you wanted a computer to do your math homework, you had to use FORTRAN. It wasn’t what you might call ‘interactive’. You wrote your code, submitted it to the mainframe, which compiled and ran it. Assuming you didn’t have any typos, you got a printout of the results. (FORTRAN was my first programming language back in 1977. We used punch cards.)

This was always annoying and occasionally painful, but there were no good alternatives until the mid-70’s, when researchers at Bell Labs developed the programming language ‘S’. It was standard practice at the time to give programming languages single letter names.

I’m picturing the marketing meetings:

“How about ‘Bell Labs: We Don’t Have Time For This’?”

“Not bad. But I really like ‘Bell Labs: Smart But Terse’.”

“Love it!”

Moving on.

In the early 90’s, researchers at the University of Auckland, New Zealand developed a new version of S that they called R. Currently it’s being maintained by the R Development Core Team, with contributors  from all over the world. The name R is not just a play on the name S, but is also a tribute to the original developers, Robert Gentleman and Ross Ihaka, who were known at university as “R & R”.

R is free and available for Linux, Windows and Mac OS X. The source code is also freely available so you can compile it for any platform you like.

Discussion:

I’ve been looking forward to this for some time. I teach undergraduate math and occasionally blog about math education so math software is a particular interest of mine. I’m a firm believer in letting machines do the grunt work of mathematics. If you understand the problem well enough to explain it to a computer, then by definition you understand the problem.

I downloaded the Mac version of R from the main project site. R is a command line based tool so I wasn’t that surprised when I started up the program and got a window with a command prompt:

R for Mac startup window

R for Mac startup window

 

The window has a toolbar with easy access to common functions:

  • Load data or a script file
  • Open a new window (for charts and plots)
  • Authorize R to run commands as root (system administrator)
  • Show/hide R command history
  • Set R console colors
  • Open document in editor
  • Create a new empty document
  • Print this document
  • Quit

Most of your work is done at the command line.

Before we get going, I’d like to perform the traditional “Hello World!”:

Hello World! in R

Hello World! in R

This term I’m teaching an introductory statistics course so I’ve got some sample data from classroom exercises to run R through it’s paces. R stores with data tables in variables called data frames. There are pre-loaded data frames available in the software with which to experiment. You can enter data manually or just load the data from an outside source.

My data is in spreadsheet format and there are a number of ways to import spreadsheet files directly into R. Since I use Google Sheets as my primary spreadsheet program, the easiest way for me was to save off my data in CSV format. (Excel files can be imported directly.)

R assumes files are in the current working directory. The default is my home directory so I changed that setting to where I’d saved the files.

Get and set the working directory

Get and set the working directory

My first test data was a simple table comparing car prices to the age of the car. I chose a specific make and model (Toyota Sienna) and pulled these numbers straight from AutoTrader.com. I converted the worksheet and loaded the data table into R:

Car age vs. price data table

Car age vs. price data table

Now I can work with it directly. First let’s give it a once-over using the summary() function:

Summary of data table

Summary of data table

This gives me my central tendency numbers amongst others. Now let’s do a quick plot using using the pairs() function.

Data plot using pairs()

Data plot using pairs()

I got two plots, one with age as the dependent variable and other with price. I didn’t tell R which was which so it did both. I can be more specific using the plot() function:

Plot command syntax

Plot command syntax

This tells R that price is dependent on the age of the car. This gives me a single chart:

Chart using plot()

Chart using plot()

Now I can calculate the correlation coefficient with cor() to see how strongly the two sets of data relate to each other:

Correlation Table

Correlation Table

So price is negatively correlated with the age of the car, which fits what the chart told us. Older cars cost less, in other words. It’s a pretty strong correlation, too, at 85%.

Now we’d like to do some prediction so we’ll perform a linear regression on the data. First create a data structure with the regression data, then pull a summary:

Linear regression

Linear regression

Now you have a processed data set and you can continue working with it.

We can get data in and manipulate it but how do we get it out? For text data, such as the correlation summary, you can just copy and paste it from the R gui window. The plots appear in a separate window. I was able to click on the image, select Copy from the Edit menu and paste directly in a document.

R is a very powerful, interactive language for scientific and math computing. So why would you use it instead of a spreadsheet?

Frankly, if you’re not a full-on numbers nerd, you may just want to stick with spreadsheets. But they’re a general purpose tool and R has more math functionality. You can write your own functions and even groups of functions (called packages) to extend R even further.

Another advantage of R is automation. Anything you can type in at the command prompt can be saved into a file, letting you easily set up long, complex sets of calculations that can be loaded into your workspace with a single command. If you’re doing batch processing of multiple datasets, this can save a lot of time and effort.

The documentation is very good and there are plenty of tutorials and examples available at the project homepage and around the Web.

 

Advertisements

#Book Review – Code Reading

The reading of code is likely to be one of the most common activities of a computing professional, yet it is seldom taught as a subject or formally used as a method for learning how to design and program.

 

Aspiring writers are always told to read as much as they can if they want to become better writers. As Dave Thomas points out in his foreword to Diomidis Spinellis’ Code Reading, aspiring programmers almost never get this advice. By code, of course, I mean the program source code, the fundamental recipe for any piece of software.

Imagine that you’re taking a writing course. You get assignment after assignment – persuasive essays, memos, poetry, research papers or prose. Now imagine that you have to do every one of these assignments from scratch, without any examples. You have to work everything out yourself.

This is the traditional method of teaching programming. I know because I used to teach programming classes.

Code Reading is both refreshing and an eye-opener. Not only does Spinellis present a solid case for the habit of reading program source code, he also fills his book with code examples, complete with commentary. Though the examples are mainly from Java and C, the lessons learned can be applied to any programming language.

Just to be clear, the code presented is not from the toy examples found in programming textbooks. This is material from real, working software projects. The book covers major programming topics and even includes analysis of a complete, working program. Spinellis gives tips and techniques for the novice code reader to aid them in developing their skills.

From my own experience, reading code can be very educational, even entertaining. Every programmer tries to put their own personal stamp on their work and part of the fun is seeing the human mind behind the algorithms.

For example, I was teaching game software development and wanted to get my students some practice in reading code. We downloaded the source code for BZFlag, a tank game based on the video game BattleZone combined with Capture the Flag. It’s a fun, cross-platform game that you can play solo or over the Internet with teams.

There was one particular feature in which I was interested. During play, you can set your tank to AutoPilot mode and let it play for you. This makes a nice change from having to pause your game whenever you have to get up and take care of business.

We grovelled through the source code files for a bit and I finally found the sections having to do with AutoPilot. As I read them, I spotted some code that looked very intriguing but was never actually called by any other part of the program. It looked like someone was trying to build a heuristic system for the AutoPilot mode. In short, it was meant to have the program build a solution starting with the goal and working its way backwards. It was very clever and had a lot of potential. I could add see why it hadn’t been  implemented due to the inherent complexity of the method.

The fact that the code was just left there, unfinished, was fascinating. When I saw that code, I put myself in the mind of that programmer. I’ve also had coding ideas that got stuck in blind alleys. But here was someone like me, trying to solve a problem in an interesting way and failing that, leaving a note for the explorers to come after in hopes that they would ultimately succeed where he did not.

This book shouldn’t just be on any programmer’s reference shelf, it should also be the basis of at least one undergraduate programming class.


Spinellis, Diomidis. Code reading: the open source perspective. Addison-Wesley Professional, 2003.

#Coding4Humans #DIYMath FreeMat

(Cross-posted at We Hate Math)

Today in DIY Math we’re looking at  FreeMat. As the name suggests It’s modeled after MatLab. FreeMat has been in development for over a decade by a group of volunteers

System Requirements – Specific hardware requirements were not available but the pre-built packages I tested all run on 32 or 64-bit Intel-compatible CPUs. The application itself doesn’t seem to use much memory. As an example, the Mac version uses about 85 MB of real memory on my system. Since Windows XP is supported, we can assume that XP-compatible hardware constitutes the base system.

Installation – The latest version is 4.2 and is available for Windows (XP and up), Linux (various) and Mac OS X. In addition to pre-built packages for the above platforms, the source code is also available and is released under the GPL license. All versions of FreeMat are kept at the same version level and functionality.

Windows: Simply download the 52.5 MB setup file and double-click it. (NOTE: A portable version of Freemat is also available so you can run it from a thumb drive without installation.)

Linux – I installed FreeMat on Debian Linux using APT and on my system it was a 12 MB download, using an additional 22 MB of disk space.

Mac OS X – The installer is a 79.5 MB compressed disk image (DMG) file. Double-click the file to mount it, then drag the program and documentation to your Applications folder. The two files together take up about 250 MB of disk space.

Documentation – The Mac download comes with a PDF manual detailing all of the functions available in FreeMat. (For Windows or Linux, you can download the manual here.) The manual is automatically generated using Doxygen, which scans specially marked comments in the source code and outputs documentation in a variety of file formats.

This is both a good thing and a bad thing. It’s good in that it makes it easy for developers to actually maintain their documentation, assuming they remember to update the comments. It’s a bad thing because there’s no guarantee that the resulting document will be well-written. In fact, the included manual is very sparsely written, despite the 162 page (!) table of contents. It is less a manual than simply an API reference. Each function or class is briefly described and includes one or two usage examples. The target audience for this manual are those who don’t need a manual. It’s comprehensive but very terse.

A much better option to start with is the FreeMat Primer. Who’s the audience? Let the authors (Gary Schafer and Timothy Cyders) tell you:

We assume that you have Freemat properly installed and working. If you have any issues, direct them to the online Freemat group, http://groups.google.com/group/freemat.

This book was originally written for the Windows version. The book now covers more of the Linux and Mac versions, as well. In those cases where there are differences, we’ll point them out.

It’s a much friendlier introduction to the software. It’s very readable, with plenty of screenshots, little tutorials and code examples. With this and the official function reference you have a very good documentation base. In addition, there is also a Google group available for more interactive support. There is another Google community intended to host FreeMat tutorials. (At this time the content is a bit sparse.) You can also type helpwin at the command prompt from within FreeMat.

Compatibility – Based on the scripts I tested, MatLab support is somewhat hit-or-miss. I’ve been able to run scripts with no modifications, minor modifications or not at all. I would suggest that you test your Matlab scripts on a case-by-case basis and then decide whether you want to make the changes or just re-write from scratch. The scripting syntax is similar enough that most of your work will be figuring out equivalent function calls.  (A MatLab to FreeMat translation guide would be a really good project. Better yet, some kind of conversion tool.)

Command Line vs. GUI – The Windows and Mac versions of FreeMat are targeted at a graphical interface so accessing the tool from the command line is at best a non-trivial . The Linux version can be launched from the CLI. With no parameters, the graphical client starts up by default. To use the CLI version only, start the tool with the option -noX or -nogui to suppress the graphical subsystem This will give you a FreeMat command prompt in your terminal window. If you simply wish to run a Freemat command and then exit, use the option -f to run the tool in command mode. (NOTE: if you want to see the output of your command, make sure to specify that as FreeMat will not show any output.)

Integrating FreeMat with your native scripting environment is problematic (okay, just about impossible),as FreeMat scripts are meant to be run from within the FreeMat interface. You can edit them inside FreeMat or using your favorite text editor but make sure that they are saved to FreeMat’s working directory. (You can set this up by running pathtool from within FreeMat.)

 

The GUI for each version is comparable in look and feel.

FreeMat Interface

FreeMat GUI

This is from the Mac version of the tool. In addition to the main terminal window, FreeMat also tracks your command history (allowing you to invoke a previous command simply by double-clicking on it), tracks what variables are currently in memory, along with their data types and values if applicable. The Debug window is supposed to show any error or warning messages but on all three platforms I tested, the messages showed up in the main terminal window and the Debug window remained blank.

Summary

Pros: Easy installation, all supported platforms are kept current with a common codebase, decent documentation and online support.

Cons: Development progress is a bit slow. The latest release (4.2) was posted in June of 2013 and that was two years after the previous release. CLI support is limited or non-existent in the Windows and Mac versions and all scripts are restricted to running within the FreeMat environment. Third party support is a bit anemic.

Would I use this in my class? – I would feel confident recommending this to my students. The ease of installation and minimal setup are a definite plus, you don’t need the latest hardware to run it and the price fits everyone’s budget. It supports nearly everything we might do in 100- and 200-level math classes with enough overhead room for more advanced work.

#DIYMath – Math Wants to be Free

(Cross-posted at We Hate Math)

As a programming and math nerd, I’ve certainly made good use of Wolfram Alpha. After all, it’s free*, it’s ubiquitous (all you need is a Web browser but there are also apps for both Android and IOS) and it’s natural language interface is very powerful and easy to use.  It’s certainly a cost-effective alternative to commercial math packages like Matlab ($50 – $2,150) or even Wolfram’s own Mathematica. ($139 – $2,495)

However, much as I love the folks at Wolfram, it’s nice to have your own math software that:

  • doesn’t require an Internet connection
  • runs on computers you control
  • still gives you a lot of power and flexibility

It’s even better if the software is:

It turns out that there are several software packages that fit the bill, each with their own strengths and weaknesses but all absolutely free and cross-platform. With that in mind, I’m going to be reviewing each of them from the perspective of a teacher and casual programmer. To keep things consistent, I’ll be looking at the following categories:

System Requirements – Because there’s no point downloading the software unless you can actually run it.

Installation – How easy is it to find and install the software? How big of a download is it and how much disk space and RAM does it need? How does installation compare between platforms? I’ll be installing the software on Windows 7, Debian Linux and Mac OS X Mavericks and comparing the experience.

Documentation – Does the developer offer good documentation and/or tutorials? (By ‘good’, I mean documentation you are actually expected to read**.) Is information available from third parties?

Compatibility – Like it or not, MatLab and Mathematica are the big dogs in the math software field. How easily could a MatLab or Mathematica user transition to this package? How easy is it to port code? The easiest way to test this is to see if scripts designed for MatLab or Mathematica will run with minimal or no modification.

Command Line vs. GUI – Some of these packages allow you to run them from the command line as well as in a graphical interface. This is very useful as it allows you to integrate the software with your native scripting language for easy automation. How do the two compare? Do both offer the same functionality? Does the software operate in the same way on different operating systems?

Summary – Pros, Cons and whether I’d recommend this to my students.

As I’ve said, I’m looking at this from the perspective of a math teacher. Are there other aspects of the software you’d like me to examine?

*for a certain definition of ‘free’

**I’ve noticed that a lot of open source software documentation seems to assume that the target audience are those who don’t need to read it. Yes, poor documentation makes me cranky.

#52WeeksOfCode Week 14 – C++

Week: 14

Language: C++

IDE(s): XCode

Background:

It’s been a few years since I’ve used C++. I started out with Fortran in 1977 (with punch cards…pardon me while I adjust the onion in my belt), then Basic, moving on through Pascal, shell scripting,Lisp, Assembler, awk and C. I generally picked up programming languages as I needed them for work or school. (Frankly once you get past the first two or three, it becomes easier to get up to speed on new ones. The trick to learning a programming language is to have a project that holds your interest.)

C++ was basically the C language with some extras. (The name is a bit of an inside joke, meaning literally “increment C by 1”.) So this means that you can mix C code with C++ code and it will still compile and run. It’s not a good idea, for the sake of manageability, but it will work.

I like C++. I was comfortable with C and C++ added enough good features that the transition wasn’t too tough. (C# on the other hand…I’m not a fan. Just my opinion.)

C++ was my first introduction to Object-Oriented Programming (OOP). Previously, I felt like I had to micromanage every activity of my software. With OOP, however, I could create software objects with properties (things they know) and methods (things they know how to do) and just set them loose with instructions. It seemed pretty natural to me and there was a good library of pre-written objects that I could use so I didn’t have to re-invent the wheel.

At the time, C++ and Java were the New Hotness so these were the languages I taught in my school’s Software Engineering program. C# did come up later and we incorporated it into the curriculum, displacing both C++ and Java.  But before that happened, I discovered two of what are still my favorite C++ textbooks:

Fundamentals of C++ and Data Structures (Lambert) – Despite the title, this is a surprisingly friendly book. You will need to have some programming background but the book opens with a quick review of the essentials of C++. The writing is friendly, with plenty of diagrams and code examples and it even walks you through the math of analyzing algorithms, a topic that can be a bit intimidating to the newbie coder.

Beginning C++ Game Programming (Dawson) – This is a surprisingly subversive book. Your typical programming textbook is pretty dry and full of dull, mostly theoretical assignments. They might try to liven it up a bit by having you ‘create an inventory management system for a video rental store.’ Get it? Because renting videos and managing store inventory are what all the cool kids are doing these days!

But Dawson takes a different tack and I applaud him for it. He spends a lot of time talking about computer games and how they work with plenty of examples. The fact that these examples just happen to use the programming technique in the current chapter is just a happy coincidence. So the student spends the entire time messing around with games and by the end of the book is dealing with topics like inheritance and polymorphism. I think this is brilliant especially since my edition is copyright 2004, several years prior to the gamification of learning to code. I’m not sure why more computer textbooks for beginners don’t use this technique. I think you could even teach math like this. (Note to self: idea for a math textbook….)

Both of these books still have pride of place on my bookshelf.

Discussion:

C++, Java and C# were all designed to solve the same problem – those darn programmers. All of these languages impose structure and new rules on programmers in an attempt to keep them from stomping all over system resources either accidentally or on purpose. C++ and C# did this by building on C (C# added some features like garbage collection from Java) and Java just wrote the rules from scratch.

As a result, C++ and C# still let you write misbehaving programs and count on you wanting the new features enough to code in a safer, more managed fashion. Java doesn’t let you do that, which is why some programmers think Java is too structured. Which, to Java, is sort of the point.

Once again, this week’s program is pretty simple. Just a little hangman program with some sample code from Dawson:

macpro15:week_14_cplus tsinclair$ ./week_14_cplus
Welcome to Hangman.  Good luck!
You have 8 incorrect guesses left.
You've used the following letters:
So far, the word is:
-----
Enter your guess: e
That's right! E is in the word.
You have 8 incorrect guesses left.
You've used the following letters:
E
So far, the word is:
-E---

Enter your guess: l
That's right! L is in the word.

You have 8 incorrect guesses left.
You've used the following letters:
EL
So far, the word is:
-ELL-

Enter your guess: h
That's right! H is in the word.

You have 8 incorrect guesses left.
You've used the following letters:
ELH
So far, the word is:
HELL-

Enter your guess: o
That's right! O is in the word.
You guessed it!
The word was HELLO

 

In case you’re interested, the source code is available here.

 

References:

Lambert, K., & Naps, T. L. (1998).Fundamentals of program design and data structures with C. Cincinnati: South-Western Educational Pub.

Dawson, Michael. Beginning C through Game Programming. Australia: Course Technology, 2011. Print.

#52WeeksOfCode Week 9 – Google Maps

Week: 9

Language: Google Maps API

IDE(s): MAMP, TextWrangler

Background:

Everybody gets so much information all day long that they lose their common sense.

Gertrude Stein

(Sorry about the late post this week. Real Life[™] sort of caught up with me.)

Common sense would indicate that the more information we have, the better decisions we should be able to make. We currently have the ability to collect and access more information than at any other time in history. This should be a Golden Age where we can solve problems and find answers to questions that have bedeviled mankind since the dawn of time.

This is the premise (somewhat) of what is popularly known as “Big Data”. We have more information than ever and that turns out to be a problem. First, information is not the same as wisdom. We need the tools to analyze information so we can draw conclusions out of it. Unfortunately we have so much of it that most of our current tools are overwhelmed by the sheer volume that needs to be processed.  In addition, information is traditionally kept in ‘silos’, isolated from related content so that it’s difficult to get a complete picture. There is also the trust issue. In other words, it’s hard to convince people or organizations to share their information.

But many companies are still soldiering on, convinced that if only they just knew enough things about enough things, they could accomplish miracles.

No company presents a more public face for Big Data than Google. They not only gather and process massive amounts of information (Google Search, Google Maps, Google News, YouTube, Google Scholar) but they also sell massive amounts of information (targeted ads based on your search terms, your online video preferences, your Gmail messages) as well as give others the ability to process their carloads of data as well (Google Analytics, Google BigQuery). In fact, I use Google Docs for much of my writing and I notice links pop up in the research pane based on what I happen to be typing.

“My internet browser heard us saying the word Fry and it found a movie about Philip J. Fry for us. It also opened my calendar to Friday and ordered me some french fries.”

– Hubert Farnsworth, Futurama, “The Luck of the Fryish”

Discussion:

Google Maps data is accessible to IOS, Android or Web developers. There is plenty of documentation available and I started here. Similar to working with Twitter, you need to create a key to identify yourself when your software talks to Google’s servers. Fortunately this process went much more smoothly than my Twitter experience.

So I used some sample code and, in keeping with the tradition of these posts, modified the HTML code to produce a map that centers on Hello World Communications. Here’s a grab of the browser window:HWC.png

The code I used is here (my API key has been redacted).

#52WeeksOfCode Week 8 – Java

Week: 8

 

Language: Java

 

IDE(s): Eclipse, Netbeans

 

Background:

Consider the vast communications gap between human and computer. The latter sees everything as a flow of current with subtly varying voltages (that we imagine as 1’s and 0’s) while the former uses a combination of mouth sounds, facial expressions, gestures, body language, context (time, day, weather, inside/outside) to convey meaning.

Now consider programming languages as existing in a multi-layer continuum bridging the gap between humans and computers. At one end we have machine code  and at the other “Siri, where can I get a good cup of coffee?

In between we have a choice of either compiled languages (which are converted to machine code before they can run) or interpreted languages (which are sent to an interpreter which then translates them into machine code on the fly). The closer a language gets to the hardware layer, the more a program needs to be modified when you want to run a program written in that language when you change hardware. Not only that but languages that are able to directly address the hardware are more vulnerable to malicious or insecure code.

So at the end of the 80’s the computer world found itself in a quandary. Scripting languages were very portable but didn’t have the power or efficiency to scale up for serious work. On the other hand, compiled languages were not readily portable and further didn’t protect the computer from a bad programmer. In addition, with the rise of the public Internet, networking and remote code execution were becoming terrifically useful but these capabilities weren’t readily available in existing programming languages.

In 1991, James Gosling developed a language called Oak (later renamed to Java). It combined the advantages of interpreted languages in that it was highly portable and compiled languages (the code is compiled to bytecode which is then quickly compiled to more efficient machine code at runtime.) In addition, it had built-in support for networking as well as remote procedure calls. Java was similar enough to existing languages like C/C++ so that it was fairly easy for experienced programmers to learn. Java programs run in the Java Virtual Machine (JVM) which adds a layer of protection for the underlying operating system.

Discussion:

I like Java. If you have an orderly (okay, maybe a little OCD) way of thinking, programming in Java feels very structured and organized. It’s sort of the programming equivalent to using Lego. Java has a substantial library of reusable code so you don’t have to re-invent the wheel.

Java is not without its disadvantages, however. The price of portability and protected code means that the JVM is the limiting factor in performance of your application and it uses more memory than native code.

The barrier to entry is Java programming is very low. The development kit is cross-platform and available free of charge. The documentation is readily available online and tutorials are easy to find. All you need to start coding in Java is a text editor (once you’ve downloaded the JDK). But I don’t recommend it unless you’re a fan of working at the command line. There are GUI IDEs available, however. Two of the best (free) ones are Netbeans and Eclipse.

I’m torn about Eclipse. It’s free, cross-platform and very powerful since it has a plug-in architecture that lets you easily add new capabilities, including support for C/C++, PHP and even COBOL. The problem is that Eclipse is not, shall we say, ‘for the weak’. With this power comes considerable complexity and even with available tutorials, getting started with Eclipse can be a very intimidating experience.

NetBeans, on the other hand, is a much friendlier experience, particularly for someone like me who hasn’t worked with Java for about five years or so. In any event, I don’t recommend Java for beginning programmers. You really need to be comfortable with object-oriented programming (OOP), plus the state of the art of programming has moved on since the 90’s, with friendlier languages such as Ruby and Python available today which are much more accessible to beginners.

My program this week was a simple animation, developed using code from Beginning Java SE 6 Game Programming (Harbour, Jonathan S. Beginning Java SE 6 Game Programming. 3rd ed. Boston, MA: Course Technology, 2012. Print.) This is a very well-done book which takes you from a basic introduction to the Java language to vector and bitmap-based graphics, 2D and 3D animation including sound effects and music. All of the examples come with sample code, which is very well documented.

This program simply renders a 2D animated sprite and bounces it around in a window on your desktop. All I did was replace the default animation with one of the word HELLO morphing into WORLD. (A link to the animation frame image is here.) The source code can be found here.