Re: dynamic type checking - a pauline conversion?

From: Cristiano Sadun (TAKEcristianoTHISsadunOUT_at_hotmail.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 15:09:51 +0000 (UTC)


"Ilja Preuß" <preuss@disy.net> wrote in
news:c373s4$3f5$1@stu1id2.ip.tesion.net:

> I don't find this to be rare - though this might have something to do
> with my style of programming which is somewhat influenced by Smalltalk
> (though I never really developed in that language).

However, I suppose a lot changes on whether or not you have access to -
and can change - existing code or not.

In general I love as much static typecheck as I can in a language - since
it makes it faster (to me :) to spot trivial errors. That depends a lot
on the way I work - I write big chunks of code before even compiling as
opposed to quick write-and-check sequences that other people favors.

If I get it right, in your case the only reason for not creating a
"Closeable" interface and have all the relevant objects implement it (or
creating an adapter which does) is that you either work with binary
objects or cannot otherwise touch their source. In that case, there's no
doubt that entirely dynamic binding a-la-smalltalk is good.

Still, I dont know how often this happens. After all, most good java
libraries are usually tought "in java" and therefore tend to come with
such interfaces already defined, courtesy of the author. For example,
every time I write a library I tend to have interfaces for the main
actors and roles. Certainly it can be a problem when you mix different
libraries with partially overlapping functionality ("cant do with, cant
do without" :).

> For example, we do have a utility method which gets a collection and a
> Block and executes the Block for every member of the collection:
>
> CollectionUtils.forEach(myCollection, new Block() {
> public void perform(Object each) {
> System.out.println(each);
> }
> });
>
> Handling Exceptions in a consistent and convenient way is near to
> impossible in this case.

Well, again in Java you can always define a base astract exception
(checked or unchecked). Is there anything specific in a dynamic-typed
language which would do any difference?

> And this is just one example for a quite general problem: a generic
> middle man between two more specialized code snippets which want to
> communicate via Exceptions.

Having written a lot of (supposedly ;) reusable libraries - and assuming
I understand what you mean - I found that the issue is structural; you've
got to decide what is the usage scope and control for the exception:
alling code, or specific exception-handling logic. Then you need to write
your decision in Big Red Letters and make it an evident element of choice
for whoever is going to select the right library for his job.

Java supports natively the notion of caller-code exception; in the other
case, a listening pattern is all is needed - someobject which is
registered as receiver of "perform exceptions" in your example, receives
the necessary state information and perhaps decides what to do (i.e.
abort the forEach or not).

-- 
You dont know what to do when you dont know what you're doing.
http://space.tin.it/computer/csadun


Relevant Pages

  • Re: performance
    ... efficient language and still have an inefficient system. ... > Even on these super performant silicons, some kernel code and device drivers ... > exceptions. ... > relates to the efficiency/performance of the libraries ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Comparing Lisp conditions to Java Exceptions
    ... All the ISO standards in the world will not make the world ... Nothing keeps you from annotating your program with exceptions based on what ... language should adhere to your theory. ... Curiously, although you don't say it, Java has the opposite problem. ...
    (comp.lang.lisp)
  • Re: I wish to learn Ruby ,can anyone teach me???
    ... First, let's get the FUD out of the way: Ruby comes with a lot of libraries, ... Here's the biggest problem I have with Java: Right there, ... Now let's try that in Ruby: ... and I would call it the perfect beginner's language. ...
    (comp.lang.ruby)
  • Re: Java equivalent of C++ Spirit or Boost Graph Library ?
    ... Chris warns me about the difficulty of learning Java. ... The posters are generally far more familiar with the language, and more accomplished in their fields. ... management techniques in C versus using a standard garbage collector. ... regular-expression libraries or scanners (such as ...
    (comp.lang.java.programmer)
  • Re: Reddit Guys on the Pros and Cons of Lisp
    ... >> I never have to do that with Java. ... > language features, etc. ... They either have the feature or they don't. ... > libraries doing almost the same - for those languages. ...
    (comp.lang.lisp)