Chris wrote:
Ideally, scripts should be compiled to include code only for the commands they actually use. However, this seems too difficult and impractical to be worth it.
...Exactly! I've wondered why my compiled scripts are just another copy of AutoHotkey.exe...152 KB...even when the only command is MsgBox, a C program compiled with one MessageBox could be 5 KB or less. If you distributed a bunch of compiled AHK scripts, that would very quickly get excessive in file size...each one including the code to do everything AHK can do, even when it only does one thing.
Chris wrote:
Currently, both AutoHotkey.exe and compiled scripts are compiled in C++
...huh? compiled? it looks more like it's just a simple AutoHotkeySC.bin + Script.ahk = Script.exe, no compiling, but raw tacking onto the end.
Chris wrote:
This increases the size of each EXE by about 15 KB (and this increase will get larger over time as more code is added).
...15 KB for performance isn't the problem, 152 KB for every .exe is.
Chris wrote:
...will behave differently in compiled form due to their slightly lower performance.
...it shouldn't start acting different because it's compiled, if anything compiling should make it work better, not worse.
Chris wrote:
One way is to offer an optional scaled down feature-set that omits syntax checking (5 KB),
...you could syntax check on compile, then omit syntax check in the final .exe, the compiled AHK code isn't going to change after it's compiled...without re-compiling...when you could do another compile-time syntax check.
Chris wrote:
keyboard/mouse hooks (40 KB?), and maybe the GUI feature (15 KB?)
...any feature that the script don't use, should be omitted.
Chris wrote:
However, I have some doubt that these small savings are worth the confusion of an extra compiler option,
...options are good...if people don't know how to use them, they can use the default & that default can either do the most efficient thing (make it as small as possible) or just do what it does now (make it as large as possible).
Chris wrote:
not to mention the extra effort to maintain two different AutoHotkeySC.bin files.
...I don't get where with those options you only have 2 .bin files, you would more logically have a bunch of em with each possible combination of options, where do you get just 2?
If you currently do just tack the .ahk onto the .bin, couldn't you make a .bin for each part of the code...split the 152 KB up into parts...gui.bin, key-mouse.bin (or perhaps key.bin & mouse.bin separate), blah.bin, then tack them together in a way that works. I really need to know how it really does it now to know how I would change it. Does it store the raw .ahk or does it do the run-time pre-process & store that in the .exe...would storing the run-time pre-process have any advantages? If it does raw file tacking-on now, couldn't it be changed to a more gcc-like compile?
Could you include an option to compile an .exe that is dependant on either AutoHotkey.exe or another file that was compiled full? So on my own computer I could compile a 5 KB Script.exe that looks for the code in my AHK install dir? & for the example of distributing multiple compiled AHK's, include one main compiled AHK & have the children dependant on that...like...
main.exe (152 KB)
child1.exe (5 KB)
child2.exe (5 KB)
...main.exe is compiled normally, child1 & 2 are compiled to be dependant on a main.exe in the current dir, with the option of falling back to an AHK installation (AutoHotkey.exe), if one exists. If you can't do the full optimize-all-compiled-AHK's this would at least help on my own computer & be a semi-workable solution for multiple distributed compiled AHK's. Perhaps all compiled AHK's could support 2 command line options by default...
-ahk-portable
-ahk-dependant [<on what>]
...the ahk prefix so it don't conflict with any command line the script expects, portable would re-compile that .exe (a 5 KB dependant .exe) to include the AutoHotkey.exe code in all it's 152 KB glory, the other option would reverse that, cut a 152 KB portable .exe into a 5 KB dependant .exe, the <on what> would either be the name of the .exe it should look for or not be there to indicate that it should look for an AHK installation...I just thought of this...telling it to go portable when it's already portable is pointless, so maybe instead of 2 options, just one...
...would take a 5 KB & make it a 152 KB & vice-versa. Going from 5 KB to 152 KB would require either an AHK installation or a fully compiled script, so if some dumb user tried to take the above main.exe & cut it to 5 KB it could give an error saying that there is no AHK installation or fully compiled script found to undo what they are trying to do & it would fail, but if they 1st told child1.exe to go portable, then they could tell main.exe to go dependant, with no error.