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:
- 64-bit Long Integers: Supports large numbers (e.g.,
123456789012345j). - Smart Integer Division:
4 % 2returns2(integer) rather than a float. - Compact Syntax: No spaces required for symbol vectors (e.g.,
`a`b`c). - No Duplicate Keys in Dictionaries: Overwriting a key simply updates the value (unlike standard K's duplicate handling).
- K Version 2 Compatibility: Better support for legacy syntax like
_n?iandd@s. - 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").
- Time Functions: Complete datetime manipulation.
- IPC Support: Full Inter-Process Communication system (TCP-based) contributed by Michal Wallace.
- 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.
- Download SDK: Visit dotnet.microsoft.com.
- Note: On Windows, you might not need
wgetordpkg. Download the "Install .NET 8.0 SDK" installer directly from the Microsoft site.
- Note: On Windows, you might not need
- Install: Run the installer.
- Verify: Open a new PowerShell or Command Prompt and run:
powershell dotnet --version(If this fails, ensure the installation directory is in your systemPATH).
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
- "dotnet: command not found": You haven't installed the SDK yet, or your terminal window is old. Close and reopen your terminal after installation.
- Build Errors: Ensure you are in the
K3CSharpfolder. Rundotnet cleanthendotnet buildif errors persist. - Performance: For heavy computations, try building in Release mode:
dotnet run -c Release.
By contributing or using this, you acknowledge it is subject to the MIT License.
Enjoy exploring K with the speed and power of C#!