On Tue, Jul 09, 2024 at 08:03:15PM +0000, kiboshimo via Digitalmars-d-learn wrote: > On Tuesday, 9 July 2024 at 14:42:01 UTC, monkyyy wrote: > > On Tuesday, 9 July 2024 at 07:54:12 UTC, kiboshimo wrote: [...] > > > Really liked the idea of doing it with betterC to start my systems > > > programming journey > > > > Theres nothing even slightly pleasant or easy about d's wasm > > "support"; I wrote my own cos, sqrt functions, you get *nothing* > > from phoboes > > Writing my own math functions is outside of my range, I still have > hopes of this not being so hard. So you get another opportunity to > crush it. [...]
What are you planning to run your wasm on? If in the browser, you could just use the browser's JS math functions. The performance won't be stellar (the wasm-JS boundary is SLOW), but it'd work and you wouldn't have to write your own math functions. This is what I use in my own D/wasm project. (It'd probably still beat any hand-written WASM reimplementation of math functions that you write. Remember, wasm is interpreted, so it won't beat the browser's built-in native math functions, which in all likelihood use the CPU's hardware math instructions.) If you're planning to run your wasm in a native environment, you could probably just use the C API to interface with the host system's C library functions. Don't reinvent the square wheel unless you're planning to ride it on an inverted catenary road. :-P // On a larger note, if you're planning to write something small that runs in a browser, you might be interested to check out: https://github.com/Ace17/dscripten This is the D equivalent of emscripten. While it's nowhere near the maturity of emscripten itself, it may be Good Enough(tm) for your use. Rather than wrangling with the WASM/JS API (it's still early stage, there are a LOT of bumps currently still in the road), just let LLVM convert your D code straight into JS and run it as JS in the browser. Then you can leverage all the existing JS APIs your browser already supports, instead of having to reinvent yet another square wheel. T -- Some days you win; most days you lose.