4 ms·
Great demo, well written code. Though reading through it also highlights that JS is not a great language for linear algebra. But I don't think anyone is really
by thearn4 13y ago
Great demo, well written code. Though reading through it also highlights that JS is not a great language for linear algebra. But I don't think anyone is really suggesting otherwise.
- segmondy 13y ago"JS is not a great language for linear algebra." what does that even mean? It's a general purpose language. It all boils down to how you want to use it, like any other general purpose language. A lot of times in cases like this, people choose not to make it look pretty and easy to read to gain performance. This simulation is very CPU intensive, trying to have pretty code and speed is going to be tough.
- relaunched 13y agoLook into something like Octave, where matrices are first-order data types, and you'll know exactly what he means.
- Kiro 13y agoHad a look. Still think JS is fine.
- relaunched 13y agoJS is fine; in the same way that is fine to use a sandbox shovel to dig the foundation of a house. Languages are designed for a purpose, though they can be used for all sorts of things. There is a larger upfront cost to learning the right language for the right job. However, many people opt to try to fit a square peg into a round hole.
- Crito 13y agoOr look at Python/Numpy. General purpose language with a sufficiently advanced library that doing linear alg stuff becomes a very pleasant experience. Way, way, way nicer than spelling it all out like this JS code has to. Then again, I might be biased there since I've spent a decent chunk of time porting MATLAB/Octave code to Python/Numpy so that we could get it into production in a robust way..
- relaunched 13y agoI actually like python/numpy, mostly b/c I'm very comfortable in the python stack. Numpy has come a long way, such that it has sufficiently shaved the squared off corners of the square peg, so it pretty much fits into the round hole.
- Crito 13y agoTo me, Numpy/SciPy are Pythons "killer apps". I would say the plurality of times I have decided to use Python in the past two or three years, it was because of them.
- dingdingdang 13y agoNot only tough but ultimately impossible; like C it is nice that people can stretch JS to maximize performance - a developer can always maintain separate file with "nicely" formulated calculations but at the end of the day what matters is the end user's experience of speed in the final app.
- waterlion 13y ago"what does that even mean?" "It's a general purpose language" You answered you own question.
- neumann 13y agoCan I ask why JS is no good? (Genuine question) I thought the only consideration would be speed? The algebra is mainly looping. Isn't that way most languages try to handball algebra to LAPACK/BLAS?