Archive for May 2009

Reply to Randal on dynamic type systems

At first this I wrote this as a comment on my original post, but it grew a bit too long so I decided to post it like this instead.

@Randal, “Static typing is still effectively a syntax check, not a semantic check though.” Now, I think we might have a different understanding of the word “syntax”. I can guess at yours, but my understanding mirrors what’s on Foldoc, that is syntax determines what is a valid string in a program, in this case it determines where a type declaration/definition/statement goes, but not what type declaration/definition/statement is semantically valid in a particular position in a string. That “what” is very much part of the semantics in my mind, it tells the world (me, other users of my library, the compiler) a part of the intention of a function, it tells how something may be used. I gather you are mostly familiar with type systems like Java so what is clearer to you, this declaration:

int add(int i, int j);

or this declaration:

int add(i, j);

In the former the intent of the function is obvious, it adds integers. In the latter it isn’t, does it handle complex numbers? Does it handle matrices? In dynamic languages you’d have to document it somewhere, but there is no consistency check between code and documentation (maybe there are external tools for that though, but why not use the compiler to check?). You would also have to test that no caller of this function can be tricked into calling add with a non-integer.

Also, though your example of “semantic type checking” in the talk is interesting (I simply don’t know if there are any type systems that could deal with it) you completely skip all the cases where the type system can do the job and where it does save on testing and typing. In these cases you would have a proof relating to your use of types in the program, unit testing can never give that proof it can only show you haven’t disproved it yet :-)

If you remain unconvinced then I strongly urge you to read Tom Moertel’s post on providing safe strings, and the assurance you can achieve by using a strong type system in relation to information flow through your program. The same technique has been used in Darcs (watch the video, the bit relevant for this dicussion starts about 43 minutes in).

I urge you to read Kristian’s blog post (linked to in his comment).

If you want a podcast to listen to there’s episode 62 of Software Engineering Radio where Martin Odersky talks about Scala (a statically typed language built on the JVM).

I’d also like to clear one thing up, I don’t dislike dynamic languages and I don’t think that static languages are inherently better. What I do dislike about your talk is that it’s uninformed, presents very narrow arguments and then draws conclusions that are very general and simply don’t follow from the given arguments.

Finally, I really enjoy FLOSS Weekly. You and Leo are doing a fantastic job on it, but since it is where I first heard of your talk (I suspect Industry Misinterpretations might not get a lot of attention outside the Smalltalk community) I really think you should talk to someone from the FLOSS FP community. Get someone who can explain, much better than me, what a modern, advanced, strong, statically typed language will get you. I only have experience with OCaml and Haskell, and there are others, like Scala, all are FLOSS and hopefully it wouldn’t be too much work to find someone knowledgable who’d be willing to set you straight on the dynamic vs static typing issue. I’d be happy to do what I can to help you find someone, just let me know if you are insterested :-)

Struggling with “the Arch way”

So, I’m struggling somewhat with the move to Arch. Not that Arch is problematic in any way, it seems to be me and my “debianised thinking”.

I noticed that the Vim plugins that were packaged for Arch all install in system directories and hence are imposed on all users. Not a good thing. So, inspired by Debian’s vim-addons-manager, I hacked up a solution relying on pacman. Then I packaged two Vim plugins for Arch. The idea was to do rather than talk, so it wasn’t until after this that I asked for feedback on aur-general. Just to have the idea shot down :-)

Anyway, after being presented with an existing solution more inline with “the Arch way” I decided to try it out. I’ve now subscribed to using GetLatestVimScripts. Brilliant.

Now I need to convince the author of haskellmode to put it on vim.org and I really ought to get my packages off AUR.

Randal Schwartz on why dynamic beat static—a rather rubbish talk

Well, not the most diplomatic title maybe, but listening to Randal Schwartz’ talk “Dynamic Returns” first made me laugh and then made my fingers itch to write him an email addressing the fallacies he is peddling. Anyway, I wrote this large, rather ranting, blog post but then decided to not publish iti.

Randal, my suggestion to you is that you get someone like Don Stewart on FLOSS Weekly (I believe he is based in Portland as well) to discuss how Haskell’s advanced type system can be harnessed to completely remove whole classes of bugs.

  1. Randal, if you read this I’ll be happy to send the draft version of the post to you, just drop me an email :-) [back]

Vim haskellmode packaged for Arch

A few days ago I packaged the vim haskellmode for Arch Linux and uploaded it to AUR.

Configuring audio for my Arch desktop

I probably started in the wrong end, by installing a few GStreamer packages:

  1. gstreamer0.10-bad-plugins
  2. gstreamer0.10-ugly-plugins
  3. gstreamer0.10-ffmpeg

It was first after that that I actually configured sound :-)

As always the Arch Wiki contains all the information needed, and more. There’s a page for configuring Alsa. All I did was install alsa-utils, make sure my user was a member of audio and then configure using alsamixer until aplay /usr/share/sounds/alsa/Front_Center.wav played properly. Then I put alsa in the DEAMON list in /etc/rc.conf.

Next I installed and configured PulseAudio. Again there’s an excellent page with instructions for configuring PulseAudio on the wiki. For me that meant first installing pulseaudio and alsa-plugins. Then I used vigr to add my user to pulse-access and pulse-rt. I also created /etc/asound.conf, following the instruction on the wiki it contains the following:

pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

I then double checked that PulseAudio uses HAL to detect the needed modules. Lastly I made it possible for gstreamer to use PulseAudio by installing gstreamer0.10-pulse.

[edited 22/5/2009] Added info on group membership.

Odds and ends for my Arch desktop

After the previous setup steps I found the next task was to add a few odds and ends really were needed before proceeding to other major things, like audio, email, and such. Several of the things I needed are available from AUR so to make things easier I started by adding archlinuxfr to my /etc/pacman.conf:

--- pacman.conf_orig    2009-05-09 18:47:19.825013872 +0100
+++ pacman.conf 2009-04-26 08:22:05.471685249 +0100
@@ -70,6 +70,9 @@
 # Add your preferred servers here, they will be used first
 Include = /etc/pacman.d/mirrorlist

+[archlinuxfr]
+Server = http://repo.archlinux.fr/x86_64
+
 # An example of a custom package repository.  See the pacman manpage for
 # tips on creating your own repositories.
 #[custom]

After that I updated the package listings (pacman -Sy) and installed yaourt (pacman -S yaourt).

After this I could easily install the other packages I need:

  1. nautilus-dropbox
  2. encfs
  3. pam_mount
  4. keysafe
  5. hpodder
  6. twitux

Only pam_mount needed some extra configuration. First I added two lines each to /etc/pam.d/gdm and /etc/pam.d/login:

auth        optional    pam_mount.so
session     optional    pam_mount.so

Then I modified /etc/security/pam_mount.conf.xml to allow users to have their own configs, that’s done by uncommenting the line

<luserconf name=".pam_mount.conf.xml" />

Arch and Haskell, on little snag

Dear lazyweb (Arch users and especially DonS :-) ),

I just used yaourt to update my system and it noticed that haskell-time was available in a new version. After answering a few questions I was greeted with this message:

ghc-pkg: unregistering time-1.1.2.3 would break the following packages: hslogger-1.0.7 MissingH-1.1.0
    ConfigFile-1.0.4 convertible-1.0.1 HDBC-2.1.0 HDBC-sqlite3-2.1.0.0 HSH-1.2.6 (use --force to override)
error: scriptlet failed to execute correctly

Is there already some automated way to deal with this? (How to deal with it manually is fairly obvious to me…)

Setting up my network services on Arch

After having set up X (not sure I really can call just installing it “setting up” though :-) ) and Gnome, which of course included installing and configuring Xmonad, I went on to configure some network-related stuff.

At home I use mDNS to make it easy to connect to the computers we have at home. I added avahi to the list of services to start in /etc/rc.conf and installed nss-mdns. Then I following the instructions on how to configure mDNS on Arch, which resulted in the following changes:

--- /etc/nsswitch.conf_old  2009-05-02 21:17:06.460591935 +0100
+++ /etc/nsswitch.conf  2009-04-25 18:08:39.719853968 +0100
@@ -6,7 +6,7 @@

 publickey: files

-hosts: files dns
+hosts: files mdns_minimal [NOTFOUND=return] dns mdns
 networks: files

 protocols: db files

I also need SSH access to my desktop machine so I installed OpenSSH (openssh). No changes were needed to the configuration but following the instructions I made the following change to /etc/hosts.allow to allow connections at all:

--- /etc/hosts.allow_orig   2009-05-02 21:31:16.243401337 +0100
+++ /etc/hosts.allow    2009-04-28 17:55:57.553603986 +0100
@@ -2,5 +2,6 @@
 # /etc/hosts.allow
 #

+sshd: ALL

 # End of file

Then of course I added sshd to the list of services in /etc/rc.conf.

The last step was setting up NTP, based on suggestions on the Arch Wiki I installed OpenNTP (openntp) rather than the standard NTP package. No changes to the configuration were needed, just adding it to DAEMONS in /etc/rc.conf.

That was it, all the crucial network-related services set up and running at boot.

Arch, Gnome, and shutdown/reboot

I’ll soon continue documenting my experience with installing and configuring my desktop, but first a note on fixing an irritating issue in Gnome 2.26. Soon after installing Gnome I noticed that I couldn’t reboot or shutdown from inside my Gnome session, I had to log out and use GDM’s action menu instead. Rather irritating, but something I could live with until the weekend. It took a while to find the solution so to safe myself time in the future I’ll document it here. It might even help someone else, who knows?

Whenever I tried to reboot or shutdown I saw the following message appear in ~/.xsession-errors:

gnome-session[4134]: WARNING: Unable to list sessions: Rejected send message, 2 matched rules;
type="method_call", sender=":1.50" (uid=1000 pid=4134 comm="gnome-session ")
interface="org.freedesktop.ConsoleKit.Manager" member="GetSessions" error name="(unset)"
requested_reply=0 destination="org.freedesktop.ConsoleKit" (uid=0 pid=2838
comm="/usr/sbin/console-kit-daemon "))

After giving up on finding a solution with Google I turned to #archlinux and was pointed to a forum post. That discussion doesn’t mention the warning message at all, so it wasn’t obvious to me at first that it was the same issue. However, about half-way down the page I found a post by justusjonas that looked relevant. I tried that change, or rather something very similar, and a manual reboot later I could confirm that the change indeed fixed the issue. This is the change I applied:

--- /etc/dbus-1/system.d/ConsoleKit.conf_org    2009-05-02 15:59:40.235077390 +0100
+++ /etc/dbus-1/system.d/ConsoleKit.conf    2009-05-02 16:00:10.108231150 +0100
@@ -32,6 +32,8 @@
     <allow send_interface="org.freedesktop.ConsoleKit.Manager"
            send_member="GetSeats"/>
     <allow send_interface="org.freedesktop.ConsoleKit.Manager"
+           send_member="GetSessions"/>
+    <allow send_interface="org.freedesktop.ConsoleKit.Manager"
            send_member="GetSessionForCookie"/>
     <allow send_interface="org.freedesktop.ConsoleKit.Manager"
            send_member="GetSessionForUnixProcess"/>