3 ms·
I should turn this into a FAQ, but PowerShell is natural on Windows, where the OS provides objects (either via the .NET VM, or COM and .DLLs, etc.) A Unix shel
by chubot 6y ago
I should turn this into a FAQ, but PowerShell is natural on Windows, where the OS provides objects (either via the .NET VM, or COM and .DLLs, etc.)
A Unix shell like bash or Oil is natural on Unix, where the OS uses text files. And in distributed systems where data is JSON, YAML, XML, protobuf, msgpack, etc. not objects.
So basically shell is a "situated" language, and the easy of accomplishing any given task depends a lot on the environment.
Windows is more tightly coupled and trying to provide something nice for you. Unix is messier but doesn't limit you, and it's what basically all big systems are made of these days. A major strength of shell is to glue things together that nobody thought should be glued together.
---
Good example here from Paul Bucheit: http://www.oilshell.org/blog/2020/01/simplest-explanation.html#productive-programmers-secretly-use-shell http://www.oilshell.org/blog/2020/01/simplest-explanation.ht...
http://paulbuchheit.blogspot.com/2009/01/communicating-with-code.html http://paulbuchheit.blogspot.com/2009/01/communicating-with-...
However, we needed a way for Gmail to make money, and Sanjeev Singh kept talking about using relevant ads, even though it was obviously a "bad idea". I remained skeptical, but thought that it might be a fun experiment, so I connected to that ads database (I assure you, random engineers can no longer do this!), copied out all of the ads+keywords, and did a little bit of sorting and filtering with some UNIX SHELL COMMANDS
I then hacked up the "adult content" classifier that Matt Cutts and I had written for safe-search, linked that into the Gmail prototype, and then loaded the ads data into the classifier. My change to the classifier (which completely broke its original functionality, but this was a separate code branch) changed it from classifying pages as "adult", to classifying them according to which ad was most relevant. The resulting ad was then displayed in a little box on our Gmail prototype ui. The code was rather ugly and hackish, but more importantly, it only took a few hours to write!
----
Also, use whatever's best for you, but Unix people tend to hate PowerShell:
https://medium.com/@octskyward/the-woes-of-powershell-8737e5346b1 https://medium.com/@octskyward/the-woes-of-powershell-8737e5...
PowerShell feels like it was built by people who had heard about command lines a long time ago and tried to recreate one based on stories passed down through generations of their ancestors
The fact that they cargo-culted operators like -eq, -le, -lt, while not maintaining compatibility is just silly to me. In Oil it's "x == y" for string equality.
- titanomachy 6y agoHadn't heard this story. Wouldn't they already have had some sort of ad relevance engine for Search?
- jayd16 6y ago> JSON, YAML, XML, protobuf, msgpack, etc. not objects. JavaScript Object Notation doesn't map well to objects?
- tick_tock_tick 6y agoNo, have you seem what kind of mish mash of a scheme most systems output? They'd be back to text processing anyway just making sure it returns the expected values.
- diroussel 6y agoAn object should have identify, state and behaviour. JSON only encodes state.
- oblio 6y agoOn the other hand, for interoperability, passing around behavior is horrible. It's either a security risk or a compatibility (forward/backward) risk or both. We should try to pass around just state and keep objects strictly for code.
- chubot 6y agoRight, I'm not really familiar with PowerShell, but my understanding is that the objects in object pipelines are literally .NET objects with methods on them. So the entire shell script is confined to the .NET VM? In that case, I would hesitate to even call it a shell in the traditional sense. Shell has a kind of code <-> data <-> code <-> data architecture, i.e. programs in different languages processing standard language-independent data formats (lines of text, JSON, HTML, QSN, etc.) It's more like functional programming, where functions stand alone. (And note Oil is in a very OO style, because it deals with significant program state, so I'm not against objects. Right tool for the right job.) ----- Other questions: What if I want to pass some data to R and plot it? Or throw away some outliers with a little formula? I now have to figure out how to serialize those objects. Or do I have to write an R interpreter for the .NET VM? :) What about splitting the pipeline over two different machines? I can do "ssh user@host find / -type f" trivially in shell. And I do this in practice, e.g. in Oil's continuous build: http://travis-ci.oilshell.org/jobs/ http://travis-ci.oilshell.org/jobs/ "Distributed objects" have proven to be a bad idea. "Real" (large scale, deployed) distributed systems are architected more like Unix than Windows. The point of shell is to integrate disparate tools, so if there are some privileged tools in the .NET VM, and then some other tools that require a lot of work to get at, then that misses the point IMO.