amber-lang / amber

💎 Amber the programming language compiled to Bash
https://amber-lang.com
GNU General Public License v3.0
3.9k stars 85 forks source link

[Feature] STD optimization - make it be stored as parsed AST in the binary #170

Open matejsmycka opened 4 months ago

matejsmycka commented 4 months ago

Wouldn't amber std be more efficient if bash was used directly? Right now, std has to be parsed and compiled. Std in Amber would make sense if types were used, but unsafe untyped amber is not optimal. This is case with some of the functions in std lib.

b1ek commented 4 months ago

it could be shipped precompiled with the binary if it takes too much time to compile it.

right now, it takes 22ms to compile this program:

import { input } from "std";
echo "hi, " + input("who r u: ") + "!!!"
$ time amber hi.ab hi.sh
amber hi.ab hi.sh  0.02s user 0.00s system 97% cpu 0.024 total
Ph0enixKM commented 4 months ago

It’s not a problem now, but you’re right this may lead to slower performance with time. Good issue