Slide 1

Slide 1 text

Scientific computing with Javascript It’s not such a bad idea, after all.

Slide 2

Slide 2 text

Scientific computing?  Applied mathematical, statistical computing – applications across data science, astrophysics, biostatistics, cheminformatics, and many others.  It doesn’t stop there: computational finance uses the same libraries, languages and tools.  Current languages: Python, R, Julia.

Slide 3

Slide 3 text

So what’s wrong with Python or R?  Nothing’s “wrong” with them.  But for one, they don’t have Javascript’s advantages – async, runs everywhere.

Slide 4

Slide 4 text

Javascript: The PhoneGap for scientific computing?  PhoneGap changed mobile app dev.  Javascript could do the same for technical computing.  A powerful experience across servers, clients and embedded hardware.

Slide 5

Slide 5 text

Applications  Enormous. Calculating airline ticket costs on the basis of aviation fuel rates, and Great Circle routes, all on the client side.  Running clustering/classification/regression algorithms on the server, and passing their results to the client as D3.js visualizations.  Running Javascript-based neural networks on the server, and sharing them with Parrot drones running Javascript, for facial recognition. The possibilities, to put it mildly, are rather endless.

Slide 6

Slide 6 text

But. Is Javascript really suitable?  Two basic guidelines to evaluate any language’s feasibility for a problem:  Does the language provide the right semantic constructs to model your problem and its possible solution(s)?  Does the language have a decent ecosystem to help you solve your problem?

Slide 7

Slide 7 text

 Javascript does straddle the two disparate worlds of object-oriented programming.  The ecosystem is a bit of a challenge, however. But, there’s a solution to that too.

Slide 8

Slide 8 text

Demo: Some sample libraries and their applications.  Numbers.js – Basic differential and integral calculus, linear algebra.  Numerical Javascript – Advanced linear algebra, mathematical optimization.  Clusterfck – Hierarchical clustering, for machine learning.  Brain.js – Neural networks for deep learning. All these libraries, work with Node, browsers and embedded Javascript.

Slide 9

Slide 9 text

Not enough, though.  Obviously, Javascript just doesn’t have the kind of libraries that Python or R or Julia do.  Three options:  Drop the whole idea of using Javascript.  Start writing libraries for Javascript.  Compile existing libraries to Javascript. Let’s be honest. Dropping it isn’t a nice option. Neither is writing libraries. But the third one sounds interesting!

Slide 10

Slide 10 text

The power of Emscripten  Emscripten is Mozilla’s implementation of the asm.js specification.  A gcc-compatible compiler, that translates C/C++ into runnable Javascript. C/C++ module LLVM bitcode Javascript

Slide 11

Slide 11 text

Demo: Emscripten

Slide 12

Slide 12 text

Forging ahead with Emscripten  Cython + Emscripten = Numpy and SciPy on Javascript  Emscripten + MLPACK, Intel’s MKL  “Piggyback” off existing ecosystems to build one for scientific computing around Javascript.  Biggest challenge – exploring Emscripten’s optimization methods, and using them to make models faster.

Slide 13

Slide 13 text

Not just Emscripten…  Heard of Duetto? It’s called Cheerp now. #dontask  LLVM+Clang, like Emscripten.  Bi-directional interop between C++/Javascript.  Uses RPC.  Allows access to DOM elements in a lightweight manner – think C++ manipulating d3.  Battle-tested on a large library on bullet physics.

Slide 14

Slide 14 text

“One language, to rule them all.”  Elm.  RESTify scientific models using Express.  Math on the client, for rendering more powerful WebGL scenes, or interfacing with Famo.us.  NaCL – running complicated models in the browser.  Cylon.js – running scientific models on Raspberry Pis, Parrot Drones and more.  Tessel.io – sharing intelligent neural nets across servers and microcontrollers to make automation more intelligent.

Slide 15

Slide 15 text

Questions? Accost me.  https://github.com/rudimk/jsmath  https://twitter.com/rudimk  [email protected]