logoalt Hacker News

simonwtoday at 4:27 AM1 replyview on HN

The QuickJS thing doesn't seem like a big deal to me, provided the documentation makes it clear that code will run slower if you use Any.

If I was using this project for something I'd expect to write custom TypeScript for it.

The floats rather than integers thing does look bad though. I tried compiling their fibonacci example to C (--backend c) and got this:

  static double sc_f_fib(double sc_l_n_0) { /* /private/tmp/fib.ts:1 */
    double sc_t0 = sc_l_n_0;
    double sc_t1 = 2.0;
    bool sc_t2 = sc_t0 < sc_t1;
    double sc_t3;
    if (sc_t2) {
      double sc_t4 = sc_l_n_0;
      sc_t3 = sc_t4;
    } else {
      double sc_t5 = sc_l_n_0;
      double sc_t6 = 1.0;
      double sc_t7 = sc_t5 - sc_t6;
      double sc_t8 = sc_f_fib(sc_t7);
      double sc_t9 = sc_l_n_0;
      double sc_t10 = 2.0;
      double sc_t11 = sc_t9 - sc_t10;
      double sc_t12 = sc_f_fib(sc_t11);
      double sc_t13 = sc_t8 + sc_t12;
      sc_t3 = sc_t13;
    }
    return sc_t3; /* /private/tmp/fib.ts:2 */
  }

Replies

slopinthebagtoday at 4:33 AM

If you’re writing Typescript with zero dependencies and trying to target native I feel like it makes more sense to write it in a different language like Rust or Go. The main reason for this I think is getting cheap perf wins by running existing code natively.

show 1 reply