Live data from Hacker News

Amber: Programming language compiled to Bash

amber-lang.com

271–280 of 330 posts

Re: Amber: Programming language compiled to Bash

#271

Earlier quoted context omitted.

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…

Using firefox on a mac is basically enough to put me as all time unique on that site.

Me too, my user agent was something like 0.01%.

Re: Amber: Programming language compiled to Bash

#272

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…

[deleted]

Re: Amber: Programming language compiled to Bash

#273

Earlier quoted context omitted.

> I spent 2h debugging a script only to find out there was an extra space character that made the whole thing break silently. When I was learning C++, I lost 2 days because of an extra ";" in an if statement. However this does not mean C++ is an insane language. It means it has quirks. > I would be willing to learn a sane language, but bash isn't one I kindly, but strongly disagree. > If you need to know of a million…

> However this does not mean C++ is an insane language. It means it has quirks. Any sufficiently quirky technology is indistinguishable from insanity. https://yosefk.com/c++fqa/index.html

C++ is not dead, it just smells funny.

Thanks for this time sink.

Re: Amber: Programming language compiled to Bash

#274

Earlier quoted context omitted.

GitBash (MinGW) doesn't ship with bc or dc, but it does ship with awk.

This is targeted at Linux and Mac. If you're using Windows you are in the lucky position of probably not having or needing Bash.

GitBash is a POSIX environment that includes the titular bash, and it doesn't include bc, which is a direct counterexample to your original assertion. Lots of people who are stuck on windows for one reason or another still want or need to use bash, and that's why they use GitBash!

Clearly, if Amber did not have a dependency upon bc, it could then potentially provide value to those users.

Re: Amber: Programming language compiled to Bash

#276

Earlier quoted context omitted.

> need to know of a million tiny gotchas to implement even the simplest task safely and portably While this is clearly exaggeration, I'm not sure I find much merit in the argument. C is full of gotchas, footguns, and a tremendous threat vector. But it is also the standard for many uses. Yes, bash has legacy cruft, and potentially confusing ways of doing things. But for the realm in which it operates, it is extremely…

> While this is clearly exaggeration, I'm not sure I find much merit in the argument. > > C is full of gotchas, footguns, and a tremendous threat vector. But it is also the standard for many uses. (I'm not GP) Yes, and the same way there's a plethora of bash-alternatives in the making, there are multiple languages trying to essentially be a "better C", such as Go, Rust and so on, not to mention C++ and its descendant…

> I definitely think there's room for an improved bash.

Absolutely! I wholeheartedly agree, and would love for such a project to exist, and see sufficient adoption such that it's a standard at my job.

I may not have articulated my prior point precisely enough.

Too often I'll see a professional JS programmer (for example) who will forego everything they've learned the second they touch a shell script. No useful comments, no functions, poor design & implementation, no care towards idioms, no regard for readability/maintainability.

Given that bash is currently the standard, someone is better served by actually learning it than a worse, novel alternative.

Any successor must encompass the power and feature-set that exists within contemporary shell scripting.

Re: Amber: Programming language compiled to Bash

#277

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…

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.

Re: Amber: Programming language compiled to Bash

#278

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'm guessing because Bash is "more everywhere" than Python.

As slow as Python is, though, Bash is more slow. Much more slow.

Re: Amber: Programming language compiled to Bash

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

Re: Amber: Programming language compiled to Bash

#280

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

Post reply on HN