Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



(Tongue-in-cheek)

    #![allow(arithmetic_overflow)]
    fn main() {
        let x = 1073741823;
        println!("x = {}", x*3);
    }
    
    # cargo build && cargo run
    thread 'main' panicked at 'attempt to multiply with overflow', src/main.rs:4:24
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
To be fair, Rust is improving over time, as of I think last year you now have to explicitly have that first line to allow the overflow? This behavior is somewhat annoying to replicate in Lisp if you aren't familiar with type declarations and suppressing the debugger:

    (defun main ()
      (let ((x 1073741823))
        (declare (type (signed-byte 32) x))
        (format t "x = ~a~%" (the (signed-byte 32) (* x 32)))))
    
    (handler-case
      (main)
    
      (simple-type-error (e)
        (format *error-output* "Panicking because of ~a~%" e)
        (uiop:quit 1)))
    
    # sbcl --script main.lisp
    ; file: /tmp/main.lisp
    ; in: DEFUN MAIN
    ;     (THE (SIGNED-BYTE 32) (* X 32))
    ; 
    ; caught WARNING:
    ;   Derived type of (* COMMON-LISP-USER::X 32) is
    ;     (VALUES (INTEGER 34359738336 34359738336) &OPTIONAL),
    ;   conflicting with its asserted type
    ;     (SIGNED-BYTE 32).
    ;   See also:
    ;     The SBCL Manual, Node "Handling of Types"
    ; 
    ; compilation unit finished
    ;   caught 1 WARNING condition
    Panicking because of Value of (* X 32) in
                         (THE (SIGNED-BYTE 32) (* X 32))
                         is
                           34359738336,
                         not a
                           (SIGNED-BYTE 32).
A bit more work and you could muffle the compilation time warning too. As for how important this is, I'unno, personally I prefer to have my math Just Work by default -- (expt (expt 2 64) 64) or #I((2^^64)^^64) -- and I like by default being given the chance to fix things and continue/restart via the debugger rather than panic.


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.


Lisp has a rich history in games and graphics that you are not apparently aware of yet -- here's a few mostly Common Lisp Game Engines and resources to get you started (though GOAL was a Scheme variant):

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

2. https://elliottslaughter.com/2011/06/blackthorn-3d

  - Last updated in 2020 https://bitbucket.org/elliottslaughter/blackthorn-engine-3d/src/master/
3. https://github.com/gregcman/sucle

4. https://github.com/BradWBeer/clinch

5. https://github.com/Shirakumo/trial

  - This has games released on Steam built in it
6. https://www.cliki.net/game

7. https://github.com/lispgames/lispgames.github.io/wiki


How about IDE with base codebase of 1.5M loc and tons of 3rd part packages? (emacs)? Most modern programming is not about performance, it is about managing complexity.


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


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.


or a CAD program...

https://www.ptc.com/en/products/creo/elements-direct

that's C + several million lines of Lisp




this uses a C++ rendering engine


Here's a browser written in pure Common Lisp: https://closure.common-lisp.dev/

These questions are so silly. Nobody's written a web-browser in Rust, Python, Ruby, Java, Clojure, Haskell, Erlang, Typescript, Javascript, etc. but that hasn't stopped anybody from using them.

Just admit you don't want to learn Lisp.


I learnt Lisp sometime around 1986 (from library books and later, on the Sinclair QL LOL), I do love it in some ways, but found distribution of final code to be an issue. I don't think it's suitable for all tasks.


> but found distribution of final code to be an issue

in 1986 ?

> don't think it's suitable for all tasks

to this day im yet to see an example of a software engineering problem that lisp is not suitable to solve. if you have such an example ready i would be genuinely curious. otherwise its just a thought from a very common and lazy misunderstanding of what lisp actually is

im talking about computational problems. things that are non-examples include such things as business sense/requirements, availability of programers, availability of ready made libraries/frameworks, or claims of apparent unsuitabilty in large teams


Doesn't support HTML5, CSS3, JS. Non-starter.


so what ? the parent asked for a web browser. nyxt is rendering-engine agnostic by design

otoh how much rust is there in firefox? a:

https://4e6.github.io/firefox-lang-stats/


the hard part about a web browser is the rendering engine, which is why it was raised as a challenge. Sticking a Lisp front end over an existing rendering engine doesn't answer the challenge.


then he didnt ask the right question. nyxt is a browser in every sense of the word. anyway there is no reason lisp cant be used for making a good rendering engine




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: