✨ Generated script readability
In many practical use cases people will use Amber to generate scripts that might be later on tweaked directly by someone who does not know Amber or does not want to use it. If this is a supported use case, can I suggest to:
- Generate friendly variable and function names where possible
e.g.
get_archinstead of__AF_get_arch26_v0,arr0instead of__AMBER_ARRAY_0 - Generate scripts with 4-space indentation
Thanks!
i agree, the variables names are unnecessarily bloated. i have also suggested on the discord server a debug mode feature - to print the variables names "as is" (to some extent), and preserve all code comments.
identation and formatting is not necessary imho (that has already been suggested in #103, btw), as it cam be easily achieved via feeding the compiled file to any third party bash prettifier
Yeah we can get rid of the __ before the names and make them more human readable. More over the variables imported from other files (ex. lib/main.ab) could be shortened to something like: lib_main_name="Rob" instead of __name_12="Rob" and I think this would make a ton of sense.
Amber is already doing 99% of the work. I can imagine generating code with the correct indentation should be an easy addition.
Well and why not minimized code? Something like a parameter to build production / optimized and minified code?
optimized and minified code
what for? its not a JS bundle to be transferred to a user every few minutes. afterall a bash script needs to be transferred only once, and some paranoid users might want to review the code before running it
IMHO the most important feature of Amber is to generate Bash scripts that can be understood and even slightly tweaked by non-Amber users and run without dependencies
Bash Scripts are running on personal deveices thus it's important for people to let them review it's contents and see what the script is doing.
I am wondering if we can do a process that just remove stuff in a line that starts with __ but only functions will be affected, with variables will not work.
Looking at the code there are various mentions for __ https://github.com/search?q=repo%3Aamber-lang%2Famber%20__&type=code
So probably to move this task:
- We need a new parameter like
--debugthat generate the version as it is now - When it isn't used all that stuff is not generated only in the compilation (when Amber is used to execute the script instead use the debug version)
do we even need __ before everything? it feels like a totally useless prefix especially since that bash namespace probably won't be shared with anything else