Linked by Thom Holwerda on Sun 9th Sep 2007 18:08 UTC, submitted by koki
Thread beginning with comment 269961
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[5]: Writing multithreaded applications in C++
by Vanders on Mon 10th Sep 2007 15:31
in reply to "RE[4]: Writing multithreaded applications in C++"
You clearly have a pet language, so this discussion is kind of pointless, but there is one thing I want to pick up:
Maybe a message handler for one specific message type. If I remember correctly, a BLooper processes BMessage objects which are basically hashtables. So to handle multiple different message type, you end up with a giant switch statement. In each branch of the switch statement, you have to manually extract all message parameters from the BMessage. For a complex message that will be several lines of code for each message type just for the decomposition. And then you need to handle the case where some parameters are not present or of the wrong type, etc.
The thing is, all of this is trivial and no more difficult or error prone than any other form of procedural programming. It's a total non-issue, and irrelevant to any argument about threading issues, other than the fact that message passing is a good solution to reduce locking. How it is implemented is irrelevant. It's well known that C & C++ are verbose when compared to newer HLL's. If Kaj wern't so busy I'd ask him to come tell you about how wonderful and compact REBOL is.
RE[6]: Writing multithreaded applications in C++
by tuttle on Mon 10th Sep 2007 18:02
in reply to "RE[5]: Writing multithreaded applications in C++"
You clearly have a pet language, so this discussion is kind of pointless,[q]
I don't have a pet language. I just like modern languages with an orthogonal feature set and decent reflection capabilities. C++ has neither.
I used scala as an example of such a language. But any other language with a) pattern matching and b) strong support for immutable data structures would do just fine. For example ocaml or even plain old standard ML.
[q]The thing is, all of this is trivial and no more difficult or error prone than any other form of procedural programming.
I don't have a pet language. I just like modern languages with an orthogonal feature set and decent reflection capabilities. C++ has neither.
I used scala as an example of such a language. But any other language with a) pattern matching and b) strong support for immutable data structures would do just fine. For example ocaml or even plain old standard ML.
[q]The thing is, all of this is trivial and no more difficult or error prone than any other form of procedural programming.
So you are saying that writing 10 LOC is no more error prone than writing 1 LOC?
Don't get me wrong here: I used to love BeOS, and I even think that using C++ to write the core OS parts of Haiku is a good idea. I also do not want to criticize the author of that article. But I sincerely think that C++ is a very bad choice as a language to write multithreaded applications.





Member since:
2006-03-01
I work with many scientists and engineers. None of them are idiots. In fact, many of them are quite smart and also good programmers. But most of them do not get low level threading primitives.
Maybe a message handler for one specific message type. If I remember correctly, a BLooper processes BMessage objects which are basically hashtables. So to handle multiple different message type, you end up with a giant switch statement. In each branch of the switch statement, you have to manually extract all message parameters from the BMessage. For a complex message that will be several lines of code for each message type just for the decomposition. And then you need to handle the case where some parameters are not present or of the wrong type, etc.
In a language with pattern matching, all that is just one line of code.
There is a huge difference between understanding how e.g. a mutex works in principle and applying them correctly every single time.
Most of them probably use erlang because they understand threading so well that they know that low level threading primitives are very error-prone and result in very hard to find bugs.