From Karel to Java

While there is conceivably gads to learn just in programming Karel to do assignments, or invent problems to solve with the simply robot, the goal is to learn Java itself. At Stanford the class leaves Karel behind after the first week, and the class moves pretty fast. Last week I got interested in extending Karel, almost cheating by using more advanced solutions than called for and exploring things in Karel that aren’t covered in class, like her paint methods.

At the same time, I want to continue learning at the speed of the class or if possible, faster. I’ve done Java before, so much of this I’ve seen before. I would say thus far I have gained in some experience solving more problems in the assignments than I did when I originally set out to learn Java almost twenty years ago more than learn anything. At lecture 7, I’ve still not seen anything truly new for me. Going through the lectures certainly helps clarify and clear memory cobwebs from the first go around.

While going through lecture 7, I know that very soon I’m going to bump into things that I may have seen before which perplexed me and was never used. That is the true value for me taking new stuff that hearkens old stuff I learned a long time ago. I am wiser, if not smarter today than I’ve ever been. My life experience lets me review materials that I’ve gone over before given new light from learning outside the discipline of programming. This is easily explained by something from somewhere else.

There is a great analogy about filling a big jar with pebbles, one at a time. This instance of the analogy might not be perfect, it’s simply how I think of it. When you want to go fast, you want to avoid grains of sand and start with bigger pebbles the size of the biggest rocks that fit. You’ll filling as much space as possible. You’re also not filling as much space as you could with sand. When you can only go one pebble at a time, start with the big stuff and eventually you will only have enough room for small pebbles and sand.

If what I know about programming is silo’d into a metaphorical jar, twenty years ago I got the big rocks in and largely filled programming Java. I knew generally how Java worked to do things, what some of its limitations were and where it would be extremely useful. The learning long ago informed my thinking around the Search Return Sidecar. The big concept is write once, run anywhere, including applet implementations that live client-side on the browser. It’s a truly platform independent software programming language. Now it’s time for me to work on filling the rest of my jar. There’s a terrible pun there, if you see it.

Shortcuts With Karel The Robot

Looking for shortcuts in the programming assignments for Karel the Robot taking Stanford’s CS106A online. The instructor knows Karel doesn’t have full functionality of the Java language but a good portion of them. They also intentionally offer two versions of the class: Karel and SuperKarel. I’ll jump ahead.

The class and instructor move as quickly as possible through the material, so sometimes there are things which should be forgiven. In my case, I came to the class having some experience almost twenty years ago programming Java and I can’t help but remember what I learned. In the instructor’s case, there is one small error I noticed that flies by and no one seems to catch it.

It doesn’t matter either way, as long as I get the value from the class material I’m going through in order to better prepare my capability to take Sidecar 2.0 to the next level. Karel the Robot doesn’t turn around, or turn right in order to teach us to program those methods. In the case of the instructor teaching us to program a method for turning left three times for turn right, he said 6 lefts turns would do the same thing.

That’s not true. It would take seven left turns for Karel to have rotated to the effect of ultimately turning right. No big deal right? Well when I was going through to complete the code assignments for class, I realized after looking at the solutions that I was cheating with Karel the Robot. After a class where I was reminded how to use the ‘for’ loop for counting, I used it for assignments that involved counting.

When the class solutions were revealed, often I realized that I missed the concept of the instruction by way of my cheating using counting. For example, I was to drop a ‘beeper’ in the middle of a street. I simply counted steps to the end of the street using a ‘for’ loop for the move() method, divided by two, turned around and used the count variable to walk halfway back, dropping the beeper. If only I could do that with my taxes 🙂

Creating Worlds for Karel the Robot in Java

One of the things you’ll find taking CS106A at Stanford online, is that the version of Eclipse Stanford uses for teaching the course comes with Karel the Robot. You can probably figure out how to get it to work in any version of Eclipse, or run Karel the Robot in any Java IDE but I learned a valuable lesson trying to do this that to save time, I should just stick to the program as set out by the school.

I’m such a rebel. So I want to create my own worlds for Karel just so I know how. The interface is clunky but works fine. You can click and drop construction items like walls and beepers and you can define dimensions. What I liked about looking at world files is that I can do a lot of this in text and skip the interface altogether. The advantages are I don’t have to fight with the clunky click-drag actions on my touchpad.

The things to be aware of is that you still load worlds but can use the file browser to go find worlds you’ve built somewhere in your filesystem. Keeping everything relative to the path where your program resides can save you time navigating. Just remember to name new files the the dot ‘w’ extension, as in filename.w, and Karel the Robot can load your worlds. Be aware of your max 50×50 size limit.

Karel the Robot’s world definitions for Standford CS106A lecture one:

Dimension: (6, 3)
Wall: (4, 1) west
Wall: (4, 1) north
Wall: (5, 1) north
Wall: (6, 1) north
Beeper: (2, 1) 1
Karel: (1, 1) east
Speed: 0.00

You can use the built-in Textedit program on your Mac (or notepad.exe in Windows) to edit this definition file. The best reason I can think of for writing worlds for Karel the Robot is that, not having physically attended the class, the world from the first lecture is not there by default. A blank Karel the Robot starts with a world that has no objects (except the robot in the starting position) and a 10×10 grid. Knowing how to create worlds should help you follow along the way I did.

Steve Jobs PBS Video Interview

Check out what Steve Jobs is saying here, and consider it in context with the time it was filmed. He describes the spark of a computing revolution coming from a spreadsheet program. It was that program he cites as being responsible for Apple’s success. Computers do great at math, as the name “computer” implies. It follows what came next, brought print to its knees.

Now if you’re interested in my additional observations, note his prediction at the start of the 1990s he alludes to ‘interpersonal computing’ and the Internet from DARPA. His idea of the future held true for the following two decades, not just one, as the first was marked by strides in networking on the Internet itself which led to a second wave resulting in the social media of today.

The infectious fun we had in the ‘beehive’ days of I-Search starting in 1997 through to the ocean of distraction that is social media today, you can see where Steve Jobs is caught in that time thinking about the future of possibilities. The age of interpersonal computing as described by Steve Jobs is here. I am struck by other thoughts from his NeXt software initiative and platform thinking.

The notion of platform thinking intrigues me greatly. Apple has taken this to a great height by way of confining the Mac operating system to a mobile extension with touch features built into iOS. The revolution we are seeing now is his vision played out in the third decade, one that hearkens back to the terminal days of the mid-seventies. The tablet is the terminal we use to log into the cloud.

He also speaks of wanting to be able to operate his computer separate from the cloud. The iOS platform delivers this. He also wants third-party developers to extend on the platform designing software to make the whole machine more valuable. The Apple store delivers this. The difference in thinking between Apple and Google is that the closed architecture ensures quality that Google is missing.

The approach I want to take with Sidecar, after the original Sidecar prototype, is in pursuit of what can be done with the concept of platform thinking in a microcosm of distributed Web crawling software that is Sidecar. The goal is to realize with software code what I-Search was like for me more than ten years ago. You can hear Steve’s enthusiasm for something he lived to see in his lifetime with email lists such as I-Search and later ultimately with what Twitter is now. The power of our connected world can bring us together to conferences, or allow us to benefit without being there.

On a personal note, I was lucky enough to work with Kevin Mitnick to put together the more difficult cryptograms for the paperback version of his Ghost in the Wires. When Steve Jobs remembers building ‘blue boxes’ with Woz, I know Kevin was doing the same thing. Kevin and Woz are now friends. I was on the phone with Kevin when news about the death of Steve Jobs came across Twitter. We both took note and he wanted to immediately break away and call Woz about it. Regardless how the media characterizes relationships, Steve and Woz were close by way of their shared history, which is special to them.