Last active
January 17, 2024 12:04
-
-
Save anonhostpi/c18abd1158dce07ff18ab94e3111a514 to your computer and use it in GitHub Desktop.
The PowerShanos Thanos Shauntlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace Python.Runtime | |
# Import the C# libraries: | |
Import-Package pythonnet | |
Import-Package Microsoft.ClearScript | |
Import-Package NLua | |
Import-Package IronRuby.Libraries | |
Import-Package R.NET | |
# Setup Python: | |
& { | |
$dll = where.exe python | ForEach-Object { | |
$root = $_ | Split-Path -Parent | |
$name = $root | Split-Path -Leaf | |
"$root\$name.dll" | |
} | Where-Object { Test-Path $_ } | Resolve-Path | |
[Python.Runtime.Runtime]::PythonDLL = $dll | |
[Python.Runtime.PythonEngine]::Initialize() | Out-Null | |
[Python.Runtime.PythonEngine]::BeginAllowThreads() | Out-Null | |
} | |
$lock = [Py]::GIL() | |
# Import the CPython libraries: | |
$py = [Py]::Import("builtins") | |
$java = [py]::Import("jpype") | |
$julia = [py]::Import("julia") | |
# Setup JavaScript: | |
$js = [Microsoft.ClearScript.V8.V8ScriptEngine]::new() | |
$js.AddHostType( [System.Console] ) | |
# Setup Lua: | |
$lua = [NLua.Lua]::new() | |
# Setup Ruby: | |
$ruby = [IronRuby.Ruby]::CreateRuntime().GetEngine("rb") | |
# Setup R: | |
$r = [RDotNet.REngine]::GetInstance() | |
# Setup Java: | |
[py]::import("jpype.imports") | Out-Null | |
[py]::import("jpype.types") | Out-Null | |
$java.startJVM() | |
# Setup Julia: | |
# $julia.install() # needs to be run the first time you run PyJulia | |
[py]::import("julia.Base") | Out-Null | |
# PowerShell built-ins: | |
[System.Console]::WriteLine( "Hello World from C#, F#, and VB!" ) | |
Write-Host "Hello World from PowerShell!" | |
# C# embeds: | |
Write-Host | |
$js.Script.Console.WriteLine( "Hello World from JavaScript!" ) | Out-Null | |
$lua.GetFunction( "print" ).Call( "Hello World from Lua!" ) | |
$ruby.Execute("puts 'Hello World from Ruby!'") | |
$r.Evaluate('cat("Hello World from R!")') | Out-Null | |
# CPython embeds: | |
Write-Host | |
$py.print( "Hello World from CPython!" ) | |
$java.JPackage("java.lang").System.out.println("Hello World from Java!") | |
$julia.Base.print('Hello World from Julia!') | |
$lock.Dispose() | |
$java.shutdownJVM() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment