Amber icon indicating copy to clipboard operation
Amber copied to clipboard

✨ Generated script readability

Open FedericoCeratto opened this issue 1 year ago • 10 comments

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_arch instead of __AF_get_arch26_v0, arr0 instead of __AMBER_ARRAY_0
  • Generate scripts with 4-space indentation

Thanks!

FedericoCeratto avatar May 26 '24 14:05 FedericoCeratto

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

b1ek avatar May 26 '24 15:05 b1ek

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.

Ph0enixKM avatar May 27 '24 09:05 Ph0enixKM

Amber is already doing 99% of the work. I can imagine generating code with the correct indentation should be an easy addition.

FedericoCeratto avatar May 28 '24 09:05 FedericoCeratto

Well and why not minimized code? Something like a parameter to build production / optimized and minified code?

paraflu avatar Jun 12 '24 21:06 paraflu

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

b1ek avatar Jun 13 '24 05:06 b1ek

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

FedericoCeratto avatar Jun 13 '24 07:06 FedericoCeratto

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.

Ph0enixKM avatar Jun 13 '24 10:06 Ph0enixKM

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.

Mte90 avatar Sep 10 '24 10:09 Mte90

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 --debug that 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)

Mte90 avatar Sep 12 '24 09:09 Mte90

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

b1ek avatar Sep 14 '24 23:09 b1ek