Archive for the ‘Haskell’ Category

Subsequent Thoughts on Concurrency

Tuesday, November 7th, 2006

Over the past few years my opinions on concurrency have changed. I mean, threads were always a pretty scary thing. I figured that no matter what I did, there must be a race condition or deadlock in there somewhere (and really, if you ever think otherwise, you\’re just fooling yourself). I didn\’t know of any alternatives. Java\’s approach seemed to have some merits — all you had to do was write synchronized, right? — and I took it a bit further with a language I was designing some years back. Here\’s an image from the spec:


Typing Done Right

Saturday, September 17th, 2005

I\’m a big fan of all the sort of agile/dynamic sort of stuff. C2:TestDrivenDevelopment, C2:IterativeDevelopment, etc. But one thing I\’ve always had trouble with is accepting C2:DynamicTyping as the Right Thing. I mean, yeah, C2:ManifestTyping sucks, but C2:TypeInference is there to pick up the slack, as ML and Haskell show. With type inference, you get the clear code of dynamic typing, with the safety and performance of static typing. Which, I thought, was everything.

Yeah, I had heard the whining of those die-hard dynamicists who procliamed that there are correct programs that can not be statically typed. I didn\’t disagree, but I felt that for all practical purposes it was irrelevant. However, I\’m now working on a project where static typing gets in my way every day. It\’s unbearable.

I have a solution, which I think balances all the important bits. Yes, it\’s not perfectly \”safe\” like you static guys like, but it gives you the flexibility when you need it.

  1. type inference is key;
  2. there should be something like C2:CommonLisp\’s DECLAIM that allows you to say whether un-inferenceable bindings are errors, warnings, or ignored (and should default to errors, making the static guys happy);
  3. you can DECLARE individual bindings as dynamic, regardless of whether they\’re treated as errors.

Anyone who just wants dynamic fun DECLAIMs that un-inferenceable bindings are ignored, while others can make them warnings or errors and deal with the exceptions on a case-by-case basis. Type inference is always used whereever it is possible.

Patterns of Deconstruction

Wednesday, March 16th, 2005

One of my favorite features of Haskell is its parameter patterns (yes, it\’s in ML, but I\’m not really the ML guy). They\’re a nice way to break down structures automatically, and to avoid doing conditionals explicitly. In an imperative language, you might have:

sh: /home/pfeilgm/bin/enscript: No such file or directory