buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.16k stars 32 forks source link

Comptime replacement of os-related functions #119

Open gaycodegal opened 1 year ago

gaycodegal commented 1 year ago

Lua defines many of it's features via Macro, allowing a user to provide their own implementation of things like file reading, printing, library linking etc.

This is very useful because it allows users like me to write a small amount of code to get the scripting language work in unsupported platforms or turn off features not needed in an environment.

For example in WASM, iOS, and Android, there's very different solutions needed for these problems and sometimes I'd want to optimize for things like size in a WASM deploy at the expense of working file I/O.

I don't know if this is even reasonable to do in Zig, but it is a feature I would love to make use of. Macros in Lua make solutions to these problems work seamlessly on version upgrade because I'm not actually modifying the Lua source files.

Would love if there was an easy Zig compatible small scripting language I could add to projects that run on both web and native easily, and I'm excited about the prospects of this project in that regard!

giann commented 1 year ago

Features like I/O are dynamic libraries like this + this Without to much effort you could replace it with your own. Buzz maybe lacks the equivalent of lua searchers to prioritize your own lib over buzz's.

But if I understand you well, you want something more fine grained. Zig comptime feature should make this possible so i'll keep this issue open and will look into it.

giann commented 1 year ago

Btw buzz is no more zig compatible than lua is. Its api follows C ABI just like lua. This is required so that a buzz lib can be dynamically used and so that someone could write one in C instead of zig.

gaycodegal commented 1 year ago

yeah fine grained is definitely what i was going for but this approach is definitely reasonable. I didn't realize the standard library had a buzz definition file, and hence could be swapped for your own file. I think that gets close enough to what I'd need for an easy wasm build if I just don't include the buzz standard library, which is really what i'm after.

Given this, I think I'll give a wasm build a try and let you know how that goes

giann commented 1 year ago

Do make a PR if you need to add some specific things to build.zig