Would it make any sense to use Scala for real-time control of hardware such as scientific instruments, telescopes, high energy particle acclerators (never know when you might find one at a yard sale), and bringing in the data over USB or audio card? By real-time I mean millisecond-scale handling of events, such as turn off a pump when some sensor starts returning '1' instead of '0', without taking more than 2 or 3 ms, and simultaneously keep recording the firehose of data from the Subquantum Antisynchronous Magneto-Photonic Hyper-Frobnicator without missing a beat.
We've been using Python, but it is slow and the standard implementation (cpython) has the infamous "GIL". I'm reluctant to use an old creaky language like C or C++, with slow compile times and chains of included headers, while at the same time lust to satisfy my curiosity about these new powerful "functional" languages that work magic and make concurrent programming easier. But do these new languages and Scala in particular have the ability to run hardware, take immediate action upon certain conditions, and record data streaming over old-fashioned links such as serial-USB?
Suppose the answer is "yes" - then, to be clear on this, what advantages would we enjoy by using Scala instead of other languages for our lab software?
Google turned up nothing but maybe I didn't think of the right search terms.
Well, Daren, looks like nobody else has a clue ether, so here's my $0.02, based on very limited knowledge of Scala and zero knowledge of software for laboratory equipment. My gut instinct is that Scala (or indeed Java) might not be the best solution here. It sounds like you want pretty fast real-time responses, and the JVM doesn't exactly have a reputation for excellence in that area. The usual route would probably be C/C++, as you suggest, where you effectively sacrifice extra time for development (and bug-fixing) in order to achieve runtime performance.
But you could look at Erlang, for example, which was developed for real-time processing on telecoms hardware and is also a functional language. I know nothing about it except that it has a strong reputation for reliablity, uses message-passing with actors and lightweight processes to support concurrency (instead of threads), and seems to out-perform Java (not sure about C/C++ though). There's a brief discussion of Erlang performance here, and a bit more on the Apache CouchDB pages. Erlang was used to implement CouchDB, but the original developer Damien Katz has a blog post here explaining why he's re-writing it as a separate project called CouchBase, using more C/C++ as well as Erlang:
Damien Katz wrote:We are moving more and more of the core database in C/C++, while still using many of the concurrency and reliability design principles we've proven with the Erlang codebase. And Erlang is still going to be part of the product as well, particularly with cluster management, but most of the performance sensitive portions will be moving to over C code. Erlang is still a great language, but when you need top performance and low level control, C is hard to beat.
Well, so I figured. Erlang is worth looking into, as I'm more a hardware/electronics/laboratory guy than app, mobile or web developer, which seems to be where Scala thrives. OTOH, when it comes to signal and image processing, the functional languages may have some nice tricks up their sleeves.
subject: Scala for laboratory equipment control /data acquisition?