News for hackers. Stuff that matters.
Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @07:06PM (#22571647)
The only problem is that Powershell as language is pretty bad. I wouldn’t want to write my vB6 projects in Powershell.
Re:Microsoft plots the end of Visual Basic by Pxtl on Saturday March 14, 2020 @07:50AM (#22574623)
Yeah, I write a ferocious amount of PowerShell it's an amazingly bad language. I use it for its API, but its language design is a nightmare.

I'm not talking about its unorthodox syntax - that's the least of its problems. The language is hellishly inconsistent and has an inexcusable number of legacy issues for being so young.

And the quality of the standard library is poor. More and more often I find I have to drop down into .net commands to work around showstopper bugs in their PowerShell wrappers.

Re:Microsoft plots the end of Visual Basic by SOLAR_FIELDS on Friday March 13, 2020 @07:11PM (#22571677)
It’s definitely one of the ugliest languages (syntax wise) that enjoys widespread usage, at least in Microsoft land.
Re:Microsoft plots the end of Visual Basic by Fr0styMatt88 on Friday March 13, 2020 @10:54PM (#22572806)
I don't find it ugly, just strange. It's optimized for interactive usage though from what I understand. I think of it mostly as calling .NET methods that all have named parameters:

myfunc -param1 this -param2 that

instead of:

myfunc(param1: this, param2: that);

I get the impression it's designed with the intent that you're supposed to type the dash, then hit Tab to get tab-completion in most cases. Same with the verb/noun syntax (I know I want to 'Get' something, so typing Get-<Tab> for the list of things is usually the thing to do). I do find it a bit difficult sometimes to think of an approprioate verb right off the top of my head (is it Get- or New- that I need?).

I'd also love to see the concept of proper namespaces in PowerShell; it seems really inconsistent right now (unless I've missed something). For example, type Show-Command and hit ENTER, then look at the different modules that are available. Some will express a 'namespace' by having it prepended to the noun (see for example, commands from the BitLocker module, their nouns all start with BitLocker) while others express no namespace at all (see for example commands from the 'Dism' module). For everyday use I've gone with the 'add the name to the noun' approach in my own scripts. That does mean I tend to use short namespace names though.

I've mentioned this in an older PowerShell-related thread here - MenuComplete is absolutely awesome and improves the PowerShell experience in the console. I actually think it should be the default. If you havent already, try these commands:

Set-PSReadLineKeyHandler -key Tab -Function MenuComplete

Set-PSReadLineOption -ShowToolTips

PowerShell is my full-time shell in Windows now (and it will be in Linux also when I get back into it); I rarely use CMD for anything and parsing text in bash just seems antiquated.

Re:Microsoft plots the end of Visual Basic by worldsayshi on Friday March 13, 2020 @07:17PM (#22571702)
It seems that shell scripting languages tend to be quite ugly out of necessity? I mean bash is not a looker.
Re:Microsoft plots the end of Visual Basic by samatman on Friday March 13, 2020 @07:43PM (#22571844)
It isn't inevitable by any means, fish shell scripting is clean and pleasant.

I use fish as my command line, but I still write scripts in bash, even personal ones I only expect to use on my own machine. Just out of a vague sense that I might reuse it, or it might escape confinement, or something.

Re:Microsoft plots the end of Visual Basic by mattmanser on Friday March 13, 2020 @07:29PM (#22571765)
They had an opportunity to make a whole new, good, scripting language. And blew it spectacularly.
Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @07:35PM (#22571801)
The decision to make the console output as the return value of a function alone almost destroys it for larger scripting projects. It’s a really bad decision and they could still fix it by adding some environment variable that disables this “feature” while staying compatible with old scripts.
Re:Microsoft plots the end of Visual Basic by ptx on Saturday March 14, 2020 @07:09AM (#22574467)
This behavior? https://devblogs.microsoft.com/powershell/suppressing-return...

It seems like it might make some kind of sense, since it doesn't output directly to the console but rather to a pipe. Bash functions sort of work the same way since they don't have complex return values (aside from exit codes) other than the function's output stream.

Re:Microsoft plots the end of Visual Basic by Fr0styMatt88 on Saturday March 14, 2020 @09:50AM (#22575249)
Yeah, keep in mind that the output is a fully-fledged object, it is not the text you see. The text is generated by the PowerShell host if the returned object makes it back there and the host is set up to present that object to the user that way.

Take the following in PowerShell:

ls | sort DateTime -d

ls returns an array of objects, sort then sorts the array by each object’s DateTime field (and here I’m asking it to sort in descending order with -d). The point is that sort isn’t depending on any text output, so it works with any array of objects regardless of the command that returned them.

The other cool thing this enables is auto-complete awareness in the shell. If I typed:

ls | sort <Tab>

then the shell knows what makes sense in auto-completion here as ls has an actual return type and in this case it will give me a list of available fields that I can sort on.

For those unfamiliar: ls and sort here are shortened aliases to more wordy verb-noun commands. These (as well as a large bunch of others) are given to you by default.

Re:Microsoft plots the end of Visual Basic by pjmlp on Sunday March 15, 2020 @03:42AM (#22582017)
Yeah, PowerShell is the only mainstream shell that behaves like the REPL environments from Xerox PARC workstations.

Structured data with direct access to any OS API, regardless how it is provided, .NET, COM or straight C like DLL.

UNIX world never had that, beyond trying to fit language repls as user shell, which on UNIX always feels like a leaky abstraction.

Re:Microsoft plots the end of Visual Basic by apalmer on Friday March 13, 2020 @08:32PM (#22572051)
PREACH

But just so you are aware you can use the 'class' modifier To change this behavior.

It is one of the most fundamentally bizarre language design choices I have seen in my career

Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @08:54PM (#22572172)
I have used classes too but this has all kinds of other weird behavior.
Re:Microsoft plots the end of Visual Basic by SOLAR_FIELDS on Friday March 13, 2020 @07:28PM (#22571757)
Possibly, though bash is from a much earlier time when shell scripting language design probably wasn’t a very well known topic and bash evolved more naturally from open source. Powershell is much more recent plus had much more complete control over the language to prevent the kind of syntax warts bash has. Even then I would still probably take bash over Powershell for scripting but that’s probably more because of familiarity than anything else.
Re:Microsoft plots the end of Visual Basic by asveikau on Saturday March 14, 2020 @12:33AM (#22573213)
The first release of bash was in 1989. Shell scripting was already a thing at that time. Csh and ksh were also around for roughly a decade at that time. I think you are confusing bash with sh with this kind of statement.
Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @07:16PM (#22571695)
The cmdlets are super useful but the language is just really weird.
Re:Microsoft plots the end of Visual Basic by mattmanser on Friday March 13, 2020 @07:27PM (#22571753)
Is it widespread? I've never seen anyone else using powershell 'in the wild', admittedly for the last 3 years I've mainly worked alone, but I still see people using CMD scripts.

I usually get frustrated with it and bash out a quick cmdlet instead.

Re:Microsoft plots the end of Visual Basic by vbezhenar on Friday March 13, 2020 @07:46PM (#22571856)
CMD is the worst language I ever saw. It's full of hacks for simplest tasks. The only reason I'm using it is for old systems where PS is not preinstalled.

I used PS to write small scripts and I actually like it. I'm more fluent with bash, but that's only because I used bash a lot. PowerShell feels more robust, no silly space-in-filename problems, no silly parsing of text output to access fields. May be it's ugly for big scripts, I don't know, for me it looked like a vastly superior version of shell.

I would love to learn why people think that power shell is ugly, especially comparing with bash.

Re:Microsoft plots the end of Visual Basic by mattmanser on Friday March 13, 2020 @09:14PM (#22572315)
For me the big problem is that I know it can do loads, but it's not C#. So between the awkward wait for it to boot, the stupid naming convention, and the knowledge that the whole power of the .net framework should be at my finger tips, but in a really alien and unintuitive way, I prefer to either write a really small bat, or write a small C# console app.

And so I never become comfortable with it, even though I've tried several times since it was released.

The newer IDE is pretty good too.

But C# shows what it could have been if they'd had a talented language designer do it (which no-one can determine if someone is beforehand I admit).

I just wish they'd admit defeat and just use a subset of C# instead of stubbornly sticking with something that seems fairly widely loathed.

Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @07:55PM (#22571896)
"I would love to learn why people think that power shell is ugly, especially comparing with bash. "

I don't think people compare it with bash, but with more modern languages.

Re:Microsoft plots the end of Visual Basic by gerdesj on Friday March 13, 2020 @08:44PM (#22572102)
One criticism I've seen and levied myself is the sheer amount of typing:

[PS] C:\> Get-MyReallyLongFunctionName -Server furtle

$ lol --floop

PS is fine but it takes ages for the bloody thing to wake up and notice command completion. It is like dealing with a teenager in bed.

Actually, I have no problems with PS but with MS's idea of search as deployed to users.

(I run KDE on Arch. Search is faster than I can blink)

Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @08:58PM (#22572194)
Verb-first was also a bad choice. When I type “get” I am getting thousands of suggestions which makes autocompletion pretty useless. There is also no way to find all cmdlets that deal with active directory. It would be much better if I could type “AD” first and then get all cmdlets that deal with active directory.
Re:Microsoft plots the end of Visual Basic by InvaderFizz on Friday March 13, 2020 @09:12PM (#22572305)
Try:

  man *-AD*
Re:Microsoft plots the end of Visual Basic by ygra on Sunday March 15, 2020 @02:42AM (#22581809)
You want Get-Command here, usually, not Get-Help.
Re:Microsoft plots the end of Visual Basic by kuzimoto on Friday March 13, 2020 @09:39PM (#22572441)
I don't think it's that bad. Better than bash where every command has is either something archaic or just what whoever wrote it wanted it to be. It better resembles English than the other way around. Plus you can use "get-command "something`" which gives you everything that contains that string, or search for a certain provider for all commands related to a specific thing.

Autocompletion still works, just type first letter or two after get and filter most stuff out.

Re:Microsoft plots the end of Visual Basic by vbezhenar on Saturday March 14, 2020 @07:08AM (#22574462)
Powershell was made to allow launching arbitrary programs with redirections and pipes. That's why some language choices were made and that's why I'm interested in comparison with bash.
Re:Microsoft plots the end of Visual Basic by toyg on Friday March 13, 2020 @07:35PM (#22571798)
sysadmins who are fully invested in the MS ecosystem do use it a lot. People doing cross-platform work, don’t.

In terms of wider adoption, it suffered by maturing at a time when a lot of people had moved on to more powerful devop solutions. And of course, being MS tech (although technically it was acquired), it carries a stigma.

I just found it un-intuitive, ugly, and verbose. Compared to my beloved python it looks really really bad.

Re:Microsoft plots the end of Visual Basic by zozbot234 on Friday March 13, 2020 @09:27PM (#22572390)
PowerShell is cross-platform these days.
Re:Microsoft plots the end of Visual Basic by nbevans on Saturday March 14, 2020 @06:44AM (#22574397)
I don't believe PowerShell was 'acquired' - it was built in house. I can recall reading the MSDN blog posts about its development way back when.
Re:Microsoft plots the end of Visual Basic by fortran77 on Saturday March 14, 2020 @12:08AM (#22573111)
I probably write a few lines of Powerhshell every day. All my automation is done in Powershell, including bringing up new Amazon AWS instances, etc.
Re:Microsoft plots the end of Visual Basic by Ididntdothis on Friday March 13, 2020 @07:33PM (#22571788)
It’s pretty widespread if you have to do sysadmin scripting. There are a lot of useful cmdlets. I am embarrassed to admit that I also run it on my Mac with good success.
Re:Microsoft plots the end of Visual Basic by PascLeRasc on Friday March 13, 2020 @07:33PM (#22571791)
bash out

Freudian slip?