3 ms·
We have all of that in C# without the rediculously bad syntax. It's such a shame powershell didn't come 2 years later, I feel like they'd have had no choice bu
by mattmanser 9y ago
We have all of that in C# without the rediculously bad syntax.
It's such a shame powershell didn't come 2 years later, I feel like they'd have had no choice but to use C# instead of inventing a new language.
- ZenoArrow 9y agoI realise this is a bit of a cop out, but it's fairly easy to mix and match PowerShell and C# code, even without needing to precompile C# code, by using Add-Type. It's worth noting that all code in .NET is enclosed within a type (at a fundamental level .NET code is either contained within a value type or reference type, but knowing those names isn't important when you're starting out), so this doesn't limit you to creating/importing data types, you can use it to write inline C# functions too. It's also interesting to note that the .NET Framework comes with its own .NET compiler, so you don't need to install any dev tools on Windows to code in C#, it's possible to do so with the tools that are available out of the box. If you want to try out referencing C# code using Add-Type, the following article is a good introduction: https://blogs.technet.microsoft.com/stefan_gossner/2010/05/07/using-csharp-c-code-in-powershell-scripts/ https://blogs.technet.microsoft.com/stefan_gossner/2010/05/0...
- JeffreySnover 9y agoWe thought about that but the reality is that it does not work well for interactive experiences. When you look at how admins get their job done, it starts in the interactive shell and then when the do things frequently, they put it into a simple script and when then need it to be more formal, they invest in making it production quality. That is the flow that PowerShell was designed to support. Jeffrey Snover [MSFT]
- mattmanser 9y agoI still feel it was a massive waste, the millions of programmers who could be using scripting C# right now, it would have been awesome.
- figgis 9y agoCould you just allow interaction with objects in a shell while just using c#? There are interactive c# interpreters that already do great.
- InclinedPlane 9y agoYou know you can write PowerShell cmdlets in C# right? It's super easy.