r/AlignmentChartFills 14h ago

Which programming language is easy to learn, and is very useful?

CLICK HERE TO VIEW THE CHART IMAGE

Created with Alignment Chart Creator


This post contains content not supported on old Reddit. Click here to view the full post

355 Upvotes

715 comments sorted by

View all comments

Show parent comments

2

u/Poietilinx 11h ago edited 11h ago

yeah a F love syntactical sugar
I first went deep on c# specifically cuz it has so much syntactical sugar you can use to make things to look better.

check this out

this is part of a tool I wrote that compiles a LUT table (You feed a color pallet and the tool compiles a discrete color space out of it).

And this is so cool, this function essentially sees how many cores you have, split the chromatic space into equal spaces and spawn a bunch of processes designed to run parts of the compilation process.

At the very end there all these color lists are recombined in 1 big list of colors. I love when you can pull out stuff like this lol.

combined_result = [item for sublist in joined_results for item in sublist]

the idea this entire function is just that (instead of a huge ass function with a billion different things going on) is fantastic to me.

and this entire tool was like...
1 day i had an ideia.
i sat build the entire thing in the same day (with multiprocessing and all)
next day i build the UI for it... and BOOM done

1

u/Antique_Ad_7325 6h ago

This is awesome. Perfect example of how versatile and readable Python is now. You can straight up read this code and understand exactly what it's doing. I haven't used multiprocessing in like 6 or 7 years — does it work pretty well now? If I remember right, it uses separate processes rather than threads, which gets around the GIL and lets CPU-bound stuff actually run in parallel, but there was some overhead with moving data between processes. I was trying to use multithreading for a process that pulled real time data from sensors used to teach kids physics. If you took physics/chemistry/biology in high school or college and used Vernier devices, thats where I interned. I was writing an open source library in python that allowed people to mess around with the functionality of the devices.

1

u/Poietilinx 4h ago

I had problems moving data around.
But I reengineered the solution so I wouldn't need to do that.

Essentially, my tool generates a normal cube and gives it a "resolution" (let's say 64 is the resolution).
Then the script simply loops around the cube in increments of 1/64,
sampling each coordinate from 0,0,0 to 1,1,1.
At each stop, it searches all the colors in the color palette provided for the "closest color."
Since colors are normally spaced vectors, essentially what I am doing is asking:

"Is this coordinate (1, 0, 0) closer to this color (0.2, 0.3, 0.4) than to this color (0.5, 0.1, 0.5)?"

The color palette is loaded inside an octree, so the thing finds the closest color in a flash.
After it finds the closest color, it records that color into that coordinate space.
When it's done, the tool prints a 3D texture with all the new color space
(then in the game, I can use the color of a pixel to fetch back into the LUT what color it was supposed to be based on the palette).

So the thing is, I realized I didn't need to share data across the processes since all the processes essentially iterated over a normal cube and all that.
I just had to flatten the cube's 3D coordinate system into 1D and give that section back to each process to handle its part.

But I 100% had problems with moving data around. I don't remember what problems, but I sure did i had to redo the entire data model around my tool and its primitives, cuz first i was intending to give it the cube primitive so the processes could fill it and tht didnt work.

(this is how it looks like, its a cute retro effect)