Introduction to Programming

Taking an introductory programming course this semester has been an interesting experience. Since I grasp the course material well, I’ve spent some time helping others with their work. As anyone who has taught math can attest, teaching even basic concepts requires you to understand the material far better than the student must. When it comes to programming, helping people is even more difficult because you can’t just tell them how to do it. You need to let them to figure it out on their own, otherwise they won’t have learned anything.

But leading someone along without explicitly telling them anything is really, REALLY difficult. Our professor is a master at this, and I respect him deeply because of it. A student will ask a question, and the professor will reply with an oblique statement that doesn’t seem to address the student’s question at all. Yet soon enough the student says “Oh! I get it!” and goes on their merry way. I try as hard as possible to emulate this method when I help those who are struggling, but it is nigh impossible to strike the correct balance. Help them too much, and they don’t learn. Help them too little, and they despair or begin to resent programming. And as much as I don’t like seeing it happen, many of the people in the class have come to resent programming.

This is as sad as a student resenting literature because of a bad English class experience, or resenting math because of a bad math teacher. Yet I don’t fully understand how to prevent it. If there was a good, standardized methodology for teaching difficult concepts without causing students to resent the field, I feel a lot of the problems in society today could be solved. Maybe that is just wishful thinking, though.

The second interesting observation from taking this class has come from observing a peer. The first language she learned was Python, and learning C++ this semester has caused some distress. There were many lamentations along the lines of “why is the computer so dumb?!” Of course, I found this hilarious because it mirrors a situation in the novel A Fire Upon the Deep. As the protagonists head towards the bottom of the Beyond, much of their advanced computer technology stops working, and they are forced to adopt more primitive methods. Needless to say, the characters who grew up with the advanced technology are indignant that they are forced to use such primitive technologies as a keyboard. Meanwhile, the character who grew up using primitive technology merely smiles.

In my mind, this helps clear up the argument of whether new students to the art of programming should be started on a high-level language, or a low-level language. Until such time as low-level programming is never needed except in rare circumstances, students should be started at a medium-to-low level. For example, it is easier to step up to Python from Java than it is to step down. I was originally of the mind that new students should start at a high-level as to learn common computing concepts without getting bogged down in obtuse technicalities and syntax, but getting a first-hand view of the results of such an approach has changed my mind.

Advertisements

The Simulation Problem

(No, not this)

I’ve been struggling with this problem for a while now every time I sit down to start playing KSP. As you may know, I am a huge space enthusiast, and a stickler for realism when it comes to portraying space and science topics. Then, of course, I also like playing fun video games. So I’m fundamentally at war with myself when I ask myself: how much realism is enough?

The key here is not striving for realism, but making it feel realistic. This means simulating what I know, and glossing over that which I know nothing about. Yes, this is lame. Additionally, there are some things that take far too much effort to simulate realistically — engine physics, weather patterns, n-body gravitation, physiology.

This problem has been eating away at me enough that I haven’t actually been able to play KSP. I tried a variety of different play styles, but ultimately I got stuck on one problem: I wanted my rockets to be as small as possible, and to take the optimal ascent route.

As I began researching this problem, I realized it was not trivial. In fact, planning an ascent path is quite complex, and the equations have a large number of parameters. Another compounding factor was that there is really no good documentation on the internet about ascent patterns. I’m not sure if this is because that information falls under some sort of ITAR restriction, or just because nobody is interested in it. I wasn’t even sure how to start thinking about it. I knew there was something called a “pitch-over maneuver”, but how does it work? Do they pitch over at a constant rate starting at some altitude, or is a more complex function? Are there multiple pitch-over functions? I could find nothing that answered this.

The second problem was that it is not easy to simulate rocket ascents. You have to account for the curvature of the Earth, so it is not a ballistics problem but a set of differential equations in a polar coordinate system. I tried some basic solution in both Scilab (a free version of Matlab) and in Python, but in both cases the complexity of the problem became so great that I threw up my hands before reaching a satisfactory solution. I mean, it’s hard enough if you consider one stage, but once you consider that a rocket can have any number of stages, the design space spirals out of control.

The design feedback loop

This problem would not stop bothering me. Every time I sat down to play KSP, I realized I was sitting down into a self-imposed math nightmare. Then after that nightmare was solved, I would still be stuck with a inability to truly simulate all the aspects of spaceflight I wanted to simulate, at least not without a lot of work making my own mods.

The moral of the story is: you can’t trust the system. don’t mix realism/math and videogames.

(There is another corollary problem, which is that Reality Is Unrealistic. We have these notions of how phenomenon look drilled into our heads by TV and movies, but the truth is often different and less COOL. Unfortunate that we have been trained to have that heuristic for coolness. TV Tropes says it best. An interesting example is Star Citizen, which shows the ship engines as firing all the time — even when they are off in the physical simulation — because it “looks cool”. Sigh.)

I’m Not Part of that Generation

There is something that really irks me. People have this tendency to assume that kids are ignorant when it comes to “older technologies”. This is akin to assuming that anyone of non-Caucasian ethnicity is a recent immigrant. Please don’t assume I don’t know what a landline is. I’m 17, but I’m sure this applies to younger kids.

Here is a list of the most common ones:

  • Records: I have a friend who owns a record player and shops at record stores.
  • VHS tapes: My childhood memories include watching movies on VHS. I still own VHS tapes and a VHS player.
  • CDs: Really? This is not an outdated technology.
  • Floppy disks: Again, I can remember using floppy disks, and it wasn’t that long ago.
  • Landlines: Everyone I know has a landline.
  • Manual transmissions: I have a friend who recently bought a new car with a manual transmission. He prefers them.
  • Dialup: I can’t speak for everyone, but I’ve used dialup before.
  • Dedicated flip phones: Some of my friends still use those.
  • Cassette tapes: Most cars still have tape players, and most people probably have a selection of tapes sitting around somewhere.
  • Life before the mainstream Internet: I was there.
  • Radio: NOT AN OUTDATED TECHNOLOGY.
  • Books: Stop that.

So, for the sake of everyone, please don’t immediately assume a kid doesn’t know what a given technology is. Maybe they don’t, but it’s offensive either way.

Obsessive Rationalization of Unrealistic Genres

I am constantly amazed and disappointed by people’s perpetual insistence on willful ignorance and disregard of logic. It is common to tout that people are able to “distinguish reality from fiction”, but I am finding that hard to believe. This ailment is especially prevalent in fans or supporters of a particular lore; enjoyment of a genre appears to be a debilitating disease that leaves its victims completely incapable of making concessions to critics.

Let’s examine two examples. First, zombie lore. The genre is wide and diverse, but is generally accepted to be a gross fabrication and completely improbable, right? Nope. There is a fixation on coming up with more and more “realistic” explanations of how a zombie apocalypse could “actually” come to be. This is true both in media — we see the introduction of terms like “infected” to make the scenarios seem more authentic — and in the fan culture surrounding it. Look at any article on the Internet pointing out the most obvious reasons that a zombie apocalypse would never arise, and you will see a flood of comments defending the feasibility of such a scenario. Do they think that pointing out the unrealism of the genre is somehow offensive? That explicitly distinguishing reality from fiction (in a genre that is constantly trying to move the latter towards the former) somehow invalidates the fiction? It boggles my mind that people feel the need to defend the feasibility of a clearly fictional and improbable scenario.

But this feeling of wonder is only compounded whenever I accidentally wander near Star Wars or Star Trek fans. Both these franchises are clearly future fantasy (where technology serves only to further the plot, as opposed to hard science fiction, where there is a clear bi-directional interplay between the two). Yet many fan sites are created to help flush out the technological lore and attempt to apply rational, scientific explanations to the events in the media that are clearly only in service to the plot. If you point this out to a fan, they will become indignant and start explaining their way around any obstacle you toss at them. Never mind that the whole thing is fictional and doesn’t actually need to be scientifically accurate in order to be entertaining (and in fact was never intended to be scientifically accurate). This madness continues to the degree that later productions in the franchise may even try to explain some of the happening with science, but 9 times out a 10 this only bungles things up further.

Anyways, I wish die-hard fans would accept that they are fans of a fictional entertainment franchise that not only isn’t realistic or feasible, but in fact doesn’t need to be in order to be entertaining. Being unrealistic does not invalidate zombies or Star Trek or Star Wars in any way. So get over the fact that none of those franchises make any damn sense.

Computer Mysticism

Last weekend I installed two different versions of Windows on two computers. One was a brand-new PC I built myself, and one was an HP that needed a reinstall. One needed a VPN connection to the MIT network to validate. The other one needed to have its proprietary drivers backed up and restored.

There’s a certain magic to computers when you start getting into the low-level stuff. I don’t mean programming-wise. Reinstalling Windows is more of a mystical art than a straightforward process.

Ancient forum tomes are filled with archaic tutorials. Software is a moving target, and complex formulas and hacks are prone to break down over time.

But even worse is the amount of superstition that gets poured into computer maintenance. Each user has rituals that they are convinced ward off errors. Actually, we see this in all sort of technology usage; people have rites designed to improve buffering speed, battery life, and disk readability. I know a group of people who have a running joke that involves standing on one foot when doing any complex computer maintenance to make it work.

The reclusive Linux alchemists mix their own potions (disdaining the draughts pushed by the shops in town), but use indecipherable notation in their recipes. Elixirs are delicate brews, and the average person doesn’t have the same instincts that let alchemists be productive.

Yet after going through the ordeal of reinstalling Windows or constructing a computer from scratch (and having it work!), you have a lingering feeling of power. The minor incongruities and annoyances that plague modern software usage no longer make you feel helpless. You are an empowered user, able to conquer any confounding roadblock. You may not be a mage, but you aren’t completely powerless under the whims of the wizards in the grand Corporate Tower.

Javascript

Honestly I’m not sure who thought it was good idea to make this language. I’ll admit its better than PHP, and I understand that some people actually enjoy using it. For instance, there is a web server written completely in JavaScript (hence my comparison to PHP). This boggles my mind.

My main issue with it is that there are no high level features built inherently into the language. For instance, there isn’t even an agreed upon method for importing other JavaScript files. Inheritance? Going to do some pretty messy hacks in order to get something that acts like an inheriting class structure. How about maps (aka dictionaries)? Objects and maps are the same thing. Arrays are basically just hash-maps for non-negative integers.

I suppose it’s about interesting exercise in thinking. Treating every structure (including classes and functions) as variables had its upsides. Ultimately, though, you have to use it whether you like it or not. There’s no substitute for the client-side functionality it provides. CSS can only go so far. When you start looking at something like AJAX, it makes you cry simultaneously at the pain of working with it and in joy for all the opportunity it provides.

The reason I have been thinking about and working with JavaScript (although only dabbling, of course) is that I’ve been taking another course at Udacity. This one is on game development in HTML5. Before this course, I really had no idea what HTML5 was. I had heard it mentioned, but then it all blew over. HTML5 is, to the best of my understanding, a standard that introduces some new HTML elements and JavaScript standards that lets developers manipulate pages in more creative ways.

For closing thoughts, I’ll leave you with this hilarious “talk”:

A Solution for Difficulty Curves and Power Creep

Most games portray you as a hero of some sort. A common trope is for the hero to be either inexperienced at the beginning of the game, or lack his equipment. This gives a reason for why the hero does not just plow right up to the main baddie and kill him at the beginning. In any case, a lot of games suffer from a strangely shaped difficulty curve. The game starts out fairly easy as the player learns the ropes, then the enemies get harder. Finally, you max out your stats and the game begins to get easier again.

Granted, the best games suffer from this less, but a lot of games have trouble with this type of power creep. Spore is a prime example of a ridiculously easy endgame (the space stage was essentially a sandbox). Some developers solve this by making enemies more powerful as the player progresses. This can work in games where, for instance, the enemy starts to realize just how much of a threat you are. In open-world games like Skyrim, though, this makes little sense.

Yahtzee, of Zero Punctuation, mentioned in one of his Extra Punctuation an inkling of an idea for a game that is designed with this problem in mind. I have taken the liberty of gripping the nebulous concept by the horns and fleshing it out.

The game is based around the power suit you wear. It is a magnificent piece of High Technology. Unfortunately, this means that nobody is quite sure how it works. The machining of the piece is much too fine to replicate, in any case, which means any replacement parts have to come from other pieces of High Technology, which are few and far between.

At the start of the game you escape from the main fortress of the Bad Guys with some sort of Valuable Item (perhaps information). You raid the armory and steal the suit before plunging yourself deep into the wilderness around the citadel. You spend the game running from a cadre of pursuers, trying to make your way to the border. At every encounter with an enemy, it is up to you to protect your suit as much. Each blow is physically simulated and, depending on where you place armor, where the hit was, how hard it was, etc. a component on your suit has the potential of breaking. Parts also wear down over time.

The most critical part of the game is deciding how to keep your suit in working order. Some systems are critical, like the pneumatics that let you move (damage to arm parts may impair aiming speed, damage to legs may reduce speed or jump height, etc), and some are dispensable, like weapons. If a critical system receives a hit and becomes in critical danger of breaking down, you have to stop and either fix it with any spare parts you find, or scrap a non-critical system on your suit to get the essential parts.

This meta-game with the suit solves the problem of power creep. You are at maximum power at the beginning, but enemies are also at the greatest density. Slogging through the wilderness and fighting enemies wears your suit down, so by the end you are barely limping along. As time goes on, you have to choose which weapon or system to scrap for parts. This means that you get a sample of all abilities at the beginning, and can keep the ones that best suit your play style. One of Bioshock’s biggest problems was that there was no incentive to try new plasmids. I’m sure the majority of players just improved the starting set, because buying new powers was too much of a liability.

I like the idea of having the game being mostly free-world. You can choose the best path through the different types of terrain to avoid encounters. Cold environments, wet environments, and sandy environments all have different types of wear and tear on the suit. Roads are easy to traverse (meaning less food consumption and lower likelihood of suit failure) but are more likely to find troops on them. Towns and other population centers are more likely to hold supplies (food and maintenance items are critical for survival) and spare parts, but the citizens will raise the alarm if they see you, and there are likely to be troops in towns.

The catch is that any alarms you raise will alert the search parties to your general presence and means a higher chance of encountering troops. Same goes for any military engagements in which an enemy scout or survivor escapes. The game is part stealth (avoiding conflict), part tactics(managing the suit, choosing your world route), part combat (winning conflicts you get into). At the end, instead of a boss fight, you have a final battle at the border of the kingdom as the search parties converge on your position and a friendly militia comes down from the other side of the border to help you across.

%d bloggers like this: