News for hackers. Stuff that matters.
Re:Batsh – A language that compiles to Bash and Windows Batch by yulaow on Monday September 01, 2014 @04:41PM (#8254606)
I would have preferred a bash/powershell solution. Hoping no one is still writing batch files on windows... even if he is still using xp
Re:Batsh – A language that compiles to Bash and Windows Batch by meowface on Monday September 01, 2014 @04:52PM (#8254642)
Agreed. Powershell has almost completely replaced batch scripts, and is actually a fairly pleasant language to work with.
Re:Batsh – A language that compiles to Bash and Windows Batch by 616c on Monday September 01, 2014 @05:41PM (#8254786)
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).
Re:Batsh – A language that compiles to Bash and Windows Batch by AYBABTME on Monday September 01, 2014 @11:29PM (#8255705)
This eludes me but why care about the performance of a shell scripting language?
Re:Batsh – A language that compiles to Bash and Windows Batch by Maakuth on Tuesday September 02, 2014 @03:08AM (#8256151)
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 by PeterisP on Tuesday September 02, 2014 @02:15PM (#8259184)
What could a shell possibly do so that a basic command would take many seconds?

Currently, "many seconds" is enough time to run an interpreter on the command, connect to a remote machine in Iceland, spin up a new virtual server there, send the command there to be executed, review the execution results for possible exceptions, run a malware scan, fetch the response back, execute the command again on your computer, translate the command and results to Klingon, send them to NSA for archiving, play a quick game of chess with another instance of the shell, and play a congratulatory tune.

Seriously, computers nowadays are fast enough to run a partial compile of your code at every single keystroke while you're writing it. It takes special effort to make a scripting language unusably slow - even an unoptimized interpreter that itself runs on a different interpreter should do just fine.

Re:Batsh – A language that compiles to Bash and Windows Batch by ygra on Tuesday September 02, 2014 @03:24AM (#8256178)
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.
Re:Batsh – A language that compiles to Bash and Windows Batch by Maakuth on Tuesday September 02, 2014 @01:18PM (#8258840)
Hmm, I can't seem to reproduce many such issues with this machine, except Get-Help the first time I tried it. I think it could be that the cmdlets are only slow on the first run (enough to leave me with a bad experience), or the SSD on my PC masks the problem. It's good to know that it's not always super slow.
Re:Batsh – A language that compiles to Bash and Windows Batch by mtdewcmu on Tuesday September 02, 2014 @07:56PM (#8260831)
If it's slow on the first run, then it might be loading a large interpreter from disk. If so, MS might have let the interpreter get a bit ungainly -- you might argue.
Re:Batsh – A language that compiles to Bash and Windows Batch by brazzledazzle on Tuesday September 02, 2014 @12:03PM (#8258345)
I would like to see some examples as well. The only time I've seen performance issues is with third party commandlets (or very lean hosts).
Re:Batsh – A language that compiles to Bash and Windows Batch by malkia on Monday September 01, 2014 @11:53PM (#8255756)
If its part of your build system, then it matters.
Re:Batsh – A language that compiles to Bash and Windows Batch by meowface on Tuesday September 02, 2014 @08:06PM (#8260864)
I use Powershell for many administrative tasks at work, and it can be annoying if querying data from a single machine takes 5+ minutes. Which it does sometimes.
Re:Batsh – A language that compiles to Bash and Windows Batch by knope on Monday September 01, 2014 @05:23PM (#8254746)
b a shell for the win
Re:Batsh – A language that compiles to Bash and Windows Batch by eddiegroves on Monday September 01, 2014 @07:20PM (#8255073)
For simple use cases I still use batch files as the performance is much greater. Powershell feels too heavy when I just want to run a build with some parameters and a couple of other commands.
Re:Batsh – A language that compiles to Bash and Windows Batch by klodolph on Monday September 01, 2014 @08:37PM (#8255224)
I think it's really interesting the way programmers will use phrases like, "it feels heavy", as a way to describe using programs that contain unused features. I'm guilty of the same. Powershell "feels heavy" because it is a lot more sophisticated than batch, you can do all sorts of cool things with WMI or use data structures, but in the end, what does programming in batch actually gain you? If performance is such a problem that you notice a performance penalty when switching between shells, something is seriously wrong.

But I'm guessing you don't really notice the performance difference, you just feel the weight of unused features.

Re:Batsh – A language that compiles to Bash and Windows Batch by GrinningFool on Monday September 01, 2014 @09:41PM (#8255418)
The opposite effect is, IMO, how things like node.js gain in popularity - the environment "feels fast" and "feels simple" [for the simple use cases that are always at the start of things].
Re:Batsh – A language that compiles to Bash and Windows Batch by dpweb on Monday September 01, 2014 @05:50PM (#8254818)
300 million machines still on XP guys..
Re:Batsh – A language that compiles to Bash and Windows Batch by throwaway5752 on Monday September 01, 2014 @08:17PM (#8255185)
Yup, and that's the problem, not bat vs ps1. People said the same things when 98 was EOLed. XP is dead.
Re:Batsh – A language that compiles to Bash and Windows Batch by innocenat on Monday September 01, 2014 @08:46PM (#8255237)
There are still need for real pipe (no buffering) and ASCII I/O redirection. (Not sure if the latter is possible now, though)
Re:Batsh – A language that compiles to Bash and Windows Batch by bkeroack on Monday September 01, 2014 @04:55PM (#8254652)
Totally agree. Powershell is what you need to use on windows. It's been available on the default server install since 2008 R2. No need for batch scripts anymore.
Re:Batsh – A language that compiles to Bash and Windows Batch by rmtew on Monday September 01, 2014 @05:54PM (#8254830)
This sounds like you're saying that it suits your needs, therefore we should take that as meaning it fits our needs. Unfortunately, things are not that simple.

I needed to do something and looked at using powershell, but in the end I couldn't just distribute it and have it work for whomever would be using my project. It needed to be signed or something. On the contrary, the bat script I wrote just worked and would just work for anyone who used the project.

Powershell is not a magical solution that suits everyone's needs. This kind of blanket statement helps no-one.

Re:Batsh – A language that compiles to Bash and Windows Batch by WickyNilliams on Monday September 01, 2014 @07:23PM (#8255078)
There's a config switch to allow execution of scripts. I agree it's a complete pain (literally falling at the first hurdle), but it is a one-time thing change.

I had mixed opinions of powershell when I tried my hand at it. The naming convention and documentation system were well designed, piping objects is an interesting concept, and IDE support was great for a terminal (step through debugger, intelligent auto complete). Despite this, there were numerous quirks and ugly spots that diminished the experience. I felt it was a missed opportunity. This was powershell 3, I can't speak for later versions

Re:Batsh – A language that compiles to Bash and Windows Batch by mtdewcmu on Tuesday September 02, 2014 @08:10PM (#8260876)
Thanks for this candid impression. I had some slight interest in learning PowerShell, but it looked like a little bit too high of a learning curve, given that I had other scripting languages I could use (including bash in Cygwin). Piped objects struck me as interesting when I read about it in a magazine, too, but somehow they aren't needed to perform all kinds of scripting in *nix, so I wonder if they might be more complex than the problem called for. I get the impression that PowerShell may suffer from having come from Microsoft -- a company with bottomless pockets to spend on developing software and probably little need to stop smallish system utilities from becoming ornate.
Re:Batsh – A language that compiles to Bash and Windows Batch by bkeroack on Monday September 01, 2014 @10:40PM (#8255581)

  PS> Set-ExecutionPolicy Unrestricted
It's the first line of just about every publicly-distributed script (including Chocolately, etc).
Re:Batsh – A language that compiles to Bash and Windows Batch by malkia on Monday September 01, 2014 @11:55PM (#8255764)
One of the reasons I'm still afraid to use Powershell - its just not succint enough for normal day to day operations.
Re:Batsh – A language that compiles to Bash and Windows Batch by bkeroack on Tuesday September 02, 2014 @11:36AM (#8258147)
On the contrary, one of the first things I do on a Windows box is open up a powershell window. Especially on Win 8+, it's a lot easier to do "logoff" or "Stop-Computer -Force" or "Restart-Computer" than to try to navigate the mess of Metro to find the GUI menu options. Moving files around on the PS command line is much more efficient than using Explorer, just like bash/Terminal on the Ubuntu desktop. It's just a matter of getting used to it (and learning the different syntax from Unix shells).

PS cmdlets in generally are quite consistent: there is a [Verb]-[Noun] naming convention (eg, "Stop-Computer" above) and full tab completion, so if you forget the exact name of a cmdlet you can do Get-[tab] and cycle through every Get-* cmdlet that exists. Even command line switches tab complete, just type a hyphen and then you can tab-cycle through every command line switch that particular cmdlet supports. There's also Remote Powershell, which is like SSH but also built-in. I can sit in a Powershell window and connect to a Windows server anywhere just like SSH on Linux, or even compose a script block, assign it to a variable, then send it over the wire to be executed remotely (or to a group of machines in a foreach loop). It's pretty slick, and all this is built into the shell--no third-party tools required.

I'm not a big fan of MS, but I'm willing to give them kudos on the rare occasion that they build something nice. Powershell has it's quirks like anything, but it's a damn nice piece of engineering and a godsend to anyone who has to administer Windows boxes. Why anyone would continue with the anachronism of (essentially DOS) cmd.exe is beyond me.

Re:Batsh – A language that compiles to Bash and Windows Batch by ygra on Tuesday September 02, 2014 @03:08AM (#8256150)
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 by nailer on Tuesday September 02, 2014 @12:15AM (#8255810)
Like all software it will be read far more often than it is written. It is optimised for that common use case.
Re:Batsh – A language that compiles to Bash and Windows Batch by malkia on Tuesday September 02, 2014 @10:33AM (#8257781)
Not my experience with batch files / shell scripts, but that's hardly any evidence.
Re:Batsh – A language that compiles to Bash and Windows Batch by mtdewcmu on Tuesday September 02, 2014 @08:13PM (#8260885)
They are read far more often -- by a machine.
Re:Batsh – A language that compiles to Bash and Windows Batch by ams6110 on Monday September 01, 2014 @07:10PM (#8255045)
bash in cygwin.