Are threads a meme?

Is there a single programming language that makes it easy to write concurrent programs without introducing more problems than it solves?

Other urls found in this thread:

stackoverflow.com/questions/3827892/how-can-i-change-the-size-of-an-array-in-c
twitter.com/AnonBabble

I wish. Something like be low existed:
int myArray[10][5][13][55];Para(myArray+5);foreach myArray: print myArray + "/n";

Output:

15101860

I've looked before, but the only solutions I ever found were either abandoned academic projects or convoluted, overly-complex beaurocratically-created messes.

Erlang/OTP

Erlang/Go, depending on requirements and dev team.

~ $ command time perl6 -e 'my @a = 10,5,13,55; my @b = @a.hyper.map(*+5); .say for @b'151018600.12user 0.00system 0:00.10elapsed 114%CPU (0avgtext+0avgdata 66184maxresident)k0inputs+0outputs (0major+11381minor)pagefaults 0swaps
There, CPU parallelism >1 even for that shitty example.

...

C/Cpoopoo/FORTRAN + OpenMP
www.openmp.org/resources/

C and C++ doesn't allow you to do this.
The solution would be to write a function that creates a new array with your parameter and copies the entries from the old array (even though they are null or zero).
Have you tried stackoverflow?
stackoverflow.com/questions/3827892/how-can-i-change-the-size-of-an-array-in-c

But that isn't very efficient at all. At that point it almost might as well be single threaded.

Erlang, or so i've been told

No, but if you use , which is a very common extension, it does. OpenMP is supported by gcc, icc, clang...

int a[]={10,5,13,55};int i;#pragma omp parallel forfor(i=0;i

obviously, and in any sane programmling language. I'd guess that spinning up a single thread is more work than outputting all that but i could very well be wrong

...

Java

XDDDD

Yeah, what about C

If you truly want massive amounts of threads use CUDA C++ or OpenCL and write your program to run on a GPU.

Could this be utilized in games? Both server-side and end-user or? Like having a GPU doing calculations for all the players(since that would be a highly scalable with threads) in an MMO game.

I still don't get GPU calculations, is it like having CUDA perform sin, cos, tan on 2000 cores or something more simple like increments or is it giving a piece of a larger calculation to differents parts?

A robust concurrency API for application code should allow for exception handling (interrupts, timeouts), task scheduling, checking task status, specificying thead context/pooling, allow cancelling, provide progress updates to the claling thread, at the very minimum. A "good" language will also provide blocking/sharing data structures.

Java has provided a good concurrency API (java.util.concurrent) which was further improved in version 8. The latest version of C# use a similar paradigm. Both are quite easy to use and provide such data structures. For simple concurrency, methods can be marked as synchronized or can be used with simple locks. It's actually just as easy as concurrency in Erlang, and with Java 8, just as idiomatic.

I'm not 100% sure, but I think the simplified version is that instead of saying "loop through these 1000 numbers and multiply each of them by 3" you say "multiply these 1000 numbers by 3" and then it multiplies all of them concurrently. It's great for bruteforcing hashes, since you tpyically need to apply the exact same operations to a lot of pieces of data, but the operations are very low-level so proper logical branching isn't an option. I can't think of any MMO functionality that would benefit from it.

Lol, are you a child

All threads execute the same code but the data can change (like SIMD). So for instance to copy an array you only execute "a[blockIdx.x] = b[blockIdx.x]", with no loop, and it works because each thread gets a different x. Now if your code diverts (some if is true for some but not all threads of the same thing), maybe now it changed, but last time I used it meant your performance is halved since it has to execute in two different steps.
GPU programming has many, MANY, caveats. Accessing its memory is expensive, accessing the main memory takes forever, and you get shit nothing for cache. So not all algorithms work well with it, but of course in the right cases it works great.

Yes. PhysX for instance. Not much idea what MMOs do, but I don't think they have heavy enough computation to be worth copying the data to/from the GPUs all the time.

...

...