Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scientific computing with Javascript

Rudi MK
September 08, 2014

Scientific computing with Javascript

Slides for JSFoo 2014

Rudi MK

September 08, 2014
Tweet

Other Decks in Technology

Transcript

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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?
  6.  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.
  7. 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.
  8. 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!
  9. 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
  10. 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.
  11. 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.
  12. “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.