Here I'm really interested in lowering barriers to mathematical education.


I'd like to see created for the JavaScript community, an equivalent of the Python-based/linked scientific and high-performance computing libraries (great lists of which are available through Sage and otherwise). And I want that, because I'd like to make it easy for people who learn JavaScript to get into scientific and numerical computing without having to learn Python (& company). (I know it's easy to learn Python, as I basically did it at some point, but this suggests that perhaps it'll be easy to compile some restricted subset of JavaScript to Python.)

Hypothesised method:

I'm primarily interested in a new language with minimal difference from JavaScript, because the market ("human compilers") I'm targeting are programmers who already know JavaScript. What I want to target those people for, is to give them a minimally different language in which to write code that compiles to faster C, in the manner that RPython and Cython do for Python. I'm willing to throw out a lot of JavaScript features, I just want to be careful to add a minimum number of features back in. I'll definitely be looking at Lua, Dart, ECMA Harmony (which has no formal date of release, or am I mistaken?), etc. as these are all close resemblances to contemporary (2012) implementations of JavaScript.

Questionable Motivations:

I'm personally willing to learn any language/toolset that gets things done faster (I'm learning Erlang myself, for this), but here, I am specifically interested in lowering the bar (sorry) for other people who may not have such willingness. This is just one of those "want to have my cake, and eat it too, so I am putting some time into researching the problem" situations. I have very limited prior experience in computer language design, but so far from a hacking-the-ecosystem point of view, the problem seems interesting enough to study, so, I hope to be doing more of that soon.

  • 1
    $\begingroup$ 5. Use symbols instead of strings for method names. $\endgroup$ Commented May 6, 2012 at 20:02
  • 4
    $\begingroup$ This question is not reasonably answerable in its present state. I recommend that you read our faq; your question is very broad and open-ended, and reads more like a rant against JavaScript's perceived slowness than a genuine attempt at making something better. There are, however, valid questions lurking in here, and I encourage you to improve your question so that it can be reopened. Don't “get the ball rolling”, answers belong in answers. Avoid putting too many personal assumptions in your question, objective questions will get more objective answers. $\endgroup$ Commented May 6, 2012 at 20:36
  • 2
    $\begingroup$ The main thing that is missing in your question is your goal. You want speed, and you want a likeness to Javascript; what are you prepared to sacrifice? What should your language be able to do? Is source code compatibility with Javascript important? Do you want to be able to link with existing code? What are your language's use cases? A lot of Javascript code is loaded dynamically, which is very close to having eval; should your language have this? Are you primarily aiming at compiling to machine code, to a VM, or interpretation? What kind of static type system do you envision? $\endgroup$ Commented May 6, 2012 at 20:40
  • 2
    $\begingroup$ Thanks for the edit, the question is answerable (broad and subjective, but I think not too much) now that we know what your objective is. Unfortunately nobody seems to have noticed your edit until now; I hope answers can still be useful. Please note that in order for someone to be notified that you replied to their comment, you need to use the @ sign before their name (e.g. @Gilles — and get the spelling right) — click on the help button near the comment entry box for more information. $\endgroup$ Commented Sep 2, 2012 at 14:20
  • 1
    $\begingroup$ "I have very limited prior experience in computer language design". You should fix that first. No personal offense, but we already have a deluge of amateur language designers flooding the markets with subpar creations. Be a part of the solution, not the problem $\endgroup$
    – gardenhead
    Commented May 18, 2017 at 22:48

4 Answers 4


If you want to use JavaScript for scientific computing, why not try Node.js? Node is based on Google's V8 engine with some additional functionality for interacting with the file system, writing servers and linking to C and C++ libraries (this is definitely not an exhaustive list). It sports fast execution times and provides an interactive console as well as a way to execute your programs from the command line. I found @DaveClarke's comment about Python acting as "glue code" interesting because of the wording. Here is an excerpt from the Node documentation on addons:

Addons are dynamically linked shared objects. They can provide glue to C and C++ libraries.

Node also has an excellent package manager called NPM, which would make it easy to share scientific modules which you have written. The NPM repository already contains some scientific modules, such as "natural" (for natural language processing) or "clusterfck" (a clustering library). There are most definitely many other libraries out there for a variety of applications.

The great thing about this solution is that you wouldn't have to modify JavaScript or create a new language. The syntax is essentially the same, but your code does not need a browser to execute. If you plan to follow up with node, a good first step might be to start creating addons for existing open-source scientific libraries written in C and C++, or you could port them to JavaScript. I was actually thinking about using node for scientific programming today which is what led me to this question. It would be great to see more robust tools like you find in Python.

I initially had links to natural and clusterfck, but I do not have enough rep to post them. Luckily, they come up as the first results if you google "clusterfck node" and "natural node".

  • 1
    $\begingroup$ Thanks @JasonLynch426, this makes sense. I agree with the convenience of the NPM. $\endgroup$
    – jerng
    Commented Dec 3, 2012 at 23:16

The point of the Python scientific libraries is that Python merely acts as a glue code for shuffling around the data between the scientific libraries. Python itself does little of the high performance grind work. Python is a good language for this, as it supports both the procedural and object-oriented paradigms (and functional to a large degree), and one can easily link with external libraries.

Javascript is heavily tied to browser technologies. It is mostly an awful language not at all designed to be efficient or to write large scale software, although in practice both of those happen due to huge investments in compiler technology and careful use of the language, respectively. Javascript is made 1000 times nicer by well designed libraries such as JQuery. I'm not sure whether Javascipt provides any support for linking easily with C libraries (though I guess it must, indirectly through the browser, and via Java).

I don't mean to be discouraging, but the whole idea seems ill-founded. Javascript and high-performance computing are only found together in sentences beginning with "A man walked into a bar ...."

That said, I'm willing to be proven wrong. Real-time Java exists, which is an odd combination, and is reasonable successful, so who knows.

  • 2
    $\begingroup$ Javascript in a browser doesn't have an FFI, but the implementation of the not-quite-JS language that jerng was thinking of designing could have one. JS also supports procedural, OO and functional paradigms to a large degree. So I don't share your reluctance towards JS here. (However, I don't think this is the right path either, for a different reason: to design a new language, you should have a very good reason, and I don't see one here. I think Vor is on the right mark when he suggests Java.) $\endgroup$ Commented Sep 2, 2012 at 20:01
  • 2
    $\begingroup$ “Javascript is heavily tied to browser technologies”: Historically it was, but is it still the case? According to the ECMAScript standard, the language looks to me like a decent general-purpose programming language which is not particularly tied to browsers. $\endgroup$ Commented Sep 2, 2012 at 20:33
  • 1
    $\begingroup$ IMO Javascript is a very good language for scripting, but its OO support is a little bit weird (inheritance must be simulated with prototypes, a "class" is a function in Javascript, ...) ... but on the other side prototypes are very powerful in a dynamic programming environment, for example methods can be added on the fly (interactively) both to "classes" and their instances. $\endgroup$
    – Vor
    Commented Sep 2, 2012 at 20:54
  • 4
    $\begingroup$ "It is mostly an awful language not at all designed to be efficient or to write large scale software, although in practice both of those happen due to huge investments in compiler technology and careful use of the language, respectively" — I could say the same for Python. I personally find it awful to use. As for efficiency - that comes by getting C/C++ to do the heavy lifting, which is also how JS achieves high performance. Both are horrible to multithread. I've had >100x speedup by rewriting simple Python functions in C. $\endgroup$ Commented Aug 25, 2015 at 10:56
  • 1
    $\begingroup$ @Ski Five-year-old answer is five years old. Shocking! $\endgroup$ Commented Dec 2, 2017 at 13:31

Just an idea: you can use scientific libraries written in Java (I think you'll find a lot of work already available) with Javascript - that has a syntax similar to Java - used only as a wrapping language for:

  • scripting
  • user interaction
  • (re)modeling and standardization of the underlying high level classes/packages/functions ... though I think it would be better to do this in the Java "layer"

See the Rhino project for a stable Javascript interpreter written in Java.

If you want you can use the Java JNI to use scientific libraries written in C/C++.

The whole picture:

                              ____ disparate Java libraries
Javascript   ----- Java      /
(scripting,      ("package   \____ JNI ____ C/C++ libraries
 interaction,     remodeling")   
high-level stuff)

EDIT: just Googling around a found stuff like this: Java GNU Scientific library, List of (Java) numerical libraries, Java Graph library, jHepWork Multiplatform environment for scientific computation and data analysis


Creating a new language is not necessary. One can write performant numeric computing in JavaScript today, without compilation/transpilation. As a scripting language, JavaScript compares quite favorably to Python and R. For benchmarks, run the language benchmarks in stdlib, which compares performance across a wide-range of APIs.

For server-side applications, one can write Node.js native add-ons to interface with the same C/C++/Fortran libraries used in other numeric computing environments, such as R, Python, and Julia. As shown in my work, Node.js native add-ons allow linking to hardware optimized numeric computation libraries, thus enabling high-performance numeric computation from JavaScript.

For client-side applications, one can compile to WebAssembly to achieve 1.5-2x of native performance. For older environments, one can compile to asm.js, which is a reduced subset of JavaScript more amenable to compiler optimization. In my work, asm.js can match naive reference (i.e., non-hardware optimized) implementations written in C/C++/Fortran.

In short, there are no technical reasons why you cannot write numeric and scientific computing libraries in JavaScript, itself. What is needed are people with the time and wherewithal to write rigorous and robust implementations.

disclosure: I and others are working on the stdlib project, which aims to bring robust, high-performance numeric computing capabilities to JavaScript and Node.js.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.