Hacker News

Jet

by @pillmillipedes

an array language. now I'm working on the tokens->three address code->bytecode translation. I'm hoping to get that done this week, then start implementing the more important builtins&library functions. you'd be surprised how many functions you can bootstrap just by implementing grade/argsort. for example: // C++ (naive version, sorry) vector<int> bin(vector<int>& x, vector<int>& y) { vector<int> r; for (int a:x) r.push_back(lower_bound(y.begin(),y.end(),a) - y.begin()) return r; } # Jet ord<<{x asc asc} # double grade idiom bin<<{y,x ord drop len[y]-ord[x]-1} or course this is not at all apples to apples, though it works to show the difference in possible approaches. in C++ I'm just turning an already implemented binsearch into something useable for arrays, and in jet I'm doing some weird array tricks to implement it from scratch using grade up (asc). moreover, the C++ solution is O(m*log(n)) and jet is O(m+n) (though with a large constant factor) - but of course we can do much better once I implement it as a real builtin

Discover more builders

Builderlust is an endless, joyful scroll of real projects people are shipping right now. Get the app to keep finding your next spark of inspiration.

📱 Coming soon to iOS & AndroidOpen in the app