A Tale of Two Languages
Listing 5. Programming Game Logic
Inform 6 Version: 120 daemon [; 121 if (location ~= server_room) return; 122 beeping = random(7); 123 switch (beeping) { 124 1: "^The beeping is driving you crazy."; 125 2: "^It's hard to think, with all of the beeping."; 126 3: "^The monotony of the beeping is maddening."; 127 4: "^You can't stand the beeping."; 128 5: "^The beeping reminds you of your alarm clock."; 129 6: "^beep . . . beep . . . beep . . . beep . . . beep 130 . . . beep . . ."; 130 7: "^If you don't stop the beeping soon, you'll lose 132 what little hair you have left."; 133 } 134 ], Inform 7 Version: 097 Every turn while in the server room, say "[one of]The beeping is 098 driving you crazy.[or]It's hard to think, with all of the 099 beeping.[or]The monotony of the beeping is maddening.[or]You 100 can't stand the beeping.[or]The beeping reminds you of your 101 alarm clock.[or]beep . . . beep . . . beep . . . beep . . . 102 [or]If you don't stop the beeping soon, you'll lose what 103 little hair you have left.[purely at random]"
Scoring is another thing that Inform 7 simplifies. In Inform 6, you can give an object the scored attribute, but for custom cases, like awarding 2 points instead of the default 1 point, you need to track things yourself (i6:150-156). In Inform 7, the process is much easier (i7:105-106, Listing 6).
Listing 6. Syntax for Scoring
Inform 6 Version: 150 before [; 151 Open: 152 if (openedtray == 1) { 153 score = score + 2; 154 openedtray = 2; 155 } 156 ], Inform 7 Version: 105 After opening the CD tray for the first time: award 2 points; 106 say "You press the button and the CD tray pops out."
So, which version is best? If I had to choose my favorite of the two, it would be Inform 7, hands down.
I prefer Inform 7 not because I find Inform 6 difficult to use or because it's an unpleasant experience. On the contrary—Inform 6 is well designed and has excellent documentation for both beginners and advanced users. It also has some clear advantages—a main one being precision. Inform 6 will do exactly what you tell it to do. Inform 7, on the other hand, is less precise, and you sometimes need to fiddle with it to get it to do exactly what you want. This lack of precision is a result of how Inform 7 translates your code into Inform 6 prior to compilation—it has to guess at what you mean sometimes, and occasionally, it will get things wrong.
Despite some disadvantages, the reason that I prefer Inform 7 over Inform 6 is because I am more of a writer than a programmer. The closest I get to programming on a regular basis is bash scripting with a little PHP thrown in now and again. The natural sentence structure of writing something in Inform 7 is more intuitive to me than the C-like syntax of Inform 6. As a writer, I sometimes think to myself, “If when reading code I pronounce 'somevar=42' as 'somevar gets 42', why can't I write it that way?” I realize and accept that computer languages are as terse and precise as they are for many reasons, but I also think efforts like Inform 7 should be applauded and copied wherever and whenever possible.
The precision of Inform 6, as with other programming languages, is good in some instances, but bad in others. One misplaced comma or semicolon or bracket prevents your game from compiling, for example. Inform 7 is not exactly forgiving in this area either, but I find myself making fewer mistakes because of the flexible and natural way you're allowed to write.
Another big advantage of Inform 7 is the wonderful integrated IDE that comes with it, complete with excellent built-in documentation, a debugger and other tools. With Inform 6, compilation was a command-line affair that could be difficult to set up properly. I won't go into the Inform 7 IDE here, but if you are interested, see the two-part series “An Introduction to Gnome Inform 7” on the Linux Journal Web site.
With Inform 7, there's never been a better, or easier, time to create your own interactive masterpieces. So, find the key to the grate, and join me down underground. I'll be in a maze of twisty little passages, all alike, trying to find the bearded pirate who stole my gold—if the dwarf doesn't kill me first. XYZZY!
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Validate an E-Mail Address with PHP, the Right Way
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- One advantage with VMs
26 min 10 sec ago - about info
59 min 19 sec ago - info
1 hour 18 sec ago - info
1 hour 1 min ago - info
1 hour 3 min ago - info
1 hour 4 min ago - abut info
1 hour 6 min ago - info
1 hour 7 min ago - info
1 hour 8 min ago - info
1 hour 9 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
The Link to the files
The link in the magazine was incorrect. The files are actually located here:
ftp://ftp.linuxjournal.com/pub/lj/listings/issue174/10130.tgz
One other thing to keep in mind: if you want to compile the code, first remove the line numbering.
Looking for code...
I'm also curious where the code is!
The Link was incorrect
But is fixed now.
Katherine Druckman is webmistress at LinuxJournal.com. You might find her on Twitter or at the Southwest Drupal Summit
Ah... I had been trying to
Ah... I had been trying to get the code from the link within the article, not the link at the end. The link in the article should be updated as well.
Unavailability of sources issue 174
I know Linux Journal has been getting worse lately but this is the first time that the sources for an issue are entirely unavailable. The credit crash hitting linux journal already?