Re: RFC: C and concurrency (as CC extensions)



Since I don't have much experience with most of the technologies you
mentioned, I am just going to provide you with some general opinions.

First and foremost, I think C is an awful language for concurrent
programming. Almost everything you do alters state, from iterating over
the elements of an array with a for loop to large portions of the
standard library. The more altering state there is, the easier it is for
both developers and the compiler to introduce errors, _especially_ in
the face of concurrency.

Having said that, I do see some places where concurrency can be
introduced. Implicit parallelism can be introduced in places where the C
spec leaves results, and, in particular, evaluation order, unspecified.
Also, many of the imperative constructs in C (loops, in particular) can
actually be analyzed and parallelized in many cases. At least, Fortran
compilers do this and I would be highly surprised if the same
techniques wouldn't work in C.

As far as libraries go, obviously there is already support for
processes, threads, and various forms of message passing. All these are
platform-dependent, but libraries have been written that provide a
consistent API on multiple platforms (e.g. GLib provides threads on
win32 and *nix). Whole operating systems have been written with these,
and processes and sockets are pretty much the standard way to do
concurrency on *nix and Plan9.

If you are thinking about extending or breaking the language, I would
urge you to consider how much keeping all the ugliness and limitations
of C is really worth to you, and if you couldn't get that value by
designing a new, cleaner, better language that can call C code (e.g.
through embedding C code in your programs, through allowing extensions
to be written in C, or through allowing your language implementation to
be embedded in C programs).

If you decide that you do want to embrace and extend C, things I would
think about are slightly altering the semantics to allow more
concurrency, introducing some more abstract constructs (e.g. loops that
do not use visible state), constructs that allow programmers to specify
that some steps must be done without interruption (perhaps along the
lines of Promela's d_step or Java's synchronized), and constructs that
specify that the programmer does _not_ care about the order of
execution of some statements.

Otherwise, general good design principles apply. Try to avoid building
things into the compiler; instead, provide the building blocks to build
the things you want in libraries and build them there. For exmaple, many
common constructs in concurrent programming can be built out of others;
e.g. you can build monitors from mutexes (or the other way around). This
means you need to provide only one in your language, the other can be in
a library.

Regards,

Bob

--
On the other hand, you have different fingers.



.



Relevant Pages

  • Re: CL-UNIFICATION as a library (Re: Qi Seems Great)
    ... perhaps it is time for a new revision for the language? ... Common Lisp people looking down on everybody else, ... But I'm not new to programming - that's ... should find the CL implementation and set of libraries most suitable ...
    (comp.lang.lisp)
  • Re: 3GL vs. 4GL [was: Re: LSP and subtype]
    ... But that doesn't mean the language designers shouldn't try to ... 3GL like C++, Java, C# augmented with appropriate libraries? ... Concurrency is an example of ... Java execution model is a pure synchronous model. ...
    (comp.object)
  • Re: C++ or Java ?
    ... programming styles, not just OOP. ... >> libraries and tools outweighs the benefit of having a more powerful ... pick a suitable set of libraries, and then see which language it's ... What is Python, precious? ...
    (comp.os.linux.development.apps)
  • Re: Conformance
    ... better than C for certain types of programming, and C is better than C++ ... You think that C will lose because it has far less features than C++. ... currently a superior language. ... libraries, some of which were last updated decades ago. ...
    (comp.std.c)
  • Re: Language flame wars are moot
    ... > Most windows libraries and the like use their own collection ... only after determining if the language AND libraries provide ... Likewise I refuse to write math heavy code in Objective-C ... It SUPPORTS object oriented programming, ...
    (comp.lang.lisp)