Rather than using threads, functional programming presents the superior approach for developers who must program for newfangled multicore processors, XML co-inventor Tim Bray stressed at a technical conference on Friday.
Programming for multicore chips requires that developers deal with concurrency, which brings its own issues, Bray said in a presentation at the O'Reilly Open Source Convention (OSCON 2010) conference. Multicore processors have become popular as Moore's Law pertaining to increased single-core processor performance has run out of steam, Bray noted.
"Concurrency is hard. It involves a lot of problems that are very difficult to think about and reason about and understand," said Bray, who is developer advocate at Google. Bugs and performance bottlenecks are among the issues with concurrency, he said.
"The idea of functional programming is that data is immutable. You can't share data," Bray said. If data cannot be shared, then developers do not have to worry about more than one person changing it at once, he said. Immutable data allows for use of pointers instead of sending the real data, Bray noted.
Erlang is "bulletproof, and reasonably high-performance," Bray said. Originally designed for programming massive telephone switches with hundreds or thousands of processors, Erlang has no classes, objects, or variables, and its file handling is miserable, but there is still a lot to love about it, Bray added.
Clojure, Bray asserted, is a Lisp, runs on the Java Virtual Machine, and compiles to straight Java bytecode, which makes it extremely fast. "This is super, super-high-performance language," Bray said.
Historically, it has been thought that the way to program for concurrency is through threading, Bray said. But programming with threads, which offer multiple access to shared, mutable data, is "something that is not understood by application programmers, cannot be understood by application programmers, will never be understood by application programmers," added Bray.
Bray stressed his presentation pertained to work he had done prior to his employment at Google, where he now works on the Android mobile platform. He joined Google earlier this year. Bray previously worked at Sun Microsystems, where he was director of web technologies. Sun was acquired by Oracle early this year.