X-Newsreader: Geminisoft Pimmy 3.2 Eng - www.geminisoft.com
From: "John Colagioia" <JColagioia@csi.com>
Newsgroups: rec.arts.int-fiction
Subject: Non-Imperative Parsing (was Re: Another worm for the NLP can...)
Date: Thu, 11 Jul 2002 08:50:38 -0400
References: <Xns924645FEF5002joaomendesnetcabopt@194.65.14.150> <3d2ae2a2@excalibur.gbmtech.net> <Xns924861C153DDFjoaomendesnetcabopt@194.65.14.150>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: ool-182f30fa.dyn.optonline.net
X-Original-NNTP-Posting-Host: ool-182f30fa.dyn.optonline.net
Message-ID: <3d2d7f33$1@excalibur.gbmtech.net>
X-Trace: excalibur.gbmtech.net 1026391859 ool-182f30fa.dyn.optonline.net (11 Jul 2002 08:50:59 -0400)
Organization: ProNet USA Inc.
Lines: 81
X-Authenticated-User: jnc
Path: news.duke.edu!newsgate.duke.edu!nntp-out.monmouth.com!newspeer.monmouth.com!cyclone.bc.net!logbridge.uoregon.edu!uunet!sea.uu.net!ash.uu.net!excalibur.gbmtech.net
Xref: news.duke.edu rec.arts.int-fiction:106029

Joao Mendes <public.email@anywhere.invalid> wrote:
>Hey, :)

Hey, back!

>"John Colagioia" <JColagioia@csi.com> wrote in
>news:3d2ae2a2@excalibur.gbmtech.net:
[...]
>>  It is to rule-based programming
>> what C++ is to object-oriented programming.  It carries
>> lots of dogma, and acts too much like C or BASIC when it
>> would really matter (cuts, anybody?).
>And this is bad because...

Because at the key points where you'd like to rely on "the
system takes care of all the logic for you"--any complicated
and potentially bug-ridden set of choices--you have to think
about how the engine does things, and program your rules so
that the "standard logic" will process them correctly.

I actually have some Prolog rules that I had to reorder
because--get this--the order in which I originally defined
them caused the engine to fall into an infinite loop.

For reference, I had to rewrite about 10% of the rules,
because the were (of course) dependant on each other.

>> If you're planning
>> to take this route, consider a more modern language, like
>> Mercury or HOPE, which I hear has overcome many of the
>> major "disabilities" of Prolog.
>Never heard of these. Will definitely check them out.

They're fairly new, for programming languages.  Neither has
really caught on, but I've heard good rumors.

I actually had a grammar-based replacement system, once,
that would obviously be perfect for parsing, but it was
mostly a joke, so it was dead slow and overly constrained.

>> Second, rule-based engines are typically slow, because
>> the runtime engine basically performs a depth-first
>> search on all possibilities, choosing the "closest
>> match" (except for Prolog, which optimizes, and then
>> lets you worry about things like the fact that
>> reordering your rules might cause a failure to match).
>Granted. Then again, most machines today are what, 1 GHz?... (Man, I feel
>obsolete...)

Heh...It depends on what you mean by "most" and "today."
Regardless, though, a language with a slow runtime is only
going to be fast for smaller applications.  Over a certain
size, and things go bad far too quickly.

>> Finally, because of the rule-based nature of the
>> system, it's pretty hard to do anything *other* than
>> parsing.  In particular, you really don't have anything
>> like persistent data (objects, for example), so lots of
>> convoluted code is required to maintain the simplest
>> bit of your game universe.  If you don't believe this,
>> take chapter 7 of the aforementioned book as a good
>> example.  See if you can figure out how to add a
>> description to each room (that is only written the
>> first time you enter, or when the user types the
>> equivalent of "look")...
>Eh... This depends on the implementation. As I recall, Borland's Turbo
>Prolog had predicates to which truths could be added and deleted, thusly
>being stateful. Of course, one might argue that this isn't 'pure' Prolog
>anymore, but I was never one for formalisms. ;)

It's also nonstandard.  And I haven't seen Turbo Prolog in
far too many years to think about...

>In any case, you are correct. Trying to do the whole game engine in Prolog
>would be overkill. However, it does feel rather perfect for the parser
>bit... ;) IMHO, anyways...

Actually, has anybody done any object-oriented parsing?  I
read an article not too long ago describing it as being
fairly nice, but didn't provide any useful implementation
details.
