freebasic web (toughts)

Emscripten, WASM, and asm.js related questions
Post Reply
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

freebasic web (toughts)

Post by Mysoft »

ok... i remember some conversation around a web version for freebasic... i had like 10 years ago made some concept using emscripten before wasm even existed... but that was not really great on browser , but now things changed a bit (many for worse)... and so now emscripten is a fat garbage incompatible monster

so what i will try this time, is to make a WASM backend for freebasic, so just clang with wasm target as requirement... no more emscripten, no no msys, or WSL or python, and making it usable for XP and 32bit... despite emscripten having some good things they have infinite bloat and no compatibility with sane things at all

but then there's the thing, when we compile for windows, we can use windows libraries... but when compiling for web... what will be the underlying OS? because emscripten was the actual "framework", as it implements SDL and OpenGL(compat over webgl), and probabily most things that exists out there depends on those to work... so i may have to sacrifice that at first or maybe port their versions to the raw toolchain, but my goal will be to keep it simple...

i will use the WASI sdk as base which includes clang and i assume a C runtime... https://github.com/WebAssembly/wasi-sdk

however i dont know yet how it works regarding file access for example, if it have options for a virtual file system, so that you can have a single .html to grab the data from (like NitroFS from nintendoDS) and so everything will be packed as resources inside a single .html or if it will use separate files that work trough their source protocol be it http:// or file:// (i mention this because browsers may be annoying with file:// and scripts), and i dont want to force to require webserver to run programs... but either way i want to provide a test webserver with freebasic...

And i want to have an environment compatible with what we have in windows/linux/dos ... so if fbgfx is used then the default html template will have a resizable canvas, and if -s gui is not included it will also include a console with similar capabilities (mouse/colors/keyboard/scroll/multiple pages) as we have natively

previously with emscripten i had set that "inlined assembly" would be in fact Javascript... but i think WASI have that as actual WASM, but i will see a nice and simple way to have both a wasm and javascript mixing for extended "webplatform specific" behavior , and with that i probabily introduce some "automation web" framework to act as standard, to have the same api for when running inside the web, or when using CEF,EDGE,MSIE,whatever "webviews"

and more important than ever, i will have avaliable port for extra libraries that i tend to use as a "framework"... like fbmod (fmod compatible), wshelper (sockets/websock), but it's time to also finish the one unified for GUI, which STILL does not have any good implementation to borrow the API from.

so, what you guys think?
caseih
Posts: 2158
Joined: Feb 26, 2007 5:32

Re: freebasic web (toughts)

Post by caseih »

As I understand it emscripten is simply a compiler and framework. It used to target whatever Javascript was available, but now that WASM is a thing, emscripten targets WASM. So it's definitely not an incompatible monster. All the WASM examples I've seen, including using SDL for graphics, are all built with emscripten.
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: freebasic web (toughts)

Post by Mysoft »

caseih wrote: Aug 31, 2023 16:16 As I understand it emscripten is simply a compiler and framework. It used to target whatever Javascript was available, but now that WASM is a thing, emscripten targets WASM. So it's definitely not an incompatible monster. All the WASM examples I've seen, including using SDL for graphics, are all built with emscripten.
yes but try to install it on windows 7... or on windows 10, 32bit... and try to use it without installing argh.... python and so on...
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: freebasic web (toughts)

Post by marcov »

Mysoft wrote: Aug 31, 2023 15:40 i will use the WASI sdk as base which includes clang and i assume a C runtime... https://github.com/WebAssembly/wasi-sdk

so, what you guys think?
Why do you choose all that bloat? Why not directly let FB generate WebAssembler bytecode?
Mysoft
Posts: 836
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: freebasic web (toughts)

Post by Mysoft »

marcov wrote: Aug 31, 2023 18:22
Mysoft wrote: Aug 31, 2023 15:40 i will use the WASI sdk as base which includes clang and i assume a C runtime... https://github.com/WebAssembly/wasi-sdk

so, what you guys think?
Why do you choose all that bloat? Why not directly let FB generate WebAssembler bytecode?
ok... aside the inconvenience that that would not have gcc/clang optimization that would be fine, but i dont plan to use the "whole sdk" i will just extract the binaries/library files from that, but either way FB does not generate webasm bytecode it calls llvm-as which i need to get from somewhere right? and that's from wasi-sdk.. just like there's freebasic that includes the needed stuff for compile using gcc (without needing mingw installed)

also i dont know the current state of the wasm generator in freebasic... so the "-target asm.js" is working at latest release? and the rtlib/gfxlib from that target are targeted to emscripten as far i know, so i guess either way i will have to implement the emscripten API myself for compatibility with existing stuff.
Post Reply