I’ve been diving into OCaml recently. It’s a fun language and a bit different as the statically typed, type-inferencing languages go. OCaml is not only a full-bore functional programming language; it also compiles to native code on many platforms and it's very fast. You can’t call it a propeller-head language. That won’t do. People do some incredibly practical work in OCaml. It’s sort of the functional programming language equivalent to Python.

Part of the fun of OCaml is its syntax. It's a little quirky. List elements are separated not by commas, but by semicolons:

List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];

There are some other strange choices as well. If you want to send a message, you use the hash symbol between the object name and method rather than a dot:

  method run result =
      result#test_started;
      self#set_up;
      try self#run_test result with
        TestFailure message ->
          result#add_failure test_name message;
      self#tear_down

I’m not sure why the language designers made these choices, but I suspect that history has something to do with it. OCaml is derived from Caml which, in turn, is derived from Robin Milner’s ML. Language design is evolutionary and early choices, to some extent, constrain later choices. One thing that is obvious, though, is that OCaml definitely isn’t in the C language family so if you're used to Java, C++, or C#, it does look a bit alien. For me, it's been hard to tell whether its syntax is any more inconsistent than the syntax of C-derived languages. It may just be that my eyes aren’t tuned to it yet.

It’s hard to talk about it without devolving into a language war, but syntax does matter. And, it affects more than aesthetics, it can affect correctness as well.

One of the bits of syntax I love the most is the way that Ruby handles instance variables. In Ruby, you preface them with an ‘@’. My first impression when I saw this was “Wow, what a pain! You have to have ‘@’s all over the place.” But, as I used Ruby, I appreciated how important that choice was. In C++ and Java, it is relatively easy to assign an instance variable to itself in a constructor. That never comes up in Ruby. Moreover, you aren’t tempted to make up silly names to disambiguate constructor arguments and instance variables.

No, I think syntax does matter, and I don't think it's wholly subjective.

Here's a quicksort in Erlang:

qsort([]) -> [];
qsort([Pivot|Rest]) -> qsort([ X || X <- Rest, X < Pivot]) 
        ++ [Pivot]
        ++ qsort([ Y || Y <- Rest, Y >= Pivot]).

And, here's a similar quicksort in Haskell:

quicksort [] = []
quicksort (s:xs) = quicksort [x|x <- xs,x < s] 
        ++ [s] 
        ++ quicksort [x|x <- xs,x >= s] 

Which one do you like better? Which one seems easier on the eyes? Are there some objective criteria for syntax in language design?