My contributions will probably be mostly supposedly bright ideas that will turn out to be horribly wrong, but it’s all for the sake of learning right? So share away, we can sort it out later.
The only thing I have to offer for now is this:
Make main lua contain nothing but the menu entry, which only when it is invoked reqires the file where all the actual functions are, and calls the main function.
I think if you have a hundred scripts, it would really help if those were all small, since they all get loaded at startup… !
But the real reason I like this and will try to stick to it from now on, is that editing files that are all called main.lua is confusing and painful, I’d rather have descriptive names
renoise.tool():add_menu_entry {
name = "Sample Editor:Process:Rubberband...",
invoke = function()
require("rubberbandremix")
show_rubberband_dialog()
end
}
168 bytes! Sure, most tools have more menu entries (and hotkeys), but the point is the same - everything that you do not have to do at startup, move to an external file which only gets loaded once the tool is actually activated. Keep your main.lua as slim as possible. That will not so much improve the performance of your own script, but together with all other scripts it can help keep Renoise startup times as short as they are.
I just think once we have hundreds of scripts, you would notice a MASSIVE difference between every main.lua just being a short stub, and between main.lua containing the main routines, or even all of the code. I might be wrong though, so maybe people with more clue can confirm or correct it.
But if it is a good idea, I think it’s better to pick up such habits earlier than later, especially since just like with pollution and global warming, each individual doesn’t really notice anything, but suddenly, Renoise takes longer and longer to load… wakes up in cold sweat