r/programming • • Mar 30 '16

Microsoft is bringing the Bash shell to Windows 10

http://techcrunch.com/2016/03/30/be-very-afraid-hell-has-frozen-over-bash-is-coming-to-windows-10/
5.5k Upvotes

1.2k comments sorted by

View all comments

18

u/planetmatt Mar 30 '16

What's the advantage of Bash over Powershell?

0

u/[deleted] Mar 30 '16

[deleted]

76

u/santsi Mar 31 '16

I heard even Windows is implementing it!

7

u/nooneelse Mar 31 '16

Someone was just pulling your leg with that ludicrous sounding joke.

37

u/ep1032 Mar 30 '16 edited Mar 17 '25

.

59

u/TikiTDO Mar 30 '16

Bash vs Poweshell is not really a good comparison.

Bash is a very slim, light-weight shell and scripting environment. It spots a minimalistic procedural programming language (variables, conditionals, function) with a few useful shorthands to handle things like parameter expansion, substrings, and process execution/management. Pretty much the only thing you do in bash is call other programs, do a bit of processing on the output, and then call more programs.

Poweshell is a monolithic system that natively exposes a mass of internal windows functionality, with an ever growing set of language features; the latest version is even object oriented. The idea of Powershell is that you almost never need to leave the PS environment. In that way Powershell is actually closer to python or ruby than it is to bash.

The reason that people like bash is twofold. First, it's been around forever; the first release was in 1989. That means that there are a ton of examples, a huge number of existing scripts, and legions of people that know the environment inside out. Second, it doesn't try to do too much. Bash embraces the *nix philosophy of tying together tools that do one specific job really well. That means you're not tied down to the "accepted" way of doing things.

In a way, it's like comparing a Lego set, and a model car. The car will look way nicer, and have a lot of intricate details, but it will always be a car. With a Lego set you can build a car, a space ship, or a castle, then tear it down and start again with something new.

Of course there are those that will happily point out that you can do everything bash does in powershell. To those people I will answer that you can do it all in brainfuck too, but most sane people still prefer to use the tools best suited for the job.

8

u/codekaizen Mar 31 '16

Powershell is not that monolithic and not really that heavy. To get anything done in Bash you need utilities, and the corresponding thing in PS is modules. I hear a lot of FUD like this from people who haven't really spent time with Powershell, but rather looked at some examples geared to Windows admins and made up their minds.

5

u/TikiTDO Mar 31 '16

Compared to bash, Powershell is huge. This is bash in a nutshell. Every single command is a tool you can use in support of calling external tools. By contrast, Powershell has a whole load of commands, many making assumptions about the system it's on, and the functionality that is supported. Before we get into discussion of modules, it's simply a point of fact that Powershell has over 4x the number of built in commands.

The way modules are treated in Powershell is also different from the way executables are treated in bash. In PS modules are distinct objects that can be configured, documented, packed, and distributed. In bash you just make anything in your path executable, and bash will happily run it. It just so happens we usually use bash with the GNU toolchain, which provides a good chunk of the features that Powershell offers natively, as well as a number of features similar to default Powershell modules.

I'm not necessarily saying this makes Powershell worse in any way. It's just a different design philosophy. Bash is about using whatever tool suits your needs while making only the most minimal assumptions. Meanwhile Powershell is about giving developers a lot of tools that they can use to manage a Windows machine.

0

u/[deleted] Mar 31 '16

[deleted]

1

u/tentacular Mar 31 '16 edited Mar 31 '16

You're fucking with me. A lambda character is a command?

1

u/TikiTDO Mar 31 '16

That's his prompt terminator. The command he ran is gcm.

→ More replies (9)

2

u/jeffsterlive Mar 31 '16

Using the Powershell ISE I think would make people more comfortable with using it initially. It has auto-complete and in-line documentation for the command-lets. It really isn't that bad I agree with you.

1

u/jewdai Mar 31 '16

Comparing powershell to bash is like apples to oranges.

Bash is a series of precompiled utilities down to machine code

Powershell is a precompiled utilities down to Intermediate Language (like java bitecode) it is then Just In Time Compiled by the Common Runtime Library (CLR) and then executed by the process.

It's much more heavyweight than bash; however, offers language interoperability like accessing C# objects in powershell.

1

u/roffLOL Mar 31 '16

bash is not a lightweight shell. it's a heavy shell. but it's way lighter than powershell.

1

u/DrScabhands Mar 31 '16

Brainfuck doesn't have file i/o, networking, etc

1

u/TikiTDO Mar 31 '16

It has direct memory access though.

1

u/DrScabhands Mar 31 '16

I haven't heard of an implementation like that

2

u/[deleted] Mar 31 '16

dunno bout powershell but as an example I've been calling the same rsync script from bash in OS X since like 2004 and my IT guy has it running on a linux terminal in a closet somewhere.

1

u/Greydmiyu Mar 31 '16

None. They both can start my Python scripts just fine. >.>

-10

u/sactomkiii Mar 30 '16

PowerShell sucks donkey nuts

2

u/Throwaway_bicycling Mar 30 '16

Okay, so technically this does nothing to advance the conversation here...except that the name of this thread made me recall "csh considered harmful". And, I guess "Powerrshell sucks donkey nuts" could be the title of a shell-focused diatribe in 2016.

I mean, that has to be what /u/satcomkii had in mind, right?

1

u/planetmatt Mar 30 '16

Why's that? I've never used *nix.

3

u/[deleted] Mar 31 '16

PowerShell honestly feels more like a weird cumbersome scripting language than a shell. I almost always find myself wishing I'd just wrote something in C#.

bash is very lightweight and simple, it's all about passing around streams of text and calling other little utility programs like echo, cat, grep, awk, sed, sort, uniq, wc, nl, find, xargs, etc.