JSC.js icon indicating copy to clipboard operation
JSC.js copied to clipboard

can console trigger print?

Open jswhisperer opened this issue 6 months ago • 22 comments

related https://github.com/mbbill/JSC.js/issues/10

`JSC >>> globalThis.console.log("hi")

undefined`

anyway to print stdout, would be nice to see globalThis and much more.

jswhisperer avatar Jun 08 '25 21:06 jswhisperer

@jswhisperer are you able to compile the current version of the code properly? i am able to run but gets error while running, every eval just returns :-1

gb-jos avatar Oct 09 '25 15:10 gb-jos

@jswhisperer are you able to compile the current version of the code properly? i am able to run but gets error while running, every eval just returns :-1

I was yes, on mac arm processor, I've just upgraded to a new one though, I likely had a lot of config with various tools, macports, homebrew, rosetta etc

jswhisperer avatar Oct 09 '25 18:10 jswhisperer

interesting, I have m2 arm Mac as well, strangely does not work for me

gb-jos avatar Oct 09 '25 18:10 gb-jos

If you're keen for a similar experience would look into QTframework ports like https://docs.nodegui.org/ I did some contributions on the docs, it's a bit more updated then this but same idea.

Also Tauri

https://dev.to/jswhisperer/scratch-the-surface-of-nodegui-2lfo https://dev.to/jswhisperer/nodegui-react-component-by-component-b98 https://dev.to/jswhisperer/scratch-the-surface-of-nodegui-2lfo https://dev.to/jswhisperer/webview-apps-on-your-os-2h6k

jswhisperer avatar Oct 09 '25 18:10 jswhisperer

interesting, I have m2 arm Mac as well, strangely does not work for me

Yeah I remember I was kinda obsessed with compiling and cross platform compiling back in the day, I had a very custom setup. I just got a new MBA and my old one is not readily available so I couldn't tell you.

But if I'm honest this library was last updated 5 years ago? Might be more modern similar solutions.

jswhisperer avatar Oct 09 '25 18:10 jswhisperer

@gb-jos sorry reread JSC project these might be more interesting links https://github.com/wasmerio/wasmer-js https://github.com/nodejs/help/issues/3774#issuecomment-2952998863

jswhisperer avatar Oct 09 '25 18:10 jswhisperer

@jswhisperer well i am not directly interested in consuming this project, but i am more interested in my own embedding of jsc that i want to compile to wasm, just wanted to play around this project first as this is an embedding of jsc compiled to wasm.

but never mind, i will try from scratch on jsc upstream, as like you said this is way too old version of jsc so what i may need to do with upstream might even be different.

gb-jos avatar Oct 09 '25 18:10 gb-jos

porting JSC to wasm is really a pain. most of the work is to make the interpreter work but the newer versions has many dependencies to native platform and doesn’t really worth the effort. the cmake is also tricky to work with so I converted to gn but I am not planning to do another conversion. It’s a fun project but the upstream code is not very friendly in this direction

mbbill avatar Oct 09 '25 18:10 mbbill

I also tried this with v8 btw, but that interpreter relies on handlers generated by its turbofan JIT so that’s a no go. JSC wasn’t like that but still have stuff making it difficult

mbbill avatar Oct 09 '25 18:10 mbbill

if you are interested in Wasm, the 3.0 was just released an it has GC support. so we don’th have to build a whole runtime into wasm in the future.

mbbill avatar Oct 09 '25 18:10 mbbill

I'm interested in everything haha I guess my line of thinking was the ports of native webviews "webkit2gtk" which Tauri uses etc I believe use JSC under the hood but they may be too heavy for your use case

jswhisperer avatar Oct 09 '25 18:10 jswhisperer

well, i was looking at v8, jsc and spidermonkey. V8 went out of the door very early. spidermonkey is straightforward since it supports building to wasi natively. Was just leaning towards jsc as it felt smaller from this project, spidermonkey wasi build is ~11MB. My guess was that with JSCOnly target it would be probably straightforward to compile it down to wasm with emscripten.

gb-jos avatar Oct 09 '25 18:10 gb-jos

regarding a better crossplatform ui engine or simply embedding a nicer javascript engine, you may consider this project https://lynxjs.org/ which I am currently working on

mbbill avatar Oct 09 '25 19:10 mbbill

If you are writting an embedded system makes sense with your approach, for my use case mostly on an OS using the native webview libs have been pretty good and slim in size.

jswhisperer avatar Oct 09 '25 19:10 jswhisperer

I do enjoy writing for Raspberry Pi and Arduino etc etc but its much more niche

jswhisperer avatar Oct 09 '25 19:10 jswhisperer

Not sure of interest https://github.com/wasmerio/winterjs

jswhisperer avatar Oct 09 '25 19:10 jswhisperer

well, anyways guys thanks for the feedback, i appreciate a lot, i guess i will probably just go with spidermonkey. A lot is happening in spidermoney in wasi work, recently they started adding jit support in wasi as well (well igala is doing it, but its upstreamed) https://2024.wasm.io/sessions/running-js-via-wasm-faster-with-jit/

gb-jos avatar Oct 09 '25 19:10 gb-jos

Actually I think this might be your cup o tea but not sure the end goal

https://quickjs-ng.github.io/quickjs/ or https://github.com/cesanta/elk

cheers

jswhisperer avatar Oct 09 '25 19:10 jswhisperer

quickjs is nice and fast, but sadly the spec support is lacking for what i want to do with it. I am gonna go with spidermonkey, it is slow but its what it is, given it works out of the box for wasm. btw they also have a demo like this project has of their wasi target. Its basically the standalone shell compiled to wasi, https://mozilla-spidermonkey.github.io/sm-wasi-demo/

gb-jos avatar Oct 09 '25 19:10 gb-jos

I'll stop now, sorry unemployed and I love an interesting challenge 😂

https://gist.github.com/guest271314/bd292fc33e1b30dede0643a283fadc6a https://github.com/saghul/txiki.js

jswhisperer avatar Oct 09 '25 19:10 jswhisperer

@jswhisperer i believe that's called self employed 😉

gb-jos avatar Oct 09 '25 20:10 gb-jos

@jswhisperer i believe that's called self employed 😉

When it starts paying haha, I'm so hungry

jswhisperer avatar Oct 09 '25 21:10 jswhisperer