just-js / lo

it's JavaScript Jim, but not as we know it. :space_invader:
MIT License
213 stars 9 forks source link

Lets talk about zig #40

Open lemanschik opened 1 month ago

lemanschik commented 1 month ago

@billywhizz https://github.com/lemanschik/zig-v8/blob/master/build.zig

i just found the above i am not sure if you did look into zig already but out of my current state of knowledge that would be the next step as it improves the build.

there is a strong movement into that direction (Build C with ZIG) i think we can sure go with the existing c++ templates sure but maybe zig would make it more easy to enter.

xyloflake commented 1 month ago

@lemanschik I don't even wanna argue with this as it has some clear benefits.

However I would like to state these:

That's it; if Andrew suggests that it might be a good idea, I think implementing the build pipeline for lo wouldn't be that hard.

lemanschik commented 1 month ago

@xyloflake i mean the most people do not understand the c++ template strings but i see they understand how to compose the stuff with zig.

I 100% agree that lo and just and smol are good as they are but the most people do not understand it and that makes me crazy. Most will default to lua while its time to get v8 more established.

xyloflake commented 1 month ago

@xyloflake i mean the most people do not understand the c++ template strings but i see they understand how to compose the stuff with zig.

I mean most people would just write js and not try contributing lol. And most of lo's code is in js itself; c++ being more than 70% auto generated as well. Trying to configure the build system would be renderered useless in most cases.

I also don't think template strings are that hard to understand; especially when you are trying to build a runtime(?).

I 100% agree that lo and just and smol are good as they are but the most people do not understand it and that makes me crazy. Most will default to lua while its time to get v8 more established.

Personal opinion here: anyone who wants to understand can understand easily, I don't find stuff specifically so damn complicated that it needs a rewrite in another language. Also idk about lua since I'd personally consider not using it especially for complicated stuff like V8 and stuff - I sincerely hope you know what I mean :)

lemanschik commented 1 month ago

@xyloflake i know what you mean but i also see the need that more people need to understand how to make small runtimes out of v8 it self. For me everything is clear i am even on working on using v8 as ring 0 and replace the whole Linux kernel with it but that's not a simple task as i need to embedded all the kernel stuff.

billywhizz commented 1 month ago

hey @lemanschik @xyloflake.

i have been spending some time with zig recently. i have to say i like it. but i'm not sure what exactly it would bring to the table for lo. one of goals here is to keep dependencies down to an absolute minimum and to be able to rely on libs that have C api's and reasonable build systems etc.

one big issue i think would be the fact that v8 is a very big and complex C++ api and would require doing a lot of work to create a zig wrapper for. maybe some/all of that could be automated. i'd have to do some research.

i'll take a look at the work you have done here. defo open to idea of integrating zig if there is a compelling reason to do so. you can almost build lo from scratch using CC="zig cc" CXX="zig c++". everything compiles but the linking fails against the v8 library. that should be possible/easy to fix if me or someone else gets chance to look at it.

lemanschik commented 1 month ago

@billywhizz take your time out of my view it brings to lo a easy way to add new bindings. I hear a lot about bad Opensource code that got successful build by C++ C build noops not all understand the linker flags and so on. but it looks like they understand zig so i think it could bridge some gaps where some one wants to integrate some small c c++ code base into v8 like doing AI stuff and so on.

so i expect that the Wishlist of supported modules growth more fast via being more inviting for zig coders.

billywhizz commented 1 month ago

@billywhizz take your time out of my view it brings to lo a easy way to add new bindings. I hear a lot about bad Opensource code that got successful build by C++ C build noops not all understand the linker flags and so on. but it looks like they understand zig so i think it could bridge some gaps where some one wants to integrate some small c c++ code base into v8 like doing AI stuff and so on.

so i expect that the Wishlist of supported modules growth more fast via being more inviting for zig coders.

yeah. i am just having a look at that repo. the bindings are nice. i have been really liking how easy it is to interface zig with C libraries.

it might be possible to use zig here to more easily create bindings just from header files. will take a look. feel free to make any suggestions for approaches here or submit a PR if you have time. i am probably not going to have much time to hack on this myself over next few weeks/months though.

lemanschik commented 1 week ago

collection of blessed libs https://github.com/allyourcodebase