[Tfug] Language choices

Stephen Hooper stephen.hooper at gmail.com
Wed Nov 8 01:07:11 MST 2006


>
> In particular, I think that the way Java added "synchronized"  as a
> > > special keyword in the language instead of a general mechanism for
> > > wrapping  blocks or closures is sick and wrong.
> >
> > The "synchronized" thing in Java is for dealing with concurrency.  It has
> > nothing to do with closures.
>
>
>
> Exactly what I hate about it.   I think that there should be no special
> mechanism in the grammar for doing that.  Instead, there would be a general
> mechanism for wrapping any arbitrary group of statements, and "synchronized"
> would be a specific instance.  Of course, that would be doable if there were
> closures and they were used to advantage.  Instead we get grammar warts.
>
> transaction {
>     gc disabled {
>        synchronized on: x {
>            arbitrary commands
>            for however many lines
>         }
>         more stuff()
>     }
>     commands
>     with GC
>     and stuff.
>  }
>
> But no. Transactions probably have to be another specific addition to the
> grammar. Sigh. I know that if I wrote my programs they way they write their
> grammars, my coworkers would make me refactor it.  And might pick on me.
>
>

As far as why "synchronized" is part of Java grammar... if I remember
correctly, it is to signal to the JVM that a method can only be
executed in one thread at a time.

Not that I know what language you are writing in, but I fail to see
how your instantiation above helps at all in this case  without help
of some kind of semaphore.  Aren't you going to get in trouble if two
threads instantiate synchronized at the same time?  Even with your
much beloved closures? Assuming  your language is providing a
semaphore for you, how do you then signify that threads can run
concurrently?

I also doubt that "transactions" have to be part of the grammar.  Once
you can define atomic operations in a language, then I would figure
you could pretty much come up with a transactional system.  I mean,
people have been doing that for a very long time in languages with
relatively few grammar rules.  But maybe, I am misunderstanding your
point...




More information about the tfug mailing list