Skip to content

Commit e8e2d0f

Browse files
authored
Add FAQ section on inline JS usage and Emscripten comparison (#15)
The title speaks for itself. Co-authored-by: io-eric <io-eric@users.noreply.github.com>
1 parent 3bdfd27 commit e8e2d0f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ Creating and styling HTML elements from C++.
234234
- **Tips:** Prefer returning integer handles for created resources (use `RET:int32`), register DOM/audio/image objects in the `elements` map when appropriate, and ensure your JS implementation is robust (checks for missing handles, etc.).
235235
****
236236

237+
## FAQ
238+
239+
### Why no inline JS (`EM_JS` / `EM_ASM`)?
240+
241+
Emscripten allows it because it has to support anything (game engines, Python, whole runtimes), so it can't map out every API ahead of time and just hands you raw JS access as the catch-all.
242+
243+
WebCC does the opposite. The bridge is the schema: you declare what you need in [`schema.def`](schema.def) and get a typed C++ function plus the JS that runs it. We could add an inline-JS escape hatch too, but I'd rather just grow the schema until it covers the browser APIs, so you never need one.
244+
245+
### Should I switch from Emscripten to WebCC?
246+
247+
Depends on the project, honestly.
248+
249+
- **Starting from scratch?** Go for it.
250+
- **Big existing Emscripten codebase?** Probably not yet. WebCC's STL compat layer is still limited and not every browser API is covered in the schema, so you'd hit gaps and end up filling them in yourself.
251+
252+
It's growing over time, so the gap keeps shrinking. But for now: the smaller and fresher the project, the better the fit.
253+
237254
## Modules
238255

239256
- **`webcc/dom.h`**: DOM manipulation (create, append, remove, attributes).

0 commit comments

Comments
 (0)