[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: ocamls.png (1.79 MB, 2048x884)
1.79 MB
1.79 MB PNG
What are you working on, /g/?

Previous: >>108395499
>>
>>108425619
Working on coming up with a project.
>>
>>108425691
Do you have a logo yet?
>>
I still don't know how O notation works
>>
>>108425923
Small O good, big O bad.
>>
>>108425960
Basically penis rings
>>
>>108425779
>Do you have a logo yet?
this anon is correct. the most important part of a project is a logo and a wacky name. look at open claw.
>>
>>108425923
It's just how your algorithm's runtime scales with the size of the input. It's not interested in the exact value, just the largest term, e.g. O(3n^2 + 999999n + 15) -> O(n^2), because the other terms become insignificant as n becomes large.
People rarely do it "properly" outside of academic contracts, just as the general vibe of how an algorithm might perform.
>>
>>108425923
it is not a worry my sir! you carry those doubt to me and I calm your braining! I will doing the metaphor to understand yo better! now thinking in terms of o the durga mayhaps be complexity in quadratic by ganesha. then onto this the krishna then finally the lakshimi. it is mapping directly to bubble sort! simple yes? no worries my brother!
>>
File: 1749427113553166.jpg (88 KB, 1180x720)
88 KB
88 KB JPG
>>108425923
>three responses in
>no one posts picrel

Also I wouldn't worry about it too much. >>108426165 is right about "academic contracts" because academia likes to ignore the reality of the hardware - i.e. that instructions can have wildly different performance characteristics depending on contexts, which academia autists pretend to ignore as it anxiety-inducing for them.
>>
File: Tohru IDE.png (410 KB, 1920x1040)
410 KB
410 KB PNG
>>108423895
MAIDS on Tohru IDE.
>>
>>108426521
Can't wait until you get banned again, Eli.
>>
File: 1660065512997.gif (904 KB, 614x768)
904 KB
904 KB GIF
>>108426558
This is my Science Foundation.
>>
>>108426632
Counting maids isn't science.
Putting a bullet in your head is.
>>
File: GoBhbZvaoAArOLr.jpg (2.21 MB, 3072x4096)
2.21 MB
2.21 MB JPG
>>108426521
lol wow based and maid pilled
>>
>>108426632
I wanted to show you this. I saw your maid card hex > pixel thing and made a simple python version. No compression and only image.png and card.py but it was fun.

#!/usr/bin/env python3
import sys
import os
from PIL import Image

bit_on, bit_off = (0, 0, 0, 255), (255, 255, 255, 255)
bits_from_nibble = lambda n: [bit_on if n >> k & 1 else bit_off for k in (3, 2, 1, 0)]
nibble_from_pixels = lambda pixels: sum(
((sum(px[:3]) < 384) << k) for px, k in zip(pixels, (3, 2, 1, 0))
)

def unpack():
card = Image.open("card.png").convert("RGBA")
width, height = card.size
nibbles_per_row = max(1, width // 2)
def read_nibbles(count):
chars = []
for i in range(count):
row = i // nibbles_per_row
col = i % nibbles_per_row
x, y = col * 2, row * 2
chars.append(
f"{nibble_from_pixels([card.getpixel((x, y)), card.getpixel((x + 1, y)), card.getpixel((x, y + 1)), card.getpixel((x + 1, y + 1))]):X}"
)
return "".join(chars)
size_hex = read_nibbles(8)
code_bytes = int(size_hex, 16)
total_nibbles = 8 + code_bytes * 2
hex_text = read_nibbles(total_nibbles)[8:]
open("code.py", "wb").write(bytes.fromhex(hex_text))
header_height = ((total_nibbles + nibbles_per_row - 1) // nibbles_per_row) * 2
card.crop((0, header_height, width, height)).save("image.png")
os.remove("card.png")

if __name__ == "__main__":
fail = lambda: sys.exit("Usage: maid.py pack|unpack")
cmd = sys.argv[1].lower() if len(sys.argv) > 1 else ""
if cmd == "unpack":
os.path.exists("card.png") or fail()
unpack()
else:
fail()
>>
File: card.png (1.94 MB, 3000x2124)
1.94 MB
1.94 MB PNG
>>108426842
oops
>>
File: 1529236032334.gif (2.62 MB, 540x304)
2.62 MB
2.62 MB GIF
>>108426842
This looks nice. Thank you for posting it.

>>108426848
What did you put in this one?
>>
>>108426868
just the pack function haha :P anyways thanks!
>>
File: 1747018158594001.png (4 KB, 198x58)
4 KB
4 KB PNG
>there hasn't been a new nvchad release in over 2 years
it's over...
>>
>>108427692
Isn't that just like a collection of neovim plugins? Why would that need to be updated more than once a decade? Neovim and the plugins themselves receive their own updates independently of whatever prepackaged slop you downloaded.
>>
what convinces you to use vim instead of novadays editors like vs code, or vice versa? for me the navigation in project that have more than a few files sucks in vim
>>
I concede on the pronunciation of GIF but I refuse to say char as charr
>>
>>108429114
... I'm beginning to realize why the vibecoders think they can beat your autistic asses.
>>
Is there any way to link OpenCL.std functions into shaders not being used for opencl?
>>
What if instead of silently doing compiler optimizations, compilers would curse you out for every stupid thing they have to optimize in your code
>>
>>108431526
programmers would graph the curses and use it as a compiler benchmark and compete for high scores
>>
>>108431526
What enters the category of stupid optimization?
>>
>>108431526
Rust developers have a high enough attrition rate as it is.
>>
>>108426327
>academia autists pretend to ignore as it anxiety-inducing for them
Have you ever heard of... theoretical CS?
>>
which one of you autists made this?
https://sloprank.io/
>>
>>108432271
Why would I be interested in theoretical masturbation?
>>
theoretical rape
>>
File: 1758979128760996.mp4 (1.05 MB, 480x852)
1.05 MB
1.05 MB MP4
!!! I finished today's leetcode question (dynamic programming) without any hints or outside help!!!! !!!
>>
wrote a powershell script to run two small scripts I wrote in two different languages then used task scheduler to run it once a day. was pretty fun, will do it again.
>>
Suck my penis please brogrammer. I have my C certification.
>>
>>108433996
Enjoy your fucked-up stacks.
>>
I don't understand how do they store data in clouds? don't clouds disappear after a while?
>>
>>108434397
They keep boiling water, which ends up resupplying the clouds with water. The heat makes the sun's warmth even warmer, which is what climate change is all about.
>>
File: dmg-acid.png (22 KB, 603x523)
22 KB
22 KB PNG
It's beautiful.
>>
today is the day I program. I can feel it.
>>
>>108425619
>>108425619
I am NOT koding rn. Tho it is almost wednesday, so I might prepare something today
>>
>>108434659
based emulator man
Are you doing your own ROMs now? Le emulator finished?
>>
File: cff.png (65 KB, 625x626)
65 KB
65 KB PNG
>>108425923
I still don't understand how people do not understand it.
Isn't this by far the easiest thing to understand in CS?
At least the fundamentals of it. Okay you might get confused with time and space complexity, but the general terms are cristal clear, no??
You just gotta understand high school maths. Are people too dumb for that? No offense h3h
>>
>>108436311
American highschool math is middleschool math for the rest of the world. American undergrad math is highschool math for the rest of the world. This is why the US imports so many immigrants. It has an education system which at the lower levels was designed to produce people just competent enough to work factory jobs which no longer exist. At the higher levels, it is designed to produce middle managers. You don't need a math education to produce spreadsheets nobody will ever read, or enforce arbitrary HR policies.
>>
I already posted this a few threads back.
Hi, /dpt/. I need help for my projects.
I want to benchmark my code in C. I've read that I could use time functions (Windows time functions in my case), but is that enough to have a good benchmark? Do I need something else to do a good benchmark?
Thanks to these anons:
>>108424236
>>108424555
>>
>>108436273
>Are you doing your own ROMs now? Le emulator finished?
No. Not even close.
I think essentially I have the CPU and PPU emulated correctly now. The opening animation in Pokemon Yellow seems to run slow though and I don't know why. I still need to fix video output on hardware, I'm not sure exactly why it ends up screwed up, but I have a few alternative methods I can try to resolve it.
I have no MBC and MBC1 basically supported (though external RAM is presently always active), and MBC3 enough for Pokemon Yellow (I think) but there's a bunch of RTC support stuff in that as well (I think I'll try tap the PS2 RTC for it) but no other mappers supported.
I'm only just looking at audio now. I have never touched it on PS2 yet but I think I know the gist of how to implement it.
And then I have been thinking about how to implement saving games. The most reasonable way seems to be through the memory cards, just copy the contents of the external RAM to the memory card in a blob, but unless I can hook every game's save routine I think a hotkey that will pause emulation and copy it would be best, then on emulator load it can check the memory card for a save to populate the external RAM from.

Did I mention I'm writing this all in assembly?
>>
>>108436545
>Did I mention I'm writing this all in assembly?
yes you did.
When it comes to koding i am also a bit masochistic, but assembly ain't just a fetish of mine. I would never touch it longer than I need to.
Gl getting that shit up and running.

Assembly just to make it harder for yourself or would a higher level language even be more complicated?
>>
>>108436520
Use a proper IDE and run a profiler. This will not only measure how long it takes for your program to run, it will also identify which specific parts of your program are slow, so you can address bottlenecks. CLion is pretty good for this.
>>
>>108436562
My guess is lack of a good compiler.
>>
>>108436562
I just have an assembly bug right now.
Ever since I started doing things on the NES in 6502 ASM I'm just enjoying using assembly for things.
>>
>>108436600
I use Visual Studio, but I don't get its profiler. Thanks, I'll take a look at CLion.
But I'd like to use my text editor (Notepad++) and terminal (gcc).
>>
>>108436675
>But I'd like to use my text editor (Notepad++) and terminal (gcc).
I understand this desire, but you're kind of handicapping yourself with it. Using tools designed for the task is going to result in better code, produced faster. I used to use vim and command-line Java exclusively. Compared to using something like IntelliJ, that previous workflow feels like trying to cut down a tree with a spoon, instead of a chainsaw. This effect only becomes more pronounced as the scale of projects grows.
>>
>>108436771
Nah not really. It's just a matter of taste and habit.
Not the OP, but IDEs are just too bloated for me and distract me too much.
They are good for some tasks sometimes, but when I can I avoid them
>>
https://www.boxyuwu.blog/posts/an-incoherent-rust/
Rust having such fundamental failings this late in the game is turning me off. Starting to feel like traits were a mistake. Maybe it's time for a return to good old Python sort(data, key=my_func).
>>
>>108438590
@grok summarize this article
>>
>>108438590
>Rust having such fundamental failings this late in the game is turning me off.
How exactly is this a failing? Coherence rules are important and they save you from things breaking randomly on updates.

>Starting to feel like traits were a mistake.
As opposed to what exactly?

>Maybe it's time for a return to good old Python sort(data, key=my_func).
How is this related to coherence rules?
>>
File: 1773709069175474.jpg (128 KB, 702x558)
128 KB
128 KB JPG
>>108438590
>uwu in url
>>
growing up is realizing that descriptive languages are the only real software engineering
>>
Does anyone know of any good youtube channels for programming or general compsci learning, which can be watched without having to sort of 'code along' to benefit from them?

I'm doing a course atm and working on personal projects during the day, but at night before I go to sleep or when I get mentally fatigued I basically just idly watch youtube videos. I feel I could make this time at least vaguely productive by watching something educational, but all coding videos seem to be either follow-along tutorials which don't even really explain themselves properly, or else some kind of 'I've done this' show-off type things like Sebastian Lague, who is good, but that kind of stuff isn't really suitable for actually learning fundamentals.

As an example, when I was learning Blender I found some 'what every node does' type videos which methodically go through everything in the material graph and demonstrates what they do. Doesn't need to be the same as that necessarily, but educational in that passive-learning kind of way.
>>
when writing a unit test, how do you choose the 'random' numbers for the general case test, and is it a good idea to do more than one test on the general case?
>>
>>108440002
I don't, I let AI write them and not even look at them
>>
>>108439250
If you don't know assembly you're an incomplete programmer.
>>
When I grind on code for 7-10 hours straight, I often hit a wall where my brain just shorts out and I can't think well.
Does this ever get better? Is it a matter of training? Is there anything to be done about it, or do I just have to wait it out?
Do you guys ever have this problem?
>>
>>108440361
Take breaks.
Go for a 15-30 minute walk to think about what you're doing every 3 or 4 hours.
>>
>>108440141
Assembly is descriptive, or do you write micro ops and disable out of order execution?
>>
>>108438590
https://www.youtube.com/watch?v=1iPWt1gvT_w
>>
>>108440361
The brain is like a muscle. Do your 10 hours and rest.
>no but I want to be one of those prolific supercoders that shit 18 hours of performance every day
Drugs.
>>
>>108440512
>>108440594
Noted.
>>
>>108440580
I wonder why Rust took off and Swift didn't.
Besides the hardcore memory management restrictions, Swift seems to have everything Rust does and more. When developing newer apps for iOS in SwiftUI, you're already forced to use structs for everything (yes structs, not classes) so you can't fuck up and cause memory leaks. The new concurrency system also forces you to use structs and prevents any accesses that could cause data races at compile time.

I'm definitely missing something but to me Swift seems like a less restrictive version of Rust with traditional classes and inheritance.
>>
>>108440716
Swift refcells everything.
Swift was realistically mac only for years.
Swift has shit tooling and shit libraries because it's for mac.
Why not Nim then?
>>
>>108440733
>Why not Nim then?
no curly brackets = doomed from the start
>>
>>108440760
Based.
That's what you fucking get for deviating from C.
>>
is this how I'm supposed to error handle for my library?
enum Status {
Status_Success = 0, //for easy conditionals
Status_Error_1,
Status_Error_2,
Status_Error_3,
...
};

Status foo() {
if(...)
return Status_Error_2;

return Status_Success;
}

Status bar() {
Status res = foo();
if(res)
return res;

if(...)
return Status_Error_1;

return Status_Success;
}


basically just custom errno but instead of being hidden in some global variable it's returned directly on every function
>>
>>108440866
>enum
Why not provide a translation layer via #define instead? Mapping STATUS_NO_MEMORY and ENOMEM becomes trivial like that.
>>
>>108440866
looks good, idk how it works in C++ but in over languages that support catch / throw it's standard to use that for error handling. so instead of all the "return Error" you should use "throw Error"
>>
>>108441028
what do you mean? my goal is not to replace errno or integrate with it if that's what you're suggesting, I just want a way to cleanly deal with errors in my code / create custom errors for things that are relevant to using my library
>>
>>108441073
>my goal is not to replace errno
I never suggested you should. But you very clearly talked about
>>108440866
>my library
, and I'd assume that you wanted to map error codes from different systems into something more ... universal. You don't need to store everything in a global variable (especially since those aren't global, but thread-local, but that's neither here nor there) to unify your error codes across different platforms.
>>
>>108436520
Read it and infer the growth of operations in respect to scaling of input. Unironically, use BigO notation.
>>
>>108440141
If you don't know Scheme, then you are not a programmer in a more literal sense. Knowledge of assembly does very little for anyone.
>>
>>108440866
Yeah, it's a way to go about it. The sanest way imo is taking a double pointer on functions that might fail. Set it to null, if it ever becomes non null then something went wrong. You can populate it whatever data you want, handle the errors error at any point without losing context (it's held in the error object) and the function's result is easier to see.
There's a funny case where you might want to handle OOM in some way, then attempt to malloc the error struct only for it to fail the malloc again, though.
>>
>>108440866
/* Complexity does not beget quality, the opposite is often true. */
#define SUCCESS 0
#define ERROR_1 1
#define ERROR_2 2
#define ERROR_3 3

int foo()
{
if(...)
return ERROR_2;
return SUCCESS;
}

int bar()
{
res = foo();
if (res)
return res;
else if (...)
return ERROR_1;
return SUCCESS;
}
>>
>>108441198
proceduralfags try not to shit up their codebase for no reason because they refuse to declare an object challenge: Impossible
>>
>>108441217
I am a functional programmer, go back to implementing some webpage or something.
>>
>>108441235
what's functional about littering your IDE autosuggestion with a thousand different irrelevant variables because you refuse to wrap related constants in an enum?
>>
Is it worth the bother of checking whether new/malloc fails?
>>
>>108441241
Its an example with two functions mate. Calm your false dichotomising down.
>>
My site megagamesxp dot com!!!
>>
>>108441248
for non-toy large scale projects
>>
>>108441248
Every error should be handled. Just throw an exception.
>>
Premature optimization is the root of all good
>>
>>108441508
And only autists in dire need of lobotomization would even dare to disagree.
>>
>>108441508
Optimization needs to be considered at every point in development.
You can't afford to finish a project and THEN go back to optimize it. You'll never go back.
But you also need to set realistic optimization goals, so you don't spend all your time in optimization hell and can actually progress the project.
>>
I'm trying to fix someone else's Python script after an update to nicegui added async support and broke it, however, I don't know what I'm doing. Last time I used Python was many years ago.

The traceback looks like this:
pastebin com 3bbqBkiL

From what I can gather, the main change is that in previous versions of nicegui, a function named refresh returned type None and now it returns AwaitableResponse type.

The script in question is basically this with only minor adjustments.
pastebin com LEVVAtRS

Anyone have any idea what the fix is? My understanding is that where there used to be no returns before now there is one.
>>
>>108441714
Apologies for the awkward URL posting, 4chins keeps thinking my post is spam.

Here's the bit that changed in nicegui causing me trouble:
https://pastebin.com/LzcAnziC
>>
>>108425619
im working on codegen phase of my compiler rewrite. the emits for conditionals/loops, typecasting and unary/binary operators are pretty much the last thing i have to do
>>
>>108441754
to elaborate it's a c-like, and the = [] address-of & dereference * and short-circuits || && are already implemented properly
short-circuiting was the trickiest because i needed to rework the stack frame management to ensure all tmp value slots are allocated up-front in function prologue instead of doing it on-demand so that stack height remains consistent even if rhs doesn't run, since otherwise the fp offsets associated to tmp value stores would become incoherent after short-circuited code
>>
>>108439250
wdym by descriptive?
>>
>>108441754
they are several ways of doing it so how are you doing it?
>>
>>108441248
yes but you can use a wrapper that does it for you
it it fails it can exit or throw an exception
>>
File: pkmnyop.webm (3.89 MB, 925x472)
3.89 MB
3.89 MB WEBM
Fixed the animation speed bug.
Turns out it was in servicing interrupts. It takes 20 Tcycles to service an interrupt and Pokemon Yellow has an hsync interrupt, so it was often occurring (didn't check if it was every line, but probably) and I was adding the 20 cycles to the total frame limit but not the total line limit, so at the PS2 vblank it wasn't ready for the next GB frame (hadn't completed all the GB scan lines for the frame) which halved the speed of the animation.
>>
Okay, after I few days slacking around I forced myself to kode again.
To get the motivation back up I did a little bit of vibe koding to get the general mechanics for my game up and running.
We rebuildin' the robot unicorn attack (and hopefully add a cool twist later).
Level generation in pure randomness works. Now time to clean up. Les gooooooooooo
On Tuesday we kode!!!
>>
>>108442735
something is wrong with the jump input. But in general feels good.
Trying to find the input bug, then either double jump or items. Will see.
Variable Y will come later, not important yet
>>
>>108441198
C has enums, too. Retard. Not sure why you would prefer macros over them. The enums form a natural list of things, and have more type safety than macros.
>>
>>108442735
>>108443276
the graphics looks nice
>>
>>108443276
Neat, are you going to add a rainbow trail and some hanging "pinatas" to use the horn on?
>>
>>108443276
Is there a reason why you use floats, and not integers?
>>
>>108443727
and vice versa? also on screen i see fixed point representation of unknown type
>>
>>108443727
>>108443891
No, I am just a brainlet when it comes to gamedev.
At first I was using ints but AI told me float good lol
>>
Uh, yeah, so... some time ago in a "code something in C" thread, someone posted a small "You are in a battle with a monster, please take an action" game. I would like to thank that person, your code helped me to grasp functions and strings.
>>
File: 1772883399025965.gif (474 KB, 220x212)
474 KB
474 KB GIF
who tf is still coding in c or cpp in 2026?
>>
>>108445716
More people than javascriptlets like you can imagine
>>
>>108445716
me
>>
>>108443727
>>108443944
This reminds me that anon who was learning on Quake source code and he too was wondering why the player's health, i think, was in floats, even though you can't have 10.5 health.
>>
>>108433590
>Don't mess with Linux!
>>
>>108445750
Tho I think their questions are valid.
For my tiny games i dont need float at all. I might introduce a little fixed point portion if needed and that's it.
Tho I do notice that I really dont have that much interest in programming games. It's hard to get that epic meme adhd to focus on that. Tho playing them afterwards feels nice, i gotta admit that. So I gotta give it a few more chances
>>
>>108445716
I started learning C in 2025
it's been fun as hell
>>
>>108445716
they are still most used languages in embedded
>>
I've been self studying AI dev for the past 8 years and I'm pretty sure I just revolutionized the field. How do I monetize my results without some trillion dollar globohomo corporation just stealing my work?
>>
>>108445716
>t. has memory stalls all over the place in his code
>>
>>108446325
quite frankly, you don't
you won't be able to write a patent that's legally sound, if anything it'd juts tell your enemies everything they need to rip you off
even if you did patent it properly, you don't have the resources to prove infringement
if you hire a lawyer to help you with the patent, he'll just get paid off by big AI to sabotage you and steal your secrets

if you were associated with a university you might have a chance since research patents make up a huge chunk of their income, but the university would also be out to rip you off so you'd still get fucked

you might as well just open source it and get it done with
>>
>>108445716
they are the languages of advancement. nothing has ever come from 800k webdevs writing JS (which is why AI is so effective at replacing them)
>>
>>108446363
>he'll just get paid off by big AI to sabotage you and steal your secrets
That sounds like a good way to get Luigi Mangioned.
>>
File: 1744959676486461.png (351 KB, 839x768)
351 KB
351 KB PNG
>I'll just prove that the $500 billion dollar AI corporation saw my patent and then illegally implemented it on their private servers that I will never even see a binary for let alone the source code
>>
>>108446434
dumb frogposter
>>
>>108446574
Say you created agi in your garage and put the source code up on github. 3 days later OpenAI releases their agi model. How will you prove that OpenAI stole from you?
>look at the timing
Isn't going to get you a warrant.
>>
>>108446325
Well? Can you prove it works at some scale? If so you'll have to make some buzz and become a PR guy, or seek venture funding and hire someone who can. If you can't prove it then why would anyone bother?
>>
>>108446325
The moment you posted this your PC was already penetrated by 87 different organizations.
>>
>>108427692
>nvchad
Any other preconfigured neovim packages like this? Haven't used vim in like 8 years and kind of want to get back into it, but I don't want to spend a week getting it sorted.
>>
>>108441638
>Optimization needs to be considered at every point in development.
Choosing the actual right data structure(s) and algorithm(s) isn't optimization.
Pythonfags are the literal worst for this.
>>
>>108447012
>Choosing the actual right data structure(s) and algorithm(s) isn't optimization.
It absolutely is.
>>
>>108446928
Lazyvim is the easiest to get started.
>>
>>108446928
this guy is right >>108447216 but try to make a mental note of everything you use and don't use, then make your own. it's really not that hard to make your own setups these days, you don't even need an external package manager anymore (https://echasnovski.com/blog/2026-03-13-a-guide-to-vim-pack)
>>
Just shipped my first game!
>>
>>108445716
everyday

t. EE
>>
>>108447582
Congrats dude.
>>
What is an iterator exactly? Just a pointer?
>>
>>108448481
Iterator is an object that yields values.
>>
>>108448481
it's jargon, so start with whatever some useful context calls iterators. https://www.youtube.com/watch?v=d3qY4dZ2r4w explores some of the space in an interesting way.
>>
>>108448481
>>108448629
in Java it's just an interface with two methods to be implemented, hasNext() and next()
>>
>>108448666
the video mentions that, Netanyahu. Java has a dishonorable place on a graph as worse for no benefit.
>>
Why the fuck does Gitlab logs me out of my account every time I close my browser? I use Firefox if that matters. Every time I close my browser I'm logged out of my account and it doesn't matter if I click on "Remember me", it always asks me to log in again if I reopen my browser and worse of all I have to introduce a security code sent to my email. Why does Gitlab do this? Is there setting I can change to prevent this from happening?
>>
Whhat is the best way to learn Perl in 2026?

Also what Perls limitations compared to Python?
>>
>>108448780
read Learning Perl, then Programming Perl, then Perl Best Practices, then familiarize yourself perldoc perl and subpages and use that for a reference from then on.
Perl's limitations vs. Python are all it having a ton of random bad ideas in the language, that other people may use, and that you may use unintentionally (or without realizing how bad the feature is until it gives you a very mysterious bug)
Perl Best Practices is about avoiding all of that.
Python mostly doesn't have all the random little bad ideas, just the one big bad idea of being a scripting language at all + being implemented as a slow pile of shit.
The best thing to do in 2026 is do your scripting in some language like Nim or D that are convenient and scriptable while also being real languages that you can deploy with some confidence that the thing won't fail on a Saturday night to some bullshit that a compiler should've caught immediately.
>>
>>108448711
>the video mentions that
yeah not gonna watch a 1-hour long Cnile video just to see if they mentioned Java
>>
>>108448780
open 2 terminals, one with: man perlintro, the other with perl -E 'say "hello word"; if ("hello" =~ /^(\S+)/) { say $1 }'
>>
>perl's regex variables are dynamically scoped
nice
$ perl -E 'sub func { "hello" =~ /^(\S+)/; say "from func: $1"; func2(); } sub func2 { say "from func2: $1"; } func(); say "from main: $1"'
from func: hello
from func2: hello
from main:
>>
>>108450099
$ perl -E 'if (1) { "hello" =~ /^(\S+)/; say "from if: $1"; } say "from main: $1"'
from if: hello
from main:


$ perl -E '{ "hello" =~ /^(\S+)/; say "from block: $1"; } say "from main: $1"'
from block: hello
from main:
>>
File: 20260325_181503062.webm (3.11 MB, 853x480)
3.11 MB
3.11 MB WEBM
Ok, it's not perfect but I am fairly happy with now it is rendering on hardware now.
Turns out the problem was one I had encountered a while ago and had forgotten about. You might think that once you have called on DMA to send a GIF packet to the GS and waited for it to complete that you can reuse that memory area to, say, make the next GIF packet, but you'd be wrong!
You've got to wait about a frame to go touching that again or else you end up corrupting the packet contents.
So I'm leaving the GIF packets in memory, and seeing they represent each line to render I can just overwrite the contents of them (skipping the headers) for the next frame and resend.
There are a few line artifacts you see mostly during the thundershock animation in the opening, but otherwise it's pretty good.
>>
>>108447582
>For free! Only took me a decade!
>>
>>108448746
NIGGUH IT'S PROBABLY YOUR COOKIES
>>
>>108450262
>You've got to wait about a frame to go touching that again or else you end up corrupting the packet contents
Just how big is the latency?! This is turning your staging buffers into front and back buffer resources.
>>
>>108451366
Latency is no problem. Every frame is on time, it's just a matter of getting the frames to render cleanly.
Though it doesn't seem to make much difference, each line gets prepared and sent off to a back buffer in the VRAM as it is completed, then during vblank I have that copied into the framebuffer. For safety I pretty much can't touch those areas in RAM (not VRAM) where I prepared those lines until after the vblank.
To be fair, I don't think the PS2 was really designed to render this way. Many flat assets you would have just ready to go instead of being generated dynamically, and 3D graphics similarly. You'd make use of the loading textures into VRAM as well.
I have no idea what I am doing. I'm just whacking it until it works.
>>
>>108451453
>Latency is no problem. Every frame is on time
I didn't say anything about frame latency, but about upload latency. Although, if the granularity is
>each line
, then I can see how the end parts of a graphic could get corrupted. On the other hand, if you're already dealing with line granularity, then why don't you just copy the data into the staging buffer per line as well? That should avoid the corruption.
>unless the layout isn't linear and you have to do some tiling in software, which would be weird
>>
>>108451526
>On the other hand, if you're already dealing with line granularity, then why don't you just copy the data into the staging buffer per line as well? That should avoid the corruption.
That's what I thought I was doing.
I probably have to read over the documentation again, but I just had a thought that maybe mid frame writes to VRAM are blocked, so even if I'm queuing up GIF transfers it mightn't actually copy from RAM until the start of vblank, which is why I can't touch the data in RAM until after that. It would make sense (basically how the gameboy works as well, though you can get some writes in during hblank as well).
>>
>>108425619
Why are SQLite named parameters so rarely used? They offer significantly more readable syntax, much more flexible application logic, queries, and schemas. There really isn't a performance impact either because of how SQLite queries are executed. Everyone seems to use qmarks instead
>>
Yes of course it does. Why do you even ask the question? Are you stupid?
>>
>want to learn about machine learning
>watch 4 hour freecodecamp lesson
>it's just statistics and probability maths and graph plotting

I'm not even mad, honestly. it was interesting and even a maths retard like me understood it. just not exactly what I expected.
>>
Haven't been down here in a while. Here's my "Warcraft v -0.001" rts learning project in sdl3 and C.
>>
>>108453204
>fopen
>fgets
>SDL
>>
>>108453256
Yeah? Oh... I didn't use the specific sdl wrappers for c stdio.h stdlib.h functions? I never do, because I honestly didn't even know they were there until last week.
>>
>>108453273
Dude.

fopen has tons of userspace overhead, and fgets *will* copy all data even if the implementation happens to use a mapping. Use open/openat (avoids having to use qualified paths for everything, you can simply use FDs for directories) + mmap (avoids the copy).

Also, calloc. Come on now. And SDL is a clusterfuck of memory allocations too.
>>
>>108453315
>inb4 but I wanna run it on Windows at some point
Then you'd still be infinitely better off providing your own abstractions for NtCreateFile/openat. The C standard library is lacking features that are present in all three most popular systems (Windows, Linux, Mac).

I get that if you're a beginner you're focusing on beginner interfaces, but it's going to be that much harder to later leave those interfaces once you know what you're doing.
>>
>>108453315
With zero game making knowledge or educational/ occupational background, I had to come up with a way of loading a map with collision objects with what I did know (how to read a csv). It takes about a 10th of a second at runtime to get the map with a couple hundred impassable mountains rects in there.
>>
>>108453341
I'm pulling up all of the things you mentioned now. Nobody ever gives you practical advice until you try to show off something you're proud of, and they only do it to tell you how you fucked up. Lol

Thank you for the pointers bro.
>>
>>108453353
>It takes about a 10th of a second at runtime to get the map with a couple hundred impassable mountains rects in there.
Yeah, and then at some point you scale up, and suddenly you're Factorio spending a fucking minute on the splash screen churning through some of the most niggerlicious I/O code you can imagine, copying data in 4096 byte chunks from the kernel and molesting your data layout to such a degree that multi-threading becomes impossible later on: https://factorio.com/blog/post/fff-215
>>
>>108453018
here
https://www.youtube.com/playlist?list=PLpM-Dvs8t0VZPZKggcql-MmjaBdZKeDMw

If you actually want to know how it works without just doing
import tensorflow
>>
>>108453396
I know it's hack. I just keep on swimming and learning. I'm still very green with architecture. For example, my little game there is built almost entirely with linked lists instead of proper arena allocated and performant arrays. I'm new.
>>
>>108453472
If you mmaped the file in directly you could provide all entities in a binary format, without the need to convert them at runtime. You'd need a small separate program to do the conversion from CSV to binary, and run it after every change - but, hey, you're hopefully also using makefiles, right?
>>
>>108453504
I think it looks more sophisticated than it really is. The background is just a flat png made in tiled map maker. The exported csv of one of the layers of that tiled map just gives me the pixel locations of mountains so i can generate a rect and insert inserted into the rect into the collision objects list.

It's not vacuuming up a very sophisticated map with individual sprites. I was just tired of looking at an empty white widow with little blue squares moving around, and wanted a quick and dirty way of adding the illusion of terrain

I'm definitely going to check out everything type referencing for further learning. You're the second person who's recommended handling it in binary, so I definitely have to learn.
>>
>>108453381
>Nobody ever gives you practical advice until you try to show off something you're proud of, and they only do it to tell you how you fucked up
That's why I'm scared of publishing anything
>>
>>108453753
It's all good. "Whatever doesn't kill you", right?

Over in the friendly game making places, you ask for advice, and you get crickets and rtfm. Here, you post your beloved first child, and you get some decent guidance in addition to being called a gay retard.
>>
>>108445716
Real engineers.

>>108445723
Stop that noise, Javascript is my second favorite language after C++.
>>
File: 1640028810599.png (21 KB, 328x323)
21 KB
21 KB PNG
>>108454451
I feel so sorry for you.
>>
>>108453606
Usually is faster to write a map editor and keep everything in binary, zero parsing needed.
>>
>>108454500
Skill issue.
Learn how to code.
>>
>>108454544
I don't need any more brain damage.
>>
>>108454515
I went to bed thinking about how I would impliment my own drag and drop map editor (which would've been a pretty large project for me as a newfag), and woke up deciding to just get it done in a few hours. I used an embarrassing amount of time in collision and path finding. Works pretty good. Not perfect though.

I'm not really looking to get too wrapped up in game making, at least not yet. The only thing left with this little project for me is a bit of network stuff to see if I can make it online multiplayer.

Next week, or so, I'm going to start fooling around with some stm32 Micro controller programming.
>>
>>108454500
You can't even understand types and operator precedence.
Stay away from computers, is not for you. Flip burgers or something else.
>>
>>108454594
Good, that is the way.
>>
>>108454451
>Stop that noise, Javascript is my second favorite language after C++.
https://www.destroyallsoftware.com/talks/wat
>>
>>108448831
>Python mostly doesn't have all the random little bad ideas
Oh yes it does, but they're subtle ones like making every operation overridable. That makes improving the performance really hard, and there's lots of important libraries that depend on it so it can't be fixed.
At least they've managed to fix the GIL.
>>
>>108454848
python as a first choice language is a C megalibrary for retards and brown people. python as glue and quick one offs is one of mankind's greatest achievements
>>
File: file.png (57 KB, 878x787)
57 KB
57 KB PNG
>>108454500
it just works
>>
>>108455785
in Nim this is just
from std/strutils import nil
from std/strformat import `&`

converter c2i(c: char): int =
assert c >= '0' and c <= '9'
c.int - '0'.int
converter s2i(s: string): int =
try:
strutils.parseInt s
except ValueError:
debugEcho &"Argument \"{s}\" isn't numeric"
0

assert 2 == '5' - 3
assert 8 == '5' + 3
assert 1 == '5' - '4'
assert 10 == '5' + + '5'
assert 0 == "foo" + + "bar"
assert 0 == "foo" + "bar"
assert 3 == '5' + - '2'
assert 3 == '5' + - + - - + - - + + - + - + - + - - - '2'
const x = 3
assert 5 == '5' + x - x
assert 5 == '5' - x + x
>>
>>108454602
Why would I want to understand your particular blend autism? I'd rather be useful.
>>
>>108455912
Nim gives me the ick, it's pseudo modern.
>>
>>108454500
>fooNaN
My sides
>>
>>108455922
Noncoder take.
>>
usecase for dynamic allocation?
>>
>>108457663
parsing
>>
>>108457657
Autism take.
>>
>>108457663
Literally none. If you understand your program then you would know exactly how much memory it needs to accomplish its task from the start.
>>
>>108457781
Holy autism, batman.
>>
>>108457781
retarded nigger. how much needs to be allocated depends on the input data, not on the program itself.
>>
I'm getting so close. I'm liable to start programming any moment. Stoked as fuck.
>>
>>108457813
wrong
how much needs to be allocated depends on how much you intend to support
>>
>>108457824
>he doesn't intend to support paging
>>
>>108457781
based and pragmatic pilled
>>
>>108457781
Enjoy your stack overflows
>>
>>108457962
Now you're just using words that you don't even understand.
>>
>>108457962
You didn't understand him. His code will just stop with an error code if, for example, the input data exceeds 1000 bytes.
>>
File: 1771941088762436.png (674 KB, 792x693)
674 KB
674 KB PNG
>>
best software for self hosted git?
>>
>>108460068
I was looking for a while but then I found out you can just git clone/pull/push to a repo on a server via ssh without even needing to run any service beyond sshd.
If you're actually collaborating with others or want something more fully featured then I've heard gitea is solid.
>>
>>108460068
fossil-scm.org
>>
what's your cheese of choice when coding
>>
>>108460316
Only autists have comfort food.
>>
>>108460316
Spraycan
>>
>>108459910
Haha, is this programming languages ranked?)))
>>
>>108460667
It's the tiers of drudgery available in the post-computer science world for people who didn't become licensed tradesmen.
>>
>>108460316
homogenized
>>
>>108460316
under the foreskin
>>
>>108460316
futa
>>
>>108459910
they forgot to add the african-american tier
>>
>>108460265
Fossil's excellent if you don't need a complex workflow processing system as well. That sort of thing is where the chunky services start to win.
You can do a lot without that. Fossil's damn great.
>>
>>108461710
programming thread:
perl -lne 'sub ss { join "", sort split //, shift } print if ss($_) eq ss("ginger")' /usr/share/dict/words
>>
They're starting to push AI slop in VS code way more aggressively to the point where it's fucking with you even if you don't use any of it. Might be time to find something else.
>>
>>108461903
Just stop updating dude.
>>
>>108461903
Maybe they'll stop the AI shit if people keep calling them Microslop on social media
>>
>>108440032
>>108446325
>>108446363
>>108446434


>muh AI
kys
this is /dpt/ not /slop/
>>
Is a Windows environment preferred for developing C# programs, especially web applications, or is Linux still okay?
>>
I wrote a really simple http server to serve webpages locally for websites I've scraped, using socket(AF_INET, SOCK_STREAM, 0), but is it really local though? If someone makes a connection to my IP address and at the right port, will they be served as well?

What do you need to know to only serve you own computer, or on the contrary to serve everyoone? Is is just a question of filtering the connections arriving from accept() using the IP address of the connections?
>>
>>108463125
>What do you need to know
*what do you need to do
>>
How to efficiently learn a new language when I already know another and I want to focus on the language itself, not re-learning about loops or variables unless they're actually different?
>>
>>108463125
>locally
Behind a router/NAT? There's no chance. An attacker would have to find a port on your router that just *happens* to be open at that moment, and that port is not going to connect to your service, but whatever has opened the connection in the first place (browser or such).
>>
>>108463125
>or on the contrary to serve everyoone
Again, behind a router/NAT? Port forwarding. Have your router listen at port 80, and tell it to forward everything to whatever machine is in your network. You can assign whatever port too, as long as it's internal.
>>
>>108463206
>>108463220
>Behind a router/NAT?
I really don't know, I have a standard "modem"/"box" that everybody have.

So basically if I wanted to make a real public server I would need to setup the router inside the internet box has to port-forward connections to port 80 and 443 to the private network IP address + port, maybe do something with the firewall or something, and in terms of programming:

I would also need to call bind() where the sin_addr field of struct sockaddr_in set to INADDR_ANY, and then that's it?
>>
Hey guys, need help with a pythoj library issue. Been messing with pycharm. I can't get the SoX dependency to work on this project. Feels like shitty chink code. Nvidia on Linux with the proprietary driver.
https://pypi.org/project/qwen-tts/
Error:
>/bin/sh: line 1: sox: command not found.
>if you do not have SoX, proceed here: sox.sourceforge.net

>"sox" in normal system terminal
Runs
>"import sox" in pycharm python console
Gives error, run again and no error
>"sox" in pycharm bash shell
Sh: sox: command not found
>>
>>108463373
>>"sox" in normal system terminal
>Runs
in your normal terminal, run "which sox" to find the path of sox and to get its directory. confirm that the directory is in $PATH using "echo $PATH"

in the python shell thing, run "echo $PATH", confirm that the directory of sox is not in $PATH, then add it to the path. Search in the documentation of the python library for a way to durably change PATH, find out where the configuration file containing pycharm's PATH is.
>>
>>108463402
Makes perfect sense. Didn't work.

pycharm venv path
>/home/user/projects/LLMproject/.venv/bin:/app/extensions/bin:/usr/bin

System path
>/usr/local/bin:/usr/bin:/user/local/hostname:/usr/hostname

Sox path
>/usr/bin/sox

Added a path variable to pycharm.
>name: sox
>Value:/usr/bin/sox

Same error. Fuck this dev not documenting shit on github!
>>
Restarted and now pycharm doesn't start at all. Lmao. Worst project so far!

This is after I couldn't figure out why CUDA wasn't working. In debian dev's infinite wisdom, they ship driver 550 when the current is 580.
>>
>>108463508
>Makes perfect sense. Didn't work.
>pycharm venv path
You know that there are several "path" right? Shells have a PATH which is how shells find executables but also language runtimes like the python have a path for finding thier libraries. I don't really python but I'm pretty sure the "virtual environment path" is from the 2nd category.

>Added a path variable to pycharm.
>>name: sox
>>Value:/usr/bin/sox
You add a directory to a shell PATH like this: PATH="/path/to/new/directory:$PATH". Maybe "export PATH....", not sure.
>>
>>108463607
I'm gonna chock this up to a retarded fsggot SoX dev who can't package his software properly or document it on github. I've never had this shitty fucked up PATH/library issue on any python project. Windows developers aren't people!
>>
so everyone is always talking about using ai to replace programmers but what about ai to train programmers? any good ai for that?
>>
>>108463931
Imagine >>108453204, but with additional hallucinations.
>>
>>108463931
No because it's dumb. Local AI (only one that exists) is great at making basic functions for you the programmer to build into a larger program. AI reduces labor, it does not replace it.

When you ask AI for answers it will make shit up and tell you to use functions that don't exist. It can't be trusted and scientists still barely understand it. It is extremely dangerous.


I really really wanted to make a python program to connect a LLM to qwen TTS to have fluttershy moan in my ear and also probably have the system prompt integrated with byttplug.io for sex toy control even though I don't have a digital sex toy... but the shitty sound conversion library was written by a wintard.
>>
>>108457781
based malloc autist I thought you were dead
>>
>>108457781
this, I programmed entire nes games and never had to allocate memory from the heap even once
>>
>>108464031
What heap? There's only 2 KB WRAM, shared between stack and whatever.
>>
>>108464048
>only 2 KB
You have gigabrainrot. You are why modern programs are terrible.
>>
>>108464050
OK, autist. Enjoy the cage.
>>
>>108463931
You can literally just use Grok. All the LLMs have been overtrained on programming examples and documentation and Stack Overflow so they're fine as a learning tool, just don't expect the free ones to properly write or explain any code that isn't a classic textbook example.
>>
File: 1694839079353063.png (427 KB, 1008x872)
427 KB
427 KB PNG
>>108464265
Or tutorial.
I still remember Deepseek recommending me to place data into the DMA staging buffer via memcpy, because that's what the tutorials suggested. That being said, it was fun until I learnt of the vkCreateImage debacle. Killed my interest in Vulkan to this very day.
>>
>>108463963
Why'd you tag me? I don't use ai.
>>
>>108431526
pre 2018 linus moment
>>
>>108464509
Didn't say you were, but the code quality is just about what I'd expect from an LLM.
>>
File: 1770353798910991.png (101 KB, 1440x1506)
101 KB
101 KB PNG
Is it a bad idea to use LFSRs as PRNGs?
>>
>>108464883
I'm really new. Had 2 hours in the morning before work (not tech work) to create a map from scratch, load it into the game at start up, and populate an object list with terrain collision objects for a learning C project that nobody but me will ever touch.

Option A was to spend more than 2 hours building a map editor from scratch to create a single map and object list for a practice project before I move onto learning other stuff.

Option B: use tiled to slam together a map with a freeciv spritesheet, export to csv, and parse out terrain in a 10th of a second at game load using about 50 lines of code so my "game" wasn't just blue squares moving around in blank widow.

I didn't mind the other guy shitting on it, because he offered some constructive pointers, despite not knowing he was basically instructing me to reinvent an entire game engine to do a game equivalent of "hello world" a single time in a throw away project, but your just being rude for no particular reason.
>>
>>108464959
Dude, there's no shame in being new. But the question was
>what about ai to train programmers?
, and I have to say that every time I used an LLM to generate C code for me it would generate this standard nonsense that doesn't even attempt to be optimized for the big three. It's just fopen, fgets, calloc all the time. THEN you have to tell the little shit how unoptimized it all is (and in the case of Gemini it dares to give you lip because you give sufficient enough counterexamples to prove that, yes, no really, you know more than the fucking LLM) in order to have a CHANCE at proper code generation.

Oh, and also I *AM* the "other" guy.
>>
>>108464991
>because
unless*
In my defense I have a quarter bottle gin in my system, it's a miracle I'm as coherent as I am.
>>
>>108464991
>also I *AM* the "other" guy
Well thank you for your precious recommendations.

How would you, in 2 hours, generate a map from scratch that also populates a game terrain object list. You can't use any of your own existing libraries or snippets. You can't write more than 100loc. The project is absolutely valueless. There's nothing to gained at this point by showing off, or increasing efficiency,
or learning anything new related to making a super basic 2d game. Nobody will ever touch it, but you have to do it, or someone will shoot you in the face. The man with the gun just wants to see a map with terrain you can collide with.

I'm not asking to be argumentative. I'm asking because you're knowledgeable, and every other experienced dev I've ever learned from has stated: get it done and keep it simple unless there's a compelling reason to do more.

You also keep mentioning calloc. Those dynamic allocations are from structs, filled with nested structs and unions, with up to a dozen fields each. I just didn't want to chase down and zero every value at initialization. Is there a better way?
>>
>>108465051
>precious
*previous
>>
>>108465051
>Is there a better way?
Wait... memset()?

If so, I feel retarded.
>>
Under the proviso of being rather drunk:

>>108465051
>generate a map from scratch that also populates a game terrain object list
If it's pure generation, and not just loading in an existing one: mmap. Biiiiiiig reservation (because those are cheap), and then committing memory piecemeal. At least I think that's what you want, a growing chunk of memory that doesn't require relocations or memsets (see below).

>Those dynamic allocations are from structs
calloc is its own can of worms. First of all: do you *need* to zero out all the fields, if you already set them?
>yes
Good, but mmap *also* already zeroes out the memory. Has to, in fact, because mmap gets its memory from the kernel, and the kernel has to zero out the memory in case there's data from some other user or kernel process in there. Not zeroing out the chunk would potentially leak data.

But calloc doesn't necessarily know that. So chances are that it's going to zero out the memory *again*, but this time in usermode - and that's ignoring the fact that you want to do your memory management not using a billion lifetimes, which, by the way: https://www.dgtlgrove.com/p/untangling-lifetimes-the-arena-allocator

Lifetimes are expensive. The more you can unify them the better.
>>
>>108465051
zeroing structs is useless because you're going to write to each field when you're going to use the struct
>>
>>108465100
Is malloc with a memset cheaper than calloc?

I still need to dig into mmap and other more sophisticated methods of loading and manipulating external data. It's on the list. None of the "coming from some python" resources for students even mention anything beyond basic i/o stuff.

I'll get there. Thank you for bothering to effort reply to me. It is appreciated.
>>
>>108465146
>Is malloc with a memset cheaper than calloc?
Depends on the implementation, but considering that malloc and memset deal with bytes while calloc has to do a multiplication, I'd say yes.
>even if it's just marginally
>and it's a multiplication that, unless it's inlined, it cannot be easily optimized into an ADD or a LEA
>>
>>108465110
A few of the values for things like reciprocal combat engagement and stuff like that are addresses that flag a continue on NULL for certain loops that traverse the objects list. Having the pointers prepopulated with junk would throw segfaults.

^I probably built it with poor architecture, but that's what I had to work around.
>>
>>108465182
Awesome. Thank you
>>
>>108465184
It's unlikely to matter in your specific case because your structs are so small, but you want to avoid writing data twice - i.e. first zeroing out a chunk of data and then setting individual values to something else instead.
>why
Because CPUs have caches, and caches are limited in size. If you first zero out an array of bytes there's a chance that the beginning of the array isn't in the cache anymore by the time the end is being set, and the CPU has to wait for the data to arrive in the cache again. That is why memcpy for example switches to non-temporal instructions if it detects that there is no way data is being reused, and doesn't even bother utilizing the cache.

In other words: you want to pack your writes as tightly as you can.
>>
>>108465184
>and stuff like that are addresses that flag a continue on NULL
then set those fields with NULL when you initialize the other fields, no?
>>
File: 1747056341286540.png (266 KB, 577x622)
266 KB
266 KB PNG
>>108465184
I hope you aren't ever accessing uninitialized memory, anon.
Don't give the memophobic crabs anything to screech about.
-fsanitize=address
>>
>>108465257
Honestly, yeah. The primary fields set at load were x/y, owner, and collison id (basically master object list id) and specific type id (unit number or whatever). If I was doing the allocations more efficiently with malloc, and possibly even skipping memset, I could just NULL out anything needing an address.

Ultimately, something I still need to learn, everything would've been done with arenas and arrays. I did everything with dynamic allocations and linked lists to reinforce my novice understanding of memory management and pointer notation.
>>
>>108465299
I was at first, but there's a weird conflict with sanitize and gdb. (I'm also new with real debugging) Guess it's been a persistent bug for years, so I pulled it out of the CFLAGS.
>>
>>108453204
looks pretty nice. What spatial data structure do you use?
>>
>>108465319
Just have a separate compile command for gdb thatt drops it.
Address sanitizer is the best compiler feature for C ever created. It will pick up on tons of little (and big) mistakes that might pass by for weeks before you randomly change something nearby that shifts memory, causing the bug to break everything.
>>
>>108465330
>spatial data structure
I had to look up what that term means. I'm a finished carpenter by trade lol.

Everything is stored with just a basic x/y float rect location, and whatever magic sdl uses to render that based on coordinates.

I did build a little system that breaks the map into 182 sectors, dynamically updated as units move around, that allows for collision detection without traversing the entire master object list. Cuts it down to a max of 36 checks per frame verses several hundred per unit per frame.
>>
>>108465343
Will do. I really need to actually learn cmake at some point.
>>
>>108465330
I guess, as I'm doing some research, I intuitively invented >>108465398
a really shitty form of quad tree structure for collision checks.
>>
Bump to save one of two coding threads from 404 as 10 chatbot threads are added to the catalog per hour
>>
>>108467562
The thread would be more active if the OP was a maid. Maidposters kept /dpt/ on page 1 until it hit the bump limit.
>>
>>108467602
Is that the weird guy that was building a small laptop or whatever?
>>
I hate how in Python every good variable name is already taken by some builtin
>>
>>108465303
>If I was doing the allocations more efficiently with malloc
malloc is not going to be more efficient than mmap for multiple reasons.

1. You have to go through the same prologue and epilogue (which can involve locks and function overloading) for every single allocation.
2. Placement of data can only be controlled - if at all - through the size parameter triggering heuristics that will always be imperfect (you want a 64 KB allocation in a separate arena? Sucks to be you!)
3. Each allocation has a variable amount of state associated with it (to support the free(ptr) semantic; usually that state is 8 to 16 bytes before your actual payload, which is why malloc will never give you page-aligned addresses, and manually aligning addresses just wastes your memory). Depending on its size each allocation will eat up 16 to 32 bytes, if not more ...
4. ... and it's really easy to write into the state of an allocation accidentally - if you don't do proper length checks. Which could happen even if you didn't use malloc, but the difference is that you're much more likely to notice writing into your own data than into some hidden allocation state.
5. No placement control and state holes in between allocations means bad cache line utilization (CL = units in which data is being cached, usually 64 bytes per line), worse prefetching, and issues with multi-threading (>>108453396)
6. Reallocation is a pain in the arse because malloc doesn't differentiate between reservation and commitment, leading to situations where, on Linux, you either constantly overcommit (and thus invite page thrashing and the OOM killer), or big allocations simply failing, And you may want big allocations because you want to avoid costly reallocations and their copies (which, by the way, is trival to fix via explicit reservation and commit, but most developers are apparently too retarded for that). It's one of those instances where Windows is actually more sane than Linux.
>>
>>108467735
>arse
euro detected, opinion rejected
>>
>>108467735 (cont.)
>inb4 but I don't know how to write an allocator
You don't need to, you just need to know how to use mmap. malloc is a special-purpose allocator, with its special purpose being that of providing you with individual lifetimes for your objects. Chances are that you don't need individual lifetimes for your objects, you just need non-stack memory that can grow dynamically, and for that you don't need malloc.

And speaking of which:
7. No placement control also means you cannot just free/reuse an arena without having to call free() on every single object like a retard. Windows has supported HeapCreate and HeapDestroy since 3.0 (which is a sad statement for Linux), and while they're not perfect (don't allow you to reuse that memory, only destroy it completely) at least they have been allowing allocation grouping for longer than Linux fucking exists.
>>
>>108467754
... they weren't kidding about the low education level of the US: >>108436475
>>
>>108467761
just say ass like you're supposed to
>>
File: 1623600945994.gif (321 KB, 224x256)
321 KB
321 KB GIF
>JUST SAY ASS
>BECAUSE
>BECAUSE
>BECAUSE I SAID SO OK?!
>>
>>108467754
This guy wasn't me>>108453204 BTW.

I'm very appreciative of the pointers, even if they do come from a limey-scum bastard with no buyer knife license.
>>
>>108467833
*butter
>>
File: 1738520790246613.png (410 KB, 408x743)
410 KB
410 KB PNG
>>108467833
loicence*

Also:
8. Reallocations in the worst-case scenario (no in-place resize => copy, no free memory => hitting up the kernel) also increase memory pressure - because now you have a source and a target buffer at the same time, and you cannot get rid of the source buffer before realloc() has copied the data. There is a non-zero chance that realloc() can actually fail where explicitly committing more memory works without a cinch.
9. Reallocations in the worst-cache scenario will also murder your CPU caches. Especially in instances where the payload is juuuuust small enough to not trigger NT copies, but at least on x64 - for reasons that I will never quite understand - the NT hint for loads is ignored unless it's a WC or other uncacheable type of memory (it's WB most of the time).

In other words: the source data - the one that you're going to discard because you need more memory than the current bucket provides - *WILL* fill your cache despite it never being used again.
10. Relocations (not reallocations) also become problematic if the address of an object suddenly changes. With explicit reservations you can just mark entire regions of your virtual address space as unavailable for other, hithertofore unknown parts of your program (like a library, say, SDL, doing its own set of completely retarded allocations), ensuring that you will always have enough room for growth for your objects without taking actual memory you don't need (yet).
>>
>>108467735
>>108467755
>>108468040
Fair bit to digest. Pulled over to my notes app. No reference of mmap in Beej, K&R or Seacord, and I'm just realizing (you may have mentioned this earlier) that's because it's a linux system call. I'll see if I can find a quick tutorial to shape and build a throw away program and learn it.

I have the lightest and recent exposure to those as a class, as I just started last week learning a bit about socket programming.
>>
>>108468332
Quick follow up. How broadly does map effect portability?
>>
>>108468343
mmap is available on Linux and Mac. On Windows you can use VirtualAlloc. Reservations can be emulated with the PROT_NONE or PROT_READ flags, commits by changing the permission to PROT_READ | PROT_WRITE (on Windows it's just MEM_RESERVE and MEM_COMMIT).
>>
>>108468419
And BSD, I suppose.
>>
>>108467686
examples?
>>
>>108468857
pypy_poopoo
>>
File: python-pepe.jpg (34 KB, 460x662)
34 KB
34 KB JPG
>>108468897
>>
does your brain also goes into monkey mode after 8+ hours of writing code?
>>
>>108469133
you never stop to think?
>>
>>108469133
I tend to think about it more when I'm away from the computer. It's like shower thoughts
>>
File: 1749741009622544.jpg (82 KB, 897x1024)
82 KB
82 KB JPG
>>108469199
Based thought-haver.
>>
>>108425619
>What are you working on, /g/?
M.C Escher style droste effect generator.
>>
>>108467735
>malloc is not going to be more efficient than mmap for multiple reasons
For big chunks, malloc may well use mmap too (or not; there's also sbrk).
For small chunks, malloc's a lot more efficient exactly because it doesn't need to make a system call to allocate most of the time.
Doing your own allocator can be a lot better in some cases, especially if you have a lot of allocs of exactly the same size and aren't deallocating in a different thread to where the allocate happened. Those situations can come up quite a bit.
>>
>>108467686
Just use the name anyway. Are you going to let your precedents tell you what to do?
>>
>>108430859
only in cases so specific as to be useless
i.e. only if they're native GPU binaries for AMD GPUs and only really for HIP (AMD CUDA) although you might be able to hack it with mesa gpu binaries with clang/llvm and maybe PAL binaries with the standalone pipeline compiler with a lot of work
opencl on nvidia cards is done via CUDA and there's a vulkan extension that lets you run CUDA binaries as vulkan shaders so maybe you might be able to run the CUDA equivalent of the functionality as a standalone "compute" shaders
not sure how limited that is, never used it

you'd be better off seeing if there's a SPIR-V intrinsic corresponding to the functionality that is still supported by that graphics API when consuming SPIR-V binaries
vulkan, in theory, should have access to the most modern hardware functionality including most of the stuff in the OpenCL standard library, if not directly sometimes the shader compiler can transform manual implementations of hardware provided functions into their corresponding instruction
>>
>>108464926
That depends on your use case.
>>
>>108469232
>For big chunks, malloc may well use mmap too
Don't even:
>>through the size parameter triggering heuristics that will always be imperfect
And even IF it was perfect (which it's not):
>>malloc will never give you page-aligned addresses

>malloc's a lot more efficient
False dichotomy:
>>Chances are that you don't need individual lifetimes for your objects, you just need non-stack memory that can grow dynamically

You'd need individual lifetimes PLUS buckets of wildly varying sizes (to make bitmasks signifying empty slots in an arena no longer scale) PLUS the need to mash it all into one arena (that obviously isn't accessed by multiple threads) to make malloc actually be worth the effort that was put into it.

I might include that in future versions though.
>>
>>108469294
Thread local temp allocator to put all your garbage in. No need to track slots, just reset at the end of your program's frame and avoid reallocations.
>>
>>108469341
>Thread local temp allocator

... let me repeat myself:
>individual lifetimes
>wildly varying sizes
>the need to mash it all into one arena (that obviously isn't accessed by multiple threads)
>>
>>108469353
Just don't do lifetimes.
>>
>>108469369
>>Chances are that you don't need individual lifetimes for your objects
>>
> What are you working on, /g/?
Added game profile duplication feature to my Rust app. Had to deal a bit with overlapping borrows in ui callbacks again, and this time I solved by replacing all mutations with "action = ActionType(...)" assignments and deferring mutation for later by handling those ActionTypes outside of ui callbacks, so basically by refactoring it into something better and more clean.
>>
Trying to make http requests from scratch.

"GET / HTTP/1.1\r\n\r\n"
"GET / HTTP/1.0\r\n\r\n"

Is there a reason for why the request with HTTP/1.1 fails but the request with HTTP/1.0 succeeds?
>>
>>108469891
You need a Host header.
>>
Rust....
I think it really legit unironically stresses me the fuck out. I don't enjoy this shit.

I thought I understood Rust but... no, I just don't.
>>
>>108468438
Linux kernel is somewhat unique in exposing its system calls and being determined to keep them the same (will only potentially add new ones, not removing or changing existing ones) to keep a stable abi. So mmap is only guaranteed to exist on Linux. BSD on the other hand aims to have a stable api and will change its abi. So you'd have to use whatever api functions it has. I don't know much about BSD so I don't know what it's equivalent would be.
>>
>>108469908
Thanks.
Next problem I had was the request hanging but I found that we must get the length of the content from Content-Lenght, instead of exiting the loop when the amount of data received is 0.
>>
>>108470018
... what the FUCK are you talking about?
>>
>>108470047
>we must get the length of the content from Content-Lenght, instead of exiting the loop when the amount of data received is 0.
You do not understand package-based protocols. YOU have to determine when to stop reading from a socket.
>>
>>108470116
um no sweaty, the customer is always right
>>
>>108470116
>YOU have to determine when to stop reading from a socket.
that's exactly what I said
>>
>>108470272
Go ahead then. Scream at the kernel. That will surely change its mind.
>>
>>108468857
type, len, str, list, bytes, object, next, ...
>>
>>108470671
>type, len, str, list, bytes
indeed, all good words
>object
I don't use it but I understand
>next
why do use it for? or rather what would you want to use it for?
>>
>>108470701
muh_current_item = getshit()
next = getmoreshit()
if(next.good_enough():
muh_current_item = next
>>
>>108469982
Post your struggles, maybe we can help. Ownership/borrowing isn't really that hard. It's annoying, but it's mostly just the same few similar types of issues that can be solved in the same way almost every time so you get used to it.
>>
>start working on a project
>get stuck on basic details
>remember that I wrote a script to do the exact thing I'm trying to do now maybe 5 years ago
>dig up the old code even though I wanted to start from scratch
>it does exactly what I need it to do
>a lot of it goes completely over my head
>trying to make it make sense mostly breaks things
Has anyone else experienced this? I wasn't smart before but I'm pretty sure I've somehow become completely retarded.
>>
>>108471274
You didn't leave any comments or notes somewhere? Is it also C?
>>
>>108471274
It happens.
Most projects I'm working on when I'm right in the thick of it and I look at my code I usually think "Damn, if anyone else looked at this, they would have no clue what the fuck is going on."
And then you leave it for months and come back and you become that "anyone else".
Leave comments. Not for others, but your future self.
>>
>>108471274
>>108471274
Kind of. If I'm getting interest again in a program I wrote a while ago, I generally don't understand it right away because it's not obvious what it does and I refactor it to make it more simple and more obvious for the next time I'll try to understand it.
>>
>>108471331
It's like 100 lines of Python lmao. Reading Endless Sky data files and spitting out e.g. weapon info as TSV. It also prints pretty trees using unicode box drawing characters.

It's not even a complex format.
https://raw.githubusercontent.com/endless-sky/endless-sky/refs/heads/master/data/globals.txt

>>108471360
I've got the opposite problem. When my head is down, everything makes perfect sense and the only time I feel a comment improves intelligibility is for grotesque hacks.

>>108471428
That's usually how it goes. This time, I don't know what the deal is.
>>
>>108471558
>I can't read my parsing code
git gud and write better parsers
>>
Made a new thread. Not the normal option.
>108471984
>>
>>108471994
"option"
*op
>>108471984



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.