Quote from Alan Perlis The Epigrams for Programming , which was published in 1982.
The meaning of this quote is well embodied in Lisp , where there are many functions that act and are specific to lists, and you could do a lot with lists and a set of functions that work in lists, which makes them much more powerful than any targeted structure data.
Lua , as another example, uses tables to model classes . Why use a table to create objects instead of creating language-level classes and objects, such as object-oriented languages? Since your object is now a table, you can use any number of functions defined for the tables on your object for free! However, we did not have to clutter the language with the class syntax, and we needed to redefine the functions from the table that we want for our class.
What Perlis said is definitely an outstanding way of thinking in Lisp and functional programming . These 100 functions in your one data structure can be combined in many unique ways, since they all work with the same data structure, but you also cannot mix 10 functions with 10 data structures, since they were defined only to work on your specific data structure.
A more modern and simpler variation of this is thinking in terms of abstractions. If we were coding in Java, you would prefer to write 100 functions in the List interface or the same set of ten functions, once for ArrayList, once for LinkedList, once for ....
Zach L May 28 '11 at 6:45 2011-05-28 06:45
source share