From: "Alex R. Mosteo" <alejandro@mosteo.invalid>
Subject: Re: Ada requires too much typing!
Date: Wed, 02 Jun 2010 13:08:24 +0200
Date: 2010-06-02T13:08:24+02:00 [thread overview]
Message-ID: <hu5e4u$6il$1@news.eternal-september.org> (raw)
In-Reply-To: hu3u6e024bi@drn.newsguy.com
Luis Espinal wrote:
> In article <hto4st$7g2$1@news.eternal-september.org>, Alex R. Mosteo
> says...
>>
>>Luis Espinal wrote:
>>
>>>(...)
>>> We have also come to learn that interfaces, the prohibition of multiple
>>> inheritance, (...) were not a good idea at all.
>>
>>Thanks for the elaborate reply. Not expert in Scala/Java so I can't
>>comment about most of it.
>>
>>However, seeing that Ada has just copied Java interfaces, I'd like to
>>known a bit more in detail why you say what I quoted, if you have the
>>time. I have used interfaces a bit and indeed have some grudges with them,
>>but I'd like to know if the situation is worse than I think -- or perhaps
>>I'm not using them 100% properly.
>>
>>Thanks in advance,
>>
>>Alex.
>
> Hi Alex - sorry I didn't reply sooner. I've been on the grind at work in
> the last couple of days.
>
> The issue with interfaces (which is not universally accepted among Java
> developers) is that they cannot be changed without incurring in changes to
> classes implementing that interface. This is a big issue for the way in
> which code is developed in Java. Let me try to illustrate:
Hi Luis, thanks for the detailed reply. I understand your points clearly.
My days of Java are a bit behind so I'm not sure what I'm about to say can
be done in Java. In Ada, one could extend an interface adding a new method
like this:
procedure Moo (This : A) is null;
And effectively it won't break any client, since it provides a default "no-
op" implementation. It won't work for functions, obviously. In any case,
clients would need to recompile, since in Ada land we're not talking of a
world of JVMs and dynamic hot-plugging, I presume. This alone (the use of
stand-alone executables) may make the problem much less of an issue.
Also, not needing to specify defaults to overload a method could be of help?
procedure Foo (This : A) is abstract; -- Added in 1st spec
procedure Foo (This : A; Bar : A'Class) is null; -- Added in 2nd spec
I've done sometimes the thing of having a insulating base class providing
some/most of the interface core functionality, but at the same time I
realized that this defeats to some degree the point of interfaces, since you
can't inherit from two such base classes.
In any case I feel your pain about the lot of Java programmers and
frameworks ;-) I guess it has its goods and its bads.
Alex.
>
> The common practice in Java is find a platform or framework (some sort of
> high-level "virtual" OS for lack of a better word.) Then, either write
> your apps on it, or develop another platform on top of it (another, more
> refined, more business-specific "virtual" OS. So pretty much we (try to)
> gradually refine the architecture of an application via an architecture
> pre-defined by the runtime below it. Examples of this are JEE, Spring and
> the Eclipse framework (and all the stuff + the kitchen sink that we throw
> on top of them.)
>
> All those layers are typically defined with interfaces (since we don't get
> multiple inheritance or mixin/traits). We end up with these long class
> hierarchies, and lots and lots of artifacts implementing lots and lots of
> interfaces. Libraries and libraries, and platforms and platforms...
> without a concept of versions.
>
> So for example, you have an interface named A that defines a method foo():
>
> public interface A { public void foo(); }
>
> And then you have a large number of classes implementing A, which are
> distributed to 3rd parties. A while later, you find you must include a new
> method on interface A:
>
> public interface A { public void moo(); }
>
> The moment you do that, you render every library that depended on old A
> unusable. Either your clients won't be able to compile it, or if they will
> get nasty run-time errors. The JVM will even refuse to load the old
> classes because they do not conform with the new interface anymore.
>
> The folks in the eclipse framework, for example, have had to deal with
> this problem by implementing "versioned" interfaces and have code deal
> with them at run-time:
>
> public interface A { public void foo(); }
> public interface A_1 { public void moo(); }
>
> class clientOfA {
> void dooFooAndMaybeMoo( A someA )
> {
> ...
> if( someA instanceof A_1 )
> {
> ((A_1)someA).moo();
> }
> ...
> }
>
> This could get out of hand (specially with sloppy programmers which, in
> Java, unfortunately we have too many.) This can also be a concern with
> people that develop frameworks and libraries for both external and
> internal use. So what we do is that, in addition to implementing an
> interface, we typically extend a an abstract base class that can insulate
> us from possible changes to the interface:
>
> public interface A {...}
> public abstract class AbstractA implements A {...}
> public class ConcreteA extends AbstractA {...}
>
> If we need to change A, we simply change AbstractA so that clients of A
> that extend AbstractA don't get forced to change their source... but that
> doesn't do anything for those that still extend A directly. And having an
> abstract base class like that defeats the purpose of being able of
> creating arbitrary implementations of an interface.
>
> Other folks deal with that problem by creating Adapters... ending up with
> a soup of design patterns going wild.
>
> Some people still think this is still a better trade-off over C++ styled
> multiple inheritance because of the dreaded "diamond" problem. To me (and
> this is strictly a personal opinion), it isn't.
>
> That's a lot of manual shamanism that should be better dealt with
> syntactically. We should have had multiple implementation inheritance from
> the get-go and just deal with it using the tools of the language and
> careful planning.
>
> I think the Scala guys had the most wonderful of ideas by implementing
> Traits. They offer many of the benefits of interfaces while simplifying
> the ability of inheriting multiple implementations. The focus is no longer
> on building behavior not just with inheritance but also with composition.
> I don't need to worry if my object is a-something to that can do a-task; I
> just have to worry that it can perform the task.
>
> I do think that interfaces have been great for specifying contracts. They
> enforce an order on things. However, it is important to plan ahead
> regarding interface versions. I don't know if this is a big deal in
> Ada-land, but in the JVM-land, it has been.
>
> Please take it with a grain of salt. It is simply my observation, and with
> software YMMV from one context to another :)
>
> - Luis Espinal (luis.espinal@gmail.com)
next prev parent reply other threads:[~2010-06-02 11:08 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-28 5:25 Ada requires too much typing! Luis Espinal
2010-05-28 6:47 ` Yannick Duchêne (Hibou57)
2010-05-28 15:52 ` John B. Matthews
2010-05-28 17:31 ` Dmitry A. Kazakov
2010-05-28 19:05 ` Georg Bauhaus
2010-05-28 19:39 ` Dmitry A. Kazakov
2010-05-28 9:48 ` Georg Bauhaus
2010-05-28 10:10 ` Alex R. Mosteo
2010-06-01 21:30 ` Luis Espinal
2010-06-02 11:08 ` Alex R. Mosteo [this message]
2010-06-05 19:58 ` Luis Espinal
2010-06-02 13:09 ` Yannick Duchêne (Hibou57)
2010-06-05 20:13 ` Luis Espinal
2010-06-06 4:25 ` Yannick Duchêne (Hibou57)
2010-06-06 8:55 ` Martin Krischik
2010-06-06 10:13 ` Simon Wright
2010-06-06 11:03 ` Dmitry A. Kazakov
2010-06-06 12:04 ` Martin Krischik
2010-06-07 8:34 ` Maciej Sobczak
2010-06-07 9:25 ` Martin Krischik
2010-06-07 12:04 ` Colin Paul Gloster
2010-06-07 12:17 ` Maciej Sobczak
2010-06-07 12:26 ` Dmitry A. Kazakov
2010-06-07 15:00 ` Martin Krischik
2010-06-08 7:46 ` Maciej Sobczak
2010-06-08 8:53 ` Martin Krischik
2010-06-09 7:50 ` Maciej Sobczak
2010-06-09 8:10 ` Dmitry A. Kazakov
2010-06-09 8:43 ` Maciej Sobczak
2010-06-09 9:24 ` Dmitry A. Kazakov
2010-06-09 13:54 ` Maciej Sobczak
2010-06-09 14:29 ` Dmitry A. Kazakov
2010-06-09 15:02 ` Georg Bauhaus
2010-06-09 15:53 ` Dmitry A. Kazakov
2010-06-09 18:00 ` Yannick Duchêne (Hibou57)
2010-06-09 19:10 ` Dmitry A. Kazakov
2010-06-09 21:09 ` Yannick Duchêne (Hibou57)
2010-06-10 8:07 ` Dmitry A. Kazakov
2010-06-10 8:44 ` Yannick Duchêne (Hibou57)
2010-06-10 9:07 ` Dmitry A. Kazakov
2010-06-10 10:10 ` Georg Bauhaus
2010-06-10 10:28 ` Dmitry A. Kazakov
2010-06-09 21:22 ` Maciej Sobczak
2010-06-09 23:09 ` Yannick Duchêne (Hibou57)
2010-06-10 8:15 ` Dmitry A. Kazakov
2010-06-10 13:37 ` Maciej Sobczak
2010-06-10 13:57 ` Dmitry A. Kazakov
2010-06-09 14:31 ` Yannick Duchêne (Hibou57)
2010-06-09 15:57 ` Dmitry A. Kazakov
2010-06-09 17:51 ` Yannick Duchêne (Hibou57)
2010-06-10 6:13 ` Randy Brukardt
2010-06-10 6:19 ` AdaMagica
2010-06-10 21:59 ` Randy Brukardt
2010-06-10 6:34 ` Vadim Godunko
2010-06-10 6:54 ` Yannick Duchêne (Hibou57)
2010-06-10 7:36 ` Vadim Godunko
2010-06-10 8:21 ` Dmitry A. Kazakov
2010-06-10 8:51 ` Vadim Godunko
2010-06-10 9:20 ` Dmitry A. Kazakov
2010-06-10 8:51 ` Yannick Duchêne (Hibou57)
2010-06-10 22:08 ` Randy Brukardt
2010-06-11 9:13 ` Stephen Leake
2010-06-10 7:20 ` AdaMagica
2010-06-10 8:57 ` Vadim Godunko
2010-06-10 10:12 ` Georg Bauhaus
2010-06-10 13:47 ` Alex R. Mosteo
2010-06-10 19:18 ` Vadim Godunko
2010-06-10 22:08 ` Gautier write-only
2010-06-10 22:17 ` Randy Brukardt
2010-06-11 18:38 ` Simon Wright
2010-06-29 2:13 ` Randy Brukardt
2010-06-11 9:14 ` Stephen Leake
2010-06-11 18:03 ` Jeffrey R. Carter
2010-06-11 9:11 ` Stephen Leake
2010-06-10 7:21 ` Maciej Sobczak
2010-06-10 19:33 ` Simon Wright
2010-06-10 22:23 ` Randy Brukardt
2010-06-07 8:13 ` Maciej Sobczak
2010-06-07 8:35 ` Martin Krischik
2010-06-07 8:43 ` Martin Krischik
2010-06-06 8:06 ` Martin Krischik
2010-06-07 18:30 ` Luis Espinal
2010-06-08 6:43 ` Martin Krischik
2010-06-08 7:10 ` Georg Bauhaus
2010-06-08 9:00 ` Martin Krischik
2010-06-10 13:56 ` Alex R. Mosteo
2010-06-10 14:29 ` J-P. Rosen
2010-06-11 11:57 ` Alex R. Mosteo
2010-06-08 10:10 ` Niklas Holsti
2010-06-08 11:35 ` Georg Bauhaus
2010-06-10 13:58 ` Alex R. Mosteo
2010-06-10 19:45 ` Simon Wright
2010-06-10 20:09 ` Niklas Holsti
2010-06-10 18:21 ` Yannick Duchêne (Hibou57)
-- strict thread matches above, loose matches on Subject: below --
2010-05-26 12:57 Peter C. Chapin
2010-05-26 13:29 ` Ludovic Brenta
2010-05-26 15:56 ` Peter Hermann
2010-05-26 16:12 ` Ludovic Brenta
2010-05-26 18:57 ` Pascal Obry
2010-05-26 19:30 ` Yannick Duchêne (Hibou57)
2010-05-26 14:48 ` Jeffrey R. Carter
2010-05-27 17:10 ` Warren
2010-05-27 22:15 ` Adam Beneschan
2010-05-28 15:26 ` Warren
2010-05-30 0:49 ` BrianG
2010-05-30 7:27 ` Dmitry A. Kazakov
2010-05-30 9:17 ` Yannick Duchêne (Hibou57)
2010-05-30 9:51 ` Simon Wright
2010-06-02 1:42 ` BrianG
2010-05-26 15:23 ` Adam Beneschan
2010-05-26 17:20 ` Georg Bauhaus
2010-05-26 19:33 ` Yannick Duchêne (Hibou57)
2010-05-26 21:55 ` Simon Wright
2010-05-26 23:36 ` Georg Bauhaus
2010-05-27 2:07 ` Fritz Wuehler
2010-05-27 4:19 ` Yannick Duchêne (Hibou57)
2010-05-27 19:51 ` Warren
2010-06-03 16:54 ` Colin Paul Gloster
2010-06-03 16:09 ` Yannick Duchêne (Hibou57)
2010-06-03 16:11 ` Yannick Duchêne (Hibou57)
2010-06-04 11:40 ` Nicolas Cóilin Paul de Gloucester
2010-06-04 13:54 ` Ludovic Brenta
2010-06-04 11:29 ` Nicholas Collin Paul de Gloucester
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox