Live data from Hacker News

A language that compiles to Bash and Windows Batch

github.com

131–140 of 148 posts

Re: A language that compiles to Bash and Windows Batch

#132
post #80

I am the author of Batsh. Batsh is a toy language I developed 2.5 years ago in a hackathon. It was just for me to play with OCaml. Feel free to play with it at http://batsh.org/ .

Hey man this is cool, I posted this for you on hacker news.

Re: A language that compiles to Bash and Windows Batch

#133

Earlier quoted context omitted.

I think it's a limitation more on the windows batch end. As mentioned, it's tricky for historical reasons. Powershell would be closer to Bash, functionally speaking. An adapter between the two would be more functional- however doesn't satisfy the point of batsh, which assumes cleanish-builds of the OS in question.

Powershell introduces more complications, with functions like Invoke-WebRequest being given the alias "curl". At a minimum, you would get a type validation error, as Invoke-WebRequest by default gives back headers and other data as objects inside a larger object, not just the content string that curl.exe defaults to returning. This should work in both bash and PS, with different results: > curl HTTP://example.com > f…

Isn't that just what a compiled language would sort out for you? On Bash it'd compile to

curl HTTP://example.com > file.html

and on PowerShell it'd become

(curl HTTP://example.com).Content > file.html

Re: A language that compiles to Bash and Windows Batch

#134

Earlier quoted context omitted.

> Microsoft recognizes this MS also tried to improve PowerShell by installing the PSReadLine module by default. Read https://github.com/lzybkr/PSReadLine for instructions on how to make PS a bit more usable.

The problem with PowerShell is its syntax, not the extra features of the shell environment. Trying to expose the .Net runtime to the command line is an admirable goal for a scripting language, not a shell. It comes down to this, PowerShell is a catherderal, bash and tools are a bizarre, and that's why they win IMHO. Personally the best shell for any Windows box is to install cygwin and treat it like a Linux box, and…

Most of my big complaints about syntax are related to the shell-ness of PowerShell. For example, when comparing things, I really want to use '' rather than -le and -gt.

Generally though, the syntax is different but once you learn it, it's mostly fine and sometimes the text-based nature of Unix commands means you have to do a lot more reg-exing.

For example, compare these two:

    ps -ef | grep "chrome" | awk '{print $2}' | xargs kill
vs

    ps -name chrome | kill 
Of course it's just a matter of preference, but I prefer the the PowerShell version.

Re: A language that compiles to Bash and Windows Batch

#135
post #95
post #93

Earlier quoted context omitted.

How are you going to install batsh though?

you don't need to install batsh. you maintain your code in batsh, compile to bat and have that up on your page as a download.

Or, if you have developers, some on Windows and some on *nix, check in the batsh and its outputs.

Re: A language that compiles to Bash and Windows Batch

#137

The idea is interesting, but ultimately the utility of this seems limited. The differences between windows and Unix are more than just the shell language involved; shell scripts are typically deeply intertwined with the system in question, to the point where it's often not the case that a bash script will even run reliably across different Unix systems, much less on windows. Also, you can already run bash on windows,…

I think it's a limitation more on the windows batch end. As mentioned, it's tricky for historical reasons. Powershell would be closer to Bash, functionally speaking. An adapter between the two would be more functional- however doesn't satisfy the point of batsh, which assumes cleanish-builds of the OS in question.

There is an "adapter" between PowerShell and Bash - Pash (http://pash.sourceforge.net)

Re: A language that compiles to Bash and Windows Batch

#138

Earlier quoted context omitted.

The problem with PowerShell is its syntax, not the extra features of the shell environment. Trying to expose the .Net runtime to the command line is an admirable goal for a scripting language, not a shell. It comes down to this, PowerShell is a catherderal, bash and tools are a bizarre, and that's why they win IMHO. Personally the best shell for any Windows box is to install cygwin and treat it like a Linux box, and…

Most of my big complaints about syntax are related to the shell-ness of PowerShell. For example, when comparing things, I really want to use ' ' rather than -le and -gt. Generally though, the syntax is different but once you learn it, it's mostly fine and sometimes the text-based nature of Unix commands means you have to do a lot more reg-exing. For example, compare these two: ps -ef | grep "chrome" | awk '{print $2}…

Um... pkill chrome, still prefer bash/gnu tools. The bazaar has far more tools, you just have to find the right one.

> and sometimes the text-based nature of Unix commands means you have to do a lot more reg-exing.

That's a feature that has far more upside than downside.

Re: A language that compiles to Bash and Windows Batch

#139

Earlier quoted context omitted.

The problem with PowerShell is its syntax, not the extra features of the shell environment. Trying to expose the .Net runtime to the command line is an admirable goal for a scripting language, not a shell. It comes down to this, PowerShell is a catherderal, bash and tools are a bizarre, and that's why they win IMHO. Personally the best shell for any Windows box is to install cygwin and treat it like a Linux box, and…

>bash and tools are a bizarre You mean bazaar. Nice typo though.

bah, yea, thanks.

Re: A language that compiles to Bash and Windows Batch

#140
post #110

Earlier quoted context omitted.

These days you probably want Windows Powershell. It's built on the .NET framework so it's pretty darn powerful and AFAIK is available by default on every modern WinOS.

Powershell _is_ great (I help run an OSS project written in Powershell), but it has a long start-up time. If you're doing it as a pre-build step for example, you don't want to add potentially seconds (!) to your build just to use powershell.

Startup time used to be horrible in Windows 7 (v2, I think), but they improved it a lot since then. It starts instantly for me on my Windows 10 machine here.
Post reply on HN