avatar
Shriram Krishnamurthi @shriram.bsky.social

So if I want to write these bits in something other than PowerShell-the-language but want to take advantage of PowerShell-the-CLI what would it look like? Can you rewrite this same script in some other language (say Python or OCaml or Racket or…)?

sep 3, 2025, 12:02 am • 0 0

Replies

avatar
James Brundage | MVP @mrpowershell.com

Adding a bit more context and a tool you might like: PowerShell is meant to be as easy as possible. I recently built a #Turtle #Graphics engine in #PowerShell i.e. turtle SierpinskiTriangle 42 4 # makes a fractal. I can | Select Width, Height or | Select -Expand SVG psturtle.com

sep 3, 2025, 3:00 am • 2 0 • view
avatar
James Brundage | MVP @mrpowershell.com

This may be younger than #Python #Turtle #Graphics, but it can already do many things that Python will not do out of the box. The syntax will almost always be shorter (and care less about spacing) Why? Because PowerShell is a highly extensible language with very flexible syntax.

sep 3, 2025, 3:03 am • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

I've got my own opinions about these kinds of topics as pedagogical devices, so maybe best not to get me started on this topic. (-:

sep 3, 2025, 4:27 pm • 3 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Happy to hear them, especially since I basically built this variation of Turtle to teach, inspire, and peel back layers of the universe. ( Also, in case this isn't clear, if you work on a language you end up a language nerd ) Please share your opinions, I'm eager to hear them.

sep 3, 2025, 4:34 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

parentheticallyspeaking.org/articles/how...

sep 3, 2025, 4:36 pm • 1 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Btw, if you want a real recursive head trip, do you know of any other language that allows anonymous recursion? It's one of the more fun little lambdas to bust out in #PowerShell. I still haven't seen that feature anywhere else, but my knowledge is finite. 😉. You seen it anywhere ?

sep 3, 2025, 4:45 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

I'm not sure what "anonymous recursion" means really, but the Y-combinator might be what you're looking for, and it's encodable in numerous languages directly or with a little bit of effort (depending on eager vs lazy evaluation, the specific type structure of the language, etc.).

sep 3, 2025, 4:47 pm • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Hmm. I suppose one way to think of it would be in terms of a "automatic" y-combinator. & $myinvocation.MyCommand.ScriptBlock # brief anonymous recursion example. Let's me build a recursive lambda without ever saving it to a variable. ( $myInvocation is an automatic variable )

sep 3, 2025, 4:56 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

Is this the sort of thing you mean? Note that there is no recursive name reference. I've also purposely created an outer function so we can confirm the two instances (non-rec-lucas and non-rec-fib) are not confused with each other, i.e., they really are from this *invocation*.

(define (lucas-or-fib n0 n1) (lam (n) (cond [(= n 0) n0] [(= n 1) n1] [(> n 1) (+ ($myinvocation (- n 1)) ($myinvocation (- n 2)))]))) (define non-rec-fib (lucas-or-fib 0 1)) (check-equal? (non-rec-fib 5) 5) (check-equal? (non-rec-fib 10) 55) (define non-rec-lucas (lucas-or-fib 2 1)) (check-equal? (non-rec-lucas 5) 11) (check-equal? (non-rec-lucas 10) 123)
sep 3, 2025, 8:41 pm • 1 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Looks like it. What language is that? (looks vaguely functional, but I don't think it's scheme)

sep 3, 2025, 10:17 pm • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Good article. Recursion is a tricky topic to teach and explain. FWIW, the Turtle I linked to doesn't use it ( yet ), as the object pipeline helps avoid it. If I were looking for a practical example to teach, I would probably try for serialization ( for example, converting objects to css ).

sep 3, 2025, 4:42 pm • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

For the sake of demonstration, let's just say I have a Racket or Python script that gives me back a series of numbers, one per line If we pipe that script to foreach-object, we can just cast to a [double] python ./some.py | % { ($_ -as [double])/2 }

sep 3, 2025, 12:37 am • 2 0 • view
avatar
James Brundage | MVP @mrpowershell.com

It would vary by the language. Almost every other language does not allow for seamless multi-value return, and most of them lack an object pipeline. In general, you'd use loops, but then you'd have to look at all objects at once, instead of as a pipeline of objects.

sep 3, 2025, 12:31 am • 1 0 • view