Going for a fast-prototype Lisp based language

Started by
29 comments, last by HairyTroll 18 years, 3 months ago
Quote:Original post by bboyBladeJ
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.


This is probably a common misconception concerning Lisp. Lisp is the Borg of programming languages. It allows functional programming, but you can also program in Lisp using GOTO's, structured programming, object orientated programming, aspect programming etc.

Learning the Lisp LOOP macro is a sure way to put hairs on your chest.

Advertisement
Quote:Original post by cypherx
I'd welcome any further suggestions to make the language easier to comprehend.

One thing I suggest is further simplifying 'let'. There's really no alternative in C++/Java which makes it very confusing initially. I suggest dealing with it in the following manner:
(scope  (set x 0)  (set y 1)  (+ x y))

This would be an alternative to
(let ((x 0) (y 1))  (+ x y)))

Quote:Original post by HairyTroll
Quote:Original post by cypherx
* Why "with-init"/"with-engine" and not "init"/"engine"?

Good points, the current names do not make sense. I'll change these.

Dunno, the with- prefix is a common Lisp idiom that immediately tells me what is going on. Using just init/engine would leave me a bit uncertain about what it's doing.
But since you said you are aiming for the non-lispers I guess it's ok.
---from www.yellow-hut.com/blog
Looks good to me. If you want something a little less lisp-ish, check out "Bob" by Dave Betz. It's Lisp with a C++ face (ala &#106avascript), but it's much simpler.

(my byline from the Gamedev Collection series, which I co-edited) John Hattan has been working steadily in the casual game-space since the TRS-80 days and professionally since 1990. After seeing his small-format games turned down for what turned out to be Tandy's last PC release, he took them independent, eventually releasing them as several discount game-packs through a couple of publishers. The packs are actually still available on store-shelves, although you'll need a keen eye to find them nowadays. He continues to work in the casual game-space as an independent developer, largely working on games in Flash for his website, The Code Zone (www.thecodezone.com). His current scheme is to distribute his games virally on various web-portals and widget platforms. In addition, John writes weekly product reviews and blogs (over ten years old) for www.gamedev.net from his home office where he lives with his wife and daughter in their home in the woods near Lake Grapevine in Texas.

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.
Quote:We don't use 'for' loops because we have found a cleaner approach to iteration: the tail call.
That's debatable. Then again, if you want iteration looking constructs in Scheme and have 10 minutes, you can define the syntax.

[Edited by - flangazor on January 6, 2006 5:14:43 PM]
(or just use the DO macro, which is part of the language and pretty much a generalized C for loop)

Also:
Quote:Original post by flangazor
Also, in my experience, emacs tabbed code that gets an ugly distance horizontally can almost certainly be refactored into something cleaner (and left oriented).


Can you give some examples of this? The field where I get the most ugly wide code is usually when I try to define internal functions in a function (flet or labels in CL) - I often end up just making helper functions top-level to avoid this, but it would be nice to be able to have the code itself indicate "this is just an internal helper function!".
I make the functions top level and then I don't export them from the package or module they are defined in.

[Edited by - flangazor on January 8, 2006 3:48:14 AM]
Quote:Original post by flangazor
Quote:We don't use 'for' loops because we have found a cleaner approach to iteration: the tail call.
That's debatable. Then again, if you want iteration looking constructs in Scheme and have 10 minutes, you can define the syntax.


And in (Common) Lisp there's the LOOP macro (Hyperspec) which provides for all sorts of for loops and more.
Sorry, links aren't showing, should be:

LOOP macro: http://gigamonkeys.com/book/loop-for-black-belts.html
(Hyperspec): http://www.lisp.org/HyperSpec/Body/mac_loop.html#loop

This topic is closed to new replies.

Advertisement