So, I’ve been spending some time with new programming languages over the last few months trying to see if I am missing a trick. Maybe there are some things that are easier if you find the right language.
I’m not looking for a DSL exactly, but more of a tool that people other than programmers could use. I’ve been particularly looking at data analysis systems like Matlab, python + num.py, R. One of the things you notice is that you’ve got used to C-style syntax which has completely dominated programming languages – except for aberrations like Haskell and f# – that you think everything else is weird. But you have to free your mind, maybe there is a better way.
Consider this code from Matlab, which creates a million random numbers, and profiles the performance as it does so:
Whoah. Tic toc? Seriously? But it’s readable, up to a point. The lack of structure makes it easy to read initially but then you get into trouble. Like removing all the punctuation from a novel you end up doing some weird stuff because you can’t tell when Jane is speaking or if it was Barney the dog. It is probably easier to write it that way as long as you do it right first time and don’t have correct it.
C# is becoming a language where one can adopt many different styles, and the language constructs are quite dazzling. Classes, static, virtual, public, namespaces, bracket syntax, overloaded operators, attributed code, LINQ (functional expression or query syntax?). All this adds to the syntactic noise that obscures. I saw a little of that when I tried to teach my kids to read. When they start, even the idea that letters mean sounds is hard to get across* and every distraction is a problem. Which is why Comic Sans
is so popular.
You can start putting that structure into these other languages, but then they lose some of the stuff that made them good. Plus you have to make that structure up as you go. They also lose some of the fun.
Matlab is based around an interactive session that is something like a SSMS query window where you run “live” and a powershell command line. Actually quite familiar to those of us who grew up with this:
the interactive shell prompt of the BBC micro ran BASIC right from boot up… PRINT(“Hello Sam!”)
There is something about it that is quite fun, and encourages play. Which is great for data exploration, and modelling. But I don’t build bridges from Lego.
* Me speaking to child: “What is a letter? They are on the page. I mean printed on it. It’s that mark there. On the page. No, not that one; that’s a dog. No not that one, that’s a full stop. No not that one, that’s a bar code. No please don’t throw the book.”