Live data from Hacker News

Amber: Programming language compiled to Bash

amber-lang.com

301–310 of 330 posts

Re: Amber: Programming language compiled to Bash

#301

Earlier quoted context omitted.

> 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.

If you disable WebGL you're putting yourself in the 2% of devices that don't support it. That's not fantastic, but with WebGL enabled just the extension list can be used to narrow you down way further than that - according to https://amiunique.org/ 0.35% of users share my exact supported extensions list. My `gl.getParameter(gl.RENDERER)` seems to be unique to me, for some ungodly reason. The output from rendering a s…

Thanks for the website, it's very interesting.

From their statistics, it seems that WebGL gives far less info than things like the list of fonts, the Canvas properties, or the audio input, and more comparable to effective height of the screen (or even just user agent in my case, using Firefox on Linux, though I have to admit I'm surprised about that: 0.02% sounds really low).

Re: Amber: Programming language compiled to Bash

#302
post #285

I had a brief idea for transpiling bash here: https://github.com/rbren/baml The thing I'm most proud of is the installation--you just put a single base64 encoded line at the top of your script, and everything works magically.

Neat! We did something in the similar spirit after having too many beers once : https://github.com/LinusU/monofile The idea was to be able to mix languages in a single file, including the implementation

Re: Amber: Programming language compiled to Bash

#303

Earlier quoted context omitted.

Amber doesn't have equivalent issues because bash and the utilities it uses like bc and sed are incredibly stable. I've found nontrivial shell scripts I wrote decades ago that still run entirely unchanged.

GNU and BSD tooling differs in small, but sometimes breaking ways. One example off the top of my head is that GNU sed accepts `sed -i`, but BSD requires `sed -i ''`, i.e. an empty string to tell it not to back up the existing file. Or GNU awk having sorting capabilities. Etc.

Or the lack of a portable stat :(.

Re: Amber: Programming language compiled to Bash

#304

Earlier quoted context omitted.

The generated code already looks kind of insane, I can imagine it would only be worse without the benefit of Bash features.

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…

"if ((age < 18)) ; then ..." works in bash.

Re: Amber: Programming language compiled to Bash

#305
post #222

Earlier quoted context omitted.

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…

Have you stopped to think that maybe people will use this "experimental 3 month old language" for their personal stuff, and that not everything in programming is for your "whole team"?

Then they can disregard my advice obviously. But I saw plenty of others in this thread who seemed interested in it genuinely for practical reasons, and with all the times I've seen young devs disregard old mature solutions, I thought it'd be worth mentioning.

Besides, "runs anywhere bash does" isn't really useful for a personal project. Work is where you're likely to run into a weird variety of legacy machines, not in a personal project where you have more control.

Regardless, the weird aversion to hearing advice that can just be disregarded if it doesn't apply to your case baffles me.

Re: Amber: Programming language compiled to Bash

#306
post #30

Rust, except using existing executables (or dynamic libraries) instead of downloading packages and waiting ages for it to compile? Seems like a great idea.

This is not even remotely an alternative to Rust, nor is it intended to be. It's a replacement for Bash.

I know, but it looks like it is heading in that direction.

Re: Amber: Programming language compiled to Bash

#307

Earlier quoted context omitted.

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.

If I’m going to install a tool to run my code, why would I pick any of these alternatives instead of going straight to a “real” programming language?

Most of the value in sh to me is that it’s ubiquitous. I write a script and the runtime is already available across most devices, operating systems, containers, and everywhere else without an extra steps.

Re: Amber: Programming language compiled to Bash

#308

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 tried migrating my Linux setup script to Python, but the sudo thing is quite hard to solve.

Either I have to grant the whole Python process sudo privileges and manually change the ownership of all touched files, or I have to spawn a sudo rm process to remove the files owned by root (instead of using Python's standard library).

Neither of these makes the script simpler or easier to maintain.

Re: Amber: Programming language compiled to Bash

#309
post #308

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 tried migrating my Linux setup script to Python, but the sudo thing is quite hard to solve. Either I have to grant the whole Python process sudo privileges and manually change the ownership of all touched files, or I have to spawn a sudo rm process to remove the files owned by root (instead of using Python's standard library). Neither of these makes the script simpler or easier to maintain.

> Either I have to grant the whole Python process sudo privileges and manually change the ownership of all touched files, or I have to spawn a sudo rm process to remove the files owned by root (instead of using Python's standard library).

You could have a separate python script you call via sudo.

Or you could automate the equivalent within python. Old discussion:

https://www.reddit.com/r/Python/s/tIYUq1Zgd3

Code (plus Python 3 & functionality updates; linked from the discussion, but knowing HN, some people will just wabt to skip straight to it):

https://gist.github.com/barneygale/8ff070659178135b10b5e202a...

Re: Amber: Programming language compiled to Bash

#310
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?

> 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?

In my bash scripts, using `bc` makes my script not work on git-bash under Windows. Almost everything else I do in a script that isn't linux-specific (including netcat/nc usage) runs in git-bash for Windows.

Post reply on HN