3 ms·
An analogy I like to use is prime vs zoom lenses on DSLR cameras. A common observation by professionals is that when they have a zoom lens attached to their ca
by jiggawatts 6y ago
An analogy I like to use is prime vs zoom lenses on DSLR cameras.
A common observation by professionals is that when they have a zoom lens attached to their camera, the pictures tend to be either one extreme zoom or the other. That is, they wanted "as much as possible" and just set the zoom range to the maximum in that direction.
Which means that most of the zoom range is (almost) never utilised.
The big advantage of prime lenses is that by sacrificing the ability to zoom, the quality can be better. A 35-50mm zoom is never going to be as good as two separate 35mm and 50mm prime lenses.
So if you want to maximise quality, get primes.
But then your camera bag will be heavier, and your wallet lighter.
Also, you now cannot have any intermediate zoom range in those rare times that you do need it.
So there's always some trade-off being made.
Languages like C++ are like zoom lenses. They allow almost any programming paradigm, and various mixes too. You can have a procedural program with memory safety, with functional bits thrown in, and call out to unsafe C code if you want.
Languages like Haskell or JavaScript are like a prime lens, with a lot of decisions fixed at one extreme or another.
I suspect that what's needed is the zoom-like flexibility of languages like C++, but with defined subsets that work more like a "prime" language. With physical lenses, this is impossible. You can't take the zoom bits out, leaving the prime behind. With software... I think it can be done.
This isn't that unusual an idea. Mainstream languages are already slowly converging on this concept. For example, C# has a project-level "unsafe" flag, which turns a set of language features on or off.