Facebook badge

Amol Aggarwal's Facebook profile

About Me

I like to write once in a while. I hope you will like my blog.

Wednesday, July 2, 2008

About lisp -part 2

A programmable programming language
Lisp is a great tool generating tool.Those of you who don't fully know about the advantages of programming bottom up read this :
http://www.paulgraham.com/progbot.html .
It is a fairly small article and can be read quite fast.What we are talking about here is symbolic processing . Syntax manipulation is the most commonly used aspect of Lisp's symbolic processing capabilities currently. The defmacro form provided by Common Lisp allows one to define new language forms which have full access to the symbolic information of the code within their bodies. Within the macro definition, the entire facilities of the Common Lisp language may be used, including any other functions or macros you have defined. This model is extremely powerful, and many advanced techniques for using it are explained in Paul Graham's book, "On Lisp".
Ex:
The macro loop
You can do the following with a LOOP:
  • Step variables numerically and over various data structures
  • Collect, count, sum, minimize, and maximize values seen while looping
  • Execute arbitrary Lisp expressions
  • Decide when to terminate the loop
  • Conditionally do any of these

In imperative languages, a value can be assigned a name, and this name is
called a variable. For example, “x=3”, and whenever this “name” is
encountered, it is evaluated to its value. It does not make any sense, to
have variables without a assigned value. That is, the “x” is not useful and
cannot be used until you assign something to it.However, in lisp, there is
a concept of Symbols. As a way of explanation, a “variable” needs not to
be something assigned of a value. Symbols can stand by themselves in
the language. And, when a symbol is assigned a value, the symbol can
retain its symbolic form without becoming a value.This means that in
lisp, “variables” can be manipulated in its un-evaluated state. The situation
is like the need for the “evaluate” command in many languages, where the
programmer can built code as strings and do “evaluate(myCodeString)”
to achieve meta-programing.The power of symbolic processing comes
when, for example, when you take user input as code, or writing
programs that manipulates the source code, or generate programs on the
fly.
One way for a imperative programmer to understand symbols, is to think
of computing with strings, such as which Perl and Python are well known
for. With strings, one can join two strings, select sub strings, use string
pattern (regex) to transform strings, split a string into a list for more
powerful manipulation, and use “evaluate()” to make the string alive. Now
imagine all these strings need not be strings but as symbols in the language,
where the entire language works in them and with them, not just string
functions. That is symbolic computation.Here we see, a expressibility
unseen in non-lisp family of languages.

About lisp

Why not lisp :->
1. CL lacks standardized support for many operations that are necessities in today's world (e.g. sockets, database connectivity,foreign functions). i.e. these features are not in the ANSI standard (which is 14 years old which may explain why new features were not standardised).Therefore one must choose between using implementation-specific features or writing to the least common denominator (ie writing code which works for all implementations which is very inefficient). Implementing new revisions to standard requires a lot of time and money.
2.Some of CL's core is badly designed. For example, consider NTH and ELT. The functionality of ELT is a strict superset of NTH, so why have
NTH cluttering up the language? Say I want to get nth element in a list i get confused as both elt and nth are in the language.
Why is the function that computes the difference of two sets called SET-DIFFERENCE, but the function that computes the intersection
of two sets called simply INTERSECTION? And why do all of these functions operate on lists, not sets? It's because there are no sets in
CL, which means that CL leads one to prematurely "optimize" sets as lists.More to come on this.
3.Lisp sadly lacks good library support . That means sometimes very ordinary stuff which can be done very easily in say Java will take quite a lot of time in lisp. Say you need a functionality to do something quickly ,you simply take an appropriate function from a well documented library. Creating your own libraries is not a solution when stuff needs to be done within a deadline as expected by business clients.
4.Lisp is not a mainstream language and is hardly been used in the software industry. Just being good enough is not sufficient . The lisp on your resume is not going to make much impact .Ron Garret who programmed in lisp for twenty years and has also written some highly referenced papers on lisp says that his adoption of lisp as a career option destroyed his career as a programmer.You could contact him on comp.lang.lisp on google groups.