Live data from Hacker News

Lisp-stick on a Python

docs.hylang.org

111–120 of 170 posts

Re: Lisp-stick on a Python

#112
post #61

Earlier quoted context omitted.

Thanks, that is what I thought, but didn't trust my memory. Yes, I did mean optimization - without it you can blow through your stack quickly (and the traceback will be long and redundant :)

Common lisp doesn't require tail call elimination either, fwiw

But every implementation except clisp, ECL and clisp do it reliably.

Re: Lisp-stick on a Python

#113
post #52

I've been hearing claims my entire programming career about how Lisp is supposedly "superior" to mainstream programming languages, but I've never seen a concise code example that actually demonstrates this. For instance, it's easy to demonstrate how Rust is superior to C: Just show a short piece of code where an array is returned from a function. In C, this will involve raw pointers and manual memory management with…

There is something I saw on the wild here https://github.com/Shinmera/legit/blob/master/repository.lis... which I thought was pretty cool.

We all know about memoize, but let's say I want to define a global hash-map, where the keys are actual pieces of code and the value the result that would be evaluated when executed. Something like this:

  | Key                        | Value                          |
  |----------------------------+--------------------------------|
  | "hello"                    | "hello"                        |
  | (square 5)                 | 25                             |
  | (factorial 5)              | 120                            |
  | (git-tags "~/foo")         | (list "1.0.0" "0.1.0" "0.0.1") |
  | (make-instance 'singleton) | #      |

Which can then be used like this in a trivial way, just passing code because code is data:

  (let ((path "~/foo")
        (tags (cache `(git-tags ,path))))
    (format t "Tags of ~a~% ~{- ~a~%~}"
            path tags))
Sure, something like this is possible in other languages, but having done macros in languages such as Rust and Nim, it involves such a verbose and syntax soupy way of dealing with the AST that I don't feel like reaching for those abstractions that often. I'd rather just write boring code, and most consider this a feature.

Re: Lisp-stick on a Python

#114
post #55

Earlier quoted context omitted.

I genuinely like Rust, but it's pretty amazing that you managed to write a comment on this article and make it about Rust. Peak HN :-) Re Lisp's superiority - Lisp was certainly a superior language when it was devised many decades ago, but over time much of its comparative advantage has been absorbed by other languages. Starting in the 90s when productive, GC'd scripting languages like Python started being prominent…

Is someone willing to go back in time and let comp.lang.lisp know about Rust?

I mean i would but i don't know wether going back in time would pass the borrow checker.

Re: Lisp-stick on a Python

#115
post #52

I've been hearing claims my entire programming career about how Lisp is supposedly "superior" to mainstream programming languages, but I've never seen a concise code example that actually demonstrates this. For instance, it's easy to demonstrate how Rust is superior to C: Just show a short piece of code where an array is returned from a function. In C, this will involve raw pointers and manual memory management with…

You know all those DSL's you use to do templating, SQL, scripting? You don't need them in Lisp.

Re: Lisp-stick on a Python

#116

See also PEP 638 – Syntactic Macros https://peps.python.org/pep-0638/

I for one sincerely hope this does not become a thing

Python already has 'enough' metaprogramming support, the last thing we need is a sudden fad of libraries defining their own gratuitous DSLs

Re: Lisp-stick on a Python

#117

Earlier quoted context omitted.

Considering Lisp was here first, shouldn't the real question be "why use Rust/C++/Python when there's Lisp?" You can't even create a real closure in Rust. I'd love to see 10 lines of Rust that showed me something that: 1. I can't easily do in Lisp. 2. Actually matters in practice.

This a trick question because 10 line programs are trivial. Please show me a high performance hardware-accelerated 3D game engine written in lisp. Or a web browser.

This a trick question because 10 line programs are trivial.

I mean, OP asked for a 10 line program showing something that can't be done easily in Rust and actually matters, so he seems to believe 10 line programs aren't trivial.

That said line counts are an awful metric because I could just cram an entire library definition in a single line as if it were minified JS.

Re: Lisp-stick on a Python

#118
post #57

Earlier quoted context omitted.

Just in case people don't know about C. This is a short piece of code where an array is returned from a function. typedef struct {int v[4];} Vec; Vec get_vec(void){return Vec {3,2,1,0};} Edit: alas, I've been writing too much C++. The following is correct C. typedef struct {int v[4];} Vec; Vec get_vec(void){Vec v={{3,2,1,0}}; return v;}

Yeah, there is nothing complicated about returning a static array in C. C is a much simpler language than many people assume -- of course, it can get really hairy and complicated especially when you need to do dynamic memory management, but that's not what the GP was asking for in this case.

> that's not what the GP was asking for in this case.

You really think that when they mentioned the dynamically allocated `Vec` in Rust (which has fixed-sized arrays) and "manual memory management" in C, what they were actually talking about was a static array?

Re: Lisp-stick on a Python

#119
post #60

Earlier quoted context omitted.

I can, without restarting my program: 1. Gather assembly level profiling information 2. Redefine & recompile a function 3. Gather new assembly level profiling I can iterate dozens of times between #2 and #3 in the time of a single incremental production build in rust (debug builds are not useful for gathering profiling data). Generally speaking it takes less than a second to recompile and load a source file, and it c…

Doesn’t VS do that too though? Also if you’re talking about performance or memory profiling, why are you using a Lisp in the first place?

> Also if you’re talking about performance or memory profiling, why are you using a Lisp in the first place?

Why not? CL is very performant. You'd probably be surprised. https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: Lisp-stick on a Python

#120

Earlier quoted context omitted.

Considering Lisp was here first, shouldn't the real question be "why use Rust/C++/Python when there's Lisp?" You can't even create a real closure in Rust. I'd love to see 10 lines of Rust that showed me something that: 1. I can't easily do in Lisp. 2. Actually matters in practice.

This a trick question because 10 line programs are trivial. Please show me a high performance hardware-accelerated 3D game engine written in lisp. Or a web browser.

Jak and Daxter and Crash Bandicoot (not sure how much of The last of us) are good examples in lisp.

There are a lot of video interviews with the creators. I found them extremely interesting.

https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

https://www.reddit.com/r/lisp/comments/fayhw2/how_crash_band...

Post reply on HN