Live data from Hacker News

Show HN: Compiling C in the browser using WebAssembly

wasmer.io

51–60 of 74 posts

Re: Show HN: Compiling C in the browser using WebAssembly

#52

Now all this needs is a simple OS running in a browser, that can edit and compile itself, post the resulting binary onto a WebDAV somewhere, and reload itself from there. Then it becomes a fully self-sustaining OS that can live forever in a browser.

And then use webrtc (or ideally someone can revive a webtransport-p2p please !) to serve itself from a page to other people. Ideally http3 over webtransport-p2p! Then add some network discovery so we can advertise & find what's available on our networks!

Do you have a proper link to the webtransport-p2p idea? I've done a few searches but I think there's some mix of current implementation and deprecated implementation somehow.

What is it that needs reviving?

Re: Show HN: Compiling C in the browser using WebAssembly

#54
post #53

GCC? That's easy! :-) What about a complete system? https://webvm.io Shameless plug: we are hosting a WebVM Hackathon next week (11-14 October) over Discord. For more information: https://cheerpx.io/hackathon

Can I compete with exaequOS?

No, the competition is explicitly based around CheerpX: an X86 virtualization technology built on top of WebAssembly

Re: Show HN: Compiling C in the browser using WebAssembly

#55

GCC? That's easy! :-) What about a complete system? https://webvm.io Shameless plug: we are hosting a WebVM Hackathon next week (11-14 October) over Discord. For more information: https://cheerpx.io/hackathon

What about something that doesn't even require WebAssembly and is faster? https://bellard.org/jslinux/

Re: Show HN: Compiling C in the browser using WebAssembly

#56
Not really, on Firefox

    panicked at /Users/syrusakbary/Development/wasmer/lib/api/src/js/instance.rs:62:84:
    called `Result::unwrap()` on an `Err` value: JsValue(Function(bound 846))

    Stack:

    fe/_.wbg.__wbg_new_abda76e883ba8a5f@https://wasmer.sh/assets/index-CgFg6VHw.js:17:6582
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[1125]:0x2b4276
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[2888]:0x3ab373
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[8254]:0x435ed3
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[4825]:0x3fa7de
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[517]:0x1af753
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[294]:0xbed03
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[2039]:0x34b10e
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[2896]:0x3abaa1
    @https://wasmer.sh/assets/wasmer_js_bg-BruS15W0.wasm:wasm-function[9393]:0x43fde1
    S@https://wasmer.sh/assets/index-CgFg6VHw.js:11:424
    c@https://wasmer.sh/assets/index-CgFg6VHw.js:11:264

Re: Show HN: Compiling C in the browser using WebAssembly

#58
post #49

Earlier quoted context omitted.

Presumably C's `switch` is also a problem.

Yes, I don't recall all the confusing elements and technicalities of what's allowed in Switch statements in C offhand but here are a few brainfscks: https://old.reddit.com/r/C_Programming/comments/16kg48y/mind... https://old.reddit.com/r/programminghorror/comments/ylc7f3/w...

I went down a rabbithole and wow.

Found a comment from the author of https://github.com/stclib/STC apparently and then came across this example:

https://stackoverflow.com/a/76887723

  int coro_a(struct a* g)
  {
   cco_routine (g) {
    printf("entering a\n");
    for (g->i = 0; g->i i++) {
     printf("A step %d\n", g->i);
     cco_yield();
    }
    cco_final:
    printf("returning from a\n");
   }
   return 0; // done
  }
gcc -E -ISTC/include co.c

After running it through a preprocessor, it gives me this.

  int coro_a(struct a* g)
   {
    for (int* _state = &(g)->cco_state; *_state != CCO_STATE_DONE; *_state = CCO_STATE_DONE) _resume: switch (*_state) case 0: {
     printf("entering a\n");
     for (g->i = 0; g->i i++) {
      printf("A step %d\n", g->i);
      do { *_state = 14; return CCO_YIELD; goto _resume; case 14:; } while (0);
     }
     *_state = CCO_STATE_FINAL; case CCO_STATE_FINAL:
     printf("returning from a\n");
    }
    return 0;
   }

Re: Show HN: Compiling C in the browser using WebAssembly

#60

GCC? That's easy! :-) What about a complete system? https://webvm.io Shameless plug: we are hosting a WebVM Hackathon next week (11-14 October) over Discord. For more information: https://cheerpx.io/hackathon

What about something that doesn't even require WebAssembly and is faster? https://bellard.org/jslinux/

very unscientific benchmark of `clang hello.c`, after a few runs to make sure the code is downloaded/cached:

jslinux: 4.7s

wasmer: 1.3s

webvm: 1.2s

Post reply on HN