Live data from Hacker News

Show HN: Lisp in C#

github.com

61–70 of 70 posts

Re: Show HN: Lisp in C#

#61
post #58
post #53

Earlier quoted context omitted.

It's the same old ideas, over and over again. But it's not a circle, it's a spiral; we learn something new every time.

Sometimes, and suddenly modular monoliths become a thing, as the microservices generation learns why we weren't doing SUN RPC, TOOL, DCOM and CORBA for every little piece of application functionality.

We could definitely do a better job of learning from those who came before, it would save a lot of time and effort.

Evolution is messy, every combination has to be tried, every minor detail thoroughly investigated from all angles.

Re: Show HN: Lisp in C#

#63
post #35
post #34

Earlier quoted context omitted.

Yeah, 'int is iterable' triggered "oh that's cute!" immediately followed by "... and the exact sort of cute I often find irresistably tempting myself and then regret later." My current thing in progress has basically all of its temptation points already spent because I decided I was going to make it fexpr based, but I'm very definitely having fun with that so far - "no special forms required" makes for some interesti…

A certain level of helpfulness is nice though, Ruby and to a somewhat lesser extent Perl get that part right. I guess Perl could be seen as a warning example of what happens if you go all in. Yep, I've been on a ride down the fexpr implementation hole previously; which is another reason I've been delaying user macros; still processing the experience.

There's a bunch of stuff in perl that's best restricted to one-liner or short script usage - i.e. the sort of cases where you're using it for the early inspiration super-awk purposes.

Writing perl as a programming language is, I find, a very different dialect, and perhaps amusingly one in which I rely on function composition, closures and block scoping heavily due to also loving lisp - javascript's 'let' behaves very similarly to perl's 'my' and I find it ... difficult ... to deal with python or ruby for any length of time since their scoping is "stuff randomly pops into existence at function scope" and, just, aaaaa.

Perl of course can't really have macros, but it does have the ability to define custom (also block scoped :) keywords which can allow one to achieve similar results - see e.g. https://p3rl.org/Keyword::Declare for a demonstration built on top of that functionality (there's also a code rewriter called Babble but I got distracted so while it works, it's woefully underdocumented, keep forgetting to get back to that).

I've always had a fondness for the "building the language up towards the problem" style of programming (I wrote the first ever proof of concept for custom perl keywords, though that code has happily long since been obsoleted by people who knew what they were doing) which has led me to 'fexprs for making DSLs' since those are usually building up a config structure or similar which makes fexprs' being tricky to optimise less of an obstacle.

(also with fexprs I don't have to limit myself to 'block in front' ala perl or 'block at the end' ala ruby/elixir (though it's amazing how much mileage elixir gets out of its macros, Kernel.ex is well worth a read if you're so inclined))

Re: Show HN: Lisp in C#

#64
post #30

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 co…

Integers are also iterable in TXR Lisp. But in a different way; you get an infinite sequence starting from the value. 1> [mapcar list '(a b c) 10] ((a 10) (b 11) (c 12)) This crops up on a regular basis in my coding, removing verbosity; I don't regret the decision. It's one of the "take alongs": something to repeat in a future language.

I think I'd rather have e.g.

    [mapcar list '(a b c) [count-from 10]]
or so. They look great in examples, but once you're doing

    [mapcar list '(a b c) x]
then I still suspect that you'll confuse yourself every so often by passing the wrong x.

OTOH if you've got the entire codebase in your head that isn't really an issue; it's coming back to tweak something a few months later where I usually find such features give me an unexpectedly ventilated foot :)

Re: Show HN: Lisp in C#

#65
post #54

Earlier quoted context omitted.

Integers are also iterable in TXR Lisp. But in a different way; you get an infinite sequence starting from the value. 1> [mapcar list '(a b c) 10] ((a 10) (b 11) (c 12)) This crops up on a regular basis in my coding, removing verbosity; I don't regret the decision. It's one of the "take alongs": something to repeat in a future language.

The duality of meaning (is it from or to the specified value) actually speaks against the feature for me, you just ruined it :) Or fixed it, depending on which way you lean.

We can't get rid of plurality of meaning because syntax isn't semantics. The same syntax can be assigned completely different semantics.

In Lisps, we program syntax with different semantics regularly, so the plurality is part of the daily existence. (defclass a (b c)) and (list a (b c)) have the same shape, but are completely different things.

10 is a piece of syntax, but how do we assign its semantics when it is an argument to a parameter that expects a sequence? That is up in the air the same way. Is it an error, like in most Lisp-like languages? does it count up to 10 from 1? Below 10 from zero? From 10 ad infinitum?)

The choice becomes a paradigm in the language that everyone has to understand.

What is undesirable is inconsistencies. If certain functions counted up to the number, but others from the number, arbitrarily, that would be objectively worse than consistently doing one or the other.

Re: Show HN: Lisp in C#

#66
post #62

There's also Clojure CLR (lisp) https://github.com/clojure/clojure-clr

Yeah, I admire Rich Hickey a lot, it took a lot of guts; and I learned a lot from Clojure and his talks; but I unfortunately find the language a bit too opinionated and dogmatic.

Re: Show HN: Lisp in C#

#67
post #10

Earlier quoted context omitted.

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

Why does the implementation of .Last not just check if .Count? It seems like there are things that don't implement IList but can still be indexed by the last entry?

Re: Show HN: Lisp in C#

#69

Earlier quoted context omitted.

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

Why does the implementation of .Last not just check if .Count? It seems like there are things that don't implement IList but can still be indexed by the last entry?

In a strongly typed compiled language, how would you do so (in a type-safe and performant way) only knowing that the type is some IEnumerable implementation and not a particular shape that may or may not adhere to the `T this[int i]` and `.Count //of T` contract?

Re: Show HN: Lisp in C#

#70

Earlier quoted context omitted.

Why does the implementation of .Last not just check if .Count? It seems like there are things that don't implement IList but can still be indexed by the last entry?

In a strongly typed compiled language, how would you do so (in a type-safe and performant way) only knowing that the type is some IEnumerable implementation and not a particular shape that may or may not adhere to the `T this[int i]` and `.Count //of T` contract?

Is using reflection for a quick property check that much of a performance hit? After all, avoiding it leads to footguns like this where someone didn't realize they were traversing an entire array.

I'm not well versed on this topic.

Post reply on HN