Re: dynamic type checking - a pauline conversion?

From: Jeff Brooks (jeff_brooks_at_nospam.com)
Date: 03/23/04


Date: Tue, 23 Mar 2004 03:08:07 GMT

thoff wrote:

> On code comparisons...i always wonder if someone wrote
> code to show a cleaner implementation in APL, perl, ruby, groove,
> etc if you would switch languages? If not, i am not always sure
> what the point is.

If a language is a lot better at a few solutions i might take the time
to learn it. I seriously don't expect anyone to stop developing in their
favorite language when they see my example. I don't even expect anyone
to actually write the code in Java. If they think about how much effort
it takes in java and see how little code i required in Smalltalk they
might take a look at Smalltalk. That is really the most i can hope for.

> Some questions i immediately ask are: is paging a large set from the
> database handled automatically? Are transactions handled automatically?
> Can i update objects through the collection? Is the query handled
> on the database side or the smalltalk side? Are updates from other
> clients seen through the collection?

That depends on the implemention of the collection that is used.

Think of it this way. If the jdbc library in Java had a QueryList class
that implemented List that was returned from a query any code that could
work on a List would also work on the results of query.

One of the reasons this doesn't work in Java is checked exceptions are
part of the method signature. List can never throw an SQLException. It
would be natural to return a List from a query and iterate over it but
exceptions in Java messes that up.

The QueryList could support paging, transactions, notifications, updates
etc. It could return records that when changed updated the database. The
records could also support notifications from other clients.

One of the problems with Java typing is small differences in interfaces
cause people to make different interfaces. Code is bound to the name of
the interface/class. Doing things like iterating a collection requires
different code different types of collections. For example, in java
array iteration, List iteration, and database query result iteration all
have different "interfaces" so either your code doesn't work with them
all or you have to create a new interface, and adapters for each of the
collections. The new interface isn't known by any other developer so
their code can't work with it. Also, you have to change your existing
code to work with the new interface.

In Smalltalk there is a standard way of iterating all collections so
code like a filter that works with an Array, will work with a
Collection, and also the results of a query from a database. Also,
because Smalltalk is dynamically typed anything that behaves like a
collection regardless of what class it is derived from will also work
with my filter code.

Jeff Brooks



Relevant Pages

  • Re: CLOS Properties Question
    ... In interfaces, you can declare methods, but you ... This mess was the result of the fact that interfaces ... > is even an OOPSLA or ECOOP paper published before the advent of Java ... > Back to the question what this all has to do with multiple inheritance: ...
    (comp.lang.lisp)
  • Re: Python vs C for a mail server
    ... that is mostly unnecessary with Python. ... > I don't have enough experience with languages that provide interfaces, ... > such as Java, to understand how useful they are, but it's my impression ... I can't comment on "most Java APIs", but if you look at established ...
    (comp.lang.python)
  • Re: MRO theory
    ... It creates a Python class to proxy any Java class or Java ... Java proxies go, when it creates a class it can have at most one ... The problem basically comes about because interfaces are not classes, ...
    (comp.lang.python)
  • Re: Java "interface" vs. OO interface
    ... > I think Java uses interfaces instead of classes because the designers ... To think that the designers of Java and .NET couldn't figure out a good ... Enough for a language to adopt a new keyword ...
    (comp.object)
  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... Sounds like recursion to me. ... > special purpose language - maybe they are not needed. ... Go to www.jobserve.co.uk and type Java XSLT in your search. ... >>> This corresponds best to my second example of iteration. ...
    (comp.programming)