Sorry for off-topic, but what is your opinion of C being a "bad"
language based on?
30 years of computer science and experience with other languages.
including 10 years as a member of ISO/IEC SC22/WG21 (C++ committee)
and a couple on the C committee.
Please try Haskell or Ocaml to understand. Even C++ is
superior and has the advantage of retaining compatibility with
C libraries without dramas.
in fact, experience with extending C to C++ shows just how bad C
really is (particularly generalising by templates):
it gets just about everything wrong that you could
possible get wrong: automatic conversions, casts, unsafe dereference
and array operations, ridiculously weak type system without polymorphism,
unsafe linkage, exceptionally hard to optimise due to bad semantics (cf Fortran
and “restrict” added to C99 to try to fix this), lack of sum types,
lack of anonymous product types, lack of closures, lack of control inversion
(control exchange primitive) absurdly difficult
type syntax … do I have to go on? Unsafe and non-reentrant libraries,
static/global variables … macros, non-platform independent code,
… Is there anything at all C did right?
It’s not entirely off topic in that whilst SDL library is C, you don’t
have to write C to use it. C++ binds seamlessly, Felix binds almost
seamlessly, and there are many other languages with SDL bindings.
On the topic of control inversion (lightweight threads) Felix has
channels and cooperative threads ideally suited for games;
basically every actor can have its own thread and be in control
of its actions (a control master) without a performance penalty.
Go also has channels though I’ve never tried it. The language comes
with some SDL demos using this technique. So far it works but is
still a bit clumsy to use. The model is akin to using chips and wiring
them together. The wiring is still difficult but the chips (actors)
can be programmed independently. In a similar way to a functions
only actors have state. Like an object. Only, with ordinary objects
you have to use callbacks which makes object methods slaves:
actors are just like threads (they’re masters) but control exchange
is done by reading/writing channels instead of pre-emptively.
So there are alternatives to C, although C is of course more
mature … or is that just more polite than senile? :)On 12/04/2011, at 12:39 AM, Grigory Javadyan wrote: