comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Package's private parts and protected types
Date: Tue, 09 Feb 2010 15:55:20 +0100
Date: 2010-02-09T15:55:20+01:00	[thread overview]
Message-ID: <7tdbdtF82bU1@mid.individual.net> (raw)
In-Reply-To: f502e48c-c68b-48fa-9732-2a3480950a62@b7g2000yqd.googlegroups.com

Hibou57 (Yannick Duchêne) wrote:

> On 8 fév, 11:10, "Alex R. Mosteo" <alejan...@mosteo.com> wrote:
>> Frankly, these non-orthogonalities about regular and protected/tasks
>> types were really nagging me in Ada95 (the dot notation only for these
>> types, for instance, and the visibility of privates that you point to).
>> Now at Ada05, it's the mix of traditional and OO notation caused by
>> interfaces what bugs me.
> Although I've never confessed it here at comp.lang.ada, I feel the
> same too, at least about notation. Luckily, Ada still allow me to
> preserve consistency granting me the choice to use a dotted notation
> or not : I never use the dotted notation for consistency and clarity
> purpose (except that it's mandatory with protected types and tasks,
> and that's ok for me with record components, as it's implementation
> level).
> 
>> Also, the fact that making a protected version of a regular object
>> involves so much boilerplate code is a regular déjà-vu that pains me in
>> my dreams (;-)), compare it to java where adding the keyword synchronized
>> is enough. (Not that I would want java granularity for synchronized; the
>> bugs I've seen caused by "clever" overoptimization of critical
>> sections...)
> I could not tell about comparison between Java and Ada at this point,
> as I've never experienced tasking with Java (I use to self-learn Java,
> but quickly leave it for some reasons). While the point you've spotted
> seems interesting.

My Java is fairly rusty, but if I'm not mistaken, the thing is like this 
(corrections welcome!):

(A)
public class Blah { ... } // A regular class

public synchronized class Blah  {} // All subprograms of Blah are now 
thread-safe.

However, you can also:

(B)
public class Blah
{
 public synchronized get() {}
 public synchronized set() {}
 public bang() {}

}

So basically you choose which methods are synchronized. Or, even further:

(C)
public class Blah
{
 public void set() {
   synchronized(this) {    
      // Using this as the lock, operate exclusively within this block.
   }
 }
}

In my (limited) observing experience, programmers with a tendency to 
premature optimization (we all start like that, I fear) avoid (A) because 
it's seen as too restrictive. (I don't actually know if Java has a read-only 
lock and write lock model like Ada, or using (A) makes all subprograms 
mutually exclusive).

So they tend to rely on (B) or (C). At that point, it's really too easy to 
somewhere, sometime, forget about a necessary lock, and funny heisenbugs 
start to happen caused by obscure race conditions.

I really love the tasking+protected model of Ada.



  reply	other threads:[~2010-02-09 14:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08  4:30 Package's private parts and protected types Hibou57 (Yannick Duchêne)
2010-02-08  8:30 ` Martin
2010-02-08  9:11   ` Hibou57 (Yannick Duchêne)
2010-02-08 10:10     ` Alex R. Mosteo
2010-02-08 10:46       ` Hibou57 (Yannick Duchêne)
2010-02-09 14:55         ` Alex R. Mosteo [this message]
2010-02-08 10:20   ` Dmitry A. Kazakov
2010-02-08 10:54     ` Hibou57 (Yannick Duchêne)
2010-02-08 10:58       ` Hibou57 (Yannick Duchêne)
2010-02-08 11:01       ` Dmitry A. Kazakov
2010-02-08 13:19         ` Georg Bauhaus
2010-02-08 15:17         ` Robert A Duff
2010-02-08 16:15           ` (see below)
2010-02-08 20:44             ` Robert A Duff
2010-02-08 22:00               ` Hibou57 (Yannick Duchêne)
2010-02-09  5:48               ` AdaMagica
2010-02-09 14:56                 ` Robert A Duff
2010-02-10  2:29                   ` Randy Brukardt
2010-02-11 23:46                     ` Robert A Duff
2010-02-12  1:29                       ` Randy Brukardt
2010-02-11 23:53                     ` Robert A Duff
2010-02-12  1:10                       ` Randy Brukardt
2010-02-10 16:05                   ` Adam Beneschan
2010-02-10 20:17                     ` sjw
2010-02-12  0:05                     ` Robert A Duff
2010-02-12 11:07                       ` Stephen Leake
2010-02-12 15:01                         ` Robert A Duff
2010-02-13  8:00                           ` Stephen Leake
2010-02-09  9:04               ` stefan-lucks
2010-02-08 17:11           ` Jeffrey R. Carter
2010-02-08 14:56       ` Robert A Duff
2010-02-08 15:36         ` Dmitry A. Kazakov
2010-02-08 16:06           ` Robert A Duff
2010-02-08 17:46             ` Jean-Pierre Rosen
2010-02-08 20:39               ` Robert A Duff
2010-02-08 21:54                 ` Hibou57 (Yannick Duchêne)
2010-02-08 21:50               ` Hibou57 (Yannick Duchêne)
2010-02-08 22:04         ` Hibou57 (Yannick Duchêne)
2010-02-09 10:58         ` Hibou57 (Yannick Duchêne)
2010-02-09 14:47           ` Robert A Duff
2010-02-09 19:34             ` Hibou57 (Yannick Duchêne)
2010-02-09 20:19               ` Hibou57 (Yannick Duchêne)
2010-02-09 23:29               ` Robert A Duff
2010-02-10  2:39               ` Randy Brukardt
2010-02-10  5:12                 ` Hibou57 (Yannick Duchêne)
2010-02-10  7:17                   ` Hibou57 (Yannick Duchêne)
2010-02-10 16:09                   ` Robert A Duff
2010-02-10 22:21                     ` Hibou57 (Yannick Duchêne)
2010-02-11  0:48                       ` Robert A Duff
2010-02-09  0:48     ` Randy Brukardt
2010-02-09 12:43     ` Hibou57 (Yannick Duchêne)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox