What are you working on, /g/?Previous thread: >>106715518
A topic mentioned briefly in the last thread: does C have any books, articles or guidelines about program structure and architecture?OOP languages have Design Patterns, SOLID principles, etc. - does C have anything even remotely similar?
>>106744589>>106744558Why so much cringe beta yap lil bro, you just make functions and objects and create and call them.
>>106744589>They're designed to make code more readable for low-skill wagiesthat's a false assertiondesign patterns specifically are an upfront complexity overhead. there's nothing "low-skill" about them, starting from the decision to apply them in the first place (and if so, which one). they don't make code "more readable" either, that was never a goalthe point of design patterns is to apply a working solution to a specific common problem, opposed to reinventing the wheeleventually some design patterns become common enough to be integrated or implemented as language features, eg. enhanced for-loops in Java is just syntax sugar for the Iterator pattern>If you work in a corporate environment where a bootcamp grad or an H1B might have to maintain your code eventually, then design patterns make sense.sure, that's why actual H1B-focused languages like Go actually dropped more abstract and advanced language featuresnot to mention design patterns were conceived long before pajeets started taking over the programming job market
>>106744601and cooking is just cutting and heating stuff up
>>106744670Yes. Don't forget waiting.Rust finishes compiling 10+ times in time it takes to make anything edible.
>ulimit -H -s>unlimitedSo with one syscall, yes (1), I can use alloca without undefined behavior.
I am trying to make my raytracer multi threaded. The pixels are a 1d array of size: width times height. I have two ways to distribute the pixels over the threads. One is to find the next unrendered pixel index (through mutex or atomic operations) and assign it to a free thread. Another is to alternate the threads between consecutive pixels: basically take the residue class of the pixel indices modulo the number of threads, every class is assigned its own thread. I think the latter approach works if the work required for each pixel is uniformly distributed. Is there a name for these two different approaches? And what sort of images would the latter be inefficient for?
>>106745535>I fixed the bug in the MAIDS Virtual Machine more like AIDS propagation machine
>>106745670You should stop thinking in pixels and think in how much memory every single individual pixel will touch.You can do a quick single threaded pre-pass to quickly calculate the weights based on how many models a direct ray (single sample) hits, more models means higher cache pressure.Sort those weights.Force threads to process pixels of similar weight at once so all of your cores are touching same memory. At some point you can work on making it so you can render massive scenes that don't fit in RAM, by optimizing threads to work on a patch that is not necessarily a rectangle, that ensures minimum memory usage for that specific piece of work. Some parts will still have high cache pressure, but they won't be raped by a random thread pulling in some other models on top of already existing ones, because they will together be focusing on a few select ones guided by heuristics of your choice.
>>106745670Just use atomics. Let the thread load balance themselves.
>>106745670>>106745897Also if you want threads to pick more close-by pixels for sake of cache or whatever like other anon said just use hilbert curve to pick pixels from id. Dunno how computationally expensive it is to determine pixel position this way though.
>>106745946There is no need to get so emotional. It's just programming.Rays that go to similiar direction are more likely to reuse cache than grouping random rays from all over the place solely based on an extrapolated number of hits of some extra, single threaded pre pass.
>>106745979Ok nocoder, nobody cares about your edge case of rendering one single sphere into 4K image where the sphere has less overhead than writing pixel values into the fucking image, kill yourself you total worthless retarded.
>>106745995Someone is having a mental breakdown lmao.Also just looked up on wikipedia:>The Hilbert Curve is commonly used among rendering images or videos. Common programs such as Blender and Cinema 4D use the Hilbert Curve to trace the objects, and render the scene.I honestly just randomly came up with the idea on the spot, I had no idea this is actually used in the wild. Nice.
Zamn bro, slopware uses Hilbert curve?Now lets look into what people who are employed use and how they render amazing animated scenes into 2 hour movies, do they use reddit curves too?
Is it possible to ask a SINGLE question without a fight breaking out?
>>1067460624chan is not known for being a bastion of mental stability.
>>106745920That's actually a pretty neat idea. I am a mathematician delving into graphics, not a coder, so using Hilbert curves sounds cool.
>>106746113>literal nocoder>can't do even basic math to compare what will affect performance more
>>106746106This shit doesn't happen in /mg/. I think the divide between programmers and coders or worse, "tech enthusiasts" is what attracts narcissistic complex retards like the other dude.
>>106746113You are welcome. I am also interested in such topics, I even wrote my bechlor's thesis about raytracers.What kind of ray tracer are you working on? Just basic recursive ray tracing? Path tracing? Physically based?Also considering that some large programs use hilbert curves is probably a good sign, but a good rule of thumb is to keep things simple(like just rows by columns enumeration) and then once you have MVP working, benchmark more complex ideas to find best one. There is no need to prematurely optimize stuff if your program is not even working right now. Maybe even the schizo guy was right this time, only a benchmark can tell.
>>106746062>>>/g/sqt/
>>106746174It's a very rudimentary recursive ray tracer. It's my first proper programming project really. I started immediately after finishing K&R.
I fucking hate c++, just spent 3 hours bashing my skull inside out because a pointer to an item inside a vector becomes invalid if you add shit to the vectorHow am I supposed to fix this without manually setting a capacity big enough?
>>106746272You're supposed not to use std::vector for any non-toy pro...Nevermind, just pretend I didn't even make this post because you're too stupid to agree with me anyway.
>>106746298Stop trying to start an argument, I don't even use C++, this is my 3rd day using it.Tell me your oh mighty ways, teach me proper use because I'm getting tired of all the insidious jewish tricks this language pulls.
>>106746203That's a really good choice for a project like that. As long as you know how to output a pixel, you can make a raytracer and there is a lot of techniques like multithreading and area allocators that you can learned through it.I used to make quite a lot of these, especially with my gmod bros before I even learned my first real programming language(C++). Here is a path tracer made by a friend.Post some generations once you get it working.
>>106746324If you can't figure out how to achieve pointer stability, that's on you.
do cpp tards really ?
>>106746376Such a jewish post. Nobody can help you but yourself. I can try to teach you all day but if you're retarded then you're retarded.
>>106746062not when maidniggers deploy their aggressive schizos to shit up the thread
>>106746272Depending on your usecase.In my game engine, I use id based references to entities and components. Each entity and component has a globally unique id generated through incrementing a 64bit atomic. Entities are stored in a binary tree, BTreeMap<u64, Entity> and components are stored inside entities using a BTreeMap<u64, dyn Component>. A reference to some component is stored as a tuple (u64, u64) which holds the id of the entity and the component and can be dereferenced to the concrete Component type when needed simply by looking up the entities tree and its components tree. In C++, you would just have to remember to not modify any of these trees while you are holding a reference to the concrete component/entity to not invalidate it. In Rust, this is handled by the borrow checker.
>>106746442turn the regdump schizo LLM back on, nocodeshitter
>>106746480less beta yap lil bro, turn it on and get out of my sight
>>106746385you can't even try, you just assume everyone is retardedor maybe, you don't know but think you could learn in the moment and since you think you can do that, you assume everyone else is stupidjust stop posting
>well-named classes and methods, as well as detailed stacktraces make it easy to find the correct location in code>the IDE very clearly shows usages of elements - no need to search by text and then guess/analyze if it's the same context>memory allocation a complete non-issue, can focus purely on business logicdamn I love working with Java
>>106746495No, I just assume that someone intelligent will figure everything out without me.
>>106746497I don't know about well-named. They couldn't even decide on the letter case for XML and the collection types are under "java.util" package.It's also full of boilerplate, but I agree that it is stupid simple and comfy if you use it in the bloated Java IDEs.
>>106746564in C++ this is just:>class xml
>>106746581I think many C++ users are on the verge of being / might be insane. Who else would put up with an STD that strictly offers insane defaults like std::map? Who else would look at such an insane language + STL combo and go "I can fix that"?
>>106746502why don't you take the next step and not post anything at all because no one needs you?
>>106746640I don't know, I don't use anything from std namespace.
>>106746648>I can fix that
>>106746642Because you get mad when I post something.>>106746665I already fixed it. Works fine for me. In fact, I love this, filters out retards.
>>106746497>well-named classes and methodsAhhhh, yes, don't you just love the AbstractBeanFlickerFactory's
>>106746980No, but I do love try (BufferedReader reader = new BufferedReader(new FileReader("file.txt"))){}
try (BufferedReader reader = new BufferedReader(new FileReader("file.txt"))){}
>>106746062Would be possible if people just hide the schizo posts instead of giving them attentionBoth "maids" and the buzzword spam ones have nothing to lose since they are completely delusional, it's like touching something rotten or an animal covered in feces
>>106747100What the fuck is this shit, do Javatoddlers really lmao
reject modernity
>>106747148That's nothing. As an unemplyed chad, I love making fun of java SQLIntegrityConstraintViolationException monkeys and regularly ctrl+f 'factory', 'abstract' on https://docs.oracle.com/en/java/javase/25/docs/api/overview-tree.html for a good laf.
>>106747349That inheritance tree reminds me of average amerimutt ancestry.
>C11 threads.h>pthread.h>either plus win32 and enjoy the ifdef soup Whats the way if I want this to be compiled and run by windows folks as well?
>>106745897>false sharingas expected from a rustard
>>106747684OpenMP
>>106747684Wintoddlers don't know how to compile things, now go back and make some better quality bait.
>>106746272don't store pointers to data stored in vectors, you store the index to the element and retreive it when you need it
>>106747740>pragma everywhereIt's pretty impressive how ugly it can look.
let a = f x, b = g xThis is the best let delimiter I decided
let a = f x, b = g x
Anyone feels that the code you write is the embodiment of your persona and mind and soul?
>>106747815nooo, that's how they do it in rust and I won't stand for this!
>>106747834you meanlet a = f x, b = g x
>>106747834in Haskell this is justlet (a, b) = (f x, g x)
let (a, b) = (f x, g x)
>>106747901Yes, the left hand side are patterns, but imagine g a
>>106747930let (a, b) = (f x, g a)
let (a, b) = (f x, g a)
>>106747785>hates to give people optionsAre you a gnome dev
>>106747954No, I'm actually a lot more principled than ebussy, the only options you have is fuck off or fuck off.
>>106747946I'm not sure a should be in scope desu, recall let is sugar for a function f a b applied to (f x) (g a)
>>106747815but that means I gotta store a pointer to the vector or give vector whenever I need to do something
>>106748070Get a job at mcdonalds instead.
>>106747986this is Haskell
>>106748094I sense a lot of passion in your words, high effort in every message, I am very proud
>>106748123And I sense that you'd be happier doing a menial repetitive task that didn't force you to think too much lest you get exhausted from bare minimum cognitive ability that's expected of you.
>>106748099Then I disagree with Haskell in this case (or rather, I prefer the dumbest let derivation possible)
>>106748146then you are wronglet ones = 1 : ones`
let ones = 1 : ones
>>106748138this is a menial task that doesn't force me to think too muchyou think you're a genius because you program?
>>106748208You couldn't even capitalize your sentence properly, you seem to be mentally exhausted already bud, just go to McDonalds, they're hiring all year round.
>>106748178I'm not trying to be right with respect to Haskell, but I'll think about scoping more anon
>>106748244in OCaml you would do let rec
>>106748218>already budwhere's the comma, bud?
>>106748255, already triggers my autism without adding another keyword, this feels like it should be figured out during an analysis pass
>>106748070>all that shit you wroteok and?
>>106747845Any other idiotic thought that you don't believe yourself that you'd like to share?
>>106747845Everything that you design or engineer is the embodiment of your persona and etcAbout code there's the Conway's law, code will always mimic the organization structure
>>106747293embrace power
>>106747954He's kinda right though. When I am using a windows machine, and I see a repository lacking precompiled binaries, I don't even bother with the hassle. I'd rather just use my mac.
>>106747293>orthocuck
>>106746272didn’t your parents ever warn you about stds?don’t rely on structures that internally use realloc if you want to keep pointer coherency. either keep an index instead or make an arena that uses bucketing to preserve valid pointers
>>106747293I wish the US had long-term thinking culture, so they wouldn't be making bubbles everywhere and changing what doesn't need to be changedC++ would be completely fine if it was just C + new stuff instead of trying to replace everything with bogus after bogus
>>106748639When I post code I write I feel like I am posting nude photos of myself.
i just got a mini pc with an ryzen 7 8745HSaside from hacking together a custom build of ROCm targeting gfx1103 for the iGPU and compiling more C++ more faster what's some shit i can do with the CPU to practice the subset of AVX-512 that didn't get dropped and any other extensions it may havemy main desktop is a haswell so this is the first time i've had access to anything above AVX2
>>106749140>don’t rely on structures that internally use realloc if you want to keep pointer coherency. either keep an index instead or make an arena that uses bucketing to preserve valid pointerswhat is this mental retardation? boxing exists
>>106749272what does a butthole look like in code?
I am adding more pattern matchers to MAIDS and fixing a bug involving the arb matcher.
>>106749395And where's the code?
>>106749416Under active development on the Science Computer. Once the rest of the matchers are in and and the manual is done I will release it to Public Domain via Kurumi Maid Card.
Whenever I hear talk of memory efficiency I have no hands on experience with it.I wanna learn more about how memory of a computer works. The only thing I've ever learned was the analogy "memory is like a desk you can work your documents on, they're all withing reach for you to easily access. Storage is like a file cabinet. You can stire a lot more in there but you have to get up and go open it."
>>106749692Try learning assembly/C and basic computer architectureEmbedded programming teaches you a lot about memory since you have to use it directly
>>106749391[]<>(){}
>>106749847you forgot a () to call it
>>106749391Only if you knew what 90% of the modern logos looks like...
Writing a local query engineI'm just doing shit as I go. Asking Claude for guidance, no full vibe coding.Also trying to learn either Sublime Text or Vscode as I go. Kind of tired of wasting time with nvim/emacs
>>106749692just using a manual memory management language will teach you a lot although there's a fair amount of variability even there with how low level you goif you've got an old TI graphic calculator you can do embedded dev on it or super retro-dev depending on what modelto add to the bad metaphor registers are what you have in your head at any given moment and the cache is what you have in your handsthe difference between registers, cache, memory and storage is access latency, i.e. time it takes for communication to go there and back, partially just because of distance to the CPU but other things toothis is different from access speedregisters are what CPU instructions actually do stuff on, and for all you have access to they're right there, the cache is different levels of storage physically located on the CPU which is normally implicitly manged but can be managed explicitly, memory is located near the CPU, storage is located far away from the CPU and has to go through things like the filesystemmemory is a big fat arraya pointer is an index into that array (it's literally just a number)loading or storing data to registers from memory and reverse looks up the index, it also goes through the cache first to checkcomputers don't usually just do that directly (what is called DMA or direct memory access is usually reserved for the OS and drivers)memory is virtualized and has been for a really long time (like the NES has virtual memory)this means when you load or store something instead of hitting the physical memory it goes through a memory controller of some kind (the modern ones are called IOMMUs)the memory controller takes virtual addresses (the indexes into memory you use) and maps them to physical addresses (the indexes in memory the OS and hardware use)1/?
>>106750137some of these are semi-standard, some of these are set by the hardware, some by firmware, some by the OS, some by drivers, some by the process launcher, some you can requestits used for a variety of things including security (for example, each process gets its own memory mapping so without special permissions you can't read the memory of other processes) and from what i know older hardware used it more for making it possible to address larger regions of memory than the register sizes supported with banked addressing so you'd set one register to 1 and another to 0 and it would access the second item from memory bank 1 and then change the 0 to a one and it'd be the second item from memory bank 2they can be real physical memory but they can also be other things including memory ranges corresponding to PCIe which could be storage, your GPU's memory (modern GPUs also have a IOMMU and can do this in reverse), or many other thingswhen it's used that way it's called memory mapped IOcomputer memory is also paged which basically is just chunked mapping and storage of mapped memory so things can be loaded in chunks and memory you aren't really using is saved to disk in a memory mapped file windows calls the pagefile or linux calls the swapfilenever done a deep dive on how it works but it's supported by hardware and it's multi-levelmemory efficiency basically means using as little ram as possible (like by making sure you move data instead of copying it or use techniques like copy on write, so no matter how many of something you have there's only one copy of each unique item and when you change it, that's when it makes a new one), requesting memory from the OS as efficiently as possible (i.e. you ask for big chunks so the OS gives you RAM that's physically located together then you subdivide it, RAM version of avoiding file fragmentation), requesting memory from the OS as little as possible (allocation is expensive)
>>106750310oh and by register size i mean what like 32, 64 bit, etc. refer tothat used to be called the "word" size and on some hardware was really funky but ever since intel compatible processors really took over "word" is mostly used to refer to 16 bits since that was the word size of the original processors modern intel and AMD ones are descended from (and are still technically compatible with at initial boot iirc)i don't think there's an actual word for it these days since register size isn't quite accurate eithersome processors have fancy registers that are larger bit sizes like 128, 256, or 512 but those are used for special instructions and even when you use them to access memory what's actually used is still at max the "bitness" of the processor and they instead access multiple indexes of memory
unholy yap
just to add to the other anon's lecture: optimizing a program for memory usage means some performance will be sacrificed when things need to get unloaded and loaded againbeing "wasteful" with memory means you can keep things allocated, which in turns saves on loading times, at the cost of having more memory occupied by the program (which means it can't be used for other stuff), and with a higher risk of running out of memorybut if you have an abundant amount of RAM, it's not a problem to just keep stuff in memory - as the saying goes, "unused RAM is wasted RAM"
>Start looking at Odinn, err := os.read(os.stdin, buf[:])if err != nil ...>Stop looking at OdinI thought this shit was supposed to spark joy. I don't want Go-flavored diarrhea all over the code.
n, err := os.read(os.stdin, buf[:])if err != nil ...
>>106750827why do these faggots think they can just name their shitty awful languages after God
>>106750905Odin isn't God...Odin is a god, but not God.I thought you people were supposed to be autistic and pedantic neatfreaks, but you're all just grifters.
>>106750974He is
>>106750827whats your favorite flavor>int foo(bar in, baz *out)>bool foo(bar in, baz *out)>BazResult foo(bar in)>try-catch hell
>>106751268taking two exit continuations to jump to
>>106750827>he fell for the unreal memejust learn C# + godot nigga
>>106751278might as well just do exit(1)
>>106751351you can pass such a continuation if you so desire