Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript and Scientific Processing? [closed]

Tags:

Matlab, R, and Python are powerful but either costly or slow for some data mining work I'd like to do. I'm considering using Javascript both for speed, good visualization libraries, and to be able to use the browser as an interface.

The first question I faced is the obvious one for science programming, how to do I/O to data files? The second is client-side or server-side? The last question, can I make something that is truly portable i.e. put it all on a USB and run from that?

I've spent a couple of weeks looking for answers. Server2go seems to address client/server needs which I think means I can get data to and from the programs on the client side. Server2go also allows running from a USB. The data files I work with are usually XML and there seem to be several javascript converters to JSON.

However, after all the looking around, I'm not sure if my approach makes sense. So before I commit further, any advice/thoughts/guidance on Javascript as a portable tool for scientific data processing?

like image 889
MikeB Avatar asked Jul 25 '12 13:07

MikeB


People also ask

Is JavaScript used in scientific computing?

Propel is a new JavaScript scientific computing library leveraging GPU hardware for computations to support machine learning and other scientific computing in JavaScript. While Python is often the default language of choice for machine learning, JavaScript usage is growing in popularity.

Is Node JS good for data science?

Node. js and other JavaScript libraries are excellent choices for data science. Here's why. JavaScript (also known as JS) is the lingua franca of the web, as it is supported by all the major web browsers—the other languages that run in browsers are transpiled (or translated) to JavaScript.


1 Answers

I have to agree with the comments that JavaScript is not a good fit for scientific processing. However, you know your requirements best; maybe you already found useful libraries that do what you need. Just be aware that you'll have to implement all logic yourself. There is no built in handling of complex numbers, or matrices or integrals or ... Usually programmer time is far more valuable than machine time. Personally, I'd look in to compiled languages; after I created a first version that isn't fast enough in whatever language I like the most.

Assuming that JavaScript is the way to go:

Data I/O

I can think of three options:

Sending and receiving data with ajax to a server

Seems to be the solution you've found with Server2go. It requires you to write a server back end, but that can be kept quite simple. All it really needs to do be able to read and write files as a response to you client-side application.

Using a non-browser implementation of v8 which includes file I/O

For instance Node.js. You could then avoid the need for a server and simply use a command-line interface, and all code will be JavaScript. Other than that it is roughly equivalent to the first option.

Creating a file object using the file API which you ask the user to save or load

It is the worst option in my opinion, as user interaction is required. It would avoid the need for a server; your application could be a simple html file that loads all data files with ajax requests. You'd have to start Chrome with a special switch to allow ajax requests with the file:// protocol, as described here

These options are only concerned with file I/O and you can't do file I/O in JavaScript. This is because browsers cannot allow arbitrary web code to do arbitrary file I/O; the security implications would be horrendous. Each option describes one way to not do file I/O.

The first communicates with a server that does the file I/O for the client.

The second uses "special" versions of JavaScript, with conditions other than that of the browser so the security implications are not important. But that means you'll have to look up how file I/O is done in the actual implementation you use, it's not common to JavaScript.

The third requires the user to control the file I/O.

Interface

Even if you don't use JavaScript to do the actual processing, which so far is the consensus, there is nothing stopping you from using a browser as the interface or JavaScript libraries for visualisation. That is something JavaScript is good at.

If you want to interactively control your data mining tool, you will need a server that can control the tool. Server2go should work, or the built in server in Node.js if you use that or... If you don't need interactive control of the data tool; that is you first generate the processed data, then look at the data a server can be avoided, by using the file//: protocol and JSONP. But really; avoiding a server shouldn't be a goal.

I won't go into detail about interface issues, as there is nothing specific to say and very nearly everything that has been written about javascript is about interface.

One thing, do use a declarative data binding library like Angular.js or Knockout.js.

like image 198
Odalrick Avatar answered Sep 17 '22 18:09

Odalrick