As all MacPorts users know, the process of building can take a significant amount of time when installing ports.

While setting up my new multicore machine, I had to install a lot of ports, and I was surprised to see that MacPorts only used one core when building (by the way, it seems that this may be about to change).

To have MacPorts use all cores, change the following in /opt/local/etc/macports/macports.conf (if you installed MacPorts in the default location):

# Add the following line:
use_parallel_build  yes

# Find and update this line. Specify the number of
# concurrent jobs to run or 0 for "auto" (ie. use all cores available).
buildmakejobs       8

However, note that each individual port can override these values, and unfortunately, it seems that many ports do.

JAOO 2008 recap

October 15, 2008

So, time for a (late) JAOO 2008 recap. How was it this year?

The keynotes

Unfortunately, the keynotes were clearly lacking this year, but in very different ways.

Monday, Anders Hejlsberg talked about the future of programming languages. Or should I say, the future of programming languages on the .NET platform. For which there is currently support in Visual Studio. Don’t get me wrong, I actually like .NET, even though I hate Windows. But for the opening keynote, talking about F#, LINQ and P-LINQ (with the Pascal background intro that seems to be becoming the slightly dull backdrop for Hejlsberg’s talks) simply doesn’t cut it. And switching to VS three times to do live demos is just missing the mark by a mile. I was very disappointed with this talk, but mostly because I know how brilliant Hejlsberg is, so I expected more than just an MS-centric view of the future.

Lars Bak talked about V8 tuesday. This keynote was a bit special, because obviously it had to be planned some time in advance, and the V8 project was only revealed very recently.

Working in the office next to Lars and the rest of the Google team here in Aarhus, I was very curious to hear more about what they have been up to for the last few years. In that respect, I certaintly wasn’t disappointed. The talk was rich on details, so having no experience with VMs (in the V8 sense, not the VMware sense :-)), I was lost at times. But this was no problem, and it was great to hear Lars explain about the challenges they’ve been facing in creating V8. Also the QnA session was very good.

So I was very pleased with this keynote, actually. But as someone pointed out to me later on, the topic really wasn’t keynote material. Interesting as it was, and popular as the topic is, it was obviously only relevant for a fraction of the audience. Nevertheless, I personally enjoyed this one.

Wednesday’s keynote was a complete disaster. The otherwise brilliant Guy Steele and Richard Gabriel (who is also very bright, I’m sure) did their “50 in 50” routine, and I have to say that I absolutely loathed every minute of it.

The tagline was something like: 50 remarks in 50 minutes, each 50 words long (if I recall correctly). The remarks were interspersed with images, audio and video clips. The substance of the talk was a tour through the last many (50?) years of programming languages, sprinkled with uber-geeky humour. Definitely not for me, but fortunately, judging from the reaction of the audience, others liked it better.

However, I’m pretty sure noone enjoyed the fact that they went more than 20 minutes over their time slot. Given that the talk was so rigorous in its form, I simply don’t understand how this could happen.

The talks

I didn’t see as many talks as I would have liked this year, but I did see some good stuff.

Guy Steele gave a great talk on Fortress. Not unlike the one he gave last year (or was it 2006?) but with even more substance. Some of the maths stuff was over my head, but that didn’t matter. The important this was that the talk was interesting and really whet my appetite for learning more about Fortress.

Also, Sun ran a great little competition in the exhibition area this year. A guy came around to our booth with 2-page Fortress program that solves Sudoku puzzles in a massively parallel fashion. The challenge was to figure out how many threads of execution are used, and the prize was a Sun-branded USB stick with the latest snapshot of Fortress on it. I still have the program on my home office wall, and when I feel like it, I look over it and understand another little chunk. Unambitious, you may say, but a lot better than putting it away and forgetting all about it.

Wednesday, a guy from LEGO gave a pretty weak talk about a project that actually looks very interesting. They’re building a new “robotics platform” called WeDo, which is basically a $30 (IIRC) kit with a few motors and sensors. This was a challenge spurred by the OLPT project, so various measures have been taken to target it at developing countries. For example, the robot is connected to the laptop with a USB cable because batteries may not be readily available. A very cool project, but the presentation was really a drag… For instance, I now know that LEGO uses Perforce for their software projects, and I would have lived happily on without that piece of information.

Lastly, the talk “The lively kernel” by Dan Ingalis was awesome! I urge you to check out this video demo or simply have a go at it yourself. I’m very curious to see what this project might lead to in the future.

The exhibition floor

Again this year, we had a VMware Denmark stand, and we got to show off our software and tell people what we do.

One thing that we all noticed was how much more aware of virtualization everyone was this year. At last year’s JAOO, we were very surprised to learn how many developers simple had no idea that virtualization existed as a concept. But this year, it was different. Maybe because we handed out so many VMware Workstation coupons last year 😉

On the demo side, we had taken the time to get a VMotion setup up and running this year. Two ESX hosts and a Linux VM running some streaming video server being moved between them. And obviously a third machine running Virtual Center and a VLC player showing the streaming video without a glitch as the VM was moved. A lot of the attendees didn’t know that this was possible and wanted to know the details of how it works.

Also, we brought our Mac Mini running the recently-released Fusion 2. With all the Google Chrome hype in full effect, it was a lot of fun showing off Chrome running (apparently) natively on the Mac! Of course, it was running in a Windows VM in unity mode, but we did manage to fool a few people 🙂

Version 2 of Fusion also adds the ability to run Linux VMs in Unity mode, so we were able to fire up Chrome, Safari and Evolution side-by-side on the (struggling) Mini.

Conclusion

I didn’t go to a lot of talks this year (I was at work most of Tuesday) so I shouldn’t pass judgment on the conference as a whole. But I do think the keynotes left a lot to be desired.

Also, I think the Trifork team should reconsider the number of tracks on the conference. Judging from various Ruby-related blogs, the trend for conferences is clearly in the direction of fewer tracks (often just one) and much shorter talks.

I think this makes perfect sense. We go to conferences to widen our perspectives on software development in general. And you really don’t need 50 minutes to present new ideas or projects. With so many tracks going on at the same time, attendees constantly need to discard a lot of material. This would be less of a problem if there wasn’t such a big overlap between the topics of the tracks. But as it is, I think most developers wish they could follow 2-3 concurrent tracks. This leaves you with a constant feeling of missing out on interesting stuff (which you probably are!), and if you’re unlucky enough to attend a boring talk, its 50 precious minutes gone.

I think the organizers should consider cutting the number of tracks and the length of each talk in half. The talks should inspire and engage the audience, and this can easily be done in 25 minutes, leaving us with an urge to know more. The success of a talk should be measured by the surge of hits to the project’s website after the talk, not by the number of people still present in the room after 50 minutes.

Quickly jumping to symbols

September 3, 2008

This is brilliant.

For a while, I have been using ido to quickly jump between buffers and files by just typing any part of the file/buffer name I want. In fact, typing any sequence of letters narrows the interactive search to candidates with names that contain those letters in that order:

 fb -> Foobar, FrancisGailBrown

But for finding method definitions in a big source file, I have always just used isearch. It turns out that there is a better way.

By combining imenu with ido, I can quickly find methods as well:

All it takes is this method in my init.el:

(defun ido-goto-symbol ()
  "Will update the imenu index
   and then use ido to select a
   symbol to navigate to"
  (interactive)
  (imenu--make-index-alist)
  (let ((name-and-pos '())
        (symbol-names '()))
    (flet ((addsymbols (symbol-list)
                       (when (listp symbol-list)
                         (dolist (symbol symbol-list)
                           (let ((name nil) (position nil))
                             (cond
                              ((and (listp symbol) (imenu--subalist-p symbol))
                               (addsymbols symbol))

                              ((listp symbol)
                               (setq name (car symbol))
                               (setq position (cdr symbol)))

                              ((stringp symbol)
                               (setq name symbol)
                               (setq position (get-text-property 1 'org-imenu-marker symbol))))

                             (unless (or (null position) (null name))
                               (add-to-list 'symbol-names name)
                               (add-to-list 'name-and-pos (cons name position))))))))
      (addsymbols imenu--index-alist))
    (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
           (position (cdr (assoc selected-symbol name-and-pos))))
      (goto-char position))))

I have bound it to C-t, because I realized that I don’t use transpose-chars (or whichever transpose method was there..I don’t use any of those, really).

I found this trick on the imenu wiki page.

My first AVR-based project

August 16, 2008

I have always been fascinated by electronics. As a child, I tore apart several rather expensive appliances to see how they worked. Much to my parents’ grief, of course.

However, since I got into software development, I haven’t given it much thought. Moving several levels of abstraction away from the hardware, your focus shifts quickly to completely different areas.

But recently, this project caught my attention for some reason. So even though I ended up implementing it completely differently, I couldn’t stop thinking about the potential of being able to write code for tiny, cheap embedded processors.

I’m not sure why I have never thought of this before. I have considered writing software for PDAs, but they’re pretty expensive, and the platform choices are poor. Windows Mobile is a joke, and Palm OS is not very appealing either.

So I decided to take a big step closer to the iron. Knowing nothing about the state of this field, I simply googled for a few starting points. I ended up buying the very cool USBtinyISP programmer kit (and absolutely enjoyed the process of assembling it).

Also, I got the ATtiny26 development board from Active Robots.

This last item, I have later discovered, is probably somewhat outdated. What you want for electronics prototyping these days is the Arduino.

Anyway, the great thing about the ATtiny is that it’s cheap (the processor itself is about $4) and it doesn’t consume a lot of power.

OK, so what did I do for my debut project? Nothing very interesting, I’m afraid. I wrota a program that simply morses a sentence using the LED built into the development board. I used the GNU toolchain (avr-libc et al) for writing the program and avrdude for flashing it onto the processor. Works great on both Linux and OSX.

In action, this is what it looks like:

And yes, I realize that the quality of the video is too crappy to distinguish the pulses.

Here is the complete source code for this project:

#include
#include
#include
#include
#include

/*
 * The morse alphabet.
 *
 * 0: Short pulse
 * 1: Long pulse
 */
const char ltr_a[] PROGMEM = "01";
const char ltr_b[] PROGMEM = "1000";
const char ltr_c[] PROGMEM = "1010";
const char ltr_d[] PROGMEM = "100";
const char ltr_e[] PROGMEM = "0";
const char ltr_f[] PROGMEM = "0010";
const char ltr_g[] PROGMEM = "110";
const char ltr_h[] PROGMEM = "0000";
const char ltr_i[] PROGMEM = "00";
const char ltr_j[] PROGMEM = "0111";
const char ltr_k[] PROGMEM = "101";
const char ltr_l[] PROGMEM = "0100";
const char ltr_m[] PROGMEM = "11";
const char ltr_n[] PROGMEM = "10";
const char ltr_o[] PROGMEM = "111";
const char ltr_p[] PROGMEM = "0110";
const char ltr_q[] PROGMEM = "1101";
const char ltr_r[] PROGMEM = "010";
const char ltr_s[] PROGMEM = "000";
const char ltr_t[] PROGMEM = "1";
const char ltr_u[] PROGMEM = "001";
const char ltr_v[] PROGMEM = "0001";
const char ltr_w[] PROGMEM = "011";
const char ltr_x[] PROGMEM = "1001";
const char ltr_y[] PROGMEM = "1011";
const char ltr_z[] PROGMEM = "1100";

PGM_P alphabet[26] PROGMEM = {
    ltr_a,ltr_b,ltr_c,ltr_d,ltr_e,ltr_f,ltr_g,ltr_h,ltr_i,ltr_j,ltr_k,
    ltr_l,ltr_m,ltr_n,ltr_o,ltr_p,ltr_q,ltr_r,ltr_s,ltr_t,ltr_u,ltr_v,
    ltr_w,ltr_x,ltr_y,ltr_z
};

void sleep_msecs(int msecs)
{
   /*
    * The argument to _delay_ms must be constant (ie. known at compile-time).
    */
   int i;
   for(i = 0; i < msecs; i++){
      _delay_ms(1);
   }
}

void set_led_state(int state)
{
   PORTB = (state == 1) ? _BV(6) : _BV(0);
}

/*
 * Emit single pulse
 *
 * Length choices are:
 * 0: short
 * 1: long
 */
void emit_pulse(int length)
{
   set_led_state(1);
   sleep_msecs((length == 1) ? 210 : 60);
   set_led_state(0);
   sleep_msecs(100);
}

/*
 * Emit a sequence of pulses, eg. "1000" for the letter "b".
 */
void emit_pulses(char *pulse_str)
{
   int pulse_str_len = strlen(pulse_str);
   int i2;
   for (i2 = 0; i2 < pulse_str_len; i2++) {
      emit_pulse(pulse_str[i2] == '1');
   }
}

void emit_letter(char l)
{
   if (l == ' ') {
      sleep_msecs(700);
      return;
   }

   char *buf = malloc(8 * sizeof(char));

   int index = l - 'a';
   PGM_P p;
   memcpy_P(&p, &alphabet[index], sizeof(PGM_P));
   strcpy_P(buf, p);
   emit_pulses(buf);
   free(buf);
}

void morse_msg(const char *msg)
{
   int len = strlen(msg);
   int i;
   for (i = 0; i < len; ++i) {
      emit_letter(msg[i]);
      sleep_msecs(350);
   }
}

void do_morse(const char *msg)
{
   for(;;){
      morse_msg(msg);
      sleep_msecs(2500);
   }
}

int main(void)
{
   /* Init IO */
   DDRB = _BV(6); /* make the LED pin an output */

   do_morse("er der mon mere kaffe");

   /* Not reached */
   return 0;
}

In case you’re wondering, the morsed message, “er der mon mere kaffe”, is danish for “I wonder if there’s any more coffee”. Indeed, the first thing that sprang to mind when I finally got the software working.

If you’re a cat owner, you know that cats love to drink from the faucet!
Being a cat owner myself, I was pretty excited to learn about this Cat Faucet project by Sixerdoodle Electronics. I have often thought about building something similar myself, but I had never gotten around to it.

However, even though the design of the Sixerdoodle Cat Faucet is very elegant, I find it more complicated than necessary (mainly because they wanted to keep it low voltage, it turns out).

So I started wondering how to build the simplest possible cat faucet. This is what I came up with:


(Open above image, with notes, in a new window)

(Diva enjoying the running water)

The complete list of components:

  • a solenoid from an old dishwasher
  • a movement sensor (the kind usually used to light up a driveway)
  • a few bits of plumbing
  • a piece of gaffer tape to limit the area monitored by the sensor

(Solenoid from an old dishwasher)

(The movement sensor, pointed straight down)

That’s it. The flow of water is controlled simply by adjusting the position of the red valve that lets water into the system. The sensitivity and timeout of the sensor can be controlled with small knobs on the underside.

My wife put a little bowl underneath the faucet to allow the cats to drink from a surface of water as well as from the running water. Excess water simply spills down the drain below.

Contrary to the Sixerdoodle design, my cat faucet is not low voltage (it runs on 230V, our mains voltage in Denmark). However, because both components were designed to be safe and withstand pretty rough conditions, this does not worry me at all.

(The finished setup, tucked away under a small shelving unit)

(Obviously, it takes a little practice!)

As anyone who follows the virtualization business know by now, this has been a tough week for us at VMware.

CEO Diane Greene stepped back, effective immediately, and was replaced by ex-Microsoft employee Paul Maritz.

This event led to a brief discussion with one of my collegues, who is also a former MS employee, about whether or not Microsoft is an evil company.


(Photo: batmoo)

As he pointed out, MS has invested huge sums in research, and has hired some of the brightest people out there. These people come up with excellent ideas and they receive the funding to put those ideas into practice.

So what is the problem? One word: Windows.


(Photo: aralbalkan)

I am not at all a religious man, and I certaintly don’t want to be religious about this either. But the fact of the matter is, I find Windows completely ridiculous as a platform for anything but gaming. This is my honest opinion.

I was frustrated to read an article about Silverlight 2 in the August issue of DDJ. This is actually pretty cool stuff, but it is not for me. I know it runs on my Mac, but you need Windows to do any serious development.


John Lam – what a waste of talent (Photo: timheuer)

I don’t have the patience for running Windows, because it sucks terribly. This is hardly a controversial opinion. I tolerate it at work, because the job is otherwise great, but I wouldn’t dream of running it on my home computers. Over the last few years, I have come to realize that OSX is the only OS that doesn’t suck one way or the other. For a few years, I was running Ubuntu on my laptop, but I was never very happy with it. I was wasting far too much time fixing small problems and trying to get basic stuff like suspend/resume working.

On my MacBook Pro, everything works. I have been using it daily for a few years now, and the number of times is has crashed is still below ten. You would never get that kind of milage from a Windows box, probably not even if you left it idle.

So while I really like .NET, C#, LINQ and all that, I can’t use it, because I can’t stomach the OS that comes with it. I really don’t care very much about whether Microsoft is good or evil, but I’m sad to see so much talent go to waste. This is why I don’t like Microsoft.

MySpace sucks!

July 6, 2008

I have always suspected that MySpace sucked. More than once, a profile page has killed my browser or consumed all resources on my machine for half a minute. In fact, at the time of this writing, my Safari seems to have died.

However, I always thought that the MySpace users were to blame. I knew that you can add HTML and CSS to your profile, so I assumed that people just messed up their profiles.

While that may be true, the MySpace site itself is just absolutely bloody ridiculous.

My wife is a singer/songwriter, so she needed a MySpace profile to demo her work. Naturally, I volunteered to help her create one.

Now, for some reason a “MySpace Music” profile is different from a regular profile, which translates into additional punishment trying to figure out how the s*** works.

Alright, enough bitching. I believe the following facts speak for themselves:

1) From her public profile, she can click “My MySpace” to reach a personalized, dashboard-style page where she can check out her own “mood” and enjoy lots of colorful ads.

2) Clicking “My account” brings up a section where she can change her email-address etc.

3) Selecting “Profile” -> “Edit profile” allows her to change “Interests”, “Background”, “Education” etc. In short: Social networking metadata.

4) Surprise #1: None of the information entered in (3) are visible in her public profile!

5) Selecting “My account” -> “Edit profile” bring up an entirely different section, allowing her to edit information relevant to her music (add upcoming shows, upload songs etc).

6) The information entered in (5) is displayed on her profile.

So there you have it. Two completely different meanings of the link “Edit profile”, depending on where you find it. Usability people should be weeping by now. And this is just one example of the brokenness – I won’t bore you with details of how confusing the danish translation of the site is. Even on the all-US site, you will find typos and spelling errors.

I suspect MySpace has become insanely popular for the same reason that Microsoft did: Lack of competition.

As far as I know, MySpace was the first site to offer free MP3 hosting for amateur artists. And I certainly recognize that it has helped a lot of musicisians expose their music. This is good – we all benefit from this one way or the other.

But as in the Microsoft case, the inertia of beating the competition is truly scary. Both “MS’s” are clearly deficient compared to their competition. Only diehard fans will suggest otherwise. However, they both have huge market shares, so they remain the default choice. Come to think of it, this is the same mechanism that keeps IBM consultants in business.

I need to get some sleep now. This is just too depressing.