74

In short, Amber is a programming language with Rust like syntax that compiles down to bash. More details here: https://amber-lang.com/

On the surface, it seems nice. Cleaner syntax, types, compile-time safety checks, etc. So you get to write in something nicer than bash but get the portability of bash.

My wonder is if there are pitfalls that make it worse than instead writing it in something like Python or even bash itself. I'd guess the generated bash code probably isn't the prettiest to look at or debug.

top 32 comments
sorted by: hot top new old
[-] balsoft@lemmy.ml 26 points 1 week ago

At the risk of stating the obvious, I would like everyone to know that https://www.shellcheck.net/ exists. Unless you are a bash wizard: if your bash script doesn't pass shellcheck, it is very likely to have bugs.

[-] tasankovasara@sopuli.xyz 2 points 2 days ago

Let's also remind that at least Helix the very good editor automatically runs bash stuff through Shellcheck if you have it installed, while you type. It's been amazingly useful and educational. I write a lot of bash at work and have learned many finer details from Shellcheck's hints.

It even does the Clippy thing. I'm piping something into a sed s/.../... and it tips 'try ${variable//search/replace} instead'.

[-] CameronDev@programming.dev 24 points 1 week ago

If your comfortable writing rust, why not just use rust and compile to rust binaries? Rust has toolchains for realistically everything...

[-] Quibblekrust 21 points 1 week ago

It's not Rust, OP was mistaken. It's ECMA-Script-like with Rust-like features and also Python-like features.

I think the idea is, you can develop Amber scripts "at home" then deploy them on any machine that has Bash without needing to install anything. This benefits system admins.

Amber compiles directly to shell code, so you can:

  • Leverage existing shell tooling and pipelines.
  • Deploy a single script without installing a language interpreter.
  • Benefit from shell‑native features (process substitution, job control) while enjoying high‑level syntax and safety.

Is Amber production‑ready?

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.

Well, their FAQ isn't exactly production ready.

[-] teawrecks@sopuli.xyz 4 points 1 week ago

Unless OP edited their post, they said "Rust like", not that it is Rust.

[-] Quibblekrust 5 points 1 week ago

Yeah, it's a blurry line whether to call it rust-like if it borrows features, when actually most syntax is more like ECMA Script or Python. So I shouldn't really have said "OP was wrong". But they also kind of are. I dunno.

[-] False@lemmy.world 2 points 1 week ago

Eh, go is really good for this kind of stuff. It compiles to a single binary you can just execute from shell

[-] CameronDev@programming.dev 2 points 1 week ago

Rust is the same mostly. One upside of bash is that if binary signing was enabled, go and rust binaries would get blocked, but bash would be fine.

[-] Quibblekrust 2 points 1 week ago

Doesn't that describe most languages?

[-] False@lemmy.world 3 points 1 week ago

I'd say no. Even C needs external libraries.

I guess Rust does this too though - in which case transpiling rust to bash is even less appealing :shrug:

[-] Quibblekrust 3 points 1 week ago* (last edited 1 week ago)

Even C needs external libraries

You can compile a C program while statically linking the libraries, thereby producing a single binary with no runtime dependencies. Just because Go can do this, too, doesn't mean it's special. It's just that most libraries for Go ship as source code and not as compiled libraries. But as soon as you import some actual library like Sqlite, OpenSSL, GTK or whatever, using some wrapper code, you're going to have the same dependency issue.

[-] mmmm@sopuli.xyz 20 points 1 week ago* (last edited 1 week ago)

I wonder why they decided to make it transpile to bash instead of posix sh.

[-] julian_schwinger@beehaw.org 1 points 6 days ago

They mention in the FAQ that they currently require some features of Bash but are thinking about including POSIX sh as a possible target. My guess without investigating is that they are using a thing like arrays that make implementation way easier but is not technically POSOX sh.

[-] IanTwenty@piefed.social 13 points 1 week ago

I like the idea as BASH is available everywhere but has terrible gotchas in its syntax plus at times is unreadable.

When I did some moderately complicated amber scripts I hit bugs. Also still some important features are missing.

So I'm keeping an eye on it but it's definately not ready for anything serious yet.

I am also watching https://oils.pub/ and hoping one or both of these projects succeed.

[-] False@lemmy.world 13 points 1 week ago

I think you may as well write your script in rust, if that's what you want to do, and just have it call shell commands then parse the output in rust.

I've done this in Python before, works fine.

[-] ZWQbpkzl@hexbear.net 8 points 1 week ago

Compile-to-Bash is a dead-end goal IMO. Just write it in Python or Rust and it'll be even more portable.

ECMA Script-like syntax.

That's supposed to be an improvement?

[-] novafunc@discuss.tchncs.de 4 points 1 week ago

One annoyance about Python is that I also have a Mac. By default, it comes with no Python. If you install XCode, you get Python 3.9. And of course you can get the latest version from Homebrew.

Granted, I don't think Amber would help much in this situation either. macOS comes with bash 3.2 and Amber probably targets a newer version that that. So either way I would need to homebrew install newer versions.

[-] ZWQbpkzl@hexbear.net 1 points 1 week ago

Write in rust then. Binaries are statically compiled and will even work on windows depending on the processes you call.

[-] Sandouq_Dyatha@lemmy.ml 6 points 1 week ago
[-] IrritableOcelot@beehaw.org 6 points 1 week ago

If you just want portability, then this could be useful. However, in my opinion a large part of why I use a shell script is to avoid compilation and just hack something together. If your goal is shell scripts that are easier to write you could also check out other shells:

  • fish is the easiest to use in my opinion, but is not POSIX compliant so you do have to learn the syntax.
  • zsh is a nice quality-of-life upgrade over BASH, tweaking the little things
  • There are also things like xonsh which use Python syntax for shell scripting, but I dont have personal experience with them.
[-] TrickDacy@lemmy.world 4 points 1 week ago

Bash syntax sucks but imo rust syntax is 50 times worse. Interesting idea though.

[-] ferric_carcinization@lemmy.ml 3 points 1 week ago

What do you dislike about Rust's syntax?

[-] TrickDacy@lemmy.world 3 points 1 week ago

I just didn't like it. I did a tutorial years ago and it all felt unnatural and hard to read/write.

[-] airgapped@piefed.social 3 points 1 week ago* (last edited 1 week ago)

Likewise, the constant finger dancing between various symbols gave me RSI and was a readability nightmare. Shame because I liked Rust as a language.

[-] ferric_carcinization@lemmy.ml 2 points 1 week ago

Fair enough, I guess. I too find the syntax of some languages to be a bit unergonomic. Though, I could probably get used to them, given enough time.

I was just a bit curious, as Rust's syntax is not nearly as exotic compared to its signature features.

[-] jtrek@startrek.website 3 points 1 week ago

Interesting. I dislike writing bash scripts so this might appeal to me, but probably not before a stable 1.x release.

[-] jokro@feddit.org 2 points 1 week ago

This is nice. Writing safe bash scripts includes avoiding implicit pitfalls. If the tool actively stops you from that it's great. I wished this would have existed some years back.

[-] digdilem@lemmy.ml 2 points 1 week ago

You'll never take perl from me!

[-] liliumstar@lemmy.dbzer0.com 1 points 1 week ago

I have used it, and honestly it's better than writing pure bash. But it's not perfect. Still needs a lot of work, and there are a bunch of weird limitations and things you need to remember. So I would say it's main use case is where you absolutely need bash portability over a more robust scripting/programming language.

[-] chgxvjh@hexbear.net 1 points 1 week ago

Calling commands and processing their outputs seems to be an afterthought. Nushell or oilshell or even perl have nicer syntax for scripting tasks ihmo.

this post was submitted on 26 Jul 2026
74 points (97.4% liked)

Linux

66782 readers
608 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS