Live data from Hacker News

Amber: Programming language compiled to Bash

amber-lang.com

291–300 of 330 posts

Re: Amber: Programming language compiled to Bash

#291
I kind of wish this was a tool to author bash, or better yet very compatible POSIX sh. (versus being using bash as a compile target that a human isn't meant to read)

It's a bit of a stretch, but comparing it to something like MJML for HTML emails. [0] It doesn't make great HTML, but it's not unreadable and standard quality for HTML emails. It just handles all of the weird things you have to consider for maximum email client compatibility. It's basically a bunch of HTML macros, with react being an implementation detail under the hood. It's not like it's bringing any new features to HTML emails, because if it did, the output WOULD be unreadable.

If this was just some type hints, and cleaner syntax around sh, that I think would be really useful. This in it's current state is just sort of a tech debt generating machine. If something is built in amber, it's because we can only use bash for some reason, but if we can use bash we could either... use bash, or we could call something else (Ruby, Python, etc), from a 2 line bash script.

[0] https://mjml.io/try-it-live (click "View HTML" to see outputted source.)

Edit: Idea, it would be cool if you could define the environment available to the final script when using the compiler. That way, if there was something you wanted to distribute, the person building your project could say "this docker container I'm running this in won't have sed, but it will have bc and awk" or something.

Re: Amber: Programming language compiled to Bash

#292

Slightly off-topic, but in many posts mentioning Bash, the overall consensus seems to be that when a script gets too big you should switch to using a more full-featured programming language instead. Which is fine, I get the reasoning. But imagine you need to deploy a server but for whatever reason you can't use Puppet, Ansible, or other configuration management tools. You need to write a deployment script using a "re…

Go is definitely a decent solution but I'm surprised why you aren't using Python. Most Linux and BSD distros have access to a default install of Python. Even if the version is a bit old, if all you're doing is hydrating templated configuration and doing bookkeeping for eventually running a binary with some parameters, older versions of the standard library will do just fine.

Not gonna lie, I have a certain prejudice against Python because of the whole packaging issue, something I definitely need to work on. I did ship Python code before, I just don't really like using it.

I do have the pyinfra documentation saved so I remember to take a look at it. I love Go for many reasons, but the distribution of binaries is probably at the top.

Re: Amber: Programming language compiled to Bash

#293
post #266

Slightly off-topic, but in many posts mentioning Bash, the overall consensus seems to be that when a script gets too big you should switch to using a more full-featured programming language instead. Which is fine, I get the reasoning. But imagine you need to deploy a server but for whatever reason you can't use Puppet, Ansible, or other configuration management tools. You need to write a deployment script using a "re…

I have no idea how I would tackle the problem with Go or Rust. But Python with pyinfra comes to mind as a sane enough solution. Since we decided to move from Puppet to pyinfra at work, I don't see myself writing any sysadmin scripts in bash again anytime soon. Although Bash is still king for small utilities, I have found myself writing such scripts in Janet[1] recreationally. Bringing the functional paradigm to shell…

Pyinfra's documentation is definitely on my list of things to read.

Re: Amber: Programming language compiled to Bash

#294

I love the concept of a language like this, though I haven't evaluated amber in detail. I want to do more complex things using bash for devops stuff, because it's mostly working with other command line tools. You could directly use APIs and SDKs of cloud providers, but then things become an order of magnitude more complex than just writing the bash script. However, when you do that you encounter bash's weaknesses, li…

There are lots of new shells around that does support everything you’re describing. Eg: - nushell - elvish (was featured on HN recently) - powershell - murex (disclaimer: I’m the author of that one)

Yeah. Sh needs to be abandoned. There's a million better alternatives, including those without such an asinine syntax.

Re: Amber: Programming language compiled to Bash

#295
post #13

Earlier quoted context omitted.

and i dont like how it's inconsistent that echo is not using the $ syntax (which makes sense internally, as it's a built-in, rather than executing the $echo command). Overall, it is cute and neat, but i find that if you are looking to write bash scripts that require this level of programming, you'd be better off writing it in python, or perl. Only in very austere environments can this be utilized, but the requirement…

> the requirement of having `bc` installed means you must also have the ability to run package installation I don't remember ever installing bc, but I use it frequently and it's always there. Are you sure it's not already part of most base systems?

It's not pre-installed on Debian and SUSE.

Re: Amber: Programming language compiled to Bash

#296

I love the concept of a language like this, though I haven't evaluated amber in detail. I want to do more complex things using bash for devops stuff, because it's mostly working with other command line tools. You could directly use APIs and SDKs of cloud providers, but then things become an order of magnitude more complex than just writing the bash script. However, when you do that you encounter bash's weaknesses, li…

I will make no claims or implications whatsoever that it's "production-ready", but a different strategy which could work is to use Awk (which is at least as omnipresent as bash) to bootstrap an interpreter for a richer scripting language: https://beyondloom.com/blog/lila.html

Re: Amber: Programming language compiled to Bash

#297

Earlier quoted context omitted.

I find all the "Why should I use this when X exist" nonsensical. If you can't see any use for it then it's not for you. There are a whole lot of people who will find this more attractive than Perl.

Because they've heard the "lol perl is line noise" jokes and taken them very seriously instead of the jokes they are. Perl is way more mature with way more libraries, stability, documentation, etc. I hope I don't have to work with some young fool who decided without trying that perl, an incredibly well documented language, is "too hard" and instead signed our whole team up to work with some experimental 3 month old l…

My answer still applies to this long... ehh explanation?

Re: Amber: Programming language compiled to Bash

#298

I love the concept of a language like this, though I haven't evaluated amber in detail. I want to do more complex things using bash for devops stuff, because it's mostly working with other command line tools. You could directly use APIs and SDKs of cloud providers, but then things become an order of magnitude more complex than just writing the bash script. However, when you do that you encounter bash's weaknesses, li…

I sort of see that, but at the same time why not just compile to python instead? I get that python can be less convenient syntactically for "scripting" type things, but if you're writing in what's effectively a DSL that gets transpiled for a different interpreter anyway...

i guess the idea is that you can scp the output script to a machine that has only a minimal *nix install and run it there without having to install anything more. so bash, bc and sed but not python or ruby

Re: Amber: Programming language compiled to Bash

#299
post #279

I haven't seen a mention of the Oil Shell ( https://oilshell.org ) project's OSH/YSH yet and I'm quite surprised. Oils goal is that OSH is just a new Bash implementation (although not bug-for-bug) but with an upgrade-path to the more modern YSH for real programming with type safety etc, but still as a shell language. One of their exciting ideas is using code as data in a somewhat lisp-like manner to allow function in…

What’s the use case for that though? Nobody writes shell because they want a shell language. It’s written purely out of necessity because that’s the lowest common denominator installed on all systems. Something that Amber here provides a potential exit path out of. Oil would have to reach a really critical mass before it can compete, which is sort of a catch 22 situation.

oil's idea is that you do want a shell language (e.g. if a lot of what your code is doing is job control and manipulating unix pipelines I can see shell being the best language to express that neatly in). you just want a better shell language than bash. but there is a ton of existing investment in bash itself and things like nushell their that away to start from scratch, and oil says what if we build a better bash instead.
Post reply on HN