5 ms·
The fastest Statistical Programming Language is …Javascript?
- Tichy 14y agoThe fascinating question is: why is Javascript fast? I suppose it is because of the competition between the browsers. Yay for competition!
- arunoda 14y agoOf course yes. Competition. And it has a good foundation and solid commercial backing with big fish companies.
- disgruntledphd2 14y agoUrrgh. This came through on my feed earlier today, and I left a comment on it. While javascript is fast (and can be used for many things), the real issue with using it for stats is the lack of libraries. More specifically, as far as I know it cannot interface with Fortran. That's a death knell for any statistical programming language, as it means no LAPACK, and no-one (sane) is going to rewrite all of those linear algebra libraries. So regardless of how fast it is, its not going to make it as a stats language. That being said, it does make it easier to develop statistically aware web-apps (a particular interest of mine), so that's definitely good.
- regularfry 14y agoIt does mean that there might be mileage in a native tool wrapping LAPACK et al in v8.
- icebraining 14y agoWhat about using https://github.com/rbranson/node-ffi https://github.com/rbranson/node-ffi + clapack? Not that I know what I'm talking about, I've never used Fortran.
- friggeri 14y agoSee: https://github.com/NaturalNode/node-lapack https://github.com/NaturalNode/node-lapack (haven't tested it, just to say that it exists).
- olalonde 14y ago> no-one (sane) is going to rewrite all of those linear algebra libraries Is it because it would take a long time or because it's inherently hard?
- jules 14y agoIt's easy enough to do a basic implementation, but getting good numerical stability and good performance is hard (and in Javascript, it's pretty much impossible with current implementations). See also the matrix multiplication benchmarks in the post: JS is 60x slower than Matlab, even though it's already using typed arrays. A naive triply nested for loop in C would probably perform similarly to the JS, which is to say a lot slower than something optimized for the characteristics of the processor (number of registers, vectorized floating point and cache sizes mostly, I'm not sure if Matlab is using multiple cores here).
- bmuon 14y agoYes, latest versions of Matlab use multithreading.
- tel 14y agoThere are a lot of them, they're all very picky, detailed inner loops, and they're already written and highly tested and optimized. People rewrite it all the time just to find that their versions are incomplete, slow, and buggy and nobody who wants to use LAPACK has patience for any of those three things.
- tgflynn 14y agoI don't know much about javascript implementations. Is there no foreign-function interface available ? If you can interface with C you can interface with Fortran (with a little extra work).
- TazeTSchnitzel 14y agoThere is no foreign-function interface, but you could use Emscripten to compile C libraries for it.
- melling 14y agoKickStarter project?
- aufreak3 14y agoOne relatively speedy route to getting solid numerics scriptability in JS is to do the heavy lifting in NaCl. An NaCl plugin for node would then let you use the same binaries on both the server and client.
- sandGorgon 14y agoany opinion about F#/Mono which seemingly does have blas/lapack support ?
- gruseom 14y agoSo regardless of how fast it is, its not going to make it as a stats language Why do you assume that JS can never be integrated with LAPACK etc.? That's hardly impossible.
- NonEUCitizen 14y agoHis table shows js is 40x slower on matrix multiplication.
- platzhirsch 14y agoErgo, JavaScript isn't the fasted language for that matters, because matrix multiplication is too important.
- sycren 14y agoor there is no dedicated library for matrix multiplication compared to the other languages..
- cassandravoiton 14y agoMore to the point - who cares. All these languages are hopelessly slow. If performance matters do it in a performant language like C++, C or FORTRAN. If it does not matter - then it does not matter and so stop going on about it.
- simonster 14y agoNo, it does matter. A lot of scientific computation is one-time-use code. What one cares about is the amount of time to write, execute, and debug the code. If it will take you much less time to write the code in a high-level language (which is usually the reason people use high-level languages), it may very well be worth the 2x performance hit from Julia, or even the larger performance hits of MATLAB and R. Additionally, when the amount of time spent performing vector and matrix operations greatly exceeds the amount of time spent in the interpreter, most of these languages will be as fast as C. I write MATLAB code that takes 5 minutes to run on a regular basis. If I were to write it in C, I would lose productivity, because it would take much more than 5 minutes longer to write. If I were to write it in Julia, it would probably take about the same amount of time to write, but I would hypothetically have the results in a few seconds. That matters.
- 14y ago
- lucian1900 14y agoPyPy is often faster than v8, so a more complete benchmark should include it.
- wheaties 14y agoPypy should have direct access to lapack. No need to bring in Pandas. Lapack is just that fast.
- gte910h 14y agoWho the hell would use the relatively library less javascript to do analysis? Sorry, R, Matlab, Python, Syntax, Fortran have actual libraries for this stuff, JS, no.
- xtracto 14y agoYeah, I find it kind of funny when people compare a general purpose programming language with a statistical software. In R you have libraries for things like Apprximate Bayesian Computation, parametric and non-parametric statistics, and even neural networks. Sure, you could achieve the same with a general purpose PL, but you would have to implement everything from scratch.
- gte910h 14y agoSeveral general purpose languages (Fortran, Python, and Matlab ) have very nice statistical programming packages at the current date.
- mistercow 14y agoJS does have a few (like jStat) but they're fairly young. Still, I don't think the article was suggesting that everybody should drop everything and jump on JS for statistics work. But it does raise the question of whether more focus should be put into the development of statistical libraries for JS.
- plg 14y agoWhat about straight C??? There are many great stats libraries in C (e.g. Apophenia). C is not a hipster language but maybe (like polaroid filters in Instagram) it's time for it to make a "retro" comeback. C kicks ass for speed. Obviously.
- shocks 14y agoEh... I'm getting tired of this "x is faster than y" business. JavaScript might be fast in these examples, but that doesn't mean it's faster at everything. Comparing programming languages is fruitless. X might be faster than Y at Z, but that does not mean X is better suited than Y for all applications. JavaScript is faster than MatLAB etc in these examples, but as mentioned already it's slower at matrix multiplication and I'm sure that's just one example. Does JavaScript have tonnes of libs? Does it have type-checking? Does it have all those other things that I would be desperate for if I was performing important calculations? Can I distribute the computing easily? Etc, etc. Let's stop comparing programming languages as if they're one tool to do one job. Different programming languages have different applications and are suited for different jobs.
- jbooth 14y agoFastest for everything but the statistical parts. Not that someone couldn't write the bindings to C for server-side JS, but they haven't.
- igorgue 14y agoDoes performance really matters? I rather have richer libraries (like R has) than performance, since it's impossible to plot for example, all your Apache logs or any other big data problem, you just need a subset of the data and plot them, and with that you don't need a super fast language.