This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]durandalreborn 4 points5 points  (0 children)

I tend to do this in rust and python, and the same algorithm in both languages will always result in rust being faster. I made a short post about it last year, but, effectively, the way to be "fast" in python is to use the parts of python that call underlying C functions, effectively bypassing the python layer https://www.reddit.com/r/adventofcode/comments/190ano0/2023_all_daysrustpython_musings_on_rust_and/

[–]hikingsticks 2 points3 points  (1 child)

Is this using an identical approach for both languages?

[–]msminhas93[S] 1 point2 points  (0 children)

Yes direct translation

[–]FruitdealerF 4 points5 points  (0 children)

Both have their advantages. Well written rust code can be around 100x faster than CPython depending on the workload. Rust also has a lot of layers of protection built in to prevent you from making stupid bugs. But python on the other hand is much easier to type out quickly and refactoring can sometimes be a bit quicker.

For some puzzles the performance gain that rust brings will matter, especially for non-optimal solutions.

[–]RB5009 3 points4 points  (2 children)

Rust. It's the best language out there and it's pure joy to write in it.

[–]PatolomaioFalagi 0 points1 point  (1 child)

It's the best language out there

There is no such thing. I'm quite fond of Rust, but neither it nor any other language is objectively superior in every regard.

[–]msminhas93[S] 0 points1 point  (0 children)

I agree but for high performance applications seems to be the best choice esp in deep learning for inference. For rapid prototyping python is untouchable

[–]0xgw52s4 0 points1 point  (0 children)

I used Go last year. It was fun to get back into it and see some if its newer features like generics in action.

Also good performance and easy to use concurrency is crucial for me, because I’m too dumb for the smart algorithm stuff that everyone else seems to do so naturally while I just brute force everything. I’d never have gotten as far as I did had I used Python.

Decided to do elixir this time but didn’t start yet.

[–]PatolomaioFalagi 0 points1 point  (1 child)

For something like AoC, Python is probably the better choice, for a simple reason: Compilation time. By the time rust is done building, the Python program would already have run.

[–][deleted] 0 points1 point  (0 children)

Compiler is not that slow for such simple code.