← На главную

Anthropic представила ksharp — интерпретатор K v3 с поддержкой .NET

17.05.2026 07:44 · hackernews

Eusebio Rufian-Zilbermann

Based on the documentation you provided, here is a summary of the ksharp project, its features, and how to get started on your Windows 10 machine.

ksharp is a C# implementation of the K version 3 language interpreter. It is designed to be a modern, high-performance alternative (and in some cases, enhancement) to the original k.exe.

It was developed using AI assistance (SWE-1.5/1.6, Kimi, Claude) with direction from Eusebio Rufian-Zilbermann.

ksharp offers several improvements over standard K/k3:

  1. 64-bit Long Integers: Supports large numbers (e.g., 123456789012345j).
  2. Smart Integer Division: 4 % 2 returns 2 (integer) rather than a float.
  3. Compact Syntax: No spaces required for symbol vectors (e.g., `a`b`c).
  4. No Duplicate Keys in Dictionaries: Overwriting a key simply updates the value (unlike standard K's duplicate handling).
  5. K Version 2 Compatibility: Better support for legacy syntax like _n?i and d@s.
  6. Full .NET Integration (FFI):
    • Directly call C#/.NET classes and methods.
    • Automatic type conversion between K and .NET types.
    • Load assemblies (e.g., "System.Numerics.dll").
  7. Time Functions: Complete datetime manipulation.
  8. IPC Support: Full Inter-Process Communication system (TCP-based) contributed by Michal Wallace.
  9. MCP Server: Supports Model Context Protocol for agent interoperation.

To maintain performance and focus on core functionality, ksharp intentionally omits: * show / hide (UI elements). * Attribute-based debugging/tracing. * Runtime execution without a console (.kr files).

Since you are on Windows, you need the .NET 8.0 SDK.

  1. Download SDK: Visit dotnet.microsoft.com.
    • Note: On Windows, you might not need wget or dpkg. Download the "Install .NET 8.0 SDK" installer directly from the Microsoft site.
  2. Install: Run the installer.
  3. Verify: Open a new PowerShell or Command Prompt and run: powershell dotnet --version (If this fails, ensure the installation directory is in your system PATH).

Open PowerShell or Command Prompt (as Administrator if necessary) and run:

git clone https://github.com/ERufian/ksharp.git
cd ksharp\K3CSharp
dotnet restore
dotnet build
dotnet run

This will launch the REPL (Read-Eval-Print Loop) where you can start typing K code.

Once dotnet run starts the interpreter, try these commands:

1. Math & Time:

/ Integer math (smart division)
4 % 2
/ Date and time
T
T _gtime
/ Large integers
123456789012345j

2. .NET Integration (Calling C#):

/ Load the Math namespace
"System.Numerics" 2: `System.Numerics.Complex

/ Create a complex number (using constructor)
c: complex[`constructor] 2: `System.Numerics.Complex[
    2
;
3
]

/ Call a method
c
1
:complex_new[ 2; 3 ]
c
1
.Conjugate

(Note: Syntax for object creation may vary slightly depending on the specific implementation of the constructor verb in your version, but the concept of loading "System.Numerics.dll" remains valid).

3. List Operations:

/ Create a list
list:
1
+
2
+
3

/ Map over list (K verb style)
list
*
2

By contributing or using this, you acknowledge it is subject to the MIT License.

Enjoy exploring K with the speed and power of C#!

Читать оригинал →