Why Not C? Hal Daume III ------------- I've been asked on many occasions a question like: "Why don't you use x", where x is "C", "C++" or "Java." There are, of course, many reasons, but here is list the four that I find most compelling. These all essentially boil down to the fact that I think a programming language should be a friend who helps you accomplish your goals, not an enemy you should have to fight with. 1. I refuse to allocate my own memory. I find the process of dealing with low-level bugaboos like allocating memory obnoxious. It serves only to clutter otherwise clear code. It also makes debugging a major hassle and causes programs to core dump like crazy. I'm aware of various libraries that allow some languages that don't have build in memory management to do naive things like reference counting, but this is -- if nothing else -- simply an admonishon that your language has failed you. Memory management is not something that should be tacked on to a language in the form of a library. I believe this for many reasons: aesthetics, efficiency, etc. 2. I refuse to write 20 lines where one will suffice. This is mostly aimed at Java, since I don't really know of any other language that got this so wrong. The whole "everything must be a class" thing with Java is just such a pain to deal with. Comparing, for instance, the Hello World program in C to Java is just laughable. More than that, I also just don't find the whole OO paradigm all that expressive. Everything I want to express is typically easily accomplishable with a simple data type declaration and a few simple functions on that data type. This refusal also includes refusing to write 20 characters when one will do (e.g., x.equals(y) rather than x=y). 3. I refuse to live without higher order functions. This might seem a bit elitist, but once you get use to writing code with higher order functions, it's really hard to go back. Sure, C has function pointers, C++ has something nasty like that and Java has anonymous classes, but this is all just really too much hassle for dealing with something so basic (see point 2). 4. I refuse to live without algebraic data types. They are simply too expressive. Try writing code for reading in parse trees in C or C++ or Java (for a real challenge, do it in Perl). This is just a painful experience. Algebraic data types are too useful to live without, especially when dealing with any sort of structured data. Having to introduce heavy-weight classes to handle the same thing is overkill (not to mention terribly inefficient). So that sums it up, more or less. My languages of choice, of course, are O'Caml (caml.inria.fr) and Haskell (haskell.org). I wind up using O'Caml for everything, primarily because the code it produces tends to be more efficient than Haskell and because it has better support for arrays. I would write Haskell exclusively if it optimized array operations better and had built-in syntax supporting them.