Live data from Hacker News

Amber the programming language compiled to Bash/Ksh/Zsh

amber-lang.com

61–70 of 72 posts

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#61
post #21

Earlier quoted context omitted.

Can you change the current working directory? If not, it's not a shell script.

Of course you can. How do you think `cd` utility is implemented?

cd is a shell built-in, not a script.

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#62

Earlier quoted context omitted.

Or Perl. Or Python. How many environments have only bash and not awk, perl, or python?

For small stuff I use bash / sed / awk / jq / yq / curl etc. I stopped using perl (a long time ago) and hate trying to build or distribute anything in Python. "You asked for a script! I give you... a venv, a pip install, woops need to compile something, so let's install build tools. Actually let's get github actions set up to handle this, or would you prefer a Docker image? Do you have a registry so I can share the i…

I highly recommend UV If you find yourself forced to use python, UV is the way to go

Try it out :)

uv init uv add XXX uv run main.py

( You can pin python versions and auto install them etc )

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#64
post #54

Earlier quoted context omitted.

Bash is great for orchestrating other Unix tools into an automated workflow. Only when that workflow requires stuff that Bash doesn't have is it time to break out Python. Integrate Shellcheck into your editor, and you get automated help for writing more reliable Bash.

ShellCheck is like a spaz hall monitor, filling my editor with useless warnings about what it believes are best practices. I thank my stars I mostly write shell scripts in zsh which it doesn't support.

Shellcheck has good heuristics, like making mistakes with for and subshell variables. I’ve never found its heuristics to be off-base, and when it can’t genuinely tell because of some context that is only known to you, you can opt out via # shellcheck disable=SCxxxx

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#65

Earlier quoted context omitted.

Or Perl. Or Python. How many environments have only bash and not awk, perl, or python?

For small stuff I use bash / sed / awk / jq / yq / curl etc. I stopped using perl (a long time ago) and hate trying to build or distribute anything in Python. "You asked for a script! I give you... a venv, a pip install, woops need to compile something, so let's install build tools. Actually let's get github actions set up to handle this, or would you prefer a Docker image? Do you have a registry so I can share the i…

You aren't really comparing apples to apples here. Anything you can do in bash/jq/curl you can do in python 3.x with only the stdlib. If you confine yourself to that, its still a better dev experience and can be run in any OS with a python package.

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#66
post #53

Earlier quoted context omitted.

Regardless of where it’s deployed I can edit it and run it without any additional tools.

So does an amber script after it's been compiled, that's the whole point. You can tweak it and inspect it if you want. Realistically though you'll probably regenerate it and copy the new compiled version over. But you can do both.

Is it? There is no example of what the compiled output looks like in the website or github. Just because its bash doesn't mean its suitable to be maintained in bash.

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#67

Any language is a shell script if you're brave enough: https://en.wikipedia.org/wiki/Shebang_%28Unix%29

Can go one step further and define a custom binfmt like was done here https://blog.cloudflare.com/using-go-as-a-scripting-language...

Didn't know about the binfmt_misc hooks in Linux. Good read! Thanks for sharing.

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#68
post #20

1. From the docs: "In the the project it is production ready because it is already used in this context because the shell code generated is tested and confirmed that works, the language is evolving with the tooling set." Hmm... 2. Support Fish too. Having one language that can generate zsh (macOS default), Fish (power users default), and bash would be really nice!

Hi, I am one of the project maintainers :-)

About Fish we are planning to support more bash subset but we aren't so much in the team to focus in everything. Right now the priority is to adds more stuff to the language in a way we can stabilize it and implement the other "output" target later.

About the production ready the Bash code is tested, shellchecked tested (we are not at 100% yet) and works but is an alpha because we are working in the syntax.

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#69
post #50

Earlier quoted context omitted.

The only thing I can think of is if you have an existing system you are integrating with thats implemented in shell script already - for example a packaging or build pack system; but I can’t really see how this could be justified even there because this could easily be a toy that becomes abandoned.

A really common use case is install/bootstrap/setup scripts. You know, those sketchy curl-to-bash things, or cloud-init scripts, or whatever you run to set up your actual higher level tools like Python.

Hi, I am one of the project maintainers :-)

As said there are use cases where you want to use only bash because you can't install scripting languages with their dependences as example.

As usual there is a tool for any user cases and Amber resolves some of them :-)

Re: Amber the programming language compiled to Bash/Ksh/Zsh

#70

How does it achieve memory safety? Via garbage collection? Via runtime checks? Via some clever compile-time analysis?

Hi, I am one of the project maintainers :-)

Right now we check the bash output with Shellcheck but we are not yet full valid and we test it for performances.

About security right now we are just avoiding evail and this kind of things, we are focusing right now on stabilizing the language itself.

Post reply on HN