Saturday, October 3, 2009

Windows 7

I recently got a new laptop at work (an HP 6930p) which I'm very happy with. The harddrive was blank (presumably because I ordered a 250GB instead of the standard 160GB), so I had a good opportunity to skip Vista and install Windows 7 directly. Since it had 4GB I installed the 64-bit version (Enterprise), and the overall experience is pretty good. One thing I am really impressed with is the 32-bit compatibility on 64-bit Windows. The details may be gory, but the bottom line is that there is really no reason whatsoever to take the 64-bit Windows if you have 4GB or more.

Performance-wise I don't want to say anything for a year or so when Windows-machines usually start to get bogged down, but feature-wise there are quite a few goodies in there. Here are some of my favorites:
  • The new dock-like taskbar.
  • The window-management shortcuts (window movement/maximizing), taskbar navigation.
  • Notification icon cleanup.
But of course, there are areas which Microsoft has forgotten about completely and which basically have not gotten any attention since Windows 2000:
  • Environment variable setup. WTF!? Why can I at least get a multiline-control for editing values?
  • The Windows console. Resizing? Copy/paste? Tabs? The list of missing features is endless.
I'm normally a Linux-guy, but nowadays I'm doing so much work in Eclipse that the operating system really doesn't matter too much. Also, requirements at work make it difficult for me to use Linux at work, so the last months I've worked completely in Windows. And Windows 7 is definitely a big improvement over both XP and Vista.

Friday, August 14, 2009

Top things I miss when going from Eclipse JDT to Visual Studio C++

I recently dived into Visual Studio to do some C++ hacking after several months of doing mostly Java in Eclipse, and discovered a few items which I really miss.
  • Hot code replacement. This is really addictive in Eclipse: I set a breakpoint in a function, edit the code around it. After saving, the code in the debugged JVM is replaced and PC is reset to the start of the function. The other day I got annoyed when this didn't work (I changed the class' external signature), and I actually had to restart the debug session. Oh no!
  • Drop-to-frame. I can at any time reset the execution state to a frame further down on the stack and rerun from there.
  • Automatic code formatting. In Eclipse I have function "format entire source file on save" switched on, basically letting the editor do all the formatting for me. It even does line-wrapping inside comments, something I find very handy. In Visual Studio I have to manually indent each line (well, the indentation level is given automatically), but things like line-wrapping I have to do manually.
  • Incremental background compilation. I can sit several seconds waiting for the code to build before I realize that I need to start the build manually. (You also have to save your code before you can get any sort of feedback from the compiler.)
  • The "open type" and "open resource" commands. "Open type" allows me to interactively search for a class and jump to it. Visual Studio has a similar search, but I often get multiple matches and need to think about which match I'm actually interested in. "Open resource" does the same thing, but searches for files in the workspace. Visual Studio only gives me the regular Open File dialog, which is useless since I first need to locate the directory the file is in.
  • Red squiggles for errors. Compilation errors are indicated as a tiny line in the margin, instead of a red squiggle in the code.
  • The Emacs-bindings in Visual Studio are much crappier than in Eclipse. The most annoying part is that TAB doesn't indent an empty line, so you have to start your line at column zero, and not until you've written at least one character can you indent the line. (The Emacs-bindings in Eclipse aren't perfect either, I especially miss the kill-ring).
I realize that several of these issues are very difficult to get right in a C++ IDE (hot code replacement and drop-to-frame, for example), or completely subjective (I don't really expect Microsoft to spend a lot of time getting Emacs-binding completely right; I'm actually very happy that there are Emacs bindings at all).

Tuesday, August 11, 2009

The role of exercise in weight loss

I've recently lost a bit of weight by using a controlled diet. By writing down everything I eat (using the Weight Watcher's point system) I managed to lose around 18 kg in around 30 weeks, getting me down from 105 kg to a considerably healthier 87, where I've stayed now for a while. I can now run without breaking my knees, and my current personal record over 10km is under 54 minutes. Using a pulse-meter I've also been able to keep a decent track of calories spent while exercising.

One of the revelations I got when starting to document how much I ate (calories or weight-watcher points, it doesn't really matter), is that exercise does not really matter when losing weight. First, if you're 20 kg overweight like I was, chances are that you're overeating with at least a day or two worth of food per week. A pizza easily covers 80-100% of your recommended calorie intake per day. To balance one day worth of calories, you will need at a significant amount of intensive exercise. Going swimming or running 30 minutes twice a week will not help.

According to the article Why Exercise Won't Make You Thin, exercise will also stimulate hunger, causing you to eat more. (It certainly does for me; I ofter food-hallucinate when I'm running.)

So, while exercising is a good idea for most people, don't expect to lose any weight unless you also change what you eat.

Tuesday, July 7, 2009

Mobile broadband in Ubuntu Jaunty

Writing using mobile broadband in the archipelago outside Stockholm...

Getting the broadband dongle from 3 to work, I braced myself for an afternoon of twiddling around. To my surprise it actually worked directly out of the box. Well, almost. The dongle wasn't recognized directly when inserted, but had to be manually added in the Network Manager. This was really easy; I just selected "3 (Bredband)" in the wizard, and typed in the PIN code when asked to. After that, everything worked. (Not too good bandwidth though, but I can live with that.)

This actually makes it even easier to use from Linux than from Windows, where you need to install a special client application, manually start the client application, enter the PIN, and connect to the network.

Monday, July 6, 2009

Broken sector

I seem to have bad karma when it comes to harddrives. The upside is that I've become very paranoid about having proper backups on all my data. Last week, just before leaving town for a week, my primary harddrive on my new computer started getting bad sectors. Running chkdsk seems to have fixed the problem, though. But I'm wondering what I'm doing wrong. I've got a stack of three harddrives standing on my desk in various stages of brokenness.

Thursday, June 25, 2009

Tuesday, June 23, 2009

Wednesday, June 17, 2009

nView slowdown

I've experienced some serious UI performance issues on my Windows XP workstation lately. Programs like Eclipse, Safari, have been excruciatingly slow. In particular, some string entry boxes in the Eclipse launch configuration dialog have been so slow that they only manage to echo 2-3 characters per second. Something was seriously wrong, and it didn't seem fair to blame Eclipse or Safari without some investigating.

To get some idea of what the processes were doing, I used Process Monitor, and added a filter to show only activities from "eclipse.exe". Collecting data from 15 seconds and typing some data in a file generated 12629 events (842 events/sec). 11304 of these (89%) were registry calls to HKLM\SOFTWARE\NVIDIA Corporation\Global\NVTweak\DisableWindowCaching. WTF?

Googling around a little proved that I'm not alone. Some related links:
I solved the problem by creating the registry key with a DWORD value of 0. Now everything goes much faster...

Thursday, June 11, 2009

Terminator Salvation

So, I finished playing through Terminator Salvation. This was one of those games that being a Terminator-fan for a long time, I felt that I had to get. To avoid being disappointed by any bad reviews, I bought it and played it without reading any.

The game has two gameplay modes: single player and co-op. I've only tried single-player, in which you play John Connor making his way around Los Angeles shooting at machines, together with several NPCs. The game is played from a third-person perspective, which I'm not too fond of. The game has three levels of difficulty; I played at medium.

Lets start with the positive aspects first. The graphics is what you might expect from a game with hardware requirements such as these. The cutscenes are nicely shot with cool camera-focus effects, and the overall environment is impressive. (My HD4870 had no problem running it at 1600x1200 at maximum detail.)

The designers have tried to avoid the regular arcade shooting and introduce some tactics by letting the player take cover and move from cover to cover. Some enemies can only take damage from behind, so you will need to move carefully around these enemies. The endo-skeletons carry miniguns which inflict serious damage, so using covers is necessary in order to stay alive. Also, if any endo-skeleton gets to close, it will grab you by the neck and throw you head first into the nearest wall. You can only carry two weapons at a time, so you need to think a little before switching weapons. Weapons and ammunition are rather plenty, even if I ran out of ammo at some places.

There are several places where you get to play gunner in a vehicle, but boringly enough you don't get to drive anything (at least in single-player mode). Unfortunately, none of the vehicle parts presents much of a challenge.

Which brings me to what probably bothers me the most with the game. There is really no challenge. I played the game from beginning to end in 5.5 hours (according to Steam), and long sections just felt like transport; another street with endo-skeletons and other enemies which are taken care of by suitable weapons. The "crawl around to shoot the spiders from behind"-routine quickly becomes exactly that, routine. There are also remarkably few enemy types: Aerostats (small flying things which shoot at you), Spiders (walks around and shoots at you, needs to be taken down from behind), Endo-skeletons (walks around and shoots at you, needs a grenade or rocket launcher to take down), well, that's it. Oh, yes, and some form of driver-less motorbike in some of the vehicle chase scenes.

If I pay €40 for a game, I really like it if it lasts more than 5.5 hours. Or at least presents me with a good challenge, or has a intriguing atmosphere or gameplay. Even Half Life 2: Episode One and Two gave more gameplay for the money, despite that they were pretty short.

Steam's metascore gives 56/100 to Terminator Salvation, which I think is a little on the low side. I give it a 65 for good presentation and some fun arcade shooting.

Friday, May 22, 2009

More blogger.com weirdness

I just published a blog entry I wrote a couple of weeks ago, but never really finished. I thought the post would be dated when I pressed "Publish Post", but instead it is dated the time the draft was created. Which means that it doesn't show up in the RSS feed. Urg.

EDIT: Well. Apparently it did show up, but with a longer delay than usual.

Auto-formatting source code

Code formatting is a sensitive subject. There are countless articles, blog posts, and other texts available on the subject. Everyone who's worked with other programmers knows that most programmers have a pretty good idea on how they want their code. Tabs vs spaces, 2/4/8 steps indenting, where to put the braces, etc.

There are several studies (see Death to the Space Infidels! for example) indicating that consistent code formatting improves team productivity. The hypothesis is that it is easier to read and understand code which follow certain rules. Atwood quotes a study on chess-players which compared the ability of remembering the layout of a chess-game. When the pieces were laid out as they might be in a game, the expert's memories were far superior than the novices, but when arranged randomly, there was little difference. The same type of idea seems to hold true for programmers as well.

I've written quite a lot of Java in Eclipse lately, and have become very fond if the "auto-format on save" feature introduced in Eclipse 3.4 (I think). The idea is that given a fairly detailed set of formatting rules, your editor (Eclipse in this case) formats your code automatically before saving. When I first tried it, I thought that it would be annoying and intrusive, but the feature turned out to be very nice. So nice that now I get annoyed when stuck in an editor which doesn't do this for me.

I started thinking about it, and realized that code formatting in this respect is a lot like code generation. Source code is just another representation of your program. It is different from the compiled code (or any other representation) because it is intended for human consumption and processing while the compiled code is designed to be executed in hardware. Compiler writers spend lots and lots of time making the compiler generate good code (which usually means "fast", but could also mean "small", or a combination of the two). In the same way, source code needs to be properly formatted for it to be efficient, i.e. easy to read and edit by programmers. This is a task which in very many cases can be automatically handled by the editor (or an add-on program).

The Java editor in Eclipse does this very well. Compilation and source code formatting is performed incrementally so there is no noticable delay while typing. However, there are a few drawbacks. One problem is with code which is commented out using block comments. Since the editor doesn't recognize it as code, it is formatted as ordinary text, making it unreadable. I usually work around this using "if (false) { … }". The other problem is that the formatter has a few blind spots. Complex boolean expressions are not indented in any structured way, and certain patterns of chained method calls are indented at the line width, instead of aligning. If you use the Builder design pattern, you'll know what I mean.

Monday, May 18, 2009

1 hour!


I finally ran 10 km under an hour, something that I've had as a new years resolution for at least 10 years.

Friday, May 15, 2009

Eclipse, Subclipse, and Jaunty Jackalope

Getting Subclipse 1.6.x to work with Eclipse 3.4.x and Jaunty Jackalope was a little tricky. It turns out that Subclipse 1.6.x is too new for Jaunty, so you need to roll your own Subversion/Java bindings. (Fortunately I already had a colleague at work do that for me).

The crucial step which is not done automatically is to add the path to the libsvn-javahl-1.so library to the JNI load path. This is done my adding the following line to eclipse.ini, after the "-vmargs" parameter:

-vmargs
...
-Djava.library.path=/usr/lib/jni

Wednesday, May 13, 2009

Broken camera

The other day I was planning to bring my (and my wife's) Nikon D40 along to take some pictures when I realized that the memory card reader did not lock the SD card properly. Pressing the card in usually locks the card in place, but now it just pops out again. Depressingly enough, the local camera store I went to here in Uppsala wanted 500SEK (~$60) just to send it to the repair shop, and estimated that fixing it would cost at least 1500SEK (~$190).

Maybe this is a sign from above that I should upgrade to a D60.

Tuesday, May 12, 2009

Blog weirdness

I had a blogpost "Christmas" which seemed to have disappeared. It did not show up in my blog archive list, but searching for "Christmas" turned up the post, so where did it go. I changed the blog archive box to use a flat layout, which looked like this:

In the blog archive list there are now 2 (!) entries for March:
http://thisisnotaprogrammersblog.blogspot.com/2009_03_01_archive.html, and http://thisisnotaprogrammersblog.blogspot.com/2009_03_31_archive.html.

Can anyone enlighten me about what's going on?

Friday, May 8, 2009

Getting rid of the mouse

I'm making a serious attempt at learning how to use Windows without a mouse, primarily because I feel that moving my hands between the keyboard and the mouse is slow. So, here goes.

  • The very first item on the list is to install the Mouseless Browsing add-on (MLB) to Firefox. It adds little numbers to every hyperlink, allowing you to click on any link using a number instead of tabbing.

  • Know the necessary windows shortcuts.

  • I have a multi-monitor setup, so I want a shortcut for moving windows between monitors. Since I have an nVidia graphics card, I can use nVidia's desktop manager to add a shortcut (Alt+` in my case).

  • Learning Eclipse keyboard navigation. 10 Eclipse keyboard shortcuts every programmer should know.

I've already discovered problems with several programs. (If I'm wrong, please tell me!)

  • Digsby's preferences page does not have any support for keyboard navigation.

  • WinAmp doesn't have any way of minimizing itself (Alt-F10 does not bring up the window's system menu)

  • Blogger preview function is not keyboard accessible, and the HTML compose widget interacts badly with MLB, since the numbers inserted by MLB are kept in the HTML code for the blog post.
EDIT: this did not turn out the way I hoped. There are simply too many things which are difficult to navigate by mouse: the windows task bar, quick launch field, and notification icons, Eclipse multi-page editors (plugin manifest editor, product editor, feature editor, update-site editor), etc. MLB was neat, but I think I need to be forced to live without a mouse and suffer a couple of weeks of pain before actually getting used to working without a mouse.

Wednesday, April 29, 2009

Jaunty Jackalope

I finally got around to upgrade my work laptop to Jaunty Jackalope. Things worked pretty ok, the only snag I found so far was that the ftp.funet.fi mirror was actually missing some packages, causing the update to terminate prematurely.

I haven't had time to walk around the release that much, but so far, no problems.

Keyboard shortcuts in Outlook

Sometimes I end up in Outlook, and I have to navigate around. After taking some time to try to find the most basic keyboard shortcuts (such as moving to the next message), I finally found this link. Very useful information, but one would think that "move to the next message" would be common enough to warrant its own place in the menus.

Thursday, April 23, 2009

Crane


A large mobile crane outside the railway station in Uppsala. It looked larger in real life, though.

Märklig dörrskylt


Såg den här skylten inne på Nickis Äventyrslek. Man undrar ju varför knappen sitter där den sitter...

Sunday, April 19, 2009

Adventures into album covers

I've spent several hours trying to complete my music library with the correct album covers, including various tracks I really don't remember where I got. I'm sure some of them are illegally copied from somewhere, but the majority are ripped from physical CDs that I own. (I have a whole bunch of old vinyl albums which I haven't digitalized yet, though.)

Mp3Tag has been an invaluable help; it can search freedb given a set of tracks, and it can also search Amazon.com. There is also a menu option for searching discogs.com, but that never seems to work. I'm not sure why.

Several hundred tracks did not have any tag info at all. I had to go purely by file and directory names. Very weird, I'm sure that when I ripped them, they looked good. My programmer brain wanted to start disecting the files to figure out if the files contained any clues to which program I used to rip them, but the rational part of my brain said that that was a waste of time. Which it surely was. I'm still curious about how it really happened. After getting the album and song names correct, Mp3Tag could fix the rest.

I still have problems with a couple of albums. I borrowed a CD from my sister (which I still think I haven't returned -- I'm sure she's forgotten): "Pops by Gershwin" with John Williams and the Boston Pops Orchestra. I can't find any information about the album at all. Even Google lets me down.

The OCD part of my brain tells me that I have to keep going until there are no more unknown album covers, while the other not-so-OCD part protests and would rather play another level of GTA:IV. We'll see which part wins.

Wednesday, April 1, 2009

Christmas!



New hardware is always fun. My new machine arrived today (well, I had to actually go and pick it up at my local computer vendor, EIS).

I was a little adventurous and installed Vista Home Premium 64-bit. Since the machine has 4GB of RAM, it felt less than optimal just to be able to use 3 of those. Lets see how that turns out.

The graphics card is a ATI HD4870, which takes up two slots (just one PCIE slot, though), one being used just for the fan and heatpipes. However, I was expecting the box to be full of cables, wiring, etc., but it was surprisingly empty. The cpu and cpu-fan was much smaller than I expected. The included keyboard wasn't too good though. Much too noisy and cheap-plastic feeling. I think I'll switch back to my old and battered HP keyboard.

The Antec Sonata III chassi is very nice, black and silent. When writing this, I actually cannot determine if the faint humming sound is the ventilation in the room itself or the computer case/graphics card. Excellent!

So on the list of things to do (after installing Firefox, which is the very first thing I always do on any Windows machine I get my hands on), is:
  • Set up a backup solution
  • Install Steam
  • Figure out a way to transfer all my old game files (I don't really want to play GTA: San Andreas from scratch)
  • Restore stuff from my old harddrive
And a bunch of other things, but that'll probably be enough for tonight.

Saturday, March 28, 2009

New hardware

After my 3 years old PC started malfunctioning I decided it was time for an upgrade. I'm not very much of an hardware freak), so I ended up at EIS here in Uppsala ordering a complete PC: EIS XTREME i2 GAMER PLUS E8500, 1TB & HD4870 512MB, but with a Antec Sonata III chassis. Should be enough for any household task, such as playing GTA:IV. :-)

Friday, January 30, 2009

The X-Files Revisited

The other day I bought the first season of The X-Files on DVD. I found it at a groceries store for 99:- (ca $14), and having followed almost all episodes when they aired in Sweden I thought it would make for some good nostalgia.

Quite right. The series started in 1992, 17 years ago. Anyone born then is allowed to take driving lessons now! There were no digital cameras, computer monitors were small, fat, and monochrome (at least in the series) and Gillian Anderson looked like she was barely out of high-school.

Thursday, January 29, 2009

Infrastructure and terrorists

Another excellent article by Bruce Schneier on the topic of how infrastructure helping terrorists, and why this shouldn't cause us to, for example, ban Google Earth.

Wednesday, January 28, 2009

Malfunction

It seems that hardware failure is epidemic, and can even spread through human contact. I went with two friends to Kungsberget this weekend, and apparently David's hardware problem have now infected my machine as well. Not that any of the symptoms are the same, though. Did I say that I ramble sometimes?

The major issue at the time is that the USB support seems to be shot. I think it started a week or two ago when the machine refused to boot. BIOS complained about "DISK BOOT FAILURE...", and I was getting a little nervous having suffered several harddrive failures recently. Well, I decided to be a little optimistic, and out of a hunch I entered the boot menu and selected the correct harddrive to boot from, and things worked nicely. It seems that suddenly there is a conflict between my external USB backup drive, which was what the machine was trying to boot from. Anyway, I don't reboot very often, so I didn't think more often.

Yesterday I shut down the machine in order to mount the case on a new set of wheels, and when I tried to bring it up today, only some USB devices seemed to work. The mouse doesn't work at all (I've tried several different mice), the keyboard works sometimes. My external soundcard also works sometimes.

These two might be related, but I really have no clue. I don't even know where to start troubleshooting. "usb doesn't work" gives me 27.5 million hits on Google. I think I'll just power down the machine, and hope that things will magically improve tomorrow.

Tuesday, January 20, 2009

Monday, January 12, 2009

The Big Picture

The Big Picture is a really good photo-blog covering current events. Highly recommended if you like good photography.

Sunday, January 4, 2009

Birthday




My birthday this year was unusually cold. It is right now -13.5 degrees, but there isn't very much snow. These pictures were taken on New Year's Day.