[ prog / sol / mona ]

prog


scheme vs common lisp

7 2020-05-31 19:09

>>6
There are different definitions of "functional languages", but I consider 1. functions are data 2. functions are composed 3. data is immutable to be the general style. Now languages can either support or enforce this. If supporting is enough, then C is functional (1. function pointers; 2. eg. qsort; 3. const).
But because this seems absurd, I prefer to say that these kinds of languages "support a functional style". Functional languages either have to be designed so that a functional style is intended (Scheme) or required (Haskell).
Common Lisp can be programmed in a functional style, but you're going to suffer inefficiencies, because you're expected to think about memory and garbage collection (when to use nreverse or reverse). Also mutation is quite central, something you easily recognize when considering all the macros that work on generalized variables (setf, push, rotatef, ...).
So all in all, you can write bits and pieces in a functional style, and knowing when doing so aids performance and readability is what one learns with time, but the trying to do everything as if it were Haskell, is not the best approach.
(IMO)

41


VIP:

do not edit these