Quote:Original post by bboyBladeJ
Hey guys,
I consider LISP a write-only language. Few years ago I implemented few non-trivial algorithms (such as finding shortest path in a graph, or solving the 9-puzzle problem) using LISP and I have to say it wasn't easy at all, but I made it work with a pretty clean code. However, a month after finishing, I realized I had troubles reading the code again. I think this can happen to everyone, who's not in touch with LISP every day.
I have a question I need to ask: Why exactly do you want to use LISP? LISP is a functional language and that's what it should be used for. Clean LISP style means no variable declarations, for-loops or anything resembling stuctured programming. These features are included in LIPS for same reasons as e.g. global variables in C++ i.e. you can always avoid using them, however in some cases they make your job a lot easier (I have never used any global variables in a C++ code). I believe using a scripting language would be a better choice than LISP.
Anyway, good luck with your experiment :-)
bboyBladeJ
If don't feel comfortable with lisp, or you write code that is confusing, then you should expect to be confused when you come back a month later. Whether or not lisp resembles what you consider "structured" programming is up to you and the paradigm through which you see the world. I can't comment on Common Lisp, but having worked primarily with Scheme, I would say good style typically means writing code that makes your intentions clear, to both a human reader and to the compiler. We don't use 'for' loops because we have found a cleaner approach to iteration: the tail call. We do have the ability to introduce variables into the current environment with DEFINE, and to extend the lexical environment via LET. You are correct: lisp has imperative constructs that are typically avoided. This is because stateful programming is in general more difficult to reason about than stateless programming, but there are times when it is necessary to use these imperative constructs to succinctly express behavior which does not coincide with the properties of the functional subset of the language. Lisp programmers (well, some of them) choose to rely on invariants within the program to ensure correctness, whereas C++ programmers tend to rely on prayers. And there's a difference between the guarantees regarding behavior due to invariants and those regarding behavior as empirically measured by unit tests.