Status: tired

What I couldn't do in the last four years in Japan I've finally managed to do in only two weeks: I'm now thinking in Japanese. Involuntarily, I might add. For the past two weeks I've been knowledge-transferring my brain to other people's, and it's been mostly a Japanese-only experience. As a result my throat actually hurts from speaking too much (people who know this is a very rare thing) and my Japanese level improved a lot, ironically, just before leaving the company.

Work has been quite busy, but that didn't stop my bosses for giving me a chance to present my work in a final presentation. This announcement came as a bit of a surprise to me, and I had to rush to prepare everything in time. I wrote a couple of days back about the iPhone rocket launcher app that I wrote during lunch time. My boss is a great guy who likes this kind of stuff, so he told me it would be absolutely ok to show it in my final presentation. I have to admit that I looked forward to a chance like this, but I really lacked preparation time. Somehow I managed to finish everything 30 minutes before the presentation start. The rocket launcher covered under a bunch of napkins and quite inconspicuous, I was ready to surprise-move it during the end of my presentation. Well, it did move, for about half a second... Little did I realize that my iPhone was connected to a wireless network on the south side of the building, and the meeting room was at the north side... I got my revenge later though, after the next presentation. Walking towards the south side of the meeting room meant that I was able to give a quick demo of the accelerometer application. My boss told me afterwards that he was feeling rather endangered after the first failed launch, as the rocket launcher stopped moving just when it was pointing exactly at him...

Tomorrow is my last day at work, but in reality I feel like today was my last working day. Today I could finish programming, bugfixing and documenting, and I managed to release new versions of all the tools I worked on. Not to worry though, as people have been testing those versions for the past two weeks, and they're quite stable. As the final day approaches I am starting to realize that I'm really going to miss working here. It's really becoming 'final' now...

On a completely unrelated note: I highly recommend you to NEVER buy a Suunto Observer watch. The watch itself is great but the wrist band is a piece of crap. I've already had to replace it five times in the last four years. Note that the wrist band is a special part and needs to be ordered from Suunto directly, which costs a lot of money and a lot of time. Shame on you, Suunto.

One more day...

Posted in Daily Life , Tech | Tagged , , , , ,

iPhone rocket launcher

USB rocket launcher is a nifty desktop toy with which you can threaten your neighbouring cubicles with missile attacks. You can control the movement and firing of the launcher via USB with a program running on the PC. Being bored at work during lunch time gave rise to the idea of controlling the launcher using the iPhone. Turns out I'm not the first one to try this, but it was an interesting experiment nonetheless.

The SharpLauncher source code was a great help in building my own RocketServer, listening on a RocketSocket for RocketConnections from basically anywhere. I made two rather plain-looking iPhone apps to control the launcher. One app uses buttons, and the other one uses accelerometer values to control the movement.

Since I'm not going to have time to work on this in the near future, I decided to post the source code here, hereby released to the public domain. Have you have fun with it :)

iPhone application source code

Server binary (Update 2010-03-18: fixed a stupid bug)

(Usage: should run fine without any parameters. If it fails, try giving it your public IP. Eg: RemoteRocketController 192.168.0.x)

Posted in Tech | Tagged , , ,

Optimum Flow rate

Things have been faring well at work recently. After a couple of weeks of developing for the iPhone I finally feel that I can be as efficient as I was when working in Java. It took some brain adjustments and a lot of working environment adjustments (different keyboard, different mouse, IDE hotkey changes, ...) but I'm finally up to speed, and starting to enjoy it. Which is good, cause there's a deadline approaching. Yet it is perhaps thanks to this deadline that I am able to achieve flow once again. Just the right combination of pressure and skill. It's like a drug, really.

I think I underestimated developing for a mobile phone in the beginning, and that was the reason why I couldn't quite enjoy it. I felt limited by the framework cause the things I wanted to do were simply not directly possible. I never really felt that when programming in Java. That shouldn't really be a problem, because normally if you notice something missing, you create it. That's what programmers do: create code. Yet I was very reluctant to do so at first. The first thing Objective-C throws at you is memory management, which is scary as hell when coming from a garbage-collected language. Then the second thing that's easy to notice is the documentation. Every other line in Apple's iPhone documentation states "but be careful because processing resources are scarce! you need to code very carefully and smartly". Putting the elephant in the porcelain closet, and telling it to collect its own garbage. Ya.

I found that it's best to completely ignore these warnings altogether. Aside from a few basic rules that programmers must stick to when dealing with memory management there's really not that much to it. If you're neat and tidy, which I am in the process of becoming thanks to Apple. Great memory profiler too by the way. In the beginning I was reluctant to create a new re-usable component every time I face a problem, because I couldn't directly justify the extra time needed to make the component elegant enough to be reusable. Especially on a mobile platform I think it won't happen very often that I'll be able to re-use one of the components that I've created.

As a result the code that I wrote was quite ugly. And unmanageable. I made the assumption that on a mobile platform with a rather dodgy object-oriented implementation the rules of programming must somehow be different. Well, I can be very clear on this: they're not. It pays off to create reusable components and an elegant structure. Don't worry about resources or performance until it actually becomes a bother, and then refactor it into something faster. A cleaner design is always worth spending the extra time, even on mobile platforms.

Side note: Windows 7. Hmmmmm. It's clean.

Posted in Daily Life , Tech | Tagged , , ,

Best thing I ever did

I've been developing for the iPhone for about a month now, and the differences between Mac and PC are starting to sink in more and more. I've had some wonderful 'eureka' moments where something just clicked and I realized the Apple way of doing things (tm). The most memorable epiphamy came to me during a rather dull meeting, while I was playing with the touchpad of the Macbook Pro that I'm using. For some reason I swiped some dust off the pad with two fingers, and suddenly I noticed the window beginning to scroll. Something clicked in my mind, which resulted in an audible 'AH!', after which everyone in the meeting looked in my general direction with looks of surprise on their face. Score one for multitouch. It's awesome.

This anecdote, however, is by no means related to the title of this post. In fact, it's rather the opposite of the main feeling I wish to convey. While the Apple way is getting to me, there are still things that don't make sense to me even if I lived to be a hundred years (which I will). The Interface Builder is one of those things. At first glance it seems completely counter-intuitive, then I spent some time learning it and I thought it was brilliant. Then I actually used it and I realized that it's pretty much useless. There's never been a GUI builder that can replace good old-fashioned code, and this one is no exception. Perhaps I was expecting too much though, so I've been trying to use it as a supplement to the actual code, trying to design generic UI components that I can re-use later on. Well, no, not really. It doesn't really let you. If you want to use the interface builder, you'd better damn well define all your UI components inside it, otherwise you're screwed. Any form of nesting and you're back to coding it yourself. Oh, and don't get me started on the mystifying ways of figuring out in which initialization method you're supposed to link your buttons to your actions...

Pardon me for ranting. I am coming from a windows background, and it's a background that, remarkably,  I've grown to appreciate over time. I'll move on to the good stuff in a minute, but I'd like to end my rant first with a little code snippet, not of objective-C, but of Java, that demonstrates the incredible versatility and immensely powerful syntax of the language. Here it is:

button.setBackground(Color.red);
Rather anticlimactic, wasn't it? Does anyone want to guess how to set the background color of a button on the iPhone platform? I'll let you in on a little secret: you can set a background color, but it doesn't actually change the color of the button. It just changes the color in the four tiny rounded corners that the button covers. Without going into details about how to actually accomplish this in Objective-C (which involves images and stretchabilities), I'd just like to say that the solution is just plain stupid. It's another example that shows that Apple is clearly catering to their users, but not to their programmers.

Ok, enough ranting, let's talk about the good parts. I've been developing on the macbook for quite some time now, and it's a pretty awesome machine. With a few drawbacks though. In particular, I'm not too happy about the keyboard. And the display. And the development software. And the touchpad. And the external mouse. Ok, basically it sucks. I'll list the stuff here that annoyed me and how I fixed it.

  • Japanese keyboard layout --> switched to external US English keyboard: productivity +500%
  • Mac function keys that I'm not used to --> switched external keyboard's control key and windows key function in system config: productivity +400%
  • Changed XCode key mappings to correspond to Windows/Eclipse equivalent. Just fixing the Home and End key increased productivity by 6000% (more or less)
  • Mouse fix one: added external mouse for extra speed: productivity +10% - no matter how you configure the mac's mouse settings, the mouse is either too sluggish or apeshit crazy.
  • Mouse fix two: using Synergy to use my Windows mouse instead --> productivity increase: 5000%
  • Damn glossy screen that reflects the ceiling lights above my desk no matter in which position I put the laptop --> connected to external monitor (with higher resolution): productivity +1000%
  • Completely unrelated to all of the above but GOD WHY aren't there namespaces in Objective-C?!?!
Summarizing what I've done, I've basically thrown away as much Mac as possible and replaced it with the PC equivalent. You can hate me if you want, but in my professional opinion as a programmer it was just slowing me down. After enduring it for a month I think I have a right to say that. If possible I'd rather ditch the xcode playmobil programming environment too, but the integration with the iPhone is still too convenient to consider such a thing. I wish that Eclipse can somehow support the iPhone, because I think Eclipse is better than xcode in every other way. Well, except memory usage of course. Eclipse has a bit of a fat butt, but it'll satisfy you in many ways!

Well now, this turned out to be a huge troll. I do feel slightly sorry about that. I'm still learning new stuff about the platform every day, and I'm sure that I'll become happier and more efficient the more I use it. But just to annoy you guys I will troll a bit more by saying that I get the impression that developing on the mac will be enjoyed the most by people who enjoy getting a fresh cup of coffee after every line of code. There.

Despite this post I am quite happy actually. After setting up the macbook to behave like a PC as much as possible I feel that I've got my productivity back. I got a lot of work done today not in the least thanks to the English keyboard and the quicker mouse. There are those days where you just have to keep your down and churn out code as much as you can. It might not be the most exciting aspect of programming, but sometimes it's necessary. And thanks to the new keyboard, mouse, screen and key mappings I've managed to do my job in less time, and in a better mood. Don't neglect your quality of job-life, guys!

Posted in Tech | Tagged , , ,