It actually turns out you really can't use underscore, etc. in Sphere 1.5/1.6, the shallow memory threshold cuts off anything interesting. Which means yes, they may work, and especially for Lazy.js, you can't do big data in Sphere.
So... a lightweight query library like mine is actually a very good way to go in Sphere.
Lazy.js does not work in 1.5/1.6, it errors when writing to variables that are named keywords (due to earlier versions of ECMA). It does however work in SSFML.
Here's the interesting thing:
var t2 = GetTime();
for (var i = 0; i < 25000; ++i) {
var d = "";
var a = Query.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]).map(timesten).where(even).foreach(function(i) { d += i + ", " });
}
t2 = GetTime() - t2;
var t3 = GetTime();
for (var i = 0; i < 25000; ++i) {
var c = "";
var a = Lazy([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]).map(timesten).filter(even).forEach(function(i) { c += i + ", " });
}
t3 = GetTime() - t3;
Abort("Query: " + t2 + "\nLazy: " + t3);
The output:
Query: 1190ms
Lazy: 1656ms
Lazy.js is
slower. But why!? Because it's not doing what it was designed for: big data (see below for more). Anyways this does go to show my code isn't that inferior, in fact throwing around the term inferior without seeing results is kind of a wrong thing to do. It works in older versions of Sphere
and is faster in SSFML. That makes my initial premise true: it is indeed efficient. But! I still think there is a way to make it go faster, and work. I'm working on an experimental version of Query.js that works like a compiler (creates a tree/sequence of the functional logic, and then performs it in one pass). I'm seeing some promising results on big data in SSFML, but it needs more work to truly be efficient. It may not be better than Lazy (that guy's a genius) but it should still be much faster.
Now, the good stuff! On this:
var d = "";
var a = Query.from(genArray(200000)).map(timesten).where(even).foreach(function(i) { d += i + ", " });
var c = "";
var b = Lazy(genArray(200000)).map(timesten).filter(even).forEach(function(i) { c += i + ", " });
a took 500+ ms
b took 300+ ms
So on big data, Lazy wins, but in a real time action game you want to do a lot of short data fast. So... Query turns out to work faster for that. Lazy is a data thing, Query is a game thing. Now, yes, there will come a time where you want to use Query for data - item lists, npc lists, etc. - So therefore, I'm working on an implementation that will work for larger data in Sphere.
Query2 is coming along nicely. Doing the above over 200000 elements, the times are:
Query: 531ms
Lazy: 363ms
Query 2: 447ms
So, I'm in a middle-ground so far.