July 23rd, 2024

Show HN: Lisp in C#

The GitHub URL provides details about "sharpl," a custom Lisp interpreter in C#. It includes features like lexical/dynamic scope, branching, method definition, lambdas, closures, varargs, and more. Visit https://github.com/codr7/sharpl for details.

Read original articleLink Icon
InterestFeedbackSuggestions
Show HN: Lisp in C#

The GitHub URL provided contains information about "sharpl," a custom Lisp interpreter written in C#. This interpreter offers various features including bindings with lexical or dynamic scope, branching using `if` and `if-else`, method definition with `^`, lambdas, closures, tail calls, varargs, composition, quoting, composite types like arrays, maps, and pairs, iterators, libraries, evaluation with `eval`, testing with `check`, benchmarks, and debugging with `emit`. For more in-depth details and examples, you can refer to the sharpl GitHub repository at https://github.com/codr7/sharpl.

Related

Show HN: a Rust lib to trigger actions based on your screen activity (with LLMs)

Show HN: a Rust lib to trigger actions based on your screen activity (with LLMs)

The GitHub project "Screen Pipe" uses Large Language Models to convert screen content into actions. Implemented in Rust + WASM, inspired by `adept.ai`, `rewind.ai`, and `Apple Shortcut`. Open source under MIT license.

Common Expression Language interpreter written in Rust

Common Expression Language interpreter written in Rust

The GitHub repository features a Common Expression Language (CEL) implementation in Rust, offering a CEL-parser and interpreter for evaluating expressions. It emphasizes simplicity, speed, safety, and portability, providing examples and guidance in Rust, Java, Go, and TypeScript. Detailed documentation is available on the GitHub page.

Bio – experimental Lisp dialect, written in Zig

Bio – experimental Lisp dialect, written in Zig

Bio is an experimental Lisp dialect on GitHub, featuring macros, garbage collection, and lambda expressions. Documentation is ongoing, with examples in `std.lisp` and `test.lisp`. Explore for more details.

Show HN: Llm2sh – Translate plain-language requests into shell commands

Show HN: Llm2sh – Translate plain-language requests into shell commands

The `llm2sh` utility translates plain language into shell commands using LLMs like OpenAI and Claude. It offers customization, YOLO mode, and extensibility. Installation via `pip` is simple. User privacy is prioritized. Contributions to the GPLv3-licensed project are welcome. Users should review commands before execution. Visit the GitHub repository for details.

"Maxwell's equations of software" examined

"Maxwell's equations of software" examined

Ken Shirriff's blog post analyzes a historic Lisp code snippet, showcasing Lisp's core principles. It highlights code-data interchangeability and the essence of Lisp programming, referencing Alan Kay's "Maxwell's Equations of Software."

AI: What people are saying
The discussion around the "sharpl" Lisp interpreter in C# covers various aspects and suggestions.
  • Users are curious about the potential for FFI/interop and the rationale behind using C#.
  • The author seeks advice on optimizing performance and mentions additional features in the repository.
  • There are references to similar projects and resources, such as IronScheme and Norvig's Lisp tutorial.
  • Concerns are raised about certain language design choices, like making integers iterable.
  • Suggestions include adding macro documentation and improving code block syntax highlighting in the README.
Link Icon 11 comments
By @codr7 - 3 months
Author here.

I'm afraid I've been out of the C# loop too long to know what's fast and what isn't these days.

Now that maybe I have the attention of some serious C# nerds, any assistance in making this thing run faster would be much appreciated.

It's not terrible atm, given a managed host language, but I'm sure there are plenty of knobs left to turn.

See the benchmarks section in the README for more info, and the same benchmarks ported to Python in python/fib.py.

Oh, and there's some undocumented yet potentially useful stuff in /Libs; strings, terminal control and IO mainly.

By @codr7 - 3 months
If only we could get a tiny Lisp loving push from the HN crew, wink, nudge.

I don't much like the odds of Lisp vs. Nintendo hardware kickstarters.

By @coder94 - 3 months
There's also Clojure CLR (lisp) https://github.com/clojure/clojure-clr
By @davidelettieri - 3 months
By @keithnz - 3 months
years ago someone posted http://norvig.com/lispy.html here on HN

I wrote a lisp in C# based on that, it was only a 100+ ish lines of code. It was a great way to get into Lisp.

By @default-kramer - 3 months
Cool, thanks for showing. Are you planning for any sort of FFI/interop in either direction? I don't see it in your TODO, but I also don't understand why you would write it in C# unless you had this in mind.
By @Zambyte - 3 months
Cool! I didn't get a chance to run it but I dug around the code a little bit. I noticed there is a Macro class, but no mention of macros in the README. Are macros working?
By @mst - 3 months
Separate from anything else, I'm ... concerned ... at the idea of ints being iterable, because it seems like something I'd be much more likely to invoke accidentally than intentionally and then wonder wtf my program was doing. I'd prefer to have to write something like

    (reduce + (range 1 3) 0)
and if you find yourself wanting the natural number iteration regularly maybe

    (^upto (n) (range 1 (- n 1)))
as sugar.

This concern brought to you by e.g. the great pain induced by the difference between

    for x in "foo":
and

    for x in "foo",:
in python, for example.

It may turn out in practice that a lispy language and/or programmers who make different mistakes to me will make it not an issue ... but were it -my- project I'd probably comment out the iterator implementation for int and see if its absence annoyed me enough to decide it was worth bringing back.

(when perpetrating language myself I often find that some of my favourite bits of clever don't pass the 'annoyed me enough' test and end up as documentation examples or similar in the end instead ... hopefully you have better luck ;)

By @healeycodes - 3 months
You can annotate the code blocks in the README to get generic lisp syntax highlighting.

```lisp

(+ 1 2)

```

By @zczc - 3 months
So, it is a shortcut around the tenth rule: "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp" [1]

[1] https://en.wikipedia.org/wiki/Greenspun's_tenth_rule