24 ms·
PowerShell is my guilty pleasure of the computing world. Once you've piped strongly-typed objects around between your shell commands, text scraping seems barbar
by Analemma_ 10y ago
PowerShell is my guilty pleasure of the computing world. Once you've piped strongly-typed objects around between your shell commands, text scraping seems barbaric by comparison. The problem, of course, is that you can't use all that power for much, since the pool of PS-compatible tools and utilities is much shallower than it is for Unix shells. I'm really hoping this will help spur a new wave of PowerShell-compatible tools.
Come to the dark side, we have (strongly-typed) cookies.
- kevan 10y agoI really hope this drives a new wave of experimentation and development in shell interaction. Text as the lowest common denominator will never go away but having more powerful constructs available will be great for a lot of use cases.
- otabdeveloper 10y agoCheck out the language I wrote for that exact use case: http://tkatchev.bitbucket.org/tab/ http://tkatchev.bitbucket.org/tab/
- htor 10y agoStrongly typed cookies you say.. Maybe we all can just write our scripts in Haskell and eat some delicious type cake!
- amenod 10y agoIs this really so useful in practice? I have never used PowerShell before (nor do I have plans to do so in the near future), but I would imagine the downside is complexity, both for user and especially for developers. With text you just read and parse, while with objects you need to know the object type, its fields,... Whatever happend, I hope text stays here (and I have a bad feeling about it ever since I met systemd).
- UK-AL 10y agoObjects are discoverable in powershell. Enter the object, and lists the object out as text.
- vvanders 10y agoYes, this is so awesome. Can't remember the exact parameter/field? Just dump it to the console.
- UK-AL 10y agoThat what you would do with text? If you have no idea what its outputting, explore it by putting it to the console.
- vvanders 10y agoSure, but with text you might have empty fields that are just omitted. With Powershell you can see that the field exists but is empty. There's a bunch of subtle distinctions like that which don't sound impressive but end up being really nice when working with it.
- WorldMaker 10y agoWhat you can't do so easily with text is also just auto-convert that object directly to JSON or YAML or CSV, for that matter, and forward that easily into your favorite JSON/YAML/CSV exploration tool.
- amenod 10y agoOk, that sounds good. But what if some developer decided that some field would have prefix "ABC" in all values, then the value I am interested in, then some value I am not interested in at the end? (you say this can't happen? Clue: WMI.) Can I take the value, convert it to string, make some magic on it and convert it to another object entirely? I don't know, I never had any problems with text parsing. I love strong types in programming languages, but in system administration I think it would only get in the way. But as I said, never tried it, so I might be missing something.
- wvenable 10y agoI love the strongly-typed cookies but I absolutely hate the powershell syntax. It's like C# and Bash got together and had a really ugly baby.
- AimHere 10y agoAs long as you bear in mind that it's main purpose is a usable replacement for the CMD.EXE batch language, then you should be willing to forgive Powershell it's warts.
- wvenable 10y agoExcept that they added a bunch of new warts that don't have any relation to CMD.EXE. They took the opportunity to re-invent how a shell works from the strongly-typed object perspective but then they copied some of terrible syntax of 40 year old unix shells. I just don't understand it. I'd rather write scripts in pure C#.
- emodendroket 10y agoThe point of PowerShell isn't just to write scripts but to work as an interactive shell.
- wvenable 10y agoI'm not at all convinced that the syntax is any better for typing in as commands in an interactive shell.
- emodendroket 10y agoI think it works pretty well for that beyond the weird omission of anything like &&
- wvenable 10y agoIt works fine as an interactive shell but that's not exactly high praise. It could be better for that and for scripting but instead tries to be more familiar to bash users. As a bash user, I'm terribly happy about it's syntax either but it's the price to pay for 40 years of backwards compatibility. Powershell has no such excuse.
- dleslie 10y agoAs a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preventing a developer from using Perl, Python, Lisp or any other language that allows itself to accept stdin as an interpreted script. 0: https://scsh.net/ https://scsh.net/ 1: http://www.haskellforall.com/2015/01/use-haskell-for-shell-scripting.html http://www.haskellforall.com/2015/01/use-haskell-for-shell-s... 2: http://www.tcsh.org/Welcome http://www.tcsh.org/Welcome Edit: oh my, I posted the wrong link for tcsh. No one noticed, but my apologies nonetheless.
- codemac 10y agoI want to throw my support behind scsh! It's useful for those things that cross the boundaries between a program, and a shell script. I've found once you need functions for a shell program, it's time to step up to scsh. I also wish scsh ports were more well maintained so people could use their favorite schemes with scsh syntax, but it's quite a large codebase to port, so remember that it's scheme48 scheme.
- patrickmay 10y agoI thought I was the last person using scsh! Now if I could just imbue my coworkers with your good taste....
- codemac 10y agoNice! :) I write a lot of my stuff in guile when it's more formalized, but scsh's run syntax is just the bees knees. Can't get rid of it.
- qwertyuiop924 10y agobits of SCSH have been ported to every scheme out there now. And some have been improved. Irregex, in particular, is a dramatically improved version of the SCSH regex engine.
- 10y ago
- agumonkey 10y agoI wonder what's the difference between an object-pipable shell and a lisp machine (only 10% troll here). Kalman Reti said that passing pointers as IPC meant zero perf penalty btw. Text serialization has design value sometimes, but the amount of cpu cycles allocated on string munging seems flabbergasting.
- njkanjsd 10y agoSo many strongly typed shells exist already. I don't understand why arbitrary microsoft shit gets so much love for doing things that have already been done in the OSS world, and doing them poorly. PowerShell is a pile of shit.
- Analemma_ 10y ago> So many strongly typed shells exist already. But no one uses them, and no one is building an ecosystem around them. That's what I'm hoping will change thanks to this announcement. Even if it's not PowerShell itself, if a different strongly-typed shell gets traction because of this, I will be happy. That's what I was trying to say with my comment.
- njkanjsd 10y ago> But no one uses them, and no one is building an ecosystem around them. About as many people that use powershell, the only people I've seen say nice things about powershell are microshit fanboys that don't know any better. Not sure what you mean by 'ecosystem'.. a very ambiguous term. Linux already has a 'shell ecosystem' far superior to anything windows has. > Even if it's not PowerShell itself, if a different strongly-typed shell gets traction because of this, I will be happy. I don't see why it would, or why powershell would help it get traction. There is not really a good reason to even use a strongly-typed shell, if you need strong typing why not just use a proper programming language? If you need interactivity why not use a REPL? > That's what I'm hoping will change thanks to this announcement. No self-respecting OSS developer would want to use powershell.
- geophile 10y agoAlong the same lines, for Linux and MacOS: https://github.com/geophile/osh https://github.com/geophile/osh
- kondor6c 10y agoInteresting, nice work
- derefr 10y agoElixir's REPL (iex) makes a surprisingly-good environment for "pip[ing] strongly-typed objects around between your shell commands." It could use a form with added convenience magic, the way Pry is for Ruby, but I've managed to do some decent interactive ops work on systems through an Erlang-remote-shell (remsh) connection to an IEx shell.
- mhurron 10y ago> Once you've piped strongly-typed objects around between your shell commands, text scraping seems barbaric by comparison This is why Powershell is a great thing on Windows. Windows works with .Net objects and Powershell works directly with those objects. It's also why I don't see the reason to be excited that it can run on OS X and Linux now, because neither of those systems work by passing .Net objects around. You parse text with bash/sed/awk/perl/python ... because *NIX works on text based config files and commands that output text.
- ygra 10y ago> Windows works with .Net objects and Powershell works directly with those objects. I'd say COM, WMI, and the registry are more prominent parts of Windows itself than .NET is. However, PowerShell seamlessly works with those as well.
- jdmichal 10y agoI'm assuming that the Powershell port includes some subset of the standard cmdlets, which will handle serializing to and from objects.
- mhurron 10y agoA subset means it doesn't work as well or the same way.
- jdmichal 10y agoNo... It just means that all features may not be available. It makes no comments on how well the existing features work and how compatible they are with the Windows version. I mean, `Get-ComputerRestorePoint` and `Get-WmiObject` don't mean anything on Linux. I assume those won't be ported. `Get-Process` is certainly meaningful; I assume that will be. The ports might also have cmdlets not available on Windows. I could certainly see cmdlets to interact with `apt` in Ubuntu, or `yum` in RHEL. Especially since PowerShell is focused on provisioning and managing machines.
- Theodores 10y agoBack in the day I thought VAX/VMS was amazing. Particularly things like file versioning, however, I had to leave it behind and do things on UNIX (and then Linux) terminals. That change was relatively painless even if I did delete a file or two that I should not have. However, I have moved on and nowadays I would not have a clue how to use VMS beyond typing 'dir'. If the VMS 'shell' was suddenly available on Linux, despite its 'proven' benefits in various scenarios, I just would not have the working knowledge to get going with it again. Furthermore, there would be no easy answers on StackOverflow to do basic things such as recursively renaming part of all filenames, or batch modifying the content of said files. The problem PowerShell has for me is that it might as well be a souped up version of VMS (or even BBC Basic). It is not that I am adverse to learning, it is just that I left Windows World a long time ago. Much like my move from VMS to UNIX, there were some good things that I left behind (such as the file versioning thing), however, if you move to a new way of working then there is no need for the old stuff. I appreciate that PowerShell is new, but it does not suit my way of working, i.e. cribbing answers from StackOverflow and tutorial guides.
- jodrellblank 10y agoI appreciate that PowerShell is new, but it does not suit my way of working, i.e. cribbing answers from StackOverflow and tutorial guides. PowerShell is ten years old and there's 37,000 StackOverflow questions tagged to it - http://stackoverflow.com/questions/tagged/powershell http://stackoverflow.com/questions/tagged/powershell
- chetanahuja 10y ago"text scraping seems barbaric by comparison" "can't use all that power for much, since the pool of PS-compatible tools and utilities is much shallower than it is for Unix shells" The explanations are obvious though... aren't they. Text might be barbaric, but every programming language in the world makes sending text to stdout dead easy. The unix shell utilities are smart to support that case.
- twistedpair 10y agoIIRC correctly, the major PowerShell push started with Win Server 2008, and headless server mode (no desktop). A lot of WinX sysadmins pissed their pants that they couldn't use GUI's to control everything, and PowerShell was pushed as the way to do server management w/o GUI's (crazy, I know).
- grandalf 10y agoCare to post a few simple powershell examples that do the sorts of things those familiar with typical nx shell scripting might find useful?
- Ericson2314 10y agoI don't think it's too late for PowerShell, I think it's too late for UNIX. You need a big CLR ecosystem for this to play out. If somebody resurrected Midori as a CLR Unikernel I'd be very pleased.
- CrLf 10y agoAfter a number of years using PowerShell, my conclusion is the opposite: text "scraping" is just better for most cases. Normal shell usage means doing a lot of one-shot pipelines incrementally. This is just easier and faster to do when passing text around because you can look at it and not have to inspect some object for it's type and what attributes/methods it provides. Parsing the text is not the problem here (although many people think it is), reasoning about what we're trying to do is. And the over-verbose syntax doesn't help. I compare this to human languages. It would be tempting to create a language with minimum ambiguity and clear cut concepts, but it wouldn't be practical. I guess PowerShell as an interactive shell is somewhat like this. For automation, PowerShell is nice. The language sits between a shell script and going the Perl/Python route, but I still prefer shell scripts for simpler things and Perl/Python for more complex tools. Having said this, PowerShell is the only sane choice on Windows and has made my life easier by no small amount. I never enjoyed managing Windows servers with their focus on GUI tools and their terrible CLI. PowerShell changed that and even "invaded" products like SQL Server and Exchange making them also nice to manage.
- all2well 10y agoI'm not entirely convinced that "plain text" is "simple." For one, utf-8 is a variable-length encoding, which can cause all sorts of subtle bugs and sometimes leads to security issues because somebody failed to parse a character correctly somewhere. On top of this, using plain text means that every program has to choose its own control characters, essentially an encoding within an encoding. This is great for readability, but it's not always easy to know how a certain program will treat certain corner cases, or even really just at all. I'm not sure what you mean by "you can just look at the text," because unlike something that encapsulates functionality alongside the data, text input into a program might do anything.
- userbinator 10y agoFor one, utf-8 is a variable-length encoding, which can cause all sorts of subtle bugs and sometimes leads to security issues because somebody failed to parse a character correctly somewhere. UTF-8 is nice in that extended characters, despite consisting of multiple bytes, will never contain a low-ASCII character amongst them. Unless you're dealing with byte offsets, splitting and scanning UTF-8 strings by delimiters works just like ASCII. because unlike something that encapsulates functionality alongside the data, text input into a program might do anything. On the other hand, that "encapsulated functionality" is even more hidden and non-obvious. Unlike a stream of bytes that you can easily inspect simply by dumping them into a file, PowerShell objects are far more opaque entities.
- acscott 10y agoIt's junk. Tried to get something useful done and version incompatibilites and poor documentation made it a losing battle. Type theory is over-wrought for getting things done. My boss doesn't care that I have to cast an integer to a string.
- cburnette 10y agoPowershell is aweful
- ultramancool 10y agoI'm hoping this means running EF migration scripts on Linux will be less of a nightmare. It was one of the biggest issues I ran into developing a Web application in .net hosted on Linux.