Live data from Hacker News

Batsh – A language that compiles to Bash and Windows Batch

batsh.org

71–80 of 130 posts

Re: Batsh – A language that compiles to Bash and Windows Batch

#71

I can't think of a case where seamlessly having two different targets like this has worked - particularly if there's pressure to really support all of the features of both.

These days, if I'm writing something in bash (or batch) it's often because there is nothing better available - like kicking off an installer, or some other wrapper / bootstrap script.

For those kinds of simple tasks, the overhead of fully understanding the nuances of bash _and_ bash is way more trouble than the inconvenience of having fewer features available. This is not for bat/sh lovers, it's for those who have to use bat/sh even if they'd rather not.

Having said that, I wouldn't use batsh myself until it does something sane with errors (at least the equivalent of `set -e` in bash).

Re: Batsh – A language that compiles to Bash and Windows Batch

#72

This is great for me. As part of my day job I am often stuck writing batch scripts (yes, in 2014) for clients that refuse to run powershell. Writing a simple batch script is usually not a problem, but it can be very encumbering as the complexity increases. Thank you for sharing.

Is VBScript/JScript not an option? It should be on every machine you come into contact with.

Re: Batsh – A language that compiles to Bash and Windows Batch

#74
post #65

This is great for me. As part of my day job I am often stuck writing batch scripts (yes, in 2014) for clients that refuse to run powershell. Writing a simple batch script is usually not a problem, but it can be very encumbering as the complexity increases. Thank you for sharing.

Do you charge them additional fees? If not you're screwing yourself over.

Not sure why the downmods, web developers typically charge extra to support legacy systems requiring additional work, fir example, IE8

Re: Batsh – A language that compiles to Bash and Windows Batch

#75
post #63

Earlier quoted context omitted.

PS> Set-ExecutionPolicy Unrestricted It's the first line of just about every publicly-distributed script (including Chocolately, etc).

One of the reasons I'm still afraid to use Powershell - its just not succint enough for normal day to day operations.

I beg to differ, and not only because I code-golf in PowerShell. Aliases and the ability to shorten arguments while they're unambiguous both are features that have no use for scripts, but are very handy for an interactive shell. I never type things like

    Get-ChildItem -Path ~ -Recurse
if I can help it, instead it almost always is something like

    ls ~ -r
I guess -Recurse only ever appears there if I hit [⇄] for parameter completion.

Sadly there are far too many people who only know bash and see straightforward conversions of VBScript into PowerShell and think the language sucks or is too verbose.

Re: Batsh – A language that compiles to Bash and Windows Batch

#76
post #23

Earlier quoted context omitted.

As I said in the other threads, the language is great, the performance has been abysmal in relation to batch (at least for me, having started with Powershell in its first release in Vista).

This eludes me but why care about the performance of a shell scripting language?

With PowerShell level of slowness it starts to matter. Even very basic commands seem to sometimes take many seconds to run. In the middle of intense workflow it becomes a problem.

Re: Batsh – A language that compiles to Bash and Windows Batch

#77
post #3

I'm not so sure about the utility of this in my case. I usually end up using python for scripts, with perhaps a one line batch file that runs it with some default arguments for convenience.

I have to confess, that I'm also one of those guys. I usually anyway installing Python anyway. So using it all scripting is trivial. Even if Python is "heavy and slow", people seem to forget that Powershell is lot heavier and slower.

Re: Batsh – A language that compiles to Bash and Windows Batch

#78
post #57

So are we really supposed to install OCaml and compile it or do we use it as a hosted service? I can see that you just post a batsh script and specify your output, but I don't know if that's intended for public consumption. Otherwise this just looks like a POC.

I think you missed the second option in the README, “Install from OPAM” (https://github.com/BYVoid/Batsh/tree/master#install-from-opa...). To summarize, you can install the OPAM system with your package manager with a command such as `brew install opam`, then install batsh with `opam install batsh`. That should give you a `batsh` command that you can use to compile your scripts.

Re: Batsh – A language that compiles to Bash and Windows Batch

#79
post #37

There's no mention of error handling, which is what really makes Windows batch files completely hopeless for anything involving more than one or two commands. Being able to write code with exceptions and having it compiled to the corresponding mess of ERRORLEVEL and GOTO would be sweet! (I've switched to just writing everything in JavaScript for WSH. It's ECMAScript 3 and the API has some issues, but it's still a mil…

Ive leaned towards node.js for a couple years now in windows.. with edge.js I get about anything I could ask for.... You can also put a thin shim to launch node for the script in case it's in a wsh environment.

Link to Edge.js: https://github.com/tjanczuk/edge

WSH is Windows Script Host: https://en.wikipedia.org/wiki/Windows_Script_Host

Re: Batsh – A language that compiles to Bash and Windows Batch

#80
post #76

Earlier quoted context omitted.

This eludes me but why care about the performance of a shell scripting language?

With PowerShell level of slowness it starts to matter. Even very basic commands seem to sometimes take many seconds to run. In the middle of intense workflow it becomes a problem.

Care to give examples? I know that the language isn't fast, but afaik nearly all shells are interpreted. There have been performance problems with break/continue in earlier versions as they were implemented using exceptions internally. But that doesn't really qualify as "basic commands", I guess. Cmdlets should be not much slower than running the equivalent C# code yourself.
Post reply on HN