Java
- languages
- in current work
used in
Java is what Hanzi Path is written in: a native Android app, with no cross-platform layer in between. After years of React Native for LoS, going native meant the Android SDK and Gradle instead of JavaScript and a bridge.
The trade is more code for more control. A fully offline app with no internet permission, a writing canvas for practising characters stroke by stroke, and spaced-repetition scheduling all live in one codebase that talks to the platform directly.
// ── the scheduler ──
// The formulas are FSRS-4.5's; the weights they take are W, or the ones fitted to the learner (Fit).
static double recall(Card c, long now) { return recall(c.s, Math.max(0, now - c.last) / (double) DAY); }
/** The chance of recall after so many days at a stability. */
static double recall(double s, double days) { return Math.pow(1 + F * days / Math.max(s, 0.01), C); }
static double d0(double[] w, int g) { return Math.min(10, Math.max(1, w[4] - (g - 3) * w[5])); }
static double nextD(double[] w, double d, int g) {
d = d - w[6] * (g - 3);
d = w[7] * d0(w, 3) + (1 - w[7]) * d;
return Math.min(10, Math.max(1, d));
}
static double recallS(double[] w, double s, double d, double r, int g) {
return s * (1 + Math.exp(w[8]) * (11 - d) * Math.pow(s, -w[9]) * (Math.exp(w[10] * (1 - r)) - 1) * (g == 2 ? w[15] : 1));
}
static double lapseS(double[] w, double s, double d, double r) {
return Math.min(s, w[11] * Math.pow(d, -w[12]) * (Math.pow(s + 1, w[13]) - 1) * Math.exp(w[14] * (1 - r)));
}