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.
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.
#![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.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/sucle4. 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/gameotoh how much rust is there in firefox? a:
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.
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
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.
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...
https://www.ptc.com/en/products/creo/elements-direct
that's C + several million lines of Lisp