Better Programming Languages
Why are so many successful websites in PHP? I can list plenty of reasons why it is a poor language by the standards of the computer language research community. Dismissing PHP as 'fractally broken' is easy, except for the annoying fact that it is the implementation language of many successful websites. Is it just luck? The people behind Facebook, Wikipedia and Slack were not kids who didn't know better. I think we should start being more empirical when discussing technology choices.
Nearly all of Linux is written in C. Basically every computer game in the last 10 years has been written in C++.
It is very easy to find articles that explain why Lisp/Smalltalk/Haskell/Rust... are far better languages than PHP, C or C++, but they almost invariably answer the question "Why doesn't anyone use this?" with "Because the world is stupid".
A definition of 'better' that delegates to popular opinion is basically just fashion and about as relevant to software engineering as London Fashion Week is to someone planning an artic expedition.
Personally trying a few languages is also a poor way to choose, for 2 reasons:
- Languages take a long time to become proficient in. It takes maybe 4 years of full-time usage in an environment surrounded by experts to get to the point of really knowing a language, so most people can only try a handful.
- If you spent 40 years trying the top 10 options, then how do you (as a 60 year old greybeard) convince the 20-year old young-punk version of you to listen?
If 'better' is not defined by 'popular opinion' or 'personal belief', then what should the definition be?
One definition of 'better' would be 'How much more likely is my software product/startup to succeed if I pick language X over language Y?' That might not be perfect, but would at least be economically rational. Measuring this probability directly is hard given the noise in the system, but if there was a strong advantage to picking LISP over PHP, then you would have expected someone to have out-executed Facebook during the early social network land-grab.
But the top 100 websites are dominated by so called 'rubbish' languages. Why?
Here are some possible reasons (but I don't have any good ideas for tests to validate these)
- Hiring and the time to get productive in a language are important. During the critical growth phase of Facebook they were doubling headcount every 10 months. If it takes an extra 6 months for someone to be productive, then you have to be 50% larger to get the same productivity out of the team.
- Externalities matter.
- Fancy languages encourage fancy thinking, and developers tend to gold plate the backs of draws before building the desk.
- These common languages map better to the real-life problem domain. The designers of PHP said that they changed the language until it could succintly express common website tasks. ML came from the world of accademic Computer Science, and shows a similar bias toward common problems in that domain.
- There is a very strong bias in the population of new startups away from 'better' languages, so any advantage provided is hidden by the much larger base rate for 'boring' choices.
- The behaviours that lead to picking PHP as the implementation language also result in choices that lead to success, so success/PHP are correlated but there is no causal link.
Unix beat Smalltalk in the market. Why? One story is the old faviourite that 'Marketing screwed it up' by overpricing Smalltalk. Maybe, but what about another explanation:
Suppose that software doesn't succeed based on how well it works in the environment it is designed for, but by how well it works in an environment it was never intended to be used in.
Unix was simple and portable. C could be ported to new platforms very easily, and the existing cannon of software put directly to use.
If you take a Linux system and chroot into a user space with no /dev /proc or /sys then a very surprising proportion of it still basically works. It is running completely out of spec, but you can often Get Work Done.
To travel to space you need a carefully designed, perfectly assembled vehicle that is tested and designed against a precise specification. To travel across Africa you take a rugged 4x4 and a set of tools. Unix seems to win not by being the very best possible solution to a problem, but by being good enough, low risk and available right now.
Another aspect is how well it interacts with aliens. Take a Unix system and connect it via a serial port to your legacy mainframe and since everything is a stream of bytes, your mainframe is now a first-class citizen. Making a mainframe a object orientated first-class citizen in SmallTalk would require some kind of distributed garbage collection, which even today is still a research topic. That mainframe isn't going to appear as an object any time soon. There is a slightly sad 'lowest common denominator' effect going on here, where everything is pulled down to the level of the worst system, but the effect is real.
Interacting well with existing systems also matters because doing so gives you all the functionality of those systems instantly and for free. An integration with an existing, tried and tested system is always going to be better than a new from-scratch implementation.
Also, being easy to play with means that other people will value it and pay with either \$ or code.