Sunday, December 30, 2012

What makes a language?

I've been thinking a bit about what makes a computer language. None of these thoughts are probably original, I only think they're worth writing down for me because I haven't picked them up from elsewhere. As I try to learn to use scala (not just write a simple program in it) this issue is substantially in the fore.

So here goes.

A language seems to have at least three important aspects: the language syntax itself, the environment (hardware/virtual machine/operating system) where programs in the language will execute, and the cultural norms built around the language. Each of these have a significant impact on the final utility of the language. And it isn't clear if any one of these has primacy over the others. I'm not going to dwell on any of these aspects, only present them through example.

For learning scala I've chosen to implement a simple program that merges data from two CSV files and then performs some calculations. The program's simple enough that, had I just wanted to solve this problem, I would have proceeded through trial and error to complete the program, using whatever tutorials are available out there regarding the language itself. In doing so, I would only have learned a bit about the language. I would have experienced the impact of the environment only minimally. I don't think one really experiences that until one implements a truly substantial piece of software. And I would have learned very little about the language ecosystem. I could implement such a project entirely through eclipse and the scala plugin.

Put another way, this would be a depth first approach to learning a language: learn one aspect of the programming language really well. Then backtrack, and learn another piece, perhaps re-implementing the original program with the new found knowledge.

Another way to approach learning a language, which I think is much more effective for an experienced programmer, is much more akin to best first search. I've written substantial code in Java, enough to know reasonably good programming practices. My goal is to produce scala programs of comparable quality. To do so, I have to find the parts of the scala language and ecosystem that will let me develop a program that's comparable in quality to my java programs.

If the goal is to practice test driven development, for example, I might learn enough of scala and ScalaTest to write a failing test case. And I'd learn to write and execute the test cases through eclipse. I'd also want a build tool that doesn't rely on my IDE. In the case of scala that would be sbt. These few tools would give me sufficient scaffolding to learn more of the language. And so on. My goal after all is to not just learn to program in scala, but learn to produce a high quality program using scala.