←back to thread

389 points kurinikku | 5 comments | | HN request time: 0.207s | source
1. blackeyeblitzar ◴[] No.42165532[source]
A computer fundamentally isn’t functions though. That’s not how a processor works. If functions are a useful abstraction, why haven’t functional languages taken off?
replies(3): >>42165967 #>>42167317 #>>42168684 #
2. doublepg23 ◴[] No.42165967[source]
It seems functional language experts are too busy rewriting SICP instead of actually useful programs.
replies(1): >>42166398 #
3. blackeyeblitzar ◴[] No.42166398[source]
I just haven’t seen anything concrete as to why SICP’s materials are useful in either the real world or academia. Sometimes these discussions talk about how it is useful for computer science and for theory but even that seems like a claim without evidence. Is this just people reminiscing about their first introduction to programming or a favorite professor?
4. antonvs ◴[] No.42167317[source]
> A computer fundamentally isn’t functions though. That’s not how a processor works. If functions are a useful abstraction, why haven’t functional languages taken off?

If computers and their processors are a useful abstraction, why don't we write everything directly in machine language - or microcode for that matter?

This is more about computing than about computers. As Dijkstra put it, "Computer science is no more about computers than astronomy is about telescopes."

Computing involves languages, including many languages that are not machine languages. Every language that's higher level than machine code requires translation to actually execute on the particular machines that we've developed as a result of our history and legacy decisions.

The lambda calculus is a prototypical language that provides very simple yet general meanings for the very concept of variables - or name-based abstraction in general - and the closely related concept of functions. It's a powerful set of concepts that is the basis for many very powerful languages.

It also provides a mathematically tractable way to represent languages that don't follow those principles closely. Compilers perform optimizations like static single assignment (SSA), which are fundamentally equivalent to a subset of the functional concept of continuation passing style (CPS). In other words, mainstream languages need to be transformed through functional style in order to make them tractable enough to compile.

The mapping from a lambda calculus style program to a CPU-style register machine is quite straightforward. The connection is covered in depth in Chapter 5 of SICP, "Computing with Register Machines." Later work on this found even better ways to handle this, like Appel's "Compiling with Continuations" - which led to the SSA/CPS equivalence mentioned above.

There's a lot to learn here. It's hard to recognize that if you know nothing about it, though.

5. dahart ◴[] No.42168684[source]
Just to pick some nits with those claims… CPUs do have hardware support for functions in the form of a stack and CALL/RET instructions. Functions are a useful abstraction since more or less all software uses them. Functions and functional languages are two related but different things, and the usefulness of functions as an abstraction doesn’t depend on whether functional languages have taken off. And last, I’d say functional languages have gained ground over time, as well as semi-functional languages like, say, Python and JavaScript. Even C++ is gaining more functional language features over time.