Live data from Hacker News

Show HN: Lisp in C#

github.com

11–20 of 70 posts

Re: Show HN: Lisp in C#

#11
post #10

Earlier quoted context omitted.

Here, calling `.Last()` on `ArrayStack ` traverses it from the start. `.Last()` is a static extension method defined on `System.Linq.Enumerable` class and has a signature `static T Last (this IEnumerable source)`. Internally, `.Last()` will try to optimize for the common cases where a type implements `IList ` and uses an indexer to simply get the last element. However, because ArrayStack does not implement IList , .L…

Just the kind of information/expertise I was looking for, awesome!

And you can find that specilisation here: https://source.dot.net/#System.Linq/System/Linq/Last.cs,80

Re: Show HN: Lisp in C#

#12
post #10

Earlier quoted context omitted.

Here, calling `.Last()` on `ArrayStack ` traverses it from the start. `.Last()` is a static extension method defined on `System.Linq.Enumerable` class and has a signature `static T Last (this IEnumerable source)`. Internally, `.Last()` will try to optimize for the common cases where a type implements `IList ` and uses an indexer to simply get the last element. However, because ArrayStack does not implement IList , .L…

Just the kind of information/expertise I was looking for, awesome!

Thank you too!

Re: Show HN: Lisp in C#

#13
post #5

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…

By all means, keep them coming people :)

We just roughly doubled the speed by changing one line of code, that means there's plenty more fun before it gets really tricky.

My issue isn't really profiling, its not knowing enough about the platform to do anything constructive with the hot spots.

Re: Show HN: Lisp in C#

#15
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.

Re: Show HN: Lisp in C#

#16

It's worth mentioning https://github.com/IronScheme/IronScheme

Right, I recognize the name.

Curious though, I'm pretty sure it emits MSIL rather than its own bytecode like sharpl? So that would be one difference, in most cases an advantage because of performance.

The other obvious difference is I'm not aiming for any standards, quite the contrary; this is about being so fed up with the alternatives (including Scheme) that spending the rest of my life getting it just right looks like a reasonable deal.

Re: Show HN: Lisp in C#

#17
post #5

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…

https://github.com/codr7/sharpl/pull/1 Was: 686 98 1195 Now: 226 79 293 (with net9.0 preview: 201 70 269, another release another free >10%) The reason for such a significant difference is that `ArrayStack ` only implements `IEnumerable `, which prevented the Enumerable.Last(stack) call from seeing that the type has an indexer which can be used to quickly access the last element instead of traversing it in its entire…

Alternatively ArrayStack could be modified to implement IList right?

Re: Show HN: Lisp in C#

#18
post #17

Earlier quoted context omitted.

https://github.com/codr7/sharpl/pull/1 Was: 686 98 1195 Now: 226 79 293 (with net9.0 preview: 201 70 269, another release another free >10%) The reason for such a significant difference is that `ArrayStack ` only implements `IEnumerable `, which prevented the Enumerable.Last(stack) call from seeing that the type has an indexer which can be used to quickly access the last element instead of traversing it in its entire…

Alternatively ArrayStack could be modified to implement IList right?

Right, already tried that; Last() is still slightly slower (I guess because of more layers of indirection).

Re: Show HN: Lisp in C#

#19
post #8

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.

Yes, I am aware.

I started out designing Forth interpreters, actually calculators and template engines, but Forth was a natural progression.

My design differs a lot from idiomatic Lisp implementations (likewise Forth), and I do sometimes wonder what it would look like if you started in that end and worked your way towards supporting all the features of sharpl.

Re: Show HN: Lisp in C#

#20
post #8

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.

There's also Make-A-Lisp and, unlike most write-you-a-lisp/scheme-s out there, that one also covers TCO interpretation, quasiquotation/unquote for macros and their expansion, and goes up to self-hosting: https://github.com/kanaka/mal/

I just went through it over 2-3 days, great practice IMHO to do once in your life from start to finish: https://github.com/metaleap/go-lisp

Post reply on HN