6 ms·
C++11 threads tutorial
- tim_h 15y agoIs C++ usage on the decline? I've used a lot of different languages, but I've never had the occasion to learn C++. I work in web search and we tend to use interpreted languages. The argument is that Java or C# is much easier to write/maintain and that we can make up for performance shortcomings by scaling out.
- octopus 15y agoIs C++ usage on the decline? No it is not. C++11 is a modern programming language that lets you harness every bit of power from your computer. From a productivity point of view I think Java and C# are as verbose as modern C++. In the end it really depends on what kind of application you develop, for web development you can be a few orders of magnitude more productive than in C++ if you use Python or Ruby. For number crunching nothing beats Fortran. You should chose your tools (programming language, compiler, OS etc.) based on what you know and on the application domain.
- tim_h 15y agoI wasn't suggesting that that C++ is somehow outdated or inferior. I'm just wondering if the percent usage of C++ is declining with respect to other languages. I'm trying to estimate the chance that me not knowing C++ will pose a problem later in my career. I normally pick up languages quickly, but the C++ learning curve seems a bit steeper, both in terms of language nuances and libraries. So my normal approach of "wait until I need it" may not work that well.
- cornedpig 15y agoThis is a difficult question. If the number of C++ developers is growing, but at a slower rate than the number of total developers, is that a decline?
- yannickt 15y agoWhat are the classes of problems that interest you? What is the standing of C++ in the communities involved in solving these problems? For example, if you are interested in HPC, graphics programming or systems programming, and would like to pursue these areas professionally, then not knowing C++ may pose a problem.
- ahelwer 15y agoI work in HPC. Every application I've seen has been written in C++, with the exception of proof-of-concept Matlab code hacked together by the researchers. This is then contracted to be rewritten in C++.
- jbarham 15y agoFor C++, that's actually not too bad. Now try creating 100,000 threads with synchronized communication. In Go it's trivial: $ cat goroutines.go package main import ( "flag" "fmt" ) var n *int = flag.Int("n", 100000, "thread count") func thread(x int, result chan int) { result <- x } func main() { flag.Parse() results := make(chan int) for i := 0; i < *n; i++ { go thread(i, results) } for i := 0; i < *n; i++ { fmt.Println(<-results) } } $ time ./goroutines | tail 99990 99991 99992 99993 99994 99995 99996 99997 99998 99999 real 0m0.723s user 0m0.396s sys 0m0.840s http://weekly.golang.org/doc/effective_go.html#concurrency http://weekly.golang.org/doc/effective_go.html#concurrency
- ramy_d 15y agoI feel like your comment ignores what languages are for and what people looking for a c++11 tutorial on threading already know. You might think an equally trivial example with erlang is in order, but it totally marginalizes why anyone chooses to write with any given language in the first place.