[My reply address is at the end]
jlc@sofluc.demon.co.uk (Jonathan Cunningham) writes:
> Date: Wed, 07 May 1997 00:48:22 +0000
in response to
> richardm@cogs.susx.ac.uk (Richard Matthias), who wrote:
[RM]
> >The reason there are not enough c++ programmers is that there are (a) not that
> >many good programmers full-stop and (b) programming is not taught sufficiently
> >well.
[JLC]
> I'm not so sure about (b). It assumes that there are enough people
> with the innate ability to program well. An ideological assumption,
> which is currently becoming less fashionable (that everyone has the
> same potential. Very PC, but patently absurd, if you think about it).
I don't see what is absurd about it. Of course it is far from
obviously true. On the other hand I believe so much is done in our
educational system to cripple the intellectual development of the
majority of learners (often starting in the home even before kids go
to school) that we have no idea what the real innate potential is
that could be brought out by a different sort of educational system,
e.g. kids being taught mathematics and programming from the age of 4
or 5 by people who really understood mathematics, programming, and
human learning processes while leaving life rich and enjoyable.
(My guess is that very few actual teachers score even 1 out of 3.
Try asking various teachers and non-teachers to explain why
multiplying two negative numbers yields a positive number for
example, and see how much gibberish you get. Kids are normally
fobbed off with various totally inadequate explanations by
(frightened) teachers who are unaware of the inadequacy. So no
wonder children get confused and lose confidence and prefer to move
their learning into areas where there's no question of getting
things right or wrong, or grasping the difference between valid and
invalid arguments.)
My conjecture is that that a totally different educational process
is possible, but there will never be any real political will to
introduce it. (And I don't mean just teaching children Logo.)
[RM]
> >(though it is well suited to AI work)
I know very little about Java, but I find that a very strage
statement. What sort of AI work? What exactly makes Java good for
that.
From the little I know about it I guess there are two possible
answers (a) garbage collection so that people can easily build
tangled networks without everyone having to re-invent safe
algorithms for deciding what can be returned to free store and
(b) incremental compilation, which can make exploratory design
development and debugging very much faster.
Does it also support user definable macros which, when they are
expanded, can use arbitrary user defined procedures in the expansion
process (as in Lisp and Pop-11), or anything like Pop-11's syntax
words?
Over and over again AI language users have found that it is useful
to introduce powerful new syntax forms to support forms of
programming that are appropriate to different sorts of tasks
(thereby making development and maintenance much easier).
Examples are rule-based extensions, pattern matchers, the addition
of object-oriented programming constructs, the addition of new
syntactic forms for natural language processing, syntax for planning
languages, etc. Some of this can be difficult to do using simple
forms of macro expansion - e.g. expanding code to make use of a
closure of a previously compiled procedure.
(With an incremental compiler you can, I presume, partly achieve
this by having a command to compile a file of text after passing it
through a pre-processor, which can be defined to use arbitrary
previously compiled procedures.)
[RM]
> > and even if you compile directly to the
> >physical machine the madated garbage collection makes Java unsuitable for many
> >many things.
Some people don't realise that even when a garbage collector is
present you are not forced to use it. For many purposes in AI
languages you can write code that re-uses arrays, vectors, lists,
etc. without ever invoking the garbage collector.
Of course if you are using libraries or built in subroutines that
are badly implemented they may trigger unnecessary garbage
collections.
[JLC]
> For real-time control work, I would still expect to use C, at present, not
> C++. For a variety of reasons. However, there is no intrinsic reason why
> garbage collection should preclude this kind of use. Asynchronous
> incremental GC algorithms have been known for years. But I don't
> expect them to be implemented for Java;
Why not? If there's a demand, and the market is large enough, they
will be implemented!
John Gibson worked out a scheme for putting incremental GC into
Pop-11 but when we discussed it we decided that it would be a
mistake (a) because the fastest (??)incremental GC (using two
spaces) would require a significant change in the implementation
which would probably slow everything down by a factor of about 2 as
well as requiring twice as much heap space to be permanently
allocated, (b) because the existing poplog garbage collector is very
fast (though its speed relative to other Pop-11 stuff varies from
machine to machine, and can depend very much on the availability of
free memory so that paging is avoided). Because of (b) the vast
majority of well written Pop-11 programs spend a relatively small
proportion of their time in garbage collecting, especially if you
make use of heap locking and popminmemlim.
[However I've recently found what seems to be a design flaw: if you
repeatedly lock and unlock the heap AND use Xved or X utilities, or
external calls that involve the use of fixed location structures,
then the heap keeps growing because new fixed location structures
are ALWAYS put into a new area beyond the locked heap, and if you
then unlock and call sysgarbage and lock, the new locked point is
beyond that fixed area, even if that means locking large amount of
empty heap.
I've reported that as a bug. Till it is fixed, don't do
repeated locking and unlocking if you are using XVed or X
utilities, e.g. propsheet, graphics, etc. See REF EXTERNAL_DATA
for information on fixed structures.]
[RM]
> >Garbage collection is about the only thing Java actually buys you over c++
> >from an AI point of view and you can get GC in C++ with a library so its no
> >big deal.
What about incremental compilation?
[JLC]
> Or smart pointers (what I use). But this is a small point. The reason for
> preferring Java is that C++ is ugly. Much more important ;-). A language
> which lets you pass arguments as pointers *or* references? That's only for
> backwards compatibility <Shudder>.
Is this like Algol68's distinction between an INT and a REF INT ? I
guess it's a useful facility as it makes it unnecessary to create an
explicit REF data structure when you want to do this (e.g. to enable
different procedure invocations to share an updatable variable).
On the other hand, plenty of Pop-11 programmers are happy to use
consref when they need to do this, though there is a GC overhead.
[JLC]
> Oh, I don't believe in the NC,
Why not? My guess is that until NC's (glorified X terminals
supporting various protocols besides X) are widely and cheaply
available and there are lots of servers providing services of
various kinds to support them, computers will NEVER be used at home
by more than a tiny proportion of the population because of the
difficulty of setting up and managing your own PC or workstation.
Of course for people like you who want control and have no problem
learning to use computers, it's a different matter. Most computing
professionals will prefer their own computer. However even some of
those will find it more convenient to know that wherever they go if
an NC is available they can link up to their normal servers and use
them exactly as if they were still at their normal workplace. And
not having to worry about backup of files, etc. because it is all
done by the server management, can be a considerable saving, with
huge economies of scale.
I am expecting networking links to get much faster.
[RM]
> >Object orientation is usefule in AI for simulation work, but with Java you are
> >forced to use it. No problem for the experienced programmer, but when you are
> >teaching a beginner to program (something pop11 has been used for at Sussex)
> >you really don't want to have to explain OO at the same time before they can
> >even get their eliza or whatever going.
[JLC]
> Aaargh!! No wonder you said programming was not being taught properly: if
> you aren't teaching OOP from day one, you are making life *much* harder.
> Do you also teach algebra using Roman numerals before introducing
> the decimal system?
Here I agree more with Richard.
Maybe Jonathan has forgotten what it is like to teach people with
very little mathematical or scientific expertise, with NO
programming experience, who are taking an AI course out of
intellectual interest (it's the best form of liberal education for
the next millenium, if done properly), and many of whom will never
be programmers.
For such students I base all the introductory programming around
list structures (plus words and numbers when necessary) making heavy
use of a pattern matcher, conditionals, loops, and in some cases
recursion.
I also sometimes introduce rule-based programming as a different
paradigm.
I then introduce object oriented programming (using the Objectclass
extension to Pop-11, which works very well in Poplog V15) and
various home grown teach files. A very nice way to introduce and
motivate OOP is via a simple adventure game where you can very
naturally introduce different classes of objects in a class
hierarchy (or network), e.g. different kinds of agents, different
kinds of houses and rooms, different kinds of movable objects, etc.
But I think it helps to already be fluent at writing programs that
do things using conditionals, loops, procedures, local variables,
etc. before you start on defining classes and methods.
Of course, when students do their first mini-project, whether they
are using an object oriented style or not, I try to get them to
think very clearly about the ontology they are working with. I
sometimes think that some of the enthusiasm for OOP is misplaced
because it is really enthusiasm for Ontology-oriented design, which
is important whether or not you make use of the powerful features of
OOP (e.g. inheritance, polymorphism and methods).
[JLC]
> I'm not going to argue this point: if you don't agree that OOP is
> simpler than procedural, then I won't be able to convince you.
You are wrong because use need procedural programming techniques,
including such things as conditionals, loops, variables, in order to
do OOP, not the other way. I.e. learning OOP involves learning more.
QED.
[JLC]
> But I
> would also be sceptical that you've yet acquired the OOP mindset, and
> think in terms of objects and methods rather than procedures and data.
Well maybe I haven't got the OOP mindset though I have written lots
of code that makes significant use of objects (or rather object
hierarchies) and methods in order to achieve modularity and
extendability with maximal reuse of existing code.
I have done this both in the sim_agent toolkit (a mixture of OOP and
rule-based programming, see
http://www.cs.bham.ac.uk/~axs/cog_affect/sim_agent.html
and in my recently announced graphical extensions to pop-11,
summarised in
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/rclib/help/rclib
The main code is in the sibling lib/ directory. It's also all in the
rctar.gz file in the poplog directory.
[RM]
> >Object orientation is usefule in AI for simulation work, but with Java you are
[JLC]
> What a strange thing to say. I wouldn't dream of writing *any* program
> other
> than as an OOP. See above re mindset.
What a strange thing to say. OOP is just one of a number of
programming paradigns, and different paradims are useful for
different purposes.
[RM]
> >Because somewhere along the line people decided they wanted to write useful
> >software in pop. Lists are a nice data abstraction, but you pay a huge
[JLC]
> You misread my post. Lists are *not* a nice data abstraction. They are
> one way to implement the abstraction of sequences, and are the most
> efficient way to do this for certain algorithms. Vectors are more
> efficient for other algorithms.
I agree
> It's because of the way that pop11
> compilers have traditionally been written (a neat idea, BTW) that it
> is difficult to carry out global optimisations, which would include
> late commitment to data structure choice *by the compiler* if you
> had Sequence as a basic abstract data type.
I suspect that this could be done via clever use of REFs which hold
an uncommitted structure specification and then commit it the first
time the structure is accessed, depending on how it is accessed.
There would be a slight extra overhead thereafter in going via the
ref, but that might be more than compensated for by the right choice
of representation for a large sequence.
However, I suspect that in general it can be very difficult to
determine which is the best global optimisation, even at run time,
since the very same sequence may be capable of being used in
different ways and I suspect that working out whether a commitment
to a particular representation is right, even at run time, is as
difficult as solving the halting problem.
E.g. some of the time I may want to jump directly to the N'th
element of the sequence, favouring a vector implementation. Later I
may wish to store various "tails" of the same list in different
places, favouring a list implementation.
Sometimes copying and producing two implementations may be the best
solution, but only if the compiler can be sure I never want to
update the common parts. With an incremental compiler interacting
with a user who may explicitly or implicitly cause some new library
to be invoked later on there can be no way of telling in advance
how a particular sequence is going to be used.
You can get round this to some extent my having a typed language,
where a declaration can limit possible uses. Maybe retroactive
declarations can also be used to commit or freeze something after a
particular point, so that its use can be optimised thereafter, and
attempts to generalise the use later on will just produce an error.
[JLC]
> I think there may now
> be a consensus that it would be better to generate a full parse
> tree as an intermediate, rather than directly emitting pop VM in
> the syntax procedures.
yes, but for other reasons.
Cheers
Aaron
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A. Sloman @ cs. bham.ac.uk(||| MAKE BULK EMAIL ADVERTS ILLEGAL |||)
Phone: +44-121-414-4775 (Sec 3711) Fax: +44-121-414-4281
|