News for hackers. Stuff that matters.
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.