Skip to content
HN On Hacker News ↗

GitHub - ERufian/ksharp: Vector calculator and language inspired on K

▲ 55 points 15 comments by tosh 3d ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is primarily human-written, with some AI-generated and AI-assisted content detected

24 %

AI likelihood · overall

Mixed
74% human-written 20% AI-generated
SEGMENTS · HUMAN 6 of 6
SEGMENTS · AI 0 of 6
WORD COUNT 1,772
PEAK AI % 8% · §1
Analyzed
May 18
backend: pangram/v3.3
Segments scanned
6 windows
avg 295 words each
Distribution
74 / 20%
human / AI fraction
Verdict
Mixed
Pangram v3.3

Article text · 1,772 words · 6 segments analyzed

Human AI-generated
§1 Human · 8%

kharp - k version 3 Language Interpreter in C# A comprehensive implementation of the K programming language, version 3, a vector programming language from the APL family.

LEGAL TERMS: ksharp Copyright (c) 2026 Eusebio Rufian-Zilbermann et al. This software is licensed under the terms of the MIT License with Commons Clause. You are free to use, modify, and distribute it (including in commercial products), provided you include attribution and do not sell the software (or a product whose value derives substantially from this software) itself. Full license text: LICENSE Highlighted details: This Software is provided "AS IS". You are responsible for (a) Maintaining appropriate backup copies of any data file that this software is expected to modify, (b) Ensuring that data written to a storage system using this software can be read back in its entirety and with integrity. The author(s) of this product cannot be held responsible for any data loss resulting directly or indirectly from the use of this product.

📚 Table of Contents

🎯 Current Status

Beta Release Remaining Targets Cuts Latest Test Results Recent Improvements

🚀 Quick Start ✅ Implemented Features

Core Data Types Native Operators Core Adverb System Adverbs for Verbialized Nouns Amend, Index, Apply, Assign Core Function System Attributes Conditionals I/O and Communication System Variables and Functions

📡 IPC Operations ⚙️ Statement Parsing System 🔧 K 3 Features Not Available in K# 🎉 ksharp Enhancements Over k version 3

Foreign Function Interface (FFI) Hint System with _gethint and _sethint Object Instantiation and Disposal The _dotnet Tree Method Invocation Error Handling Performance Considerations

🏗️ Architecture

Project Structure Core Components

🛠️ Building and Running

Prerequisites Install and Run

Windows Linux (Ubuntu/Debian) Linux (Fedora/CentOS) macOS

Troubleshooting

🤝 Contributing

§2 Human · 1%

👨‍💻 Authorship 📓 Note Regarding Project Name

🎯 Current Status 🆎 Beta Status The core language in the K Reference Manual is fully implemented: native verbs, adverbs, amend, index, apply and assign, functions, conditionals, I/O and communication, system variables and system functions. The Foreign Function Interface allows using Microsoft .NET objects. When I started this project, getting to the point where it could run all the idioms in my book was only a dream, and actually achieving it in less than 6 months has been an exhilarating experience. This is a milestone that deserves to be released as the beta version of the project. 📉 Remaining Targets

Debugging: My development has been centered around the unit test framework and I haven't needed debugging so I just de-prioritized it, but is it still part of the 1.0 goals.

Parsing: The architecture is a simple Tokenize-Parse into AST nodes-Evaluate. It doesn't use a stack or finite state machines, like other interpreters for k and APL-family languages use. The result is not as robust as I'd like. Note: if you run into parsing issues, please report the problem and try to simplify the expression, long and clever one-liners, and even some expressions that aren't that "long and clever", will have a moderate probability of confusing the parser.

Simplifying: AI-assisted development was fast, but it also accumulated technical debt at a fast pace. In particular the removal of the "legacy parser" was never completely finished (the original "legacy" parser attempted left-to-right evaluation with backtrack, until that became was eventually unsustainable and it was replaced with the current Long-Right-Scope parser). The end result is code that is more complex than necessary and would benefit from simplification

Optimizing: I don't expect ksharp to compete with native implementations of k in terms of performance. Being based on the .NET VM and using managed memory brings some benefits (garbege collected memory usage, no crashes from memory access problems with malformed data, a rich ecosystem, etc) but those come at a cost in performance.

§3 Human · 3%

That said, there are some performance improvements that can be implemented: Leveraging a global symbol table hashset, or leveraging Linq-to-objects state-machine optimizations before evaluating results.

✂️ Cuts

I eliminated the k UI from the project goals. I think effort is better spent on making things work with .NET (which opens up many UI choices, like WinForms and Unity).

📈 Latest Test Results

Test Suite: 1549/1549 tests passing (100% success rate)

🎯 Recent Improvements

🏃 Publish profiles - Generate executables for Windows Mac and Linux 🍏 Improved support for command-line editing - Editing now supports Mac and Linux 🔃 Improved support for recursions - Added limits to recursion depth (40) and signal instead of crashing. 📂 Support for delimited file I/O (May 2026) - Enhanced 0: and 1: functionality, fixed 5: functionality 🚀 Improved comparison tolerance (May 2026) - Updated comparison tolerance to better match K compatibility 🎯 Full test suite passing at 100% (May 2026) - Successfully resolved parsing issues that were preventing some K idioms from producing correct results 🔥 Support for adnouns (May 2026) - The over, scan, each and each-prior adverbs can now be used with nouns (vectors, matrices and tensors) for scatter indexing, transitive closure and state transitions.

🚀 Quick Start Run K3Sharp Interpreter cd K3CSharp dotnet run K User Manual - Complete K language guide with tutorials and examples ✅ Implemented Features K Reference Manual - Detailed reference for all K functions, operators, and concepts Core Data Types ✅

Atomic Types: Integer, Float, Character, Symbol, Dictionary, Nil/Self-typed Null, Function, 64-bit Integer Collections: List, (complex or mixed-type,

§4 Human · 1%

including nesting), Integer vector, Float vector, Character vector, Symbol vector, 64-bit Integer vector Special Values: Self-typed Null (0n), infinity (0I, 0i, 0Ij), negative infinity (-0I, -0i, -0Ij), negative zero (-0.0), integral null/NaN (0N, 0n, 0Nj) Type System: Dynamic typing with automatic promotion Null Handling: IEEE 754 compliant null propagation

Native Operators, and meaningful glyphs ✅

! monadic - enumerate ! dyadic, atomic right argument - mod (modulo) ! dyadic, vector right argument - rotate # monadic - count # dyadic - take $ monadic - format (simple format) $ dyadic, character vector right argument - form $ dyadic, right argument other than character vector - format (format with specifier) % monadic - invert % dyadic - divide & dyadic - min ( ) - grouping separator , monadic - enlist , dyadic - join - monadic, followed by space - change sign - dyadic - subtract . as last character to variable path - attribute path . inside variable path - descend into value .. in variable path - descend into attribute . as index for a dictionary - attribute dictionary . monadic, list (type 0) argument - make dictionary . monadic, character vector argument - execute . monadic, dictionary argument - unmake dictionary . dyadic, first argument is a function - dot apply . dyadic, first argument is a variable - index at depth . triadic, third argument is a verb - apply at depth . triadic, third argument is : - error trap at depth . tetradic - apply at depth with arguments / with whitespace on the left - comment marker ' as the single item in an expression - Signal ' monadic - Signal : REPL command - resume : monadic - return :: with variable name to the left - Global Assign (statement) : with variable name to the left - Assign (statement) :

§5 Human · 1%

with monadic verb to the left and no arguments - Monadic apply and assign : with dyadic verb to the left and arguments - Dyadic apply and assign :[ ] variadic - conditional execute and assign (statement) < monadic - grade up < dyadic - less = monadic - group = dyadic - equals > monadic - grade down > dyadic - more ? monadic - uniques ? dyadic with list or null (type 6) on the left - find ? dyadic with function left argument - inverse function ? triadic - apply inverse function @ monadic - Is Atom @ dyadic, path left argument, character vector right argument - execute at path @ dyadic, function left argument - shallow apply @ dyadic, variable left argument - shallow index @ triadic, third argument is verb - shallow apply @ triadic, third argument is : - shallow error trap @ tetradic - shallow apply with arguments [ ] with function to the left - Group and dot apply [ ] with variable to the left and assignment or apply and assign to the right - Amend [ ] with variable to the left with no assignment to the right - Group and index at depth \ at the start of a line (whitespace allowed, ^\s*\\) - Marker for REPL command ^ monadic - Shape ^ dyadic - Power _ monadic - Floor _ as a prefix - system reserved verb or variable _ dyadic with integer left argument - drop _ dyadic with integer vector left argument - cut { } - group and make function | monadic - reverse order | dyadic - max ~ monadic, with numeric argument - not (is zero, logical negation) ~ monadic, with symbol (variable path) argument - attribute handle ~ dyadic - match + monadic - flip (transpose) + dyadic - add * monadic - first or default * dyadic - multiply ` before a name or a string literal - symbol marker " " (string literal) enclosing a single item - character " " (string literal) enclosing multiple items - character vector ; inside grouping (except enclosing quotes) - list separator \n inside grouping (except enclosing quotes) - list separator \n in the REPL, outside grouping/enclosing

§6 Human · 2%

- evaluate

Core Adverb System (Iterations) ✅

Over (/): +/ 1 2 3 4 5 → 15 (fold/reduce) Scan (\): +\ 1 2 3 4 5 → (1;3;6;10;15) (cumulative) Each ('): -:' 1 2 3 4 → (-1;-2;-3;-4) (element-wise) Each-Left (\:): 1 2,\: 3 4 5 → (1 3 4 5;2 3 4 5) (apply operation for each item in left argument, with entire right argument) Each-Right (/:): 1 2 3 +/: 4 5 → (5 6 7;6 7 8) (apply operation with entire left argument, for each right argument) Each-Pair (':): ,': 1 2 3 4 → (2 1;3 2;4 3) (apply operation to consecutive pairs, reversing left and right) Initialization: 1 +/ 2 3 4 5 → 15 (with initial value) Adverbs for already modified verbs 🆕: ((1 2);(3 4)),/:\:((9 8);(7 6)) → ((1 2 9 8;1 2 7 6);(3 4 9 8;3 4 7 6)) (adjacent adverbs are nested iterations)

Adverbs for Verbialized Nouns (iterative indexing) ✅

' with matrix/tensor immediately to the left - Scatter Select / with vector of indices immediately to the left - Transitive Closure (index traversal iteration with convergence) / with transition matrix immediately to the left - State Transition (2D iterative index) \ with vector of indices immediately to the left - Transitive Closure