Tibor's Musings

Programming Language Psychology

What role does a programming language play in the mind of the programmer?

Language for the masses?

Michael Vanier writes:

Writing Java code, though not particulary painful in the sense that C is painful (core dumps etc.), puts me to sleep. Writing Ocaml (which is a "language designed for smart people" if there ever was one) is exciting. My motivation to tackle the project has tripled overnight. The interesting question is: why is Ocaml so much more fun than Java? Why are "languages designed for smart people" (LFSPs) so much more fun to program in than "languages designed for the masses" (LFMs)?

One possibility is that LFSPs tend to be more unusual, and hence are more novel. I'll admit that this is part of the answer, but it misses the main point. Any new language is going to be novel, but the novelty usually wears off quickly. The real point is that LFSPs have a much greater support for abstraction, and in particular for defining your own abstractions, than LFMs.

http://www.paulgraham.com/vanlfsp.html

Hacker languages winning?

Paul Graham has an interesting point about languages limiting one's freedom and how they were proven "historically bad":

  1. [Java] is designed for large organizations. Large organizations have different aims from hackers. They want languages that are (believed to be) suitable for use by large teams of mediocre programmers-- languages with features that, like the speed limiters in U-Haul trucks, prevent fools from doing too much damage. Hackers don't like a language that talks down to them. Hackers just want power. Historically, languages designed for large organizations (PL/I, Ada) have lost, while hacker languages (C, Perl) have won. The reason: today's teenage hacker is tomorrow's CTO.
  1. [...] Like the creators of sitcoms or junk food or package tours, Java's designers were consciously designing a product for people not as smart as them. Historically, languages designed for other people to use have been bad: Cobol, PL/I, Pascal, Ada, C++. The good languages have been those that were designed for their own creators: C, Perl, Smalltalk, Lisp.

http://paulgraham.com/javacover.html

First language matters

An oldie-goldie book on this topic is "The Psychology of Computer Programming" by G.M.Weinberg. It is such a great reading.

"Humanists often contend that machines tend to dehumanize people by forcing them to have rigid personalities, but really, the contrary is true. Because the machines are rigid, the people who use them must -- if they are to be successful -- supply more than their share of flexibility. Perhaps this is the effect that the humanists are describing as "dehumanization", for in ordinary human intercourse, each party gives and takes his share. Relationships in which one party does all the giving or all the taking are not fully human, and tend to produce personality distortions in one or the other.

In making our adjustments to our particular programming language, we can easily become attached to it simply because we now have so much invested in it. We often listen to a man complaining about his nagging, slovenly, and prodigal wife, only to find that when asked why he doesn't leave her, he replies that he cannot live without her. Most people would prefer almost any amount of pain to giving up the familiarity of some constant companion for an unknown quantity. We see this effect when we try to teach a programmer his _second_ language. Teaching the first is no great problem, for he has no investment in any other. By the time he has learned two or more, he is aware that more things exist in this world than he has dreamed of. But letting go of the first is, to him, just a promise of pain with no promise of compensating pleasure.

Perhaps this situation could be improved if we could enunciate and teach certain principles that are not tied to particular languages, so that even the beginner would have some less relative measure to hold up against the language he is learning. But teaching practice today [i.e. in 1971] in our universities and programming schools seems to be pointing in exactly the opposite direction. Instead of trying to teach principles [...] the objective seems to be to get the student writing some kind of program as soon as possible -- a not unworthy aim -- but at the expense of limiting the future growth of the programmer.

To be fair, we should recall our distinction between the professional and amateur. The schools, it seems, are devoting themselves primarily to turning out vast quantities of amateurs -- perhaps under the assumption that the professionals can and should take care of themselves. But when the language designers begin to believe that the principles underlying the design of an amateur's language are the same as those upon which a professional's are based, then we have a trouble." (PCP, pp.212)

Did something change since 1971? Sure in the techno part, e.g. we now have Java instead of COBOL (reminder: COBOL stands for "Common Business Oriented Language"), but otherwise very little in the human part.

People don't change much: that's why Homer is still relevant today, and the PCP book got published in a silver anniversary edition in 1998.

As for the computer languages, it's again all about flexibility and freedom.

programming