News for hackers. Stuff that matters.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by the1 on Saturday July 28, 2012 @10:29AM (#4305597)
Parallelism is when you run your program on multiple processors. Semantics of your program does not change whether you run it on single processor or multiple processors.

Concurrency is when you write your program using multiple threads. Your program looks and means vastly different if you use threads.

You use concurrency not for performance gain, but for clarity of your program. You use parallelism for performance gain, to utilize all your processors.

Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by gruseom on Saturday July 28, 2012 @11:10AM (#4305667)
That can't be right. Threads don't improve the clarity of most programs; they're notoriously unclear.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by stcredzero on Saturday July 28, 2012 @12:30PM (#4305836)
I agree with you, but not in the way you intended. I suspect that most programming language implementations of concurrency are bolt-ons and are a bit broken in terms of their human (programmer) interface design.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by aphyr on Saturday July 28, 2012 @07:09PM (#4306863)
On the contrary, I think proper concurrency constructs, including threads, do improve the clarity of programs. Part of the problem in reasoning about threads is a lack of useful primitives. Multithreaded programming in Java? For me, at least, it's tough. In Erlang? Trivial. In Clojure, if you're willing to deal with the slowness of the STM, it can be beautifully simple.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by gruseom on Sunday July 29, 2012 @02:19PM (#4309240)
Erlang and Clojure don't have threads in the common meaning of the term (http://en.wikipedia.org/wiki/Thread_(computing)). They are reactions against programming with threads.

You can expand the term "thread" to mean "concurrency in general" but even then it isn't true that the main purpose of writing concurrent code is clarity. When people say "look at this concurrent program I wrote" they rarely [1] say "look at how well the code expresses the problem". What they overwhelmingly say is "look at this benchmark".

[1] Joe Armstrong talks about how Erlang lets you represent processes more like they happen in the real world. But that's a niche view. Most people think about concurrency as a platform issue, where the platform is multicore hardware or distributed systems, and otherwise wouldn't bother with it.

Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by arohner on Sunday July 29, 2012 @07:12PM (#4310096)
Clojure absolutely has threads, in the common meaning of the term. I use futures all over the place in my code, and it's quite idiomatic.

(future (do (foo 1) (bar 2)) Runs the expression on another thread. Futures intentionally compose well with the built-in clojure concurrency tools.

Clojure has no dislike of threads. It scorns locks, and code that is safe in one thread, but unsafe in multi-threaded situations.

Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by gruseom on Sunday July 29, 2012 @07:35PM (#4310168)
Ah, thanks for the correction and teaching me something.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by aphyr on Monday July 30, 2012 @12:42AM (#4310951)
Erlang and Clojure are multithreaded. Clojure offers full access to Java-style (Thread. (fn [] ...)), j.u.c Executors, and Clojure-specific threadpools for agents and futures, including differentiation between CPU and IO intensive threads. Erlang's scheduler is also threaded, though its threads aren't 1:1 with pthreads. That's fairly common: plenty of libraries and languages map green threads to physical threads for highly concurrent programs.
Re:Ask HN: On Rob Pike's Concurrency is not Parallelism? by azernik on Saturday July 28, 2012 @02:39PM (#4306125)
Also, concurrency provides some performance gains that are not related to parallelism, such as efficient use of the CPU while waiting on I/O.