|
So has the time of Rust enjoyers finally come? Consumer reports advocates memory-safe languages like Rust, instead of legacy languages like C/C++: https://advocacy.consumerreports.org/research/report-future-of-memory-safety/ So does NSA: https://www.nsa.gov/Press-Room/News...-safety-issues/ Noticeable parts of Windows have already been rewritten in Rust: https://www.theregister.com/2023/04/27/microsoft_windows_rust/ Apparently Rust was accepted as an language for linux kernel development etc. Our School still teaches C++ and ANSI C (ugh ). No rust courses. I didn't get any job for summer, so I guess it's time to learn rust? Someone said this is more comperehensive: https://doc.rust-lang.org/stable/book/ than this: https://doc.rust-lang.org/rust-by-example/ Any pro tips on which to use? I guess Vscode is an ok editor for Rust, if I configure it as you suggested earlier in the thread.
|
# ¿ Apr 30, 2023 12:34 |
|
|
# ¿ Apr 29, 2024 11:28 |
|
Fffuuu. I need to implement a Rust code:
I am in deep crap. Do I have some other options than a circular linked list, implemented with raw pointers? I don't know how to do it but I can learn, can't be much tougher than in ANSI C.
|
# ¿ Dec 11, 2023 18:23 |
|
Dijkstracula posted:I don’t really remember precisely what the Josephus problem is, but what limits you from using a VecDeque? Consider a game where there are n children (numbered 1,2,..,n) in a circle. During the game, every kth child is removed from the circle until there are no children left. In which order will the children be removed? And I need to return a list of removed persons, in the removal order. My futile attempt was too slow: Rust code:
|
# ¿ Dec 11, 2023 19:26 |
|
VecDeque helped somewhat, but not still enough. Maybe smaller integers? I finally actually timed what takes so long, and I realized printing! Rust code:
Pointer usage will be saved for another day. Thanks...
|
# ¿ Dec 11, 2023 19:57 |
|
gonadic io posted:is locking stdout for a long time like that an issue? I don't really know what its implications are tbh. I personally would be tempted to populate a vec then write out in one go after I tried that first, populate a vector with ints. Use println! and iterators to print it in one go. I could not get either print or println work fast enough. With n=200000 writing to stdout gave a 0,4s execution time. With any kind of print it was over 1s with my (lack of) skill.
|
# ¿ Dec 12, 2023 00:32 |
|
This is just an algorithm course, so nothing serious. I began learning rust two weeks ago, because I needed a compiler which babysits me. We have 100 different algorithms to implement, and now after a soft start the tasks seem to get stricter. One thing I did not try out was storing the values to vector and then writing it instead of printing. Iterating a vector of 200k indexes adds an extra delay though, so just writing the data after each calculation is done seems to be faster.
|
# ¿ Dec 12, 2023 00:42 |
|
Before implementing a command line argument tool in "main" bin, I used a bin for each day in advent of code. Now I wonder how can I run only tests for day_13.rs for example. They are in end of day_13.rs Rust code:
It just spams my terminal with useless crap currently :I E: Heh, the "Run Test" button above mod tests in day_13.rs in VSCode magically told me the correct command: code:
Ihmemies fucked around with this message at 19:35 on Dec 13, 2023 |
# ¿ Dec 13, 2023 19:32 |
|
bitprophet posted:There’s also a half decent cargo-aoc plugin out there which greatly simplifies this stuff, if wrestling with a cli tool isn’t something you actively enjoy doing. (Its “generator” feature is flaky but also just not necessary.) I run the code on my linux server, because setting up stuff there is so much easier. So program runs on VSCode's terminal window. You mean this onehttps://crates.io/crates/cargo-aoc ? Hmm maybe I should test it, thanks. Although since I started learning rust like 2 weeks ago maybe it's good first to do things more manually.
|
# ¿ Dec 14, 2023 09:56 |
|
|
# ¿ Apr 29, 2024 11:28 |
|
I am learning structs are quite handy. For a simple struct like this:Rust code:
So it checks if the coord fits certain bounds. AoC has different sizes of maps and doing always the same bounds checking individually in different solutions starts to suck. Then I realized you can write cool comments like that, so my IDE shows tooltips for my own functions, just like it does for STD's functions. Sweet.. AoC day 17 progress is not great, but not terrible. My utils.rs is growing in functionality at least. First I used usize as coords, then I thought about what if I want to take a cruise around origin.. and realized I need to support negative coordinates too. Ihmemies fucked around with this message at 17:29 on Dec 17, 2023 |
# ¿ Dec 17, 2023 17:27 |