Live data from Hacker News

A language that compiles to Bash and Windows Batch

github.com

41–50 of 148 posts

Re: A language that compiles to Bash and Windows Batch

#41
post #17
post #10

Earlier quoted context omitted.

It also doesn't come with any of the tools bash is a glue for, about the only reason one uses bash. At least with Python I can write my own grep and so on, and piping isn't so bad with coroutines and generators.

I think you missed the point of this language. You write code in this language, and then you compile it to get Bash for Linux and Batch for Windows.

I get it, I just disagree with "it's not bundled" as a major disadvantage: neither is your script, and maybe neither is your argument to any `call()`, so you're going to be thinking about deployment in any case.

Re: A language that compiles to Bash and Windows Batch

#43
post #2

Looks nice but wouldn't you just use something like Python nowadays?

What if you want to build Python?

Oh, that' easy, you unpack the Python sources and start with:

   ./configure
But what is that? It's not written in Python. It can't be, because you don't have Python yet. It's a shell script.

It's not a hand-maintained shell script; it's written by expanding Autoconf macros (in the M4 preprocessing language) to shell code: essentially a compiler from another language to shell.

A cleaner language which does the same thing could, in principle, replace Autoconf.

A related use for such a language would be install scripts: perform complex actions to install some software, with minimal dependencies on what is already installed.

Re: A language that compiles to Bash and Windows Batch

#44
post #39
post #36

Earlier quoted context omitted.

I love python, but python is not a shell, and it makes an absolutely awful shell replacement. Python is further from a good shell than bash is from being a decent programming language. Some scripts are good, I do use python for some kinds of shell scripts, but most of what I need bash for, python is not a good replacement at all.

But the goal of this is not shell replacement correct? It is a way to write scripts for both platforms. Python has great cross-platform support in that regard: http://hplgit.github.io/edu/ostasks/._ostasks002.html

Yes, you're right. Batsh isn't trying to be a shell replacement, but it is targeting the two shells that you're nearly guaranteed to find one of on any given computer.

I dunno if @zwieback was saying Batsh should target python, or if people should use python instead of Batsh, or something else, but neither of those first two suggestions makes a lot of sense to me.

Python's decent cross platform support doesn't really make it better for shell scripts, and while I use it for some shell scripts, I don't ever default to python. My comment was reacting to the "wouldn't you just", as though python is a natural default choice. In my experience, it's not a good default choice.

It's harder to debug python shell scripts, because you typically can't run individual lines, you typically can't cut and paste parts of it, you can't ever run system commands directly without wrapping it in a python module call, output might not display automatically, and you often have to install something that isn't already on the machine.

Re: A language that compiles to Bash and Windows Batch

#45
post #24

Earlier quoted context omitted.

It's significantly better than batch

Well sure, but these days PowerShell is what Windows people use for anything non-trivial.

Really? I though PowerShell was designed primarily to replace cmd. Surely Windows people use actual programming languages for the majority of tasks with PowerShell/cmd for smaller scripting tasks.

Re: A language that compiles to Bash and Windows Batch

#47
post #24

Earlier quoted context omitted.

It's significantly better than batch

Well sure, but these days PowerShell is what Windows people use for anything non-trivial.

PowerShell took everything that was great about .NET and combined it with everything that was terrible about Bash. So we have, yet again, a difficult to understand language for shell scripting.

Re: A language that compiles to Bash and Windows Batch

#50

I've never tried but can't you already just run your node or ruby or whatever scripts on both Windows, Mac, Linux? Is there some reason targeting bash and batch is important?

Both tend to exist on their respective operating systems by default, making it something that can run without further dependencies.
Post reply on HN