rhaiscript / rhai

Rhai - An embedded scripting language for Rust.
https://crates.io/crates/rhai
Apache License 2.0
3.63k stars 174 forks source link

Add a no_plugin feature #855

Closed msparkles closed 3 months ago

msparkles commented 3 months ago

We're not using it, we don't intend to use it (as it would make us depend on it and depend on Rhai even more (no offense, but it isn't the best language for our use, it's just the best available one), and it's a lot of macros we don't need. Potentially giving the compiler extra load, but this is just speculation.

If it doesn't affect compile time, we don't mind it being around, but we'd assume macros don't get eliminated if they're in the deptree

schungx commented 3 months ago

it isn't the best language for our use

Well you're probably right. It works, but is definitely not a V8 or LuaJIT. It's main purpose is to enable quick and easy no-fuss embedding of a scripting engine into a Rust program without a lot of efforts

we'd assume macros don't get eliminated if they're in the deptree

As for the proc macros, they are not compiled into the resulting binary. They only affect compilation speed if you use them, otherwise they just sit there doing nothing. So there is nothing to eliminate.

Macros by themselves do not add any library code to your program. They only compile to code thats uses functions in your own program.

msparkles commented 3 months ago

Don't syn and proc_macro need to be compiled too?

schungx commented 3 months ago

Don't syn and proc_macro need to be compiled too?

Yes but only during compilation. Macros only work in the compilation phase

Those libraries are not embedded into the final binaries.

That's why if you'll cross compile, you don't need macros to be in the target CPU.

msparkles commented 3 months ago

Those libraries are not embedded into the final binaries.

We're only concerned about compilation time, which is why we asked if they would get skipped by the compiler if it's not used. But it's probably not skipped due to the nature of proc macros being procedural

msparkles commented 3 months ago

We don't know how much time those macros really add, though

schungx commented 3 months ago

We're only concerned about compilation time, which is why we asked if they would get skipped by the compiler if it's not used. But it's probably not skipped due to the nature of proc macros being procedural

Ah, OK. Understood. Yes, the macros crate will be built, but only once. If nothing changes, it gets cached by cargo. And if you don't use macros, it doesn't affect your compilation time.

msparkles commented 3 months ago

Alright then!