5 ms·
PowerShell also plays nicely with COM and WMI. It's not all .NET objects you interact with. (Well, technically it is, due to PSObjects wrapping everything, but
by ygra 12y ago
PowerShell also plays nicely with COM and WMI. It's not all .NET objects you interact with. (Well, technically it is, due to PSObjects wrapping everything, but that's another matter.)
How would you do it, though? Pipe around JSON or XML? Then you just have data structures, but not objects. They can't have methods and if they could, what language would they be written in?
- optimiz3 12y agoWell, if it was me... 1. Replace PowerShell with a .Net interpreter so you can "just run" a .cs_exe file or whatever. No one wants to learn/deal with yet another throwaway proprietary scripting language. 2. Replace all the PowerShell cmdlet garbage with .Net libraries. You'd also be able to then trivially automate any scripting from existing .Net programs/tests. 3. Have a JavaScript -> .Net compiler so people don't have to deal with C# or VB.Net if they don't want to. Scripts look something like (C# in this case): using Microsoft.Scripting void Main() { SQLServer.Configure(<SOME JSON>); var result = IIS.Start("MyWebPage"); if (!Installed(<some windows package>)) { File.Install() } if (!UserExists(server, user)) { CreateUser(user) } } You can't do all of this today (at least not easily or without installing many extraneous or 3rd part libs which create deployment headaches). EDIT: for clarity.
- MichaelGG 12y agoMicrosoft has had a JavaScript compiler for a while (JScript.NET). I don't think it gets much use. They also had a Java compiler. PowerShell is far better for scripting than C#. C# is terribly verbose and lacks scripting-ish stuff like string interpolation. I'm not sure it even had dynamic when PowerShell was made. It is pretty dumb that C# still hasn't shipped a proper REPL or script runtime though.
- optimiz3 12y agoJScript.net has never been a first-class citizen, and Microsoft never really made an effort to make it viable in all of the domains C# is. JScript feels like an attempt to embrace/extend JavaScript that never took hold. The problem is that rather than adding libraries to improve .Net for scripting-ish stuff like string interpolation, you have to deal with an entirely different platform that shares little with the command line, and little with .Net.
- Locke1689 12y agoIt is pretty dumb that C# still hasn't shipped a proper REPL or script runtime though. Workin' on it.
- msie 12y agoThis is an amazing repl recently released: http://channel9.msdn.com/coding4fun/blog/REPL-for-the-masses-CShell-give-you-an-open-source-C-REPL-IDE http://channel9.msdn.com/coding4fun/blog/REPL-for-the-masses...
- Touche 12y agoI don't think we can design this in HN comments... all I'm saying is that it should have been a Day 1 requirement that it is low-level enough to work with any modern widely-used programming language, on a first-class basis. That's what the comment I quoted is saying, Microsoft likes to do big up-front designs that restrict their platform to uses that they have already thought about.
- UK-AL 12y agoPowershell was an internal grass roots product, I think. I read it somewhere so may or may not be true.
- brudgers 12y agoSnover specifically set out to design "the next generation platform for administrative automation" in 2002. See the Monad Manifesto: http://www.jsnover.com/Docs/MonadManifesto.pdf http://www.jsnover.com/Docs/MonadManifesto.pdf And Snover's description of the process almost a decade later: http://www.jsnover.com/blog/2011/10/01/monad-manifesto/ http://www.jsnover.com/blog/2011/10/01/monad-manifesto/
- gohrt 12y agoWas there a connection to the math/CS concept of "monad", or did Snover intentionally pick a name that would guarantee eveyone would be afraid of it? from http://www.jsnover.com/blog/2011/10/01/monad-manifesto/ http://www.jsnover.com/blog/2011/10/01/monad-manifesto/ > I had had a number of conversations with our team in India where everyone shook their heads and smiled and seemed to get it but then the code clearly demonstrated that they had absolutely no clue what I was saying but weren’t telling me that. > We tried a number of times to get very precise in our documentation but time and time again, it was clear that they just weren’t getting the concept Wow, Microsoft Architechture Astronaut in a nutshell. He handwaves an idea, and then complains when someone actually writes some code and it doesn't match his imagination.
- 12y ago
- SideburnsOfDoom 12y ago> How would you do it, though? Pipe around JSON or XML? Then you just have data structures, but not objects "just data structures" is a subset of objects - they are objects with data but no methods. i.e. DTOs. They're not always useful, but to say that they can't be accommodated in a pipeline because they "aren't objects" is not quite right.
- ygra 12y agoGranted, but a lot of niceness in PowerShell comes from the fact that you're not just piping around objects. As in, you don't need special commands to handle certain sorts of output (though there are things liks Stop-Service, Stop-Process, etc.) because you can just as well call the appropriate methods.
- dragonwriter 12y ago> Pipe around JSON or XML? Then you just have data structures, but not objects. They can't have methods and if they could, what language would they be written in? You could pipe around DTOs like that, and as long as they had a structure that attached typing information to them, you could use something like intents (similar to those in Android or Web Intents) to attach "methods" to them. The executables implementing behavior could be written in any language that the platform could run.