r/ProgrammingLanguages • u/[deleted] • Jun 27 '21
Blog post A Dream of the Perfect Programming Language
telegra . ph/ A-Dream-of-the-Perfect-Programming-Language-06-26 (looks like Reddit’s global spam filters block Telegraph for some retarded reason)
Clickable but less good-looking version: https://github.com/natewind/articles/blob/master/2021-06-26-A-Dream-of-the-Perfect-Programming-Language.md
3
Upvotes
7
u/silicon-pizza Jun 28 '21
I'm skeptical of the goal: "a perfect programming language". There is no perfect language, there are only engineering tradeoffs, where making a language better for some use cases makes it worse for others.
One of these tradeoffs is between simplicity and ease of use, vs expressiveness, vs how effective the type system is at preventing bad things at run time by issuing compile time errors. You can't maximize all three. Pick two.
You want a perfect type system that guarantees all functions are total. There are no panics, because all potential problems are detected at compile time. You will pay a terrible cost for this. If you want the language to be as expressive as a general purpose language, and as efficient as Rust (you mention "zero cost abstractions"), then the type system will have a steep learning curve and be very difficult to use, worse than the Rust borrow checker.
For example, your language has efficient machine integers. How does the integer division operator work in your language? What happens when you divide by zero? That's a panic, so your type system has to prevent this at compile time. This probably means that when I write
i / j, I need to prove to the type system thatjis not zero. That's more complicated than division in a mainstream language. Alternatively, integer division could returnMaybe Int, and I'll be required to perform a case analysis on the result and explicitly handle the error case. That simplifies the type system requirements for division at the cost of runtime overhead, and you said you want zero cost abstractions.The Dhall programming language is total, and relatively simple. It achieves this at the cost of expressiveness. There is no division operator.