5 ms·
Functional programming was never about first-class functions. It was always about programming with pure and total functions in their mathematical version.
by dsabanin 6y ago
Functional programming was never about first-class functions. It was always about programming with pure and total functions in their mathematical version.
- acdha 6y agoThis may be true in your personal experience but that’s certainly not universal. A key distinction is when you learned this: 2-3 decades ago when most people were using languages without first-class functions, this was very commonly the most important feature mentioned because it was the most pronounced difference. That’s no longer emphasized as much now that this feature and related techniques has become mainstream.
- pyrale 6y agoI believe the statement GP made has been true since the days of Church. It is not surprising that "what's the difference between your language and mine" will yield an answer that is different than what you'll get if you ask "what is that concept you're trying to build a language after?"
- acdha 6y agoThat might be pointing out an important distinction: did you learn this formally from that academic community or elsewhere? As a global assertion it’s wrong but it could be accurately representative if you’re only talking about subcommunities in the former case.
- pyrale 6y agoI have made another comment in this thread where I make a distinction between what people _try_ to achieve, and what tradeoffs they make on the way. You are right that most functional languages do not have pure and total functions. However, the inspiration they take from is usually the pure/total functions as described above.
- adwn 6y ago> It was always about programming with pure and total functions in their mathematical version. Are you sure about this? A total function is defined for all of its possible inputs, i.e., it must always terminate. A functional programming language with only total functions isn't Turing complete.
- pyrale 6y agoSeveral recent languages that came from the FP community recently tend to achieve this. This is the case of Agda, for instance, and I believe Idris also has totality checking.
- adwn 6y agoMaybe you mean optional totality? As in, a function can be declared to be total and the compiler tries to prove it? A language cannot be Turing-complete if it completely forbids non-termination, there is no way around this. Or stated differently: If a language is Turing-complete, then there are programs that don't terminate. If a Turing-complete language only has functions which are total (i.e., which always terminate), then it has another mechanism which allows non-termination, e.g. unbounded loops and mutable state.
- pyrale 6y ago> A language cannot be Turing-complete if it completely forbids non-termination, there is no way around this. I do acknowledge this. My point is that turing-completeness is not necessarily a desirable aspect of a language. You can check out Agda if you are interested in what can be done with a total language. For some use-cases, like seting up a mainloop, you need an escape hatch because that mainloop is not going to be total. But not every program needs that. Conversely, a programming language that doesn't care about totality won't be able to sere other use-cases, such as building proven programs. My understanding is that it's much easier to build an escape hatch in total languages, than it is to retrofit non-total languages to prove programs.
- 6y ago
- dnautics 6y agoThat's not really true. Op is programming in erlang, which has never in it's history been pure functional, and specifically picked the functional paradigm for pragmatic reasons (function-internal immutability and limited global state gives the programmer guardrails), not for pure mathematical reasons.