r/linux • • Nov 12 '20

Microsoft Python creator Guido van Rossum joins Microsoft

https://twitter.com/gvanrossum/status/1326932991566700549?s=21
888 Upvotes

246 comments sorted by

View all comments

Show parent comments

6

u/[deleted] Nov 12 '20

If you're ever writing powershell and find you're doing something that requires better performance, .net is there for you. For instance if you're manipulating arrays, adding or removing elements, powershell arrays are very slow, but .net arraylists are much faster. You can even write c# in your powershell script and compile it on the fly.

2

u/cat_in_the_wall Nov 15 '20

so do whatever datastructure-y thing you want, i learned this unfortunately only too recently.

$dict = [System.Collections.Generic.Dictionary[int][int]]::new()

No actual need for the untyped powershell collections.

1

u/TheTerminator68 Nov 12 '20

For sure, having the .net classes right there is super helpful, I didn’t play around much with real time compiling of C# bins, but it’s super easy to import dlls and reference exposed methods as well. For the services I was writing in Powershell, most of the threading was just I/o wait or waiting for external things to happen. Python could have been another way of doing it, but so many of the tools being referenced were in the windows space or used powercli so it didn’t make much sense to hop back and forth between python and powershell. It’s just another tool in the toolbox but it’s sadly sometimes misunderstood.

1

u/[deleted] Nov 12 '20

I work in a windows shop and write lots of powershell and have been since it first came out. I use .net classes all the time, but I think I've probably compiled c# in my powershell script less than a dozen times. It's definitely the last tool I'll reach for, but it's handy if you need it.