Live data from Hacker News

Amber: Programming language compiled to Bash

amber-lang.com

281–290 of 330 posts

Re: Amber: Programming language compiled to Bash

#281

Earlier quoted context omitted.

Maybe if those people started visibly failing at their jobs, they'd either upskill or be forced out, and then the magical hand of the market would raise salaries for the rest of us.

Oh look you're basically me in 2006 thinking that all the sysadmins that couldn't be bothered to learn a real programming language needed to be replaced by people in India who weren't intellectually lazy (because I was a bit of an asshole and wrong).

I'm against intellectual laziness in general; I don't care what your nationality is, just don't be incurious.

Re: Amber: Programming language compiled to Bash

#282

Earlier quoted context omitted.

THIS. Why does this: if age compile to this: __0_age=30; if [ $(echo ${__0_age} ' instead of this: __0_age=30; if [[ ${__0_age} -lt 18 ]]; then ... If you're going to compile to Bash, then use Bash-isms. EDIT: `-gt` is POSIX, but tbf if there's no input sanitization, then bash (or sh) will choke on the float. In that case, as long as you aren't trying to round, you could use parameter substitution to truncate: __0_ag…

There might be reasons to use `bc` like this if you don't know the type of `age` and it could be a non-numeric string. Buuuuut a programming language where a simple integer-comparison leads to two subprocesses is going to be slower than the slowest existing programming languages, by orders of magnitude.

Right. And the check/type validation shouldn't happen on comparison, but on assignment and only if it is dynamically assigned.

Re: Amber: Programming language compiled to Bash

#283

Earlier quoted context omitted.

THIS. Why does this: if age compile to this: __0_age=30; if [ $(echo ${__0_age} ' instead of this: __0_age=30; if [[ ${__0_age} -lt 18 ]]; then ... If you're going to compile to Bash, then use Bash-isms. EDIT: `-gt` is POSIX, but tbf if there's no input sanitization, then bash (or sh) will choke on the float. In that case, as long as you aren't trying to round, you could use parameter substitution to truncate: __0_ag…

There might be reasons to use `bc` like this if you don't know the type of `age` and it could be a non-numeric string. Buuuuut a programming language where a simple integer-comparison leads to two subprocesses is going to be slower than the slowest existing programming languages, by orders of magnitude.

Am I missing something, like `bc` can parse `one + two`?

Input sanitizing should be done before trying to hand inputs over to be summed.

Re: Amber: Programming language compiled to Bash

#286

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…

This is a well-informed observation.

It's unfortunate Amber doesn't have a Map data type, pretty big limitation.

I can think of ways of doing it, e.g. something along the lines of:

* Set the constraint that all keys must be of type String

* Then abuse /dev/shm/.Amber/${pid}/${func}/${stackDepth}/

Re: Amber: Programming language compiled to Bash

#287
post #152

Earlier quoted context omitted.

And why is it using [ instead of bash native [[

I think it's targeting a really old bash for max compatibility... and also it's super early alpha software

It's interesting Amber doesn't seem to be leveraging Bash-native Regexes via:

    if [[ "${foo}" =~ ^someReg[e][x][p][r]$ ]]; then ...
What value exists in going to such great lengths to target super old and anqtiquated versions of Bash? It becomes very limiting for this poor new language :-s

Maybe still just the earliest of early days? Javascript-style RegExs along the lines of:

    if (s.match(/my[R]egex[H]ere/)) { ..
Would be pretty nice and handy.

Re: Amber: Programming language compiled to Bash

#288

Earlier quoted context omitted.

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 am wondering why not take an existing language like python, and compile that to bash? Also for this to be really unique and good it needs insanity like being able to avoid all external dependencies, or else idempotently installing them in ways that can not affect anything else externally, or even temporarily, in multiple crazy various environments including nix? my mind never shuts up

> I am wondering why not take an existing language like python, and compile that to bash?

You'll run into the Alternative Implementation Problem

https://pointersgonewild.com/2024/04/20/the-alternative-impl...

https://news.ycombinator.com/item?id=40337036 - 10 days ago, 84 comments

Relevant excerpt:

> You may read this and think that the key lesson of this post follows the old adage that “if you can’t beat them, join them”. In some ways, I suppose it does. What I want to say is that if you start a project to try and position yourself as an alternative but better implementation of something, you are likely to find yourself stuck in a spot where you’re always playing catch up and living in the shadow of the canonical implementation.

This concept doesn't exactly map 1:1, but gist seems correct. Who wants to program in a worse and very limited version of Python? Who's going to keep things up to date in e.g. Amber as Python continues to evolve? Not fun.

Re: Amber: Programming language compiled to Bash

#289

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…

One approach I've used for running arbitrary code, with arbitrary dependencies, without having to rely on much support from the host system, is to create an Arx file (a shell snippet followed by tar gz data, which is self-extracting/executing) using `nix bundle`. On one hand it feels like a "poor man's container image"; but it's better in some ways since it doesn't need any daemons, etc. to be running.

For example, we had an EC2 machine whose init would fetch and run a shell script from S3, which spun up a big JVM application. We started getting strange errors from deep inside the JVM, which seemed to be caused by some security update somewhere in the stack (either ours or Amazon's); but that machine image had evolved via snapshots of snapshots, etc. and was a pain to figure out what it was running, let alone update and manage it in a sane way. As a quick fix I bundled a known-good JVM into an Arx file (along with other dependencies like Bash, etc. since it's Nix, so I might as well!) and put that on S3 in place of the old shell script. That got the EC2 machines working again, without having to mess with the (already messy) image; we gained a more sensible way of specifying dependencies (via Nix); and, since we were now building an artifact, rather than slinging a raw script, we could do stuff like running Shellcheck on the code. This definition was also easy to re-use when we eventually switched it to ECS containers (just changing the `nix bundle` options).

Re: Amber: Programming language compiled to Bash

#290

the website doesn't seem to render right on Firefox for some reason (works with Chromium tho)

Strangely the website links do not work unless you enable Javascript (e.g. to the GitHub project page).

Why do people make things this way? Let a plain old link be a link..

Post reply on HN