The Synchronous Blog

A blog about reactive programming languages.

Threads Are Evil

with 4 comments

I never refuse to express my opinion about threads: they are Evil.

Using threads is like selling your soul to Satan without even noticing it.
They offer you the paradise with concurrency and shared memory for your programs.
After the first week using it, you see yourself working full time to correct the “special cases” you weren’t aware of. After one month you become a slave of your own program.

The other (not so) common approach to concurrency is message passing.
It seems that it is always gaining popularity, but its use is still restricted to niches. It was never really adopted by a mainstream language.
Message passing eradicates memory corruption and is seen as a safer model.

What is common with these models is that they are both asynchronous and non-deterministic.
By asynchrony I mean that the concurrent entities run unaware of each other. If they want to synchronize, they must use a language primitive for it (receive, lock, synchronized, etc).
The non-determinism is also inherent here, one can never be sure when the scheduler will preempt a running entity. This is, of course, a source of non-deterministic bugs.

What is the point of using asynchronous languages to write synchronous programs?
We feel (probably we learnt) that we have no option: If we want to synchronize code we must do it explicitly.
That is so not true as I’ll try to defend here…


Written by francisco

August 16, 2008 at 4:07 pm

4 Responses

Subscribe to comments with RSS.

  1. I agree. Threads are evil. I read somewhere a interesting paragraph about this subject (IIRC was written by Allan Cox):

    “Threads are the best way to shoot your both feet at the same time.”


    August 17, 2008 at 4:16 am

  2. “By asynchrony I mean that the concurrent entities run unaware of each other…”

    acho que estão aware sim, tanto estão, que … “If they want to synchronize they must use a language primitive for …”

    Pode ser que elas não saibam o que as outras estão fazendo a cada momento, mas que estão aware, estão.


    Gilberto Sant'Anna

    August 17, 2008 at 5:22 pm

  3. The end of your post was something like: “Don’t miss the next chapters” :-)

    It seems the other two comments were more useful :-D

    Sérgio Medeiros

    August 17, 2008 at 5:44 pm

  4. […] problem with Events Following the discussion from here and […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: