4 ms·
> Unfortunately, LISP doesn't quite match [the Von Neumann] architecture, so it has traditionally performed poorly compared to C. Exactly. It has traditionally
by steinuil 10y ago
> Unfortunately, LISP doesn't quite match [the Von Neumann] architecture, so it has traditionally performed poorly compared to C.
Exactly. It has traditionally performed poorly compared to C, but this hasn't been the case for a lot of time. There's a number of misconceptions about what is and what is not a lisp.
First of all, a lisp doesn't have to be interpreted or run in a virtual machine. While this is true for a lot of lisps, Common Lisp performs what you could call just-in-time compilation: you can even inspect the compiled code of a function by calling the `disassemble' macro on it, and optimize it based on the disassembly.
A lisp doesn't have to be dynamically typed. There are many examples of statically typed lisps (Shen, Dylan, Typed Racket, Lux), and in other dynamically typed lisps such as Common Lisp you can add type annotations as needed to optimize functions.
A lisp doesn't have to be garbage collected. It certainly is more convenient to have GC when you have such a dynamic language or want to program in a functional style; however, this is not required. Carp and GOAL[0] do not use garbage collection, and in Common Lisp you can generally give hints to the garbage collector to to make it run where you need it to.
A lisp doesn't have to be functional! While lisps usually advocate a functional style to varying degrees (mutation in Scheme is usually marked with a ! in the name of the function (set!) but normally discouraged, Clojure is immutable by default IIRC), but very few are purely functional (only Lux comes to mind) and most are in fact very procedural (Common Lisp).
Finally, Common Lisp has been designed to also be used as a systems language, and thus benefits from many optimizations targeting the Von Neumann architecture that can make it just as fast, if not faster, than C.
This is a good post detailing some of the optimizations that you can perform in Common Lisp:
https://chriskohlhepp.wordpress.com/advanced-c-lisp/convergence-of-modern-cplusplus-and-lisp/ https://chriskohlhepp.wordpress.com/advanced-c-lisp/converge...
To answer 0wl3x's question, lisps can be used for just about anything; it's just a family of homoiconic languages that generally make heavy use of macros as fundamental abstractions.
[0] http://www.codersnotes.com/notes/disassembling-jak/ http://www.codersnotes.com/notes/disassembling-jak/
- lispm 10y ago> Common Lisp performs what you could call just-in-time compilation Actually almost all Common Lisp implementation use AOT, ahead of time, compilation.
- progman 10y agoSome Lisp's are really fast, SBCL for instance. http://benchmarksgame.alioth.debian.org/u64q/lisp.html http://benchmarksgame.alioth.debian.org/u64q/lisp.html