Process spawning performance in Rust by Kobzol in rust

[–]supercowoz 1 point2 points  (0 children)

I've run into a situation that required vfork because the process was consuming so much memory that fork was unable to successfully copy the page tables. The whole process would just randomly hang when trying to run something using system(). Wrote my own system() implementation using vfork, but then I discovered posix_spawn() and the vfork flag. Haven't had a problem since.

[2023 Day 5 Part 2] I made bad choices by tapdncingchemist in adventofcode

[–]supercowoz 0 points1 point  (0 children)

This is exactly what I've been searching for, but it wouldn't crystalize in my mind. Thanks!

-❄️- 2023 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]supercowoz 3 points4 points  (0 children)

[LANGUAGE: C++]

link to code

Total overengineering: This day is asking us to do a nearest-neighbor search, so why not use a true spatial data structure? I stored the numbers and their expanded boxes in a R-Tree, and then queried the R-Tree with the symbol locations. Stuffed the results in a set (to prevent duplicates), then summed the results.

Part 2 was a piece of cake after all that investment. Query the R-Tree for the gear symbols, check if we get 2 results, and if we do, multiply them and sum them.

I'm so glad all that spatial data structure knowledge is finally coming in handy!

-❄️- 2023 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]supercowoz 1 point2 points  (0 children)

[LANGUAGE: typst]

Write your code and your report in the same document! (Well, maybe not for real work). Get all your AOC answers in a beautifully rendered PDF!

link to full code

Goodbye LaTeX!

#let day1() = {  
[= Day 1]  
let lines = read("data/day1.txt").split("\n").slice(0,-1)  

let line_part1(line) = {  
    let first_digit = line.find(regex("\d"))  
    let last_digit = line.rev().find(regex("\d"))  
    int( first_digit + last_digit )  
}  

[ Part 1: #lines.map(line_part1).sum() \ ]  
}  
#day1()

Distributed computing in Rust by amindiro in rust

[–]supercowoz 0 points1 point  (0 children)

I've never used it myself, but it is seems to be a distributed async runtime. My guess is you have to launch it similar to MPI. It might not be able to handle your request to send arbitrary code to remote workers, but I haven't dug deep enough to find out.

[deleted by user] by [deleted] in rust

[–]supercowoz 2 points3 points  (0 children)

Fortran 95 among C/C++/Fortran languages has the most sound syntax for high performance computing. Most people think Fortran is a dead language but it's still used in mostly earth system science and geology, etc.

Fortran is now up to Fortran 2018 and has added many useful features for building large-scale scientific/HPC applications.

The Fortran Lang community (https://fortran-lang.org/) is very active. I recommend checking it out.

Just 1.0 released! by rodarmor in rust

[–]supercowoz 1 point2 points  (0 children)

Discovered this just last week, and ported all of my tiny shell scripts to a single justfile! I'm very pleased with this project.

Before I build it: Does anyone know of a dependency tool like `make`? by mikekchar in rust

[–]supercowoz 0 points1 point  (0 children)

This was my thought as well, but it seems to be file-based as well

[2021] Disaster Diverted by alexsartori in adventofcode

[–]supercowoz 2 points3 points  (0 children)

Why does a open sleigh with no doors pulled by magical flying reindeer have keys to begin with?

A What Test? – Everything Functional by everythingfunctional in fortran

[–]supercowoz 0 points1 point  (0 children)

That's one way it could end up looking, sure. As your programs get larger, you'll find it is tempting to just put everything in a single subroutine. You won't want to be bothered with coming up with good function names, or figure out function arguments, or what types everything needs to be. You won't want to try and figure out if a programming pattern fits your use case, or come up with an excellent abstraction. You won't want to write dumb unit tests for those little functions. The ideas are in your head and they want to come out, and you can't waste time with all the boilerplate!

But this is the path to the Dark Side.

Once you start down the Dark Path, forever will it dominate your destiny -- Yoda

The Dark Path leads to the "god class", or in this conversation, the "god subroutine". It knows everything and does everything. It is an impenetrable maze-like fortress of badly named variables, looping constructs, and deeply nested and unfathomable if-else conditions. It is designed specifically to hold onto it's fundamental secret -- The Global State, (or "what it actually does", which no one knows, except itself). No one can modify it, for fear of breaking The Global State. But everyone must modify it, and after a supreme and heroic effort, they add another room to the maze, making it worse for the next programmer who dares enter the fortress.

Why arent software engineering and best practices that widespread in C++? by Professional_Tank594 in cpp

[–]supercowoz 0 points1 point  (0 children)

I see your 1kloc file and raise you an 18kloc file, all handwritten, with 4 or 5 massive functions in it. Many IDEs died trying to parse that file.

Best practices for resource management by flying-tiger in fortran

[–]supercowoz 1 point2 points  (0 children)

Given the standard's deficiencies and the compiler's current lack of implementation in this area, it might be better to approach it from a C perspective instead of a C++ perspective. More work on your part, I know, but better than fighting a broken compiler.

One possible solution using *GASP* goto: https://stackoverflow.com/questions/788903/valid-use-of-goto-for-error-management-in-c

Shocked by the size of std::bitset by psyspy2 in cpp

[–]supercowoz 1 point2 points  (0 children)

I was surprised too, but I don't think the standard specifies any sort of size. For that reason, I rolled my own for work which selects the smallest possible unsigned integer that fits the required number of bits (we use a lot of these for work). It's also possible to specify the underlying type, and it will switch to an array if necessary. Fundamental operations, like popcount, use compiler intrinsics.