games and code code it, play it
G-startup project
February 23rd, 2010

It’s hard to find an application or utility that wasn’t already written. If you have some problem or want some improvement for your desktop, chance is you are not first with this idea.

  • Sound card switcher? Check.
  • Better multi monitor handling? Double check.
  • Improved window managing? Check

These are obscure tools, I don’t know anybody (in person) who uses it beside me. But they exist.

Most projects start with scratching an itch: solving a problem a user or developer have. But there is already a utility for almost everything. If problem looks simple, it’s probably already solved. So I never actually developed any small, useful, hobby application. Oh joy when I finally found an unexplored land.

For some time I’ve used a script to delay starting of startup application. My startup folder in Windows and Startup applications in Ubuntu are very densely populated. Thunderbird, Skype, Pidgin, Dropbox, Deluge, Gnome Do, WinSplit, background changer, calendar… Having them all start simultaneously (competing with antivirus and firewall) at logon renders my PC unusable for few minutes. And if I just want to quickly open some file or check something on the Internet, I can’t for some time. Ant this is where my script helps.

Instead of starting all applications, only script is started. Scirpt waits for some time and then starts the first program. Then it waits some more and start the next one. And so on.

This is quick and dirty vbscript:


WScript.Sleep(240000)
call ShowApp("Pidgin")
WScript.Sleep(20000)
call ShowApp("Skype")
WScript.Sleep(60000)
call ShowApp("Mail")

sub ShowApp(app)
 Set shell = CreateObject("WScript.Shell")
 select case app
 case "Mail"
 shell.Run """C:\Program Files\Mozilla Thunderbird 3\thunderbird.exe""" , 7, false
 case "Pidgin"
 shell.Run """C:\Program Files\Pidgin\pidgin.exe""" , 7, false
 case "Skype"
 shell.Run """C:\Program Files\Skype\Phone\Skype.exe"" /nosplash /minimized " , 7, false
 end select
 Set shell = Nothing
end sub

Simple. And it works. Now, here come them features. One case is when I want to completely bypass all startup applications. Other case is that I need the application now but it’s not scheduled for next few minutes. Then I decided to convert this script into a system tray enabled GUI application. I also used this opportunity to try running the project on Google code. So here it is: G-startup (from gentle startup, yes, searching for new name).

gstartup

This is what you get: only tray icon is displayed which disappears once all applications are started. Clicking on it a window drops down allowing some actions.

Currently there is version for Linux only. It’s written in Python using Glade for GUI. Check it at: Gstartup on Google code

Episodic gaming
July 31st, 2009

At first I didn’t like the concept. It seamed to me like somebody is trying to sell the same game many times. But this was just my unwillingness to accept different concept then I was used to.

Look at for example, The Longest Journey. I enjoyed the first game released in 1999. Second game, Dreamfall, was released seven years later. Of course, I forgot everything about the plot of the first game when Dreamfall was released. And this was completely different game. Point and click disappeared and instead we got badly designed fights and somewhat dumbed down interface. Finally, it ended in a cliffhanger without any information about new releases. Currently, production hasn’t yet begun.

Compared to that, episodic gaming as Telltale Games is doing seams like the right way for adventure games. When they announced Tales of Monkey Island I was still skeptic but I tried the demo and I was pleased with the gameplay. I bought a season which includes 5 episodes. I got the first part immediately for download while others will be available monthly.

Why is such a deal so good for me? First, full length adventures requires significant time investment from a player. To finish a 30-hour game can take a few weeks if you have a life. Also, it’s hard to follow the story stretched for so long. Monthly distribution means that I got to play 7-hour episode (at least I got so much from the first episode) once per month. Story is easier to follow because every episode has it’s own plot. Still, main plot builds across the episodes to connect the whole season.

Similar fate like The Longest Journey I’ve mentioned before, almost got one of my favorite series: Gabriel Knight. All three games provided great stories but second and third game had serious technological problems. Although they turned out pretty good in the end, they would have profited from episodic releases if their content could have been produced at slower pace using the same engine for several episodes or seasons instead of always being on technological edge.

So, more quality episodic gaming please.

Windows – Gaming Edition
June 26th, 2009

Windows is not my main home OS for some time. I’m satisfied with Ubuntu. I have only two reasons to log into Windows: Visual Studio.NET and computer games. VS.NET is the most important tool on my daily job. I’m always writing something at home too. Another reason to log into Windows are video games. Yes, there are games for Linux. Yes, you can play some games with WINE. But Windows is the OS for games on PC.

What surprises me is that Microsoft doesn’t bother much to emphasize this. There are some shy attempts to connect the gaming hobby with Windows platform like “Games for Windows” and XNA but that’s not what I have in mind. I think the future of gaming on PC is tied to Windows and both Microsoft and PC gaming as a whole should profit from this.

There are many marketing versions of Windows Vista and Windows 7. They are all more or less the same but crippled in one way and expanded in others. None of the versions is targeted at gamers. And that’s bad because first, gamers are pretty large group of Windows users, and second, gamers require OS to behave differently while playing games.

So, what are the features of this supposed “Gaming Edition”?

Multitasking is of course, very nice, but it brings some problems. Games don’t cooperate nicely with other applications. It’s not that they are bad by their nature, they are just not some normal computer program:

  • Games operate at different display resolutions
  • Games have their own loop, concurrent with windows message pump
  • Games are the most CPU, memory and GPU hungry applications

So, how could Microsoft change the behavior of Windows to make it better to games:

  • Remove or disable any unnecessary Windows services. That includes:
    • Automatic Updates – steals network bandwidth
    • Indexing services – steals CPU time and hard disk IO
    • Network services
    • … and any other service that could do it’s work at some other time
  • Suspend or silence any notification like:
    • Information about antivirus updates
    • Offers to upgrade applications
  • What else?
    • I would like to play older games that do not support the native monitor resolution without blurring pixels. It could be done if game that supports 1280×960 resolution took only part of my 1280*1024 screen, leaving the rest in black, like wide screen movies on TV screen.
    • Multimonitor support. Maybe game producers are to blame rather then Microsoft but there must be reason why multi monitor support is so rare.

It’s not much but Gaming Edition sounds nice. It would benefit both Microsoft and gamers.

I hate my PC too
April 5th, 2009

I hate my PC, so does Paul W. Homer at Programmers Paradox. He did an excellent rant and I, unfortunately, have to agree with him. In search for a better systems, we fell in terrible mess.

Few years ago, I would recommend to anybody to buy a PC, I would carefully and systematically explain why and how to use a computer for things like music, photos and movies and Internet stuff like email and forums. I explained how to find information on the Internet and how your life can be simpler if you have a PC at home. Now, I don’t do that anymore. It’s not worth it. Neither will their life be simpler, neither will mine.

Let say my parents buy a computer and I’m helping them to use it. Can my mom just plug the camera in their PC and send some photos to me by email? There’s too many things that can go wrong and one of them surely will:

  • Computers have few USB ports but for some reason they work unpredictably. I have 6 USB ports. I can plug in my USB stick to front panel but external USB hard disk and cellphone do not work there: I must crawl under the desk and connect them behind. What should I say to my mom? Where should she connect the camera?
  • Some cameras need drivers to work. Drivers are bad for users.
  • What will happen if connection works? Nothing predictable: maybe nothing, maybe windows will open their autoplay dialog, maybe some flashy manufacturer’s application will run.
  • Login to email account and attach the photos. It’s easy, except that photos from the camera can get pretty large, 3 MB being common size. Email service providers can limit you to 5 or 10 MB per email. You can either:
    • Send one email for every photo and spend probably a hour doing this
    • Compress the photos with JPEG compression. That’s very complicated procedure to explain over the phone.

The simplest action I could think of is for her to sit in the car and bring me the camera.

It’s the same for almost everything one can do on the computer.

  • Burning a CD? Do you have a CD or DVD? DVD-R or DVD-RW. You want data disk or audio disk? Did you mean mp3 audio disk or normal audio disk for your car?
  • Connect a PC to TV? 4-pin S-Video or 7-pin S-Video connector? Mirror or stretch the picture? PAL B, Pal C, Pal D or Pal E? No picture? Go to display properties in Windows control panel or maybe drag and drop your devices in ATI control panel.

Malware is spreading again. You need to regularly update your windows (auto update helps), have an antivirus software and firewall. Most of the time, firewall will nag you (alert, Sims want to connect to Internet, firefox application is different (after upgrade), svchost wants to connect…) and when real threat is reported, user will probably allow it to do whatever it wants because that’s the way to remove this alert.

I could go like this whole day. I can only hope that there will be someone smart enough to simplify things. Someone who will do to the PC the same thing Google did to Internet search, Wikipedia did to knowledge sharing and Amazon did to books. Someone who will analyze and use existing systems, connect them in a new way and make us all happier and billionaire of himself.

Oh, finally somebody completed this sentence. This “Don’t reinvent the wheel” (or “Don’t invent the warm water” as we say it in Croatia) makes me feel bad whenever I code something that has already been done. And I’ve made a lot of libraries somebody already has done better then me. Like my own image viewer. Or XML reader/writer. There’s also form designer, workflow designer, TCP server-client messaging system, 2D tiled graphics engine, 3D terrain engine and probably more different wheels I’ve made someday.

Why I constantly redo something that’s already been done? There are three reasons. First, to learn more about this specific wheel technology. Second, wheels on the market didn’t quite fit with my gears. Third, those wheels came with their own air, nuts and bolts. Specifically, I built my own image viewer because bought one let me down in most inconvenient moment. I wanted my own 2D tile engine because I wanted full control over it. I learned 3D graphics programming while building my own 3D engine. In-house workflow designer allow our partners to produce incredibly flexible workflows targeted for a specific industry.

Although most of developers I know tell me that reinventing the wheel is wrong, in most cases my experience is different. Actual code as a solution to a specific problem area most of the times is simple. Testing and debugging is more expensive and that’s the part where you profit the most if you use existing, widely accepted solution. It’s probably been tested more than you could test it in your lifetime. But the most difficult part of introducing a library in a project is the integration part. And that’s where your own wheel will be much, much easier to use. It has familiar interface, known capabilities and no hidden features. It’s extensible on the site and takes no time to learn. If something goes wrong, you know who is responsible and who can fix things the fastest.

So, before you shout “Don’t reinvent the wheel!” at me, please, take some time to think about the wheel and how wheels work.

Variable names
February 7th, 2009

For a few last weeks I was attending many developer meetings. We have been planning a new product and I’m trying to assemble a team who is capable to do it right. Trying to guide a diverse group of developers when they are exchanging their approaches to development can be amazing experience. There are many rules to agree on when going into collaborative construction. If we agree beforehand, there wont be many disagreements when actual coding begin. Most of the code will be written by one person but afterwards read by many and that’s why it’s important to be written clear. One of the issues we agreed on is naming the variables.

Names in code are important. Compiler will let you use almost any kind of name and it doesn’t really care. But if programmers are not careful with choosing names for their variables, reading the code is much, much harder. “I’m typing this on a keyboard, sitting on a chair while listening to music”. If I don’t care about object names I could write: “I’m doing this on keys, above the floor, while hearing jambala”. Syntactically correct but it’s not comprehensible.

It’s important for objects to have proper names. A good name must show to a code reader its purpose and its content. So, having a collection of objects named lst or col or status variable named flag is bad because those who read the code will have to decipher how this variable is used to discover its purpose. Also, count, num, max or length are bad choices because they could mean anything. Changing that to wordCount, numDocuments, maxLength or  currentLength will give this names a meaning.

There’s a big difference between reading the code and figuring out the code.

I’m not really into action or arcade gaming. I like self paced gaming style like in turn based games, where I have some time to think, where I can slowly build my path to success. Not that I’m against good, fast action, it’s just that I hate when games are frustrating. And, oh, arcades can be frustrating.

So, looking one day at some top 100 games of all time, I’ve found “Prince of Persia: The Sands of Time”. It got some good reviews, it’s old enough for my PC to run it and middle eastern setting and eye candy graphics give it special charm. I won’t go into full review of the game, there are other places on the net for that. But when I stumble across such a good game, I want to highlight the best parts of it. And of course, rant about why is not perfect.

Game well done

From the first sight, it’s obvious that this game is something exceptionally good. Everything goes smoothly: installation, changing settings, playing… In the time when games and patches are shipped simultaneously, what strikes me the most is that 5 years after release, there are no gameplay or stability related patches for “The sands of time”. Only some Nvidia related fix to fill the patches section, otherwise the game is flawless.

When you see a game like this one, you see how wrong is for computer games to try to look photo-realistic. This game looks almost real, but details give it this fantastic touch. It would be wrong to say it’s cartoonish but look for yourself:

this is just beautiful. All these shiny marble, soft tapestries and polished metal are the real eye candy. While characters and monsters are not even near done so well, I must mention the thing about Farah, a female in the game. A compliment to her is that she looks normal. Her shapes and proportions obey the laws of physics and her clothing cover more skin then required for ESRB Teen rating.

Sound effects also add to the atmosphere. Your footsteps and environment sounds echo as you walk through empty, marble corridors. It needs just a little attention to make sound effects right. This game did it.

Combat

Combat. Always a showstopper when I want to play action games. In real life, combat is slow paced affair. You need to step carefully, concentrate on your opponent and focus your strength to only few strikes you’ll get at your opponent. Unfortunately, game developers always want to include combat like in Jackie Chan movies where action is flashing on the screen and he delivers kicks and punches all around himself. Too bad they don’t remember that such movie action is heavily scripted. Whenever Jackie kicks, there is always some face to land his shot on. Opponents close on him exactly on time to receive they portion of punches. Ladders and tables are just where they need to be for Jackie to save the day. If you want that kind of encounter in a game, put it in a cut scene.

In “The Sands of Time”, when you are faced with maximum of three opponents, battles develop very nice. You can do all kind of tricks, jump around and over the foes, striking them while hovering over them, bounce from the walls to surprise them and the game will reward you with slow motion scenes of your exhibitions.

And then you run into six enemies and the whole battle system falls apart. You are always surrounded. Forget about smart positioning and legwork, enemies teleport just behind your back. You quickly lose control of events and you can only watch the Prince as he does the all the cool stuff while you are just mashing the buttons. Replay function could be useful here so we can enjoy the combat too.

The camera hovers somewhere around you and changes it’s position to show the scene. Unfortunately, movement is camera relative so every time the camera rotate, what is front and what is back gets redefined. So, you try to avoid traps and as soon you pass around one of them camera rotates and suddenly you are running back into the trap. It gets even more frustrating in combat. You knock down the opponent and run to him towards him to finish him but camera turns around, enough to put your neck at two handed, double bladed falchion held by giant ogre.

I can’t

Around 25% of the game, I’ve run into a battle I can’t win. I tried to fight fast, I tried to be careful but either Farah or I die in the end. I’ll try few more times, maybe I succeed yet. But frustration is there.

Dune
November 4th, 2008

I rarely play any computer games these days. It’s just more fun to do some work or learn something new then playing the next iteration of some shooter/RPG/RTS/whatever. Fortunately, there are some indie games on repertoire like Mount and Blade which I bought recently, Frayed Knights (not yet released but I played the pilot and generally like it) and a few more that I’m interested in.

Many times, general feeling I have toward the current state of the gaming industry is that games were better before. Of course, such statement is completely subjective. We all look at the past through the pink colored glasses, but anyway, there are many great old games. So, if those games are that great, why nobody plays them anymore? Well, I do.

These weekend I stumbled on Dune. I saw these game even before I had a PC. My friend played it and I was fascinated. And I still am. I started it many times and finished once. I actually do not remember how it ends and that’s the sign I need to play it again. But now I have this blog and desire to write down my thoughts so let’s analyze this game as an example of an old school game.

Paul on Dune Planet Arrakis

Gameplay

Dune is combination of adventure and real time strategy. You don’t build bases, produce units or research technology as in modern RTS games. Instead, you explore the world and talk to people like in adventure games. You can hire Fremen you meet to work or fight for you. Every now and then, some of the important Fremen will provide you with new options, units or technology. Of course, you don’t just collect them, they will be available to you when you became important enough.

You interact with the world in two ways. First, you travel around the world and directly contact the people. Second, you have telepathic powers so you can contact the Fremen at distance, progressively, from short range to planet wide.

Although the game is over when you win the last battle, you have several different tasks and goals.

  • Spice harvesting. Emperor sent you to Arrakis to harvest spice and he expect you to deliver. He is interested only in spice and wants more and more.
  • War. Harkonnen’s fortresses are just north. They are cruel to the Fremen so you need to lead them and fight back.
  • Terraforming. Yes, the Fremen dream is vegetation on the planet. Later in the game, you can send ecologist units to plant the vegetation.
  • The Mahdi. When you raise your charisma enough, Fremen will start to believe that you are their messiah. You’ll became one if you drive out Harkonnens from Dune and plant the vegetation

Innovativeness

It’s interesting to note that in todays terms, Dune is a hybrid of adventure and real time strategy. But when the game was released, RTS genre didn’t existed yet. It was defined later by the Dune’s successor, Dune II.

Micromanagement

The thing I love and hate at the same time. What happens in many games is that at the start of the game micromanagement is fun but as you progress and build your empire or fast food chain it becomes a burden and you lose more and more time to ensure that all production is optimized. Not that Dune solved this completely but I like how interaction changes as you progress. At first, you must fly the Ornithopter and personally visit the sietches to issue orders or view the troop status. After some time, you are given a map so you can view regions and troops but you still must fly to every sietch. Then, you get psychic powers to communicate with distant leaders. With time (and accomplishments) your power increases so you can contact them at greater distances and finally over the entire planet.

What’s so good about the game?

It’s very easy to get yourself immersed in this game. Step by step, it introduces you to the world. At first, your job is to go and visit the Fremen to convince them to work for you. Then the Emperor drops in to remind you that you are sent to Arrakis to mine spice, not to flirt around with Fremen girls. Now you must ensure a shipment of spice every week. You have to manage the production and regularly deliver the spice to the Emperor. When you get into the harvesting business, your father becomes uneasy with Harkonnens on the north and you have to organize the army. Fremen will fight for you only when you find their leader. When your soldiers are trained, you can start attacking Harkonnen’s fortresses. Now you need to juggle the spice production and war efforts. In the midst of fighting you get another revelation: there’s water on Arrakis and Fremen have a dream: vegetation on the planet. When you find Liet Kynes, the expert ecologist, you can start terraforming the planet.

There are no dull moments in the game. You know, the part when you are strong enough so there is no real threat anymore and everything is researched but you still must manage the economy and build units so you can take the enemy territory, part by part. In Dune, when you know everything you should know about the planet, there’s only final battle left.

If you are interested in this game, you can download it from Abandonia and run it under Dosbox.

Dependency in software
September 7th, 2008

Paul W. Homer on his blog, The Programmer’s Paradox, posted an article about dependencies in software solutions. I constantly fight with this issues: old code vs new code, introducing a dependency or writing your own. I wanted to comment on his blog but I just couldn’t summarize everything I wanted to say in one comment. So here are some of my experiences with the dependency issue.

It’s interesting how you always think something is a good idea until it turns against you. So, if you don’t want to write the code somebody already has written, you’ll find out that this code is slow/ugly/buggy/heavy. If you, on the other hand, are smart and write your own code, you may find too late that it will took too much resources and it’s not as simple as you though it is and some functionality you just can’t implement on time.

Maybe the worst code is the in-house code that works good but is based on old presumptions about hardware, requirements or interoperability. I find such code hardest to evaluate. It’s a burden if it’s model is not extensible enough but you must stick to it because any replacement requires big investments.

In any case, you depend on something you can’t easily fix if something goes wrong so you have to be very careful when introducing new dependencies in your software. Of course, you always depend on something, like operating system, database and framework. But every time you add more to this dependency stack, you exponentially increase the risk for something to go wrong.

Story about third party component

I had to maintain and extend a document management solution in which images could be attached to a document. User could view an image inside the application and do some simple manipulation on it like rotating, scaling and moving. A typical scenario where you entrust specific set of problems to a third party library.

I raised some question about size of this component. Also, it was pretty memory heavy and was leaking in some cases but nothing was serious enough to think about replacing it. The only problem I saw about this component was abstract to others: we were using it for image viewing but the component was designed for image editing: conversions, effects, filters and annotations. Displaying the image was only smart part of it’s functionality. Sometime ago, we allowed the users to edit this document but nobody was using this feature. And why should they? If someone wanted to edit an image, he’ll use the right tool for the job, not document management software.

As the component was part of our library for some time, team started to use it in more and more cases: generating thumbnails on the server, drawing reports or generating images from metadata. We had deep dependency then, disaster waiting to happen.

Of course, problems came immediately. First, we wanted to make a lite version. We did it but imaging component took a third of the installation size. Then Microsoft made SP2 for XP and included a firewall. For some reason, component failed to load on one of three machines providing us only with some general error. We never discovered what was wrong but after some patches from Microsoft error was gone. Sometimes, the component didn’t work if PC wasn’t connected to Internet.

When two of our most important clients decided to upgrade our application, component finally gave us a good reason to kick it out of our software. Upgrades were succesful, but new installations didn’t work at all. Application hung at startup without an error. We couldn’t reproduce the error at home so we spent some time to organize debugging at customers place, something I don’t want to repeat again.

It turned out that imaging component failed to initialize. But instead of throwing an error, it just hung up and we couldn’t do much about it. We striped the component out and temporarily used version that opened images in an external application. It did the trick but the incident hurt our reputation.

Now we have our own component for image display, nothing fancy, just zoom and rotate. When our own component is not enough, we have a plug-in for image manipulation based on FreeImage. But important is, we don’t have deep dependency anymore.

When using software product while you work, the best product is the one you don’t notice. And today I’ve noticed one: Notepad++.

Notepad++ is a great text editor and I’m using it instead of classic Windows Notepad. It starts as fast as Notepad and it’s design is minimalistic but it has features like syntax coloring, hex editing and tabbed interface. I have many tabs constantly opened with very different content in them. Some tabs are just scratchpads where i write notes, phone numbers or names. Others contain xml or html documents I’ve edited of viewed or maybe pieces of php or javascript code. One tool, one window, everything conveniently accessible.

So, today I’m talking on the phone and a client wants to give me his IP address. I’m kinda sad when in this situation some of my colleagues start to search frantically between papers on their table for a pen and paper instead of writing the number somewhere on a PC they sitting behind. I’m always ready to write a note or two in conveniently opened tab in Notepad ++, but today when I wanted to write a client’s number, Notepad++ shown me a modal message:

Don'be scared, it's not real. That's only a screenshot

So, now I’m in a situation where I must quickly write down a phone number and one of my favorite software forces me to make decision which will definitely result in lost data and I need to decide what’s more important: something I wrote or something some other application wrote in the same file, and all that, of course, while I’m trying to remember a sequence of 12 numbers. It’s interesting how well this application defended itself from my attempts to write a few numbers in it. New tab? No, message box is modal. Existing tab? No, message box is modal and blinking. Then I tried to open a new instance. No way, only one instance is allowed. I’ve ended asking the client to repeat the number and writing it in Visual Studio somewhere between Catch and Finally keywords.

Sometimes it’s only an inconvenience. Another time you want to put your fist through this message box. But definitely is a proof how you can spoil a good software as Notepad++ and a good concept as tabbed interface with a careless design. I shouldn’t be able to write in the file in question until I resolve the conflict, but this message box is important for only this tab, for only one document. There is no good reason to prevent me to use every other tab. By the way, i should be able to save both versions of this document, but this is another story.

The same problem is with browsers. Click this link. and see what happens. See? My worthless but egoistic message disabled your complete browser until you read it or at least click on it.

So, if you are a programmer, don’t be a self-centered, selfish bastard and let people use their tabs. Don’t write alert(”), MessageBox(“”), msgbox(“”) or raise any other modal window until you are completely sure that it won’t interfere with anything other then your humble corner of the users screen.