3 ms·
Lisp is unsuitable for modern CPUs because of memory hierarchy. Lisp operates primarily with lists, which can have pointers all over memory. This was not a prob
by coliveira 2y ago
Lisp is unsuitable for modern CPUs because of memory hierarchy. Lisp operates primarily with lists, which can have pointers all over memory. This was not a problem on earlier CPUs because all memory was the same with similar random access time. Modern CPUs cannot access pointers in memory with the same speed, they need to follow locality rules for performance. This means that an algorithm using something like C or Fortran arrays will always be faster than a Lisp list based version.
- shawn_w 2y agoLuckily, lisp has arrays too, and a bunch of other data structures besides lists.
- dwringer 2y agoCommon Lisp allows one to use arrays or other structures, and can even be used to inline assembly. So despite lists being a major part of the ecosystem and code representation itself, they are not mandatory for implementing an algorithm, or necessarily a performance drawback to using lisp. By the same token, it's easy for people to accidentally use lists and pointers to implement algorithms just as inefficiently in other languages - Python comes to mind. A standard approach in Python is to lean on external libraries for high performance computation, and this can be done just the same way in Lisp - but Lisp can also be used directly to write efficient low level algorithms by making a conscious effort not to use the list- and pointer-based functions to do so.
- wtetzner 2y agoIf the cons cells are allocated linearly it's fine. Plus the fact that lisps have more data structures than just lists.
- f1shy 2y agoDepending on the implementation for short list they can be optimized (just as strings in C++). You may be right with C and Fortran. But tbh in an era where the tiniest thing has an OS with MMU, I really prefer GC when the performance is not a problem. If it is just a performance concern, then ASM will always beat C… Like everything in engineering is about the right trade off.
- lispm 2y agoModern CPUs can execute Lisp just fine, like they execute languages like Java and Javascript, which also use a lot of pointers. Just like those, Lisp offers vectors, strings, hash tables, structures/records and objects. > This was not a problem on earlier CPUs because all memory was the same with similar access time. That's not true. Many early systems had small RAM sizes (example: a DEC VAX 11/780 had a few Megabytes and often served dozens of users) and 10 (or more) times larger slow virtual memory. Lisp systems then tried to deal with that with the first generational garbage collectors, often also compacting (related objects stayed near in memory). Ephemeral GCs watched for changed memory in RAM.
- rscho 2y agoPlease try one of the big Lisp/Scheme yourself instead of spreading uninformed opinions.
- pjmlp 2y agoApparently some people keep being stuck in 1960, when Lisp 1.5 manual was published. Since the 1980's that modern Lisps support all common data structures.