Live data from Hacker News

Amber: Programming language compiled to Bash

amber-lang.com

91–100 of 330 posts

Re: Amber: Programming language compiled to Bash

#91

Earlier quoted context omitted.

This is the compiled to Bash part. Sed is used because `bc -l` can return a float when integer is expected. Not sure if can be done better in generic case but it isn't unheard. Certainly can be optimized for some cases. (Here e.g. can use Bash's built-in integer arithmetic.)

But why does it use bc in the first place? Bash does integer arithmetic perfectly well on its own. Amber claims to be type safe so it should have enough information to avoid the the use of bc in this case. Ah, just looked at the documentation. Amber doesn't have integer types just a number type. That means that any numerical operation in Amber is pretty much guaranteed to be very inefficient. It's a very strange choi…

This is the first thing I noticed. Using ‘bc’ and ‘sed’ for integer comparison seems quite odd.

But then they chose this for their front page example, the one that everyone will see, so I assumed this was to demonstrate something clever I just didn’t understand.

I wonder what the motivation was to not have an integer type?

Re: Amber: Programming language compiled to Bash

#92
post #29

Impressive project. But I always feel that if you reach a certain complexity in your bash scripts, you should rather pivot to any other $lang. Bash scripts should be simple glue between programs (unix-principle).

I think the use case for this is where you need a bash script on a machine where you can't easily install and maintain a runtime.

On a machine where you can't easily install and maintain a runtime but you can install bash and amber and bc and sed?

Re: Amber: Programming language compiled to Bash

#93

Why does the documentation need WebGL? I have WebGL disabled in my main browser for privacy reasons (super-easy to fingerprint), and I only get to see 'Application error: a client-side exception has occurred (see the browser console for more information).' with an error about ThreeJS initialization in the console. I assume it's for the fancy animation, and I find that ridiculous. Loading a whole 3D library just to sh…

> Even if you're convinced you need the fancy animation, why not gracefully fallback to not showing it and still make the docs usable? Yeah, it's not like adding a try/catch block around the webGL invocation was hard anyway… But I agree with the sibling comment about disabling WebGL likely being a fingerprinting liability more than a win.

I find WebGL driveby risk and fingerprinting risks remote and hard to compare. To wit, I've never experienced a recognized loss from any kind of drive-by or fingerprinting attack.

However the severity of drive-by risk is so high, just in theory, that I am tempted to dismiss the risk of fingerprinting. But my reasoning is not very well informed.

What principles and information sources do you use when deciding that avoiding fingerprinting is more important than avoiding WebGL drivebys?

Re: Amber: Programming language compiled to Bash

#94
Something I noticed when I went to copy/paste something off the web page for this comment: at least some of the text on this page is in the form of an SVG?! That just feels gratuitous to me, particularly given how annoying it is to not be able to copy it :/.

https://amber-lang.com/pipelines/compile.svg

It also, hilariously, feels a bit fitting given my actual complaint ;P.

    if [ $(echo ${__0_age} '
Look: I appreciate that this is a shell script, and they often aren't "fast", but if I'm writing code in a script and have a comparison it at least might be in some tight loop and the performance different of spawning bc and sed into a subshell is frankly brutal.

    if [ "${__0_age}" -lt 18 ]; then

Re: Amber: Programming language compiled to Bash

#95
post #39

Earlier quoted context omitted.

Because the runtime for those utilities is available on just about every Linuxy OS there is. Saves you having to install the runtime separately, eg in your CI pipeline.

It's not much of a "runtime", though. How is it better than a plain executable?

It's not, really. The claim would be that it's portable, but bash can be a little finicky in that respect.

The documentation didn't mention what version of bash is required, but it'll be something. And plenty of systems will have old versions of bash - especially once you move out of the world of "my laptop" - obviously.

As has been mentioned elsewhere, it makes many times more sense to just learn bash, than to learn this. You likely already know some, and it excels at the jobs it's designed for - which is chiefly to launch processes and pipe output around. Subshells are elegant, even if making sure everything launched by your script is 100% finished before you exit can be a pain.

I doubt Amber fixes that problem in any case.

Re: Amber: Programming language compiled to Bash

#96

What I really want for scripting usecases is a language that has modern language concepts (easy to use arrays and maps, text formatting strings, etc) but that allows me to call commands as easily as I could call functions. Maybe there are existing scripting langs that make this so? Ambers approach is not bad but I feel it could be even better.

Have you taken a look at PowerShell? It can infer whether you're invoking a command or function.

Disclaimer: I work at Microsoft, but not on PowerShell.

Re: Amber: Programming language compiled to Bash

#98

Impressive project. But I always feel that if you reach a certain complexity in your bash scripts, you should rather pivot to any other $lang. Bash scripts should be simple glue between programs (unix-principle).

> Bash scripts should be simple glue between programs

If a script is literally just running a list of commands and occasionally piping the output from one to another, you may as well make it POSIX compliant (therefore a sh script) since you're not using any features of Bash anyway.

> But I always feel that if you reach a certain complexity in your bash scripts, you should rather pivot to any other $lang.

This is a common critique, but what other lang?

I make Bash scripts all the time for system administration tasks, and they largely just werk™ as long as you have Bash (90% of the time pre-installed) and the necessary commands. From there, any command can be readily called, piped, or saved to variables/arrays, and Bash has powerful (enough) native math and string manipulation capabilities.

Meanwhile with Python there's always some hassle installing dependencies with pip(x) and virtual environments, plus the unfortunate rare Python 2 encounter where you either gotta rewrite the whole thing in python 3 or figure out how to install the old Python 2 runtime and 3rd party python 2 libraries used in the script on your distro.

I don't see the appeal of sonething like the OP though. I can't imagine the "precompiled" scripts are so much more readable its worth the incomprehensible mess it appears to generate with the "compiled" script.

Why are people so afraid of Bash?

Re: Amber: Programming language compiled to Bash

#99
post #77

Earlier quoted context omitted.

The reality is that in disabling WebGL, you have an incredibly unusual configuration and the author didn’t test for it. Stop making this a philosophical argument. Why does the documentation need WebGL? It doesn’t, but the web has moved beyond just addressing “needs”. Why do you need to be on HN? You don’t. Yet here you are. I’m not arguing that the juice is worth the squeeze here, but your argument has a false premis…

I don't think it's incredibly unusual. On sensitive machines in corporate settings you commonly disable pretty much everything on every page that isn't in the 'trusted zone' or whatever. Personally, by default I shut down all the browser crap that might needlessly allocate RAM or allow memory leaks or slurp cycles without giving me some kind of value. I think this allows me to hold at least a few hundred extra tabs o…

[dead]
Post reply on HN