![]() |
|
![]() |
| THIS. Why does this:
compile to this:
instead of this:
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:
EDIT2: TIL that parameter substitution is POSIX [0] Section 2.6.2[0]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... |
![]() |
| So you want it to compile to POSIX sh but you're unhappy it doesn't use more POSIX-incompatible features? Maybe full POSIX sh compat is WIP, or in some simpler cases maybe it already is? |
![]() |
| To my eye, this does not look good.
I consider myself to be quite proficient in bash. I write a lot of bash professionally. I've written a compiler (transpiler?) for a strongly typed configuration language that outputs bash. There are three main problems I see here. (1) Pipelines, subshells, and external dependencies. The example on the website compiles a conditional `if age < 18` into this monstrosity:
Pipelines and subshells are "slow". Not tremendously. But it adds up. Also, what's the point of having types in your language if you're not going to use native arithmetic when applicable:
Perfectly fine to alert users that floats will require an external dependency (such as dc), but integers will be handled in native arithmetic contexts.Seems mildly insane that a conditional this simple would require a pipeline including `echo`, `bc`, and `sed`. Now the user needs to ensure the correct external CLI tools are installed, and match the expected versions. Hope they account for BSD vs. GNU variants. Eek. (2) Namerefs. > Arrays cannot be nested due to the Bash limitations Arrays absolutely can be nested... with some trickery. Consider:
The `declare -n` line is where the magic happens: https://www.gnu.org/software/bash/manual/html_node/Shell-Par...This is a fairly trivial operation that I'd assume the authors would know about. It's fast and allows for the creation of arbitrarily complex objects. Even rudimentary classes. (3) Just learn bash. I'm perpetually confused by people taking every opportunity to not just... learn bash. An otherwise skilled programmer will somehow forget everything they've learned when beginning a shell script. Surely it can't be harder to learn the fundamentals of shell scripting than to learn whatever flavor-of-the-month alternative is? |
![]() |
| 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. |
![]() |
| That's about where I gave up too. You make it sound like you disagree with me when in reality you do. There is no real reason to write any production code in bash or any other shell language. |
![]() |
| Yeah, I stopped reading at that conversion. If it cannot handle a single "<" imagine more complicated logic, it would make debugging it a true nightmare. |
![]() |
| 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) |
![]() |
| > 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. |
![]() |
| Same for me. There's still plenty of unused gemstones as programming languages so perhaps the authors may still decide to change their name. |
![]() |
| 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 introspection in YSH etc. Based on other comments it seems like Oil Shell is much more principled in working to actually understand Bash as it exists and presenting an alternative language. I would be interested in what differentiates Amber and whether they have a response to Oils? |
![]() |
| It's an entirely different problem; the problem being solved here is not "use a better shell than bash". It's targeting bash as a universal runtime because it's (kinda sorta) ubiquitous. |
![]() |
| > In Amber, there is a rule that allows you to use a : symbol where you intend to write only one statement, wherever you can write a block of code. This can be handy when you want to perform multiple conditions with a single statement each.
This feature, optional omission of delimiters in the special case of a single statement per branch, originated in early C and has since facilitated untold numbers of bugs, not least the spectacular Heartbleed bug (which has its own homepage, https://heartbleed.com). |
![]() |
| Maybe I lack a bit in creativity: but what purpose does this serve? Almost all machines have a python or even perl interpreter if you really need to go there. |
![]() |
| 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.
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.
|
![]() |
| I can see some very niche cases where an embedded system has bash not much else and "taking the most you can out of bash" could end up being useful.
besides that? probably nothing. |
![]() |
| There is a typo in the docs:
|
![]() |
| Rust, except using existing executables (or dynamic libraries) instead of downloading packages and waiting ages for it to compile? Seems like a great idea. |
![]() |
| The homepage is good looking and I applaude them for that, but I gotta admit, it's almost too dark for me to see some of its content. I think grey text on black background is risky move. |
![]() |
| 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. |
![]() |
| I quite like that pattern, but I think 'with a different datatype' should result in a small gnome climbing out the back of the computer and hitting the developer with a mallet. |
![]() |
| The Amber installer is itself created from Amber. I suppose that makes sense....
I would prefer that it produces code with a bit more whitespace for readability. |
![]() |
| And enjoy a mad scramble to rewrite everything after Python 4 releases?
For all its faults, after a Bash script works once, it usually just keeps working. |
![]() |
| I wish there was a solution for something like
Download(file.gz) and that gets converted to either a wget or curl based on what the system has. |
![]() |
| I would assume because bash is deployable to more locations with fewer assumptions. Scripting requires environments to be set up correctly to run, and binary makes architecture assumptions. |
![]() |
| Looking at the output I find myself thinking: "if this kind of thing caught on, it would only be a matter of time until someone proposes a BASM (Bash ASM)..." |
![]() |
| I guess I don't understand the point. Could someone summarize why I would use this rather than writing my utilities in something that doesn't compile to a quirky, limited programming language? |
![]() |
| 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. |
![]() |
| Sites can tell if you’re running Adblock too.
You’re always leaking some kind of information that advertisers will pay for. The game is choosing what information you’re okay giving them |
![]() |
| It makes you look the same as everyone else with webgl disabled. This happens to be a reasonably large number of people, because it's the default setting in a variety of privacy focused browsers. |
![]() |
| 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 single triangle also narrows me down to 0.8% of all users. |
![]() |
| If you mean block all network traffic that isn't in the trusted zone then sure. But disabling features you personally don't like isn't a good security practice. |
![]() |
| I was more put off more by the initial example. Amber being used to calculate an age being less than 18. With sed. Seems almost like an attempt at humor, except the bit where one would laugh. |
![]() |
| I think the project itself sounds very intriguing and I am sure to follow how it evolves. But I have to agree with you about the website. There are also some little inconveniences in there that are sure to annoy a technical minded person. Like the links on the upper right corner (GitHub etc.) that are not in fact links (). |
![]() |
| I had the same exact reaction. Being an open source project doesn't mean the website has to be ugly or bare bones (though plenty are). But this is sending the wrong expectations about the project. |
![]() |
| I think the biggest issue is the image of the floating chunk of amber plugged into computers. It looks 100% like something you'd see from yet another Ethereum hustle. |
![]() |
| What does this have to do with their comment? The poster was giving feedback about a concern (maybe not a concern but something that they noticed). |
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.