‹ BackHN Continuity

Thread

Native apps written in TypeScript and CSS

131 points · 54 comments · arbayi

  1. slopinthebag · · focus · HN ↗
    the amount of ai used in this makes me think its pure vaporware. has anyone actually confirmed any of this is real or works?
    1. dashersw · · focus · HN ↗
      Watch the demo videos here: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=uCfFTZSG-PQ&amp;list=PL9pDl_Oth4crgIcBiX-mdMS9vtzIt-eDT" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=uCfFTZSG-PQ&amp;list=PL9pDl_Oth4...

      The code is on GitHub, for example for the first video that renders a 3D cube with CSS the code is at <a href="https:&#x2F;&#x2F;github.com&#x2F;geastack&#x2F;examples&#x2F;tree&#x2F;main&#x2F;apps&#x2F;css-3d-cube" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;geastack&#x2F;examples&#x2F;tree&#x2F;main&#x2F;apps&#x2F;css-3d-c.... It takes only a couple of CLI commands to get it running. For reference, I&#x27;m using a WaveShare ESP32-S3 AMOLED Touch 2.06&quot; device here, but the same code renders on every target Gea compiles for.

      1. slopinthebag · · focus · HN ↗
        with a lot of ai projects it&#x27;s often that the only thing that does work is the demo. and im not saying this to be rude, its an ambitious project and im afk so i cant test it myself.

        how does it compile js to c++? js is so dynamic it makes me think it either compiles to some kind of bytecode or its a heavily restricted subset of the language.

        1. dashersw · · focus · HN ↗
          It took us 6 months to build the compiler. We analyze literally the hell out of the call graph. We started with strictly typed TS, which is trivial to compile. Then we added a dynamic fallback for projects that have &quot;unknown&quot;s and &quot;any&quot;s, then we had several architectural changes which allowed us to inspect those &quot;claim&quot;s. If you think about it, marking a variable &quot;any&quot; is a lazy claim. If it&#x27;s ever used in one place and in one shape (akin to duck typing), you can create a static struct out of it...

          So there&#x27;s no byte code, and while not every single dynamic language feature has a corresponding static compilation, the base is pretty broad. So much so that Hono, the web framework, with all its dependencies, compile just fine.

          1. wannabe44 · · focus · HN ↗
            What do you do for memory management? Conservative GC or Ref counting? If ref counting, how do you detect cycles?

            It does appear most JS features can be translated to C++, even if at some overhead. Did you encounter any which wasn&#x27;t straightforward?

            1. dashersw · · focus · HN ↗
              It&#x27;s ref counting, so most objects are freed as soon as the last reference goes away. Cycles are handled by a backup cycle collector using trial deletion (Bacon–Rajan style). Any object whose refcount drops without hitting zero becomes a candidate, and the collector traces from those candidates. In practice cycles are rare, and refcounting does almost all the work.

              There were a lot of hurdles along the way and we solve them as we come across them. Keeping values native when JS uses them dynamically was a challenge. d = new Date(); d.foo = 1 is easy if you box everything, but then it&#x27;s a slow interpreter (like some other projects in the field). So we had to invent a new mechanism; native types get a side table for extra properties.

              Generics and union types were also challenging: one JS generic can need several different C++ layouts.

              eval is limited: new Function runs on a small evaluator written in C++, and direct eval isn&#x27;t supported yet.

              1. wannabe44 · · focus · HN ↗
                Thanks claude :-)
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.