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.

  • balsoft@lemmy.ml
    link
    fedilink
    arrow-up
    20
    ·
    1 month 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.

  • CameronDev@programming.dev
    link
    fedilink
    arrow-up
    21
    arrow-down
    1
    ·
    1 month ago

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

  • False@lemmy.world
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    1 month 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.

      • TrickDacy@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 month ago

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

        • ferric_carcinization@lemmy.ml
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 month 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
    link
    fedilink
    arrow-up
    2
    ·
    1 month ago

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

  • IrritableOcelot@beehaw.org
    link
    fedilink
    arrow-up
    2
    ·
    1 month 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.
  • liliumstar@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 month 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.