Feedback Request: What language do you use to write Cmdlets?

Feedback Request: What language do you use to write Cmdlets?

  • Comments 30

Hello everyone. I’m the programming writer for the PowerShell developer audience and I would like to know what language you use to write cmdlets. This is a very unscientific survey, yet getting your replies will help me decide how to add VB.NET and C++ sample code in the documentation. The content that I’m writing is the Programmer’s Guide and SDK that you find on MSDN

 

Thank you in advance, and if you have any other documentation questions don’t hesitate to send me an e-mail at stevenel@microsoft.com

Steve Nelson

Leave a Comment
  • Please add 6 and 1 and type the answer here:
  • Post
  • I've done a few in C#, but may use JScript.net for the next one because I need to do lots of string parsing, object creation, and regular expression handling.

    I've started with PowerShell script, but frankly it is not as good in comparision.  Very awkward to create objects and somewhat cumbersome to use regular expressions (compared to jscript).

  • I code all my cmdlets in C#.

    If you're going to add a language, I would recommend making it C++/CLI only because there are so many existing converters out there that can convert C# to VB.NET (and vice versa), and those are both languages you can pretty much convert in your head once you see a few samples in both.

  • c#

    i just can't take vb seriously.

  • I implore you not to bother with samples in different languages. I find they make the flow of the text harder to follow, because invariably the markup isn't quite correct when hiding some of the languages or the text is incomplete, and the pages don't seem to be intended to be read without a language filter. The samples typically only differ by syntax, so just pick a language and use it. Make it clear which one you go with.

    I understand that there's some reluctance to take sides (or rather, pick a faction, given how similarly these languages are being used), but I find it a bit patronising to see the same thing three times. I'd much rather there was a separate section for "Important considerations in <Language>" with any poignant remarks spelled out explicitly, rather than hidden in a sample; in general, I believe MSDN relies too heavily on samples to make up for sloppy wording.

  • Actually, never mind my last comment about JScript.net.  I just discovered two very interesting things that make working with regular expressions MUCH easier from script (and I'll stick to C# for creating cmdlets):

    1) captures from the last -match call are available via $matches.  Therefore, I do not need to instantiate a System.Text[...].Regex object to create a regular expression.  I can use: 'if( $s -match "tag: (.*)" ) { $v = $match[1] }' instead!

    2) the 'switch -regex' statement works like -match, in that the captures are available in the switch block!

    switch -regex ($s)

    {

     "Frob: (.*)" { $frob = $matches[1] }

     "Froz: (.*)" { $froz = $matches[1] }

    }

    However, I would still dearly like to see a more simple object model - something akin to jscript's dynamic objects makes a great deal of sense.

  • The PowerShell Community Extension cmdlets are all written in C#.

  • I only have used C#.  I won't using any other languages in the foreseeable future.  -Thanks

  • Absolutely C#.

    I do like the argument for C++/CLI, though. Converting between VB and C# is so automatic that it's almost subconscious--though there's something to be said about how much better the C# language matches the concepts of .NET.

    In contrast, C++/CLI is not as intuitive a jump to make. Furthermore, the advantages of using C++/CLI instead of C# or VB when wrapping native code are substantial. It's one of those things that you don't fully appreciate until you've done it a few times. This is important particularly because I would suspect that a lot of commandlets people write will be targeted toward bringing pre-existing technology into PowerShell.

  • I prefer C#.  Why not use the language that most closely resembles PowerShell?  After all, one of the goals of PowerShell is to create a solid "transition point" to compiled languages, is it not?  Also, most of the more recent MSDN articles (from what I've seen) that only show a single language's examples are generally written in C#.

  • C# and C++/CLI. I can't add a word to what Tyler Larson said.

  • I've been programming in some flavor of basic for close to 20 years.  I'd sure like to see more sample in VB, even though I've gotten pretty good at translating C# on the fly.

  • I also only use C# ... unless I'm writing something that's primarily a matter of interacting with Win32 APIs that aren't already exposed in the .Net Framework

  • I use C# exclusively. It feels natural and sits nicely with the rest of the managed code of my app.

    C++ examples will be nice to learn from.

  • Just for that reason I would include VB if you are asking for others besides C#.

    C++/CLI would be my third choice, but people need to understand that VB can still do it. Just about EVERYTHING that can be done in C# can be done in VB. It is not second rate or third rate.

    In the grand scheme of things, the only one that gets to the metal anymore is C++/CLI. So in the end having both C# and VB makes people feel that VB is still valid.

    (I code a lot of SharePoint things in VB just to show that it can be done, not because it is any better)

  • We use C#. We haven't tried any other language yet.

Page 1 of 2 (30 items) 12