← Home ← Back to /g/

Thread 105530074

375 posts 120 images /g/
Anonymous No.105530074 >>105532885 >>105533809 >>105545055 >>105545515 >>105550383 >>105550724 >>105551714 >>105553269 >>105557660 >>105557685 >>105564075
/dpt/ - Daily Programming Thread
What are you working on, /g/?

Previous thread: >>105515327
Anonymous No.105530141 >>105530875 >>105530990
Threadly reminder.
Anonymous No.105530169
>>105527765
>All code is singlethreaded.
Oooh, a swing and a miss. At least in general.
Realtime code sees your assertion and chuckles mirthlessly. Things are more complicated than you think.
Anonymous No.105530187 >>105530211
bringing graphemes to readline
Anonymous No.105530211 >>105530233
>>105530187
what's the point?
Anonymous No.105530233
>>105530211
perfect grapheme handling. readline has trouble with zwj sequences. my library adapts based on how your terminal internally handles grapheme clusters. Under two terminals different sequences will render differently, so this lets me support all rendering.

it would be way easier in a program that manages the entire terminal screen (raw mode all the way like vim or nano), but readline has to handle running in canonical echo mode then back to raw mode which makes things way more complex. also this code doesn't use any library, the clustering uses heuristics.
Anonymous No.105530875
>>105530141
this will be another good thread with insightful discussions about programming
Anonymous No.105530898 >>105541115 >>105541277
i wish /prog/ was still a thing
Anonymous No.105530990 >>105531134
>>105530141
Needing unsafe crates doesn't mean it doesn't have hugepage support
https://youtu.be/rTo2u13lVcQ?si=teJZ_pG9MB1tmAGd

You should at least adjust that particular point
Anonymous No.105531076 >>105531085
Let's say hypothetically I wanted users to financially support me.
Do I set up a Pateron or a Ko-Fi?
Anonymous No.105531085
>>105531076
Ko-Fi or Buymeacoffee
Patreon takes a bigger cut, and is more averse to wrong thinkers
Anonymous No.105531134 >>105531219
>>105530990
It's not just the initial allocation part though - how do you *use* them? What about dropping, dereffing, and so forth? Doesn't it just end up being a worse version than the equivalent C code?
Anonymous No.105531219 >>105531239
>>105531134
Yes, you need 'unsafe' to use them. But that does not imply that you *can't* do that in Rust. We are not talking about a language that straight up rejects any way of doing that in its functionality
Anonymous No.105531239 >>105531248 >>105539379 >>105568693
>>105531219
Alright, fine.
Anonymous No.105531248 >>105531442
>>105531239
>made mmap schizo edit his image
That's a victory if I've seen one
this day has been greatly improved
Anonymous No.105531442
>>105531248
>he's never seen the first file mapping primer
Anonymous No.105531685 >>105531784 >>105533623 >>105545946
how do I write a HAL?
Anonymous No.105531784
>>105531685
Step 1: asking yourself what a HAL does.
Step 2: asking yourself how a HAL helps you in whatever you want to achieve.
Anonymous No.105531801 >>105531826 >>105538952 >>105541188
what are some kewl projects I can make in python?

>t. nublet
Anonymous No.105531826 >>105540948
>>105531801
>kewl
>python
Choose one.
Anonymous No.105531998 >>105532008 >>105532179
Is vim really worth learning? Is there a good reason to go from vscode to neovim?
Anonymous No.105532008
>>105531998
There's no reason. Try out the vim plugin for vscode if you want to really try it.
Anonymous No.105532023 >>105532050 >>105532102 >>105534459
Gonna try making an emulator. Should I:
>make a Gameboy emulator
>make a GBA emulator
>make a DS emulator
>make a PS1 emulator
>make an 80x86 emulator
Anonymous No.105532050
>>105532023
Why bother? You cannot faithfully create the memory layout of any system on either Windows or Linux because their shitcode doesn't like NULL.
Anonymous No.105532102
>>105532023
how about an Atari 2600/5200 emulator?
Anonymous No.105532109 >>105532127 >>105532199 >>105532215
i don't know what to code
some of my personal projects:
BMP to ASCII image converter
rudimentary raycaster using raylib
rendering a 3d spinning cube using sdl3
was making a chip 8 interpreter but lost interest.
was working on a tic tac toe game that supports mp via sockets but i also lost interest (making the game itself is ezpz, now the networking part is kinda "hard").

any fun recommendations that would level up my skills and teach me important concepts?
Done these in C except the raycaster (used c++)
Anonymous No.105532127
>>105532109
Syscall tracer.
Anonymous No.105532151
Is a monoid im the category of endofunctors in the field of sublinear optical programming?
Anonymous No.105532179
>>105531998
There's no reason to switch other than preferring keyboard navigation and maybe using other tools that use vim style keybinds. Personally I find it comfortable but your mileage may vary.
Anonymous No.105532199
>>105532109
>rendering a 3d spinning cube using sdl3
next step is importing an obj file
then after that importing a skinned mesh from a gltf file
Anonymous No.105532215
>>105532109
a boxing/packing program where you give it some objects with their 3D dimensions and it'll try to calculate what boxes (or other arbitrary volumetric containers) and how many of them you would need to fit all the stuff in
Anonymous No.105532225
oh, and visualize the objects and the boxes they're in, in 3D
vibe No.105532885 >>105533733
>>105530074 (OP)
did vibe coding and gemini free + tkinter fucking works
Anonymous No.105533623 >>105545889
>>105531685
Here's how you create a HAL.

1. Create a physics simulation environment. You could theoretically do this in Unity.
2. Create a scaled version of our solar system. Include algorithmic placement of asteroids and such. Be sure larger planetary objects have simulated gravitational pull, light emission from the sun is accurate and casts shadows, and try to make the orbits semi-accurate.
3. Now that you have a programmatic simulation environment of space, it is time to construct a virtualized space vessel. You will need to meticulously ensure all mechanical and electrical systems can be partially or wholly integrated with an API external to the simulation environment. This means the Api should provide full remote control of the ship, such as the ability to navigate the thrusters, adjust power levels, read sensor data, ect. It cannot be understated how important fully integrating every little aspect of the ship into an API is. Hell, there should be a cockpit even with a 'camera' that cac have its current view accessed via a GET and displayed as an image.
4. Now that you have painstakingly created a space physics simulator with a scaled down version of our solar system, and a space vessel with every sensor and electromechanical feature integrated into the Api, you must now begin a very long journey of training a multi-modal agent to operate the vessel. You will have to integrate all the Api data feeds into it and give it proper training and directive. This could take a while. Ideally you would give it a higher level prompt, run multiple parallel instances, then manually rate the trials and use the results as training data.

Good luck!
Anonymous No.105533733
>>105532885
>vibe coding
hobby board
post it on hackernews where people might care
Anonymous No.105533795 >>105533815 >>105533823 >>105534606
i don't want to be the bajillionth guy asking about vim but is it really worth it to learn it? does coding faster really matter?
Anonymous No.105533809 >>105533823 >>105533853 >>105533878 >>105533882 >>105534386 >>105534404 >>105545087 >>105545094
>>105530074 (OP)
So it's my understanding that returning pointers to local variables in C is UB. However when using Vulkan I've encountered this pattern:

VkShaderModule create_shader(
VkDevice device,
const std::vector& shader_code)
{
VkShaderModuleCreateInfo create_info {};
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
create_info.codeSize = shader_code.size();
create_info.pCode = static_cast(
static_cast(shader_code.data()));

VkShaderModule shader_module {};
auto rv = vkCreateShaderModule(device,
&create_info,
nullptr,
&shader_module);
if (rv != VK_SUCCESS)
{
throw std::runtime_error("Failed to create shader module");
}

return shader_module;
}


Where VkShaderModule is a typedef struct VkShaderModule_T* VkShaderModule;

Why exactly does this work? Is it because the memory for VkShaderModule lives somewhere else? I'm not clear on this.
Anonymous No.105533815
>>105533795
there's nothing to really learn if you're using it on a basic level. is it "worth it" probably not if youre never going to ssh / work on servers.
Anonymous No.105533823
>>105533809
It works because vkCreateShaderModule returns a VkShaderModule a.k.a. a VkShaderModule_T*. It's the address to a structure that (most likely) points to the heap.

>>105533795
You won't know till you try.
Anonymous No.105533853 >>105552927
>>105533809
Also
>std::vector& shader_code
Imagine storing a copy of your shader code in a vector when you could be using a file mapping instead.
Anonymous No.105533878
>>105533809
It's only UB when returned to something outside of it's stack scope, ie a function. This is a handle to something somewhere else in memory outside of your program.
Anonymous No.105533882 >>105533904
>>105533809
it's not a local pointer it's a typedef of a pointer to an opaque struct which is the typical and easy way of doing a handle
the point is you don't and can't know where the memory for it is, and because of layers you can't even necessarily control or predict that either since layers can dynamically dispatch of object handles]
i've done it before but strictly speaking even if you know what you're doing and are drilling down into the real object structure from the underlying driver i don't think it's necessarily safe
Anonymous No.105533904
>>105533882
and by safe i mean safe according to vulkan
i don't think there's any guarantees that the current loader behavior is stable or that the current behavior will even ever actually give you a real object handle at some point
Anonymous No.105533962 >>105545889
>/dpt/ can explain why the local pointer to heap memory can be safely returned
>/dpt/ can't explain how to make a HAL
Anonymous No.105534386
>>105533809
It returns the pointer by copy, simply copying the address. Address is somewhere on the heap, allocated by vkCreateShaderModule.
Anonymous No.105534404
>>105533809
int* ub()
{
int a;
int *ap = &a;
return ap;
}

int* not_ub()
{
int *ap = new int;
return ap;
}
Anonymous No.105534459 >>105534490 >>105549336
>>105532023
Why not work on a "piss easy" system like the ZX Spectrum and give it a niche feature not many over emulators have like:
>lua scripting and texture pack support (Mesen)
>transistor-level accuracy (MetalNES)
>static recompilation support (surprised nobody has tried this for an older system, wouldn't be too hard to get an entire system library running natively)
Anonymous No.105534490
>>105534459
>lua
So has their memory management gotten ANY better? Because last time I checked "clusterfuck" would be selling it short.
Anonymous No.105534606
>>105533795
it takes like 1-2 days to get familiar with it, just try it
Anonymous No.105534880 >>105534956 >>105535176 >>105535522 >>105564168
why is this code passing in a double pointer to allocate on instead of just a single pointer?
Anonymous No.105534956 >>105534994
>>105534880
Learn the fucking language or stop doing whatever it is you're doing. Your call.
Anonymous No.105534994
>>105534956
Anonymous No.105535176
>>105534880
the parameter is also the return value
Anonymous No.105535522 >>105543174
>>105534880
>why is this code passing in a double pointer to allocate on
Because that code is shit.
Anonymous No.105535774 >>105535850 >>105535881
If I publish an app, is my shit visible to people? Name, email etc
Anonymous No.105535850 >>105535932
>>105535774
yes, play store is pretty strict with their review process.
Not sure about f-droid.
You can also just distribute the .apk yourself.
Anonymous No.105535881 >>105535893 >>105535932
>>105535774
define publish and define app
app as in application or app as in mobileshit?
publish as in upload publicly or publish as in distribute through a third party vendor's store?

last i looked into it the google play store basically requires you either set up a corporation or dox yourself now and i don't think you can just use a PO box anymore either
i believe that info is public
though alternative app stores and package repositories are a thing on android a fair amount are FOSS/freeware oriented
not sure if apple is any better, doubt it

i don't think steam, gog, or epic require that though so i think game distribution is safe
microsoft authenticode certificates for making signed binaries for windows (and thus for things like publishing actually installable appx packages from the windows store) are costly and i think you do have to provide docs to CAs that issue them
i do not know if you can get ask for them without embedded personal info or at least with embedded personal info not linked to a real world identity
Anonymous No.105535893
>>105535881
mobile shit on google and ios
Anonymous No.105535932 >>105536040
>>105535850
>>105535881
Well it's natural if Google/Apple knows who I am, but I mean if that info ends up being visible to other people. Users and what not.
Anonymous No.105536040 >>105536053
>>105535932
by dox yourself i didn't just mean to google, google publishes it in the app's store page and they don't let you use a PO box anymore, which you used to be able to
this is VLC for android's app page, all that is required

if google does something developer unfriendly the safest assumption is always assume apple is 100% worse but i don't actually know
it's really not worth caring about anything apple as a platform as a small/independent developer
Anonymous No.105536053 >>105536084 >>105542886
>>105536040
wtf this is fucking grim
why is this even necessary
Anonymous No.105536084 >>105536560 >>105542958
>>105536053
What's the alternative? Some Russian or Chinese provider? Lmao.
Anonymous No.105536459
Three and a half more hours spent burning brain cells in SICP today. Today's section was on time/space complexity and a lot of really dull theta(n) analysis. I've always just handwaved this stuff away, so it's probably (maybe?) good that I've got a better handle on it now. At the very least, I understand better how an idealized machine handles deferred calls with respect to pushing/reusing stack frames. None of this stuff is intuitively all that difficult to grasp since it's pretty obvious when a process is going to blow up or not, but hopefully the ability to more formally reason with more granular differences (e.g. O(log n) versus O(n)) will be helpful as I continue on the journey.

Thanks for reading my blogpost
Anonymous No.105536498
First time programming in half a year. Making a link aggregator in PHP and Postgres, no JavaScript planned yet. Took two hours just to study PostgreSQL documentation to come up with three table layouts. I'm hella washed up.
Anonymous No.105536560
>>105536084
christ
does adsense dox you too?
Anonymous No.105537954
I am forgotten
Anonymous No.105538504 >>105538964
Hmmm today I will write some Rust
Anonymous No.105538875 >>105538919 >>105539046 >>105539049 >>105554660
that's it. this is what I am up to. the retardation.
on bottom the good ol implementation, which sucks, cuz it uses static arrays, which makes this shit stack allocated, it could be wrapped inside box, but still the stack can be fucked up if size is too big.
on top is nu implementation, which now allows to use dynamic arrays (vec), but shit looks horrendous, I am too retarded to do it right.
I've also came up with a new idea: using slices, which will imply that lifetimes are stored somewhere and all shit is just representation, but then it kinda breaks the whole point of static operation checking, even though it will be the same shit as vec rn, which still uses const type parameters but they can be left out, as they are not inferred as with arrays
Anonymous No.105538919 >>105539254
>>105538875
in Haksell this is just sequence
Anonymous No.105538952 >>105540948 >>105541030 >>105542096
>>105531801
bump
Anonymous No.105538964 >>105540083
>>105538504
Leaked pic of anon later today
Anonymous No.105539046
>>105538875
also names are kinda random the builder is not the builder pattern or whatever just shit that returns matrix.
allocator trait is not really an allocator just shit that provides some kind of memory representation so an array (static | dynamic)
and types A and B don't actually need IndexMut trait bound just Index, but cuz it's not the only trait, I just copy-paste where clause
Anonymous No.105539049 >>105539219
>>105538875
Will you admit defeat and come back to C?
Or will you resist, learn nothing, and write angry posts on a Mongolian basket-weaving forum?
Anonymous No.105539219 >>105539254 >>105539287
>>105539049
wut? there is no way to do shit like this in C, the whole idea is to check operations at compile time, so for example matrix multiplication is checked at compile time since the output type is MxK and left matrix is MxN and the right matrix is NxK there is no runtime check and all other matrix dimensions should fail at compile time.
Anonymous No.105539254
>>105539219
does rust have HKTs and HRTs (no not that kind of HRT) if so you could implement traversable >>105538919
Anonymous No.105539287 >>105539356
>>105539219
>the whole idea is to check operations at compile time
Yeah, sounds useless.
Anonymous No.105539356 >>105539379
>>105539287
Why would he go back to C instead of just not doing it? That's like telling someone who lives in the US and doesn't like burgers that he should go live in Africa instead of just eating something else. Kek
Anonymous No.105539379
>>105539356
Sanity.
>>105531239
Anonymous No.105539938
>Android Studio system requirements
>32 GB RAM recommended
>GPU with 8GB VRAM recommended
Fucking bastards
Anonymous No.105540083
>>105538964
Indeed it kind of fucking sucks. But I'm kind of getting the hang of it.
Anonymous No.105540948
>>105538952
>>105531826
Anonymous No.105541030
>>105538952
Python is a shit language for niggers, you should learn literally anything else, I guess Go is an ok starter language, or Rust if you're trans. Anyway, as a beginner project you can do something like drawing some kind of pattern or image on the terminal or in a bitmap image.
Anonymous No.105541115
>>105530898
I wasn't there, how was it different?
Anonymous No.105541188
>>105531801
Idk, do CLI stuff.
(I'm assuming you're a beginner here).
Connect to a database and retrieve/push values for starters. Start stretching those programming muscles first
Anonymous No.105541277 >>105541291
>>105530898
>>>/mu/prog
Anonymous No.105541291
>>105541277
kek
Anonymous No.105541350 >>105542022
Practicing some recursion and then I may do a hello world with sneed7
Anonymous No.105541787 >>105541838 >>105541926
>"Please consult our API documentation to learn how to use this library."
>alphabetical listing of 5000 functions and types
>all descriptions are 1 sentence max
AAAHHHHHHHHHHHHHH
Anonymous No.105541838
>>105541787
Typical pajeet project.
Just don't waste your life on it.
Anonymous No.105541844
My personal project's API now requires a lot of w*bshit and it's pure suffering.
Anonymous No.105541926
>>105541787
It's self-documenting
Anonymous No.105542022 >>105542085
>>105541350
#include

void rec(char** s)
{
if (!**s)
return;
putchar(*(*s)++ - 1);
rec(s);
}

int main(int argc, char** argv)
{
char* msg = "gbhhpu";
rec(&msg);
return 0;
}
Anonymous No.105542085 >>105542173 >>105542483
>>105542022
Christ.

#include

void rec(char* s)
{
if (!*s)
return;
putchar(*s - 1);
rec(++s);
}

int main(void)
{
char* msg = "gbhhpu";
rec(msg);
return 0;
}


Dereferencing ain't cheap.
Anonymous No.105542096
>>105538952
Make a Discord bot
Anonymous No.105542173 >>105542190 >>105542191 >>105542448
>>105542085
why are you clowns accessing the byte before the start of the buffer?
Anonymous No.105542190
>>105542173
they're not, it's (*x) - 1 not *(x - 1), its like a cipher
Anonymous No.105542191
>>105542173
>what is operator precedence for 1000
Anonymous No.105542448
>>105542173
Anonymous No.105542483 >>105542554
>>105542085
>autism
Imagine if you could use your brain normally
Anonymous No.105542554 >>105542569
>>105542483
Why are you talking about things you've never done?
Anonymous No.105542569
>>105542554
>no u
Anonymous No.105542582 >>105542808
Yes.
Anonymous No.105542808
>>105542582
yes u
Anonymous No.105542886 >>105546052
>>105536053
>why is this even necessary
Because lying asshats otherwise shit the place up. To keep a lid on that, the big app stores require the software to be signed with real identities. Mostly people use corporate identities because it's convenient to keep the money side separate from personal accounts.
If you're not going through an app store, you don't need to follow any of those rules.
Anonymous No.105542905
no u
Anonymous No.105542958
>>105536084
jannies vetting and packaging everything like god intended.
Anonymous No.105543174
>>105535522
the worst part is it's c++, not c
Anonymous No.105544624
GopherG6 image board
Anonymous No.105544759
So how far are you with your registry dumpers?
Anonymous No.105545055 >>105545098 >>105545419
>>105530074 (OP)
Is it true modern compilers compile steganographic or encrypted EXIF data into your programs that you make? Ones that intelligence communities can trace back to your computer's unique MAC address?
Anonymous No.105545083
Has anyone ever made a desktop environment with nurses?
What would be the implication?
Anonymous No.105545087 >>105545098 >>105545457 >>105545507
>>105533809
What is UB?
Anonymous No.105545094
>>105533809
Is this C++?
Anonymous No.105545098
>>105545055
You mean this?
https://github.com/RichHeaderResearch/RichPE

>>105545087
Undefined behavior.
Anonymous No.105545419
>>105545055
no
they do embed a history of the binutils used on them, which i think gcc usually strips out, which has been used exactly once to track down a malware dev who used odd combinations of versions of legacy and modern tools, on account of being a dumbfuck retrocoder, in both malware and software that was associated with his public identity, and that's it


that is such a retarded schizo view of how surveillance works lmao
and all shit can spoof mac addresses these days anyway, mobile devices even do it by default
Anonymous No.105545457
>>105545087
Ultra beasts
Anonymous No.105545507
>>105545087
Utterly Based.
Anonymous No.105545515 >>105545585 >>105545637
>>105530074 (OP)
Lately, I've been wanting to model my programs as a pure data pipeline
Instead of the following syntax, which looks dead simple (albeit ugly, and the reverse to how one would expect the data pipeline to be read):
result = c(b(a(argument)));

I've been thinking of using a function which executes the arguments in it to make the program syntactically tacit, sort of like so. Note: all function signatures are the same:
execute_fns(&result, &argument, a, b, c);

Now, can the compiler see my intent to represent the programs as merely a series of transformations (and optimize accordingly), or is there something about variadic arguments that prevents any optimization?
Anonymous No.105545585 >>105545642 >>105545760 >>105546940 >>105550350
>>105545515
Function calls that exceed the amount of registers the ABI allocates for parameters (4 on Windows, 6 on Linux): bad, because the parameters end up on the stack.

Variadic argument lists: bad, because the spillover parameters will end up on the stack.

Providing function pointers: bad, because the compiler is much less likely to inline the functions (especially across translation units) to improve out-of-order execution. Also compilers are terrible at estimating call depths and will rather generate a CALL/RET pair than a LEA return + JMP target + JMP return combination even though that would improve out-of-order execution (because CALL/RET use the SP register implicitly) without increasing code size.

Oh, and compilers also suck at retaining values in registers. When the ABI says "volatile" they really do mean "volatile", even if the register could act as return value.
Anonymous No.105545637
>>105545515
just overload operator<< bro
Anonymous No.105545642
>>105545585
In contrast using a
c(b(a(argument)))

is relatively straightforward, even if the compiler ends up not inlining the thing. After every call the compiler can just rename the return to the first parameter register:
CALL a
MOV rcx,rax
CALL b
MOV rcx,rax
CALL c
Anonymous No.105545760 >>105546114
>>105545585
This sucks. I expected modern compilers to not be limited by such restrictions.

Anyway, time to present my next terrible idea: dropping down to assembly to use direct threaded code, as presented by Jonesforth.
TLDR: If my program can be represented as a flat array of calls to functions, the opcode to call a function (0xE8, iirc) can be omitted and replaced by the following two lines, provided that esi is pointing to the first member of the function pointer array itself:
lodsl
jmp *(%eax)

For an elaboration, see https://github.com/AlexandreAbreu/jonesforth/blob/master/jonesforth.S#L227
Anonymous No.105545768
>c99
>_Bool
why the fuck does this stupid shit exist. do boomers really.
Anonymous No.105545795 >>105545846 >>105546251
Anons, I need to make a fillable form that can be put on a self-hosted website. I have very little time to do this, about 9 hours and I need to sleep during that. My only coding experience is from khan academy JS exercises. This tutorial here seems to cover everything that I need: https://www.youtube.com/watch?v=fNcJuPIZ2WE

But I'm on Linux Mint, and I don't know if I can download Visual Studio and get it set up on time. What programming tool/environment should I use?
Anonymous No.105545846 >>105546155 >>105556843
>>105545795
I'm assuming this is a class assignment? No one with a brain would put someone with no experience in charge of user input.

Just use Kate or Sublime Text or something. They have guis and already have syntax highlighting.
Anonymous No.105545889 >>105545905 >>105549251
>>105533962
>/dpt/ can't explain how to make a HAL
Now hold the fuck on
Tell me why >>105533623 was somehow not a valid explanation of how to make a HAL
You could literally train a multi modal agent to operate space vessel I/O

If serious money was put into this, as in an excellent simulation environment and thorough training data, you might actually end up with a model literal space agencies would take interest in for long term deep exploration missions or other planetary ventures
Anonymous No.105545905 >>105545919
>>105545889
Hardware Abstraction Layer, anon, not whatever you've cooked up...
Anonymous No.105545919
>>105545905
I rest my case then.
Anonymous No.105545946
>>105531685
structs and function pointers
Anonymous No.105546052
>>105542886
>Because lying asshats otherwise shit the place up.
In other words, it's because of indians. Again.
>If you're not going through an app store, you don't need to follow any of those rules.
If I'm not going through an app store, I won't make a dime.
Anonymous No.105546114 >>105546260
>>105545760
>I expected modern compilers to not be limited by such restrictions.
Modern compilers become virtually blind once you remove inlining. Fuck, they can't even do partial inlining; see https://en.wikipedia.org/wiki/Loop-invariant_code_motion

>provided that esi is pointing to the first member of the function pointer array
You're confusing CALL and JMP. CALL pushes the instruction pointer to the stack for RET to retrieve and then jumps to the target, JMP jumps directly without leaving any return information on the stack.

But hey, maybe you're luckily and the CPU will prefetch the addresses into internal registers early enough that L1 latency doesn't occur.
Anonymous No.105546155
>>105545846
Nope, for a voluntary organization. I'll check those out, thanks anon.
Anonymous No.105546251
>>105545795
Have you considered giving up? You're clearly not up to the task. Sometimes all one can aspire to in life is shoveling shit.
Anonymous No.105546260 >>105546368
>>105546114
I misread the code, my bad.

Anyways, one implication of replacing the typical CALL/RET pair with only appending LODSBs and JMPs that interests me is that I'm well on my way to getting myself an indirectly threaded forth interpreter.
Now, given the concatenative nature of forth code, I could recursively inline the definitions of the forth functions into one giant program (stripping away unneeded instructions such as paired pushes, pops, etc).
Now, is there any perfomance downside to running 100% inlined code, with no jumps or calls at all whatsoever?
Anonymous No.105546368 >>105552579 >>105562309
>>105546260
>running 100% inlined code
Syscalls cannot be inlined. They run in an entirely different mode.

>no jumps or calls
And how do you handle failure? Especially if the failure comes from the kernel? If a file couldn't be opened or memory couldn't be allocated?

And let's assume you're doing nothing but userspace operations - even then you are going to experience slowdowns because the instruction cache would essentially turn into a ring buffer, and the prefetcher could only prefetch so much before bus latency itself becomes a problem. Same with the iTLB by the way, only that the prefetcher might not even prefetch these ahead of time.
Anonymous No.105546940 >>105550708
>>105545585
C++ seems to output something okay
https://godbolt.org/z/MsEbGTozc
Anonymous No.105547300 >>105547554
Since im new to django i asked ai to tell me how to populate a field thats a foreign key with an object instead of an id( pretty basic thing in web dev) and even after repeated prompts it couldnt do it. At the end i did it manually with the help of SO
Nice ai hype bubble you got there
Anonymous No.105547519 >>105547567
pair programming in emacs with AI

https://github.com/MatthewZMD/aidermacs
Anonymous No.105547554
>>105547300
Seems to be working as intended.
Anonymous No.105547567
>>105547519
Have all these people using emacs been using it for 20+ years? There's no way it's worth getting into now.
Anonymous No.105549037
>replace recursive variadic template functions by a struct and std::initializer_list
>code is easier to use and more organized
>but I don't get to feel smart when I look at it
Not sure if it was worth it
Anonymous No.105549251 >>105549322
>>105545889
>If serious money was put into this, as in an excellent simulation environment and thorough training data, you might actually end up with a model literal space agencies would take interest in for long term deep exploration missions or other planetary ventures
Yes anon, the same people that forbid heap allocations will put a probabilistic next word predictor to pilot their 50 billion dollar misison.
Anonymous No.105549322 >>105549357 >>105549416 >>105549416
>>105549251
The key points here
>long term deep exploration missions
>other planetary ventures
Give me a better solution to the problem of not being able to have crews on deep space missions then.
>cryogenics and deep sleep is a fairytale and will almost always result in a dead human
>attempting to sustain a multi-generational crew with a micro colony will almost certainly lead to a Lord of the Flies esque situation but much more grim

Make a concrete argument as to why a multimodal AI agent trained specifically for vessel operation in deep space is a bad idea and not possibly a multi billion dollar idea.
Anonymous No.105549336
>>105534459
Static recompilation of an old console where cycle accuracy requires running each subsystem for only 1 cycle wouldn't be too hard? If you know how to remove the scheduler overhead and linearize the executed code of the multiple systems running in parallel while maintaining cycle accuracy, I'd be glad to hear it.
Anonymous No.105549357
>>105549322
>will almost always result in a dead human
Good.
Anonymous No.105549416
>>105549322
>>105549322
>The key points here
>>long term deep exploration missions
>>other planetary ventures
I can't be bothered to reformulate, it's clear enough and you should easily understand my objection. If it's for safe guarding humans it's even worse.

>cryogenics and deep sleep is a fairytale and will almost always result in a dead human
Cryogenics works on egg cells, although with a significant failure rate, so it's not complete science fiction, I want to believe that it could work on an entire organism. It's an enginering problem.

>Make a concrete argument as to why a multimodal AI agent trained specifically for vessel operation in deep space is a bad idea
probabilistic next word predictor. I know it's more complex than that but there remains the fact that AI does not do precise logical reasoning, so it's unreliable.
Anonymous No.105550350 >>105550445 >>105550708
>>105545585
>Also compilers are terrible at estimating call depths and will rather generate a CALL/RET pair than a LEA return + JMP target + JMP return combination even though that would improve out-of-order execution (because CALL/RET use the SP register implicitly)
You mean like
f:
jmp rax
start:
lea rax, [rip + 2]
jmp f
would be better than
f:
ret
start:
call f
for out of order execution?
Anonymous No.105550383 >>105550473
>>105530074 (OP)
What do you think of en_US ANSI as kb layout? I am going out of my way to order a laptop with that layout even though I am not a native speaker but I think the it's just more comfortable for coding compared to my localized ISO layout. Opinions? Personal experience with the american layout (no international pls)
Anonymous No.105550422 >>105552199 >>105552493
Do you guys unironically do test-drive-development (TDD)? I don't understand how TDD is even possible because when you're adding a new feature to an existing codebase, the existing tests won't cover the new feature you're modifying the testable code for.

Do you guys just do TAD - testing-after-development to isolate the code you just added/changed?
Anonymous No.105550445 >>105550495
>>105550350
https://en.wikipedia.org/wiki/Continuation-passing_style

instead of doing a call/return, you pass a continuation to the called procedure. that procedure can then pass that continuation to another procedure if needed.

call foo(args...) become goto foo(args..., continuation)

then foo() will either do goto continuation; or pass it to another procedure
Anonymous No.105550473
>>105550383
I've used the ansi layout for years, ~, |, and " are in better positions t. bong
Anonymous No.105550495 >>105550743 >>105550822
>>105550445
What's the equivalent assembly using lea/jmp if you don't mind writing it?
Anonymous No.105550621
If you're not using FastAPI you're literally ngmi**


``
```python
@router.post("/videos/transcode", status_code=202)
async def submit_transcoding_job(
# Dependencies are just function args, clean as fuck
current_user: User = Depends(get_current_active_user),
db: Session = Depends(get_db),
tasks: BackgroundTasks,
s3: S3Client = Depends(get_s3_client),

# Handles multipart/form-data with file and form fields automatically
video_file: UploadFile = File(...),
options_json: str = Form(..., description="JSON string of transcoding options"),
webhook_url: Optional[str] = Form(None)
):
"""
Accepts a video file and kicks off a background transcoding job.
Responds immediately with a job ID.
"""
# Just works. No bullshit request parsing.
if not video_file.content_type.startswith("video/"):
raise HTTPException(status_code=400, detail="Not a valid video file.")

# Validate the JSON config string using Pydantic on the fly
try:
options = TranscodeOptions.parse_raw(options_json)
except ValidationError as e:
raise HTTPException(status_code=422, detail=e.errors())

# Business logic is clean and readable
temp_path = await save_upload_file_tmp(video_file)
job = crud.jobs.create(
db, user_id=current_user.id, options=options.dict(), webhook_url=webhook_url
)

# The actual heavy work runs in the background. API returns instantly.
tasks.add_task(run_ffmpeg_transcode, job_id=job.id, source_path=temp_path, s3_client=s3)

return {"job_id": job.id, "status": "queued"}
```
``
Anonymous No.105550708 >>105551070
>>105546940
Yeah, I can't get the same output in C if I tried. Could be that I use inband signalling with NULL to determine when the list is at its end, or maybe C++ is even more aggressive when it comes to inlining: https://godbolt.org/z/ssPMq6KqE

>>105550350
The CPU maintains a return stack buffer (RSB) for the purpose of predicting where to fetch instructions from. A RET will still cause a sync due to SP dependency, but the CPU will be able to prefetch the target address.

Code that doesn't use RET doesn't have the dependency, and as such doesn't have to sync - but LEA/JMP is only worth it if it's a leaf function that doesn't call into anything else (CALL/RET are much more optimized for stack operations). Also the CPU is solely dependent on out-of-order execution to determine where the return will happen to, so you want to have some instructions between the beginning and the end to give the CPU enough time to realize that the register holding the return address doesn't change and can prefetch instructions accordingly.
Anonymous No.105550724
>>105530074 (OP)
Visual Studio / C# question.

I understand how to make filescoped namespaces default for new classes and projects within an existing solution. Is there anyway to make it default for new solutions as a setting within VS2022 or do I just have to make a template where that is the default?
Anonymous No.105550743 >>105550822 >>105550891 >>105551070
>>105550495
i don't know. you could have a calling convention where the continuation address is passed in the register R13.

mov r13, 0x1234 ; where it should go after foo
jmp foo ; go to foo routine

0x1234:
...


foo:
... ; do stuff
jmp bar

bar:
... ; do more stuff
jmp poo

poo:
... ; more stuff
jmp r13 ; jump to continuation


this way, poo would return way back to 0x1234, bypassing the chain of call/return.
Anonymous No.105550822 >>105551070
>>105550495
CALLEE:
NOP ; Code
NOP ; Cooooooooode
JMP rax ; As long as RAX hasn't been clobbered you're good

CALLER:
LEA rax,[rip + CALLEE_RETURN_1]
JMP CALLEE

CALLEE_RETURN_1:
NOP ; Moooooore coooooooode
LEA rax,[rip + CALLEE_RETURN_2]
JMP CALLEE

CALLEE_RETURN_2:
NOP ; Coooooooooooooooooooooooooode


As >>105550743 pointed out this requires a degree of coordination between caller and callee that's usually being taken care of by the ABI. Instead of RAX you can use RCX, RDX, or whatever other registers are out there; as long as the callee preserves the register it can return to your caller.
Anonymous No.105550891
>>105550743
NTA but worth mentioning you can even have multiple return continuations to choose from like exceptions
Anonymous No.105551070
>>105550708
>>105550743
>>105550822
Thanks anons. I'm not familiar with x86 but it's kinda like the link register on arm, I'll try using it when the callee is a leaf
Anonymous No.105551714 >>105552179 >>105552929
>>105530074 (OP)
Why do people use functions to organize code when it can introduce non-trivial overhead?
Anonymous No.105552179 >>105552244
>>105551714
Because it reduces overhead in all cases assuming you have a compiler.
Anonymous No.105552199
>>105550422
I don't test my code, I simply use it, if it didn't work, it would piss me off and I'd fix it.
Anonymous No.105552244 >>105552261 >>105552579
>>105552179
So starting a new stack frame, popping all the passed values onto it and copying all returned values onto the calling stack frame is more efficient than just doing the work inline?
Anonymous No.105552261 >>105552322
>>105552244
If your function actually needs such setup, yes, it's objectively always better.
Anonymous No.105552322 >>105552372 >>105552611 >>105552936
>>105552261
So why is the game I made in C++ around 10% faster when I just copy and paste all the contents of the functions I call, inline into the hot loop?
Anonymous No.105552372 >>105552419
>>105552322
Because you're too retarded to do a pgo build or just manually mark the function to be always inline. Chances are that 10% doesn't mean anything since your "game" is just a cube rotating in empty soulless void like every 4chan project ever.
Anonymous No.105552419 >>105552439
>>105552372
Ok so you don't know or you bullshitting. Got it.
Anonymous No.105552439 >>105552701
>>105552419
Yes I'm sorry for not knowing how to explain to a retarded nigger that marking one function as always inline is trivial but wading through 100kloc spaghetti in one file is not.
Anonymous No.105552493
>>105550422
I test my code after I get something testable, notice the issues and refactor based on that. TDD comes with it's own overhead and you might end up with a headache if you decide to make radical changes, basically rewriting the entire suite.
>I don't understand how TDD is even possible because when you're adding a new feature to an existing codebase, the existing tests won't cover the new feature you're modifying the testable code for.
You gotta add (and maintain) the code so yeah. Some people make unit tests aiming for one specific part of the function instead of having a bunch of assertions in a single test precisely so they don't have to touch old tests.
If you're mocking stuff, minimize the amount of them either by increasing the surface of the unit tests by including other classes or by writing integration tests instead. It's basically guaranteed that you'll have to keep an eye on mocks and you might miss on bugs because the mock doesn't reflect the behavior of the object after you do some refactoring. Do not believe people who claim that every class has to be 100% isolated, you'll fucking hate yourself otherwise and won't feel like refactoring.
Anonymous No.105552579
>>105552244
Yes.
>>105546368
Anonymous No.105552611 >>105552645
>>105552322
If you have so little code that copy pasting the code inline is noticebly faster then it's because the relative cost is higher when you don't have a lot of things going on, the average frame time should be around 13 ms. You are claiming that your function calls in total are around 1.3 ms in a release build? That would need to be something like 5,000 function calls that you are manually inlining and there is absolutely no prefetching going on, your cache is completely trashed etc. If your game is just some shitty free spinning loop that happens 10,000 times a second then you might notice a few function calls because now 0.01 ms is "noticable" so inlining 50 function calls could do that.
Anonymous No.105552645
>>105552611
Or it means that his compiler is shit.
Anonymous No.105552701 >>105552769
>>105552439
Ahh so it's a personal preference on your part and you were lying through your teeth when you gave that answer. Now it's coming out. Anything else to add?
Anonymous No.105552769 >>105553320
>>105552701
You should put your brain into a blender and ask a doctor to inject it into your bloodstream because there's clearly a bottleneck between your head and the rest of your worrhless body, especially those brown hands that wrote your post.
Anonymous No.105552927 >>105552957
>>105533853
Could you please illustrate your point? Not quite familiar with file mapping.
Anonymous No.105552929
>>105551714
Aggresive inlining bloats program size and you will need more cache / pages to hold duplicated code and such tradeoff may or may not be worth it to just calling the function.
Anonymous No.105552936
>>105552322
You don't want me schizoing out over C++'s code generation, right?

Right?!
Anonymous No.105552957 >>105552997
>>105552927
Anonymous No.105552997 >>105553060
>>105552957
WTF I hate fread now!
...
Wait, but why don't people massively use mapped files for reading then? It seems like they're the best tool.
>Array-like access
>Linear memory
>Thread safe without any locks

Where's the pitfalls?
Anonymous No.105553060
>>105552997
Same reasons they don't use VirtualAlloc/mmap directly to manage their memory:
- they don't know any better (because their teachers were incompetent).
- they don't want to know any better (because then they got no one else to blame for slow performance but themselves).
- there are instances when file mappings end up being slower than direct I/O, namely when the file in question is bigger than your RAM and you write to it non-sequentially. Most programs don't do that to begin with.
Anonymous No.105553063 >>105553075 >>105553126 >>105553153 >>105553373
From hackernews
>I wish people used mmap less.
>Creating a new memory mapping can be pretty expensive! On both Windows and Linux, it involves taking a process-wide reader-writer lock in exclusive mode (meaning you get to sit and wait behind page faults), doing a bunch of VMA tree manipulation work, doing various kinds of bookkeeping (hello, rmap!) and then, after you return to userspace, entering the kernel again in response to VM faults just to fill in a few pages by doing, inside the kernel, what amounts to a read (2) anyway!

>Sure, if you use mmap, you get to look at the page cache pages directly instead of copying from them into some application-provided buffer, but most of the time, it's not worth the cost.
>There are exceptions of course, but you should always default to conventional reads.
Anonymous No.105553075 >>105553126
>>105553063
>Another problem with mmap is that there is no good way to handle I/O errors.
>The application will get a signal (SIGSEGV/SIGBUS, can't remember), and no information about what the problem could possibly be. Most applications do not catch these signals and will instead just terminate.

>Even if you do catch the signal there is a real challenge to know what caused the signal and to keep consistent book-keeping to be able to perform any sane action in response.

>At a previous employer we started seeing this problem when scaling things in production which was no fun.
Anonymous No.105553126
>>105553063
>>105553075
@grok is this true?
Anonymous No.105553153 >>105553163 >>105553188
>>105553063
>On both Windows and Linux, it involves taking a process-wide reader-writer lock
Windows pages stuff in lazily, but you can use PrefetchVirtualMemory to avoid mode switches and page faults. On Linux you can use MAP_POPULATE.
Anonymous No.105553163 >>105553240
>>105553153
>PrefetchVirtualMemory
I am ignorant, is this somehow related to _mm_prefetch and __builtin_prefetch or what?
Anonymous No.105553188 >>105553310
>>105553153
Yeah, and how to properly use PrefetchVirtualMemory and when? The official Microsoft docs suck ass at explaining stuff
Anonymous No.105553240
>>105553163
PrefetchVirtualMemory is a Win32 function that calls into the kernel (NtSetInformationVirtualMemory syscall) to tell it that the provided memory region will be used very soon, and to page it in.

__builtin_prefetch => CPU-independent vesion of _mm_prefetch, which translates into PREFETCHNTA of PREFETCHTX instructions on x86/x64. These instructions don't cause paging, but instead hint to the CPU that it might want to prefetch these. If the address isn't backed by memory, then it's just a more expensive NOP.
Anonymous No.105553269
>>105530074 (OP)
Trying to make a unit testing library for python where I can just add @Test and give an input or run the function and it will save the output of the function and automatically create all the tests.

Ideally the test output will be human readable, so when changes happen you can see the diff in version control
Anonymous No.105553310
>>105553188
>Yeah, and how to properly use PrefetchVirtualMemory and when?
Don't you have the same problem with madvise(MADV_POPULATE_READ) (the more fine-grained equivalent)?
Anonymous No.105553320
>>105552769
That's some impressive rage. I've not seen anyone so angry since Cniles told Rust troons that their language will never pass a systems programming language.
Anonymous No.105553373 >>105553387 >>105553396
>>105553063
mmap is cheap, all memory is allocated using mmap, why would I listen to some fucktard drivel when I can combine mmaping a file and allocation into one syscall thanks to CoW?
Anonymous No.105553387
>>105553373
I'm going to mmap my balls onto the face of your mother if you catch my drift.
Anonymous No.105553396 >>105553474 >>105553644
>>105553373
So for read-only I/O mmap is ALWAYS better, correct? Does it make sense to align blocks in the file to the cache size?(4096 bytes)
Anonymous No.105553474
>>105553396
It's already aligned.
Anonymous No.105553555 >>105553892 >>105554578
I've did a few scripts for work but I'm nowhere near an actual programmer. How do I properly learn? Books to read or courses to take. I'm looking more into web development (backend) + automation/integrations. My biggest problem is I know my fucking ass will abuse copilot because I'll be stuck in something and refuse to figure it out.
Anonymous No.105553644
>>105553396
>So for read-only I/O mmap is ALWAYS better, correct?
What's the alternatives?
>maintaining your own copy => congratulations, now the kernel has to handle two sets of pages
>maintaining your own copy using direct I/O => now the mapping cannot be shared with any other process
>direct I/O => hope you enjoy loading the same shit from mass storage over and over again, via syscalls and copies
Anonymous No.105553873 >>105553886 >>105554134 >>105554247 >>105555007
>learning c# and WPF
>tutorials start off simple
>necessarily spend 15 minutes explaining what a string is
>spend 30 minutes on what the bits of VS 2022 are
>millions of examples of console.writeline and console.readline even though it's a wpf tutorial
>methods classes are shorter for some reason despite being slightly more complex
>Anyway this is the MVVM model and here's a bunch of random shit that we're doing something something view model model view model model view view model model on repeat for barely 5 minutes
>now you know how to program with c#!

I'm beginning to suspect no one really knows how to properly explain concepts that are less simple than 'here's how to write to the console'.
Anonymous No.105553886 >>105553943
>>105553873
Welcome to programming. Throw shit at the wall until you're a master of throwing shit at a wall (the insult others who aren't as good at throwing shit as you are).
Anonymous No.105553892 >>105554578
>>105553555
I think my biggest problem is I have an idea for a project and it's kinda like okay I can do x,y,z but that sounds like too many steps, that's stupid. Then I'll AI it and it'll be like just do X -> Z and I'm like yeah that makes sense and it's more sellable but it doesn't really feel like I'm learning much except prompting. I mean I guess I'm learning a bit by osmosis.
Anonymous No.105553930
>nostdlib
>interacting with local x11 is easy enough
>need mesa for GPU access or write my own drivers
>even if I theoretically succeeded in rewriting all drivers, modern GPUs need proprietary ZOG approved and signed blobs
software renderer it is
Anonymous No.105553943 >>105554247
>>105553886
Thanks that makes me feel better.
It just reminds me of school, spend shit loads of time on the utterly basic shit and rush through anything useful ok bye good luck nigga!
Anonymous No.105554052
java and python are for stinky poopoo diaper babbies (yes, babbies)
Anonymous No.105554117 >>105554632
How cooked am I going to be if I mostly trimmed through the Smart Pointers chapter in the Rust book?
First time the book kinda lost me
Anonymous No.105554134
>>105553873
kek yeah it's crazy.
>this bloopblopp is actually simply a blooppoop for the pooppoop
>oh a pooppoop? that's just a fartshart for the blooppoop with a cartmart but you're better off using a bloopshoop shartmart in a hurrdurr if you really need the beepboop of the bloopblopp
Anonymous No.105554247 >>105554268
>>105553873
>>105553943
>read jeet shit
>get jeet quality
Either read a book or read code + documentation.
99% of tutorials are jeets grifting for 0.1 cents a click.
Anonymous No.105554268 >>105554355 >>105554490
>>105554247
It's a pluralsight tutorial by a guy named Claudius Huber. I don't think he's a jeet but go off, retard.
Anonymous No.105554355
>>105554268
>Claudius
What kind of braindamaged retards name their child "Claudius"?
Anonymous No.105554490 >>105554523 >>105554566 >>105554577
>>105554268
What's the point of a reply like this if you have already determined yourself that it was a garbage tutorial?
Just to save you time, you probably won't find a C# WPF tutorial that isn't jeet garbage, because C# WPF is itself jeet garbage.
>what are some non-jeet-garbage gui libraries then
You think it's a coincidence that everything is an electron app nowadays? There are none.
Anonymous No.105554523
>>105554490
Win32.
Anonymous No.105554566
>>105554490
>You think it's a coincidence that everything is an electron app nowadays?
>in an era where jeetcode is spammed out like shits on the designated streets
hmm I wonder why everything is a shitty electron app. HMMMM
fucking retard.
Anonymous No.105554577
>>105554490
>electron
>not jeet-garbage
Anonymous No.105554578 >>105554626 >>105555734
>>105553555
>>105553892
Not anything wrong with using an LLM, you just need to go into it with the mindset of learning. You can usually understand more about the code if you seriously look at it and try to learn everything you don't fully understand, asking coppilot to explain or looking at the source for the function it uses can help

Ask it how to structure the app and for some google terms (RESTful app, frontend/backend, etc).

Also maybe learn functional programing, at least for me, once I understood it a lot of stuff that just didn't make sense opened up
https://www.youtube.com/watch?v=nuML9SmdbJ4
Anonymous No.105554601 >>105554646 >>105554810 >>105554817 >>105555625 >>105557289
A binary I compiled on one Linux computer throws errors on another computer about missing specific library versions that don't match the ones installed. How do I prevent this?
Anonymous No.105554626
>>105554578
>vidya vlogs have now sprouted a new cancerous programming themed growth
2x playback speed is great and all but can we get an AI de-background-musicer? Just say it's about copyright or some bullshit
Anonymous No.105554632 >>105554645
>>105554117
In practice you shouldn't be using smart pointers at all as a beginner. I mean real smart pointers like Arc, Rc, Box, RefCell. Obviously you should use vecs and strings, counting those as smart pointers is a stretch anyway.
Anyway, I'd say it's still pretty important to understand the concepts. But you can come back to it later.
Anonymous No.105554645 >>105554712
>>105554632
>But you can come back to it later.
Cool, I'll just move on to the next chapter then.
I mean I understand the idea that vecs and strings are smart pointers and I think I understood the idea of Box, Rc, and RefCell but at some point the code listings really lost me, so I wouldn't say I understood how to actually use them.
Anonymous No.105554646 >>105555052
>>105554601
If it's any library except glibc, just statically link it.
If it's glibc, see if you can use musl instead. If you can, just use musl and statically link it.
If not, you have to compile it on an old linux system, so that it works with old glibc versions.
Anonymous No.105554660
>>105538875
mental illness
Anonymous No.105554712 >>105555128 >>105555432
>>105554645
That's ok, you genuinely shouldn't use that crap anyway. Box and Rc and basically never useful. RefCell is basically only useful for thread_locals. Arc is only useful when doing some kinds of hardcore concurrent or async code. You should't have to worry about any of this for several years, hopefully never.
Anonymous No.105554810 >>105555052
>>105554601
By not being a kike and giving user the code, at which point if it doesn't work, it's a skill issue.
Anonymous No.105554817
>>105554601
Ship with your libs (not glu or system shit like that) in the same dir. Patch the rpath.
Anonymous No.105555007
>>105553873
This is because Micro$oft can't stand still for more than 5 minutes before renaming .NET and changing the apis for GUI shit and web shit. Job security if you're a C# shop with hostages I mean customers.
Anonymous No.105555052 >>105557719
>>105554646
It's just libjpeg. I have .so.8 on the source machine and .so.62 on the target.
>>105554810
I am the only user, smartass. I am trying to run the code on an ancient piece of shit that would take ages to compile on.
Anonymous No.105555128
>>105554712
>You should't have to worry about any of this for several years, hopefully never.
big relief
Anonymous No.105555432
>>105554712
Why did Rust come up with all this nonsense again, if not to spite C++? And why wasn't getting rid of C's malloc nonsense sufficient either?
Anonymous No.105555539 >>105556576
Opions on java EclipseStore? I saw this in the last 24 hours.

https://youtu.be/o_7CrOVVeoY?feature=shared
Anonymous No.105555625
>>105554601
compile against the most ancient version of the lib that still works.
Anonymous No.105555734
>>105554578
thanks anon, I appreciate it. I just feel kinda fraudulent doing this. I've advanced way faster in my projects with copilot compared to doing this solo and maybe I'm learning via osmosis (i mean I would've just googled copy and pasted the code) but I'm mostly looking if there's any other books for "best practices" and what the hell am i actually typing. I could ask copilot but I don't want to burn through my free code stuff or ai credits or whatever it is.
Anonymous No.105555939 >>105556328
so dumb java stopped including javafx in the standard sdk because I'm always jumping through hoops to get it to work
Anonymous No.105556328
>>105555939
java swing, sar
Anonymous No.105556576
>>105555539
>18 seconds in
>insufferable accent
Dropped.
Anonymous No.105556781 >>105556798 >>105560178
added image decoding through ffmpeg pipe for my image viewer to support more formats
going to do the same for my music player
Anonymous No.105556798 >>105556849
>>105556781
where the fuck are her nipples
Anonymous No.105556843
>>105545846
Thanks anon. Used Kate.
Anonymous No.105556849
>>105556798
ate them
Anonymous No.105556850
>import
>include
>use
ngmi
Anonymous No.105557087 >>105557141
I'm using a JSON library in C (yajl) to parse some GLTF (not important), and the library operates by using a callback every time it processes a token.
static int gltf_double(void *userdata, double val)
{
// ...
return 1;
}

static const yajl_callbacks gltf_callbacks = {
.yajl_null = gltf_null,
.yajl_boolean = gltf_boolean,
.yajl_integer = gltf_integer,
.yajl_double = gltf_double,
.yajl_number = NULL,
.yajl_string = gltf_string,
.yajl_start_map = gltf_start_map,
.yajl_map_key = gltf_map_key,
.yajl_end_map = gltf_end_map,
.yajl_start_array = gltf_start_array,
.yajl_end_array = gltf_end_array,
};

yajl_handle yajl = yajl_alloc(&gltf_callbacks, NULL, &state);

I was starting to write a somewhat bloated state machine to handle all of the keys I was expecting, but then it occurred to me, why don't I just fuck with the callback table itself instead?
If I encounter the "scene" key, I change the integer callback to a function that writes the value somewhere (and the others to error out) then restore the table to what it was before.
Is there anything wrong with doing it this way? Is this how people actually use these kinds of libraries?
Anonymous No.105557141 >>105557265
>>105557087
this api is terrible
it should provide the path to the current value as a callback parameter
use another library or write your own json parser
Anonymous No.105557265 >>105560056
>>105557141
I was originally looking at libraries like json-c, where it basically builds the entire tree in memory, which you then traverse. It seemed a bit excessive; I don't need to create a bunch of hashtables, since I'm working with a standardized format.
>the current value
I mean, that's what I was originally going to do, but once I started writing out
enum gltf_state {
GLTF_START,
GLTF_TOP_SCENE,
GLTF_TOP_SCENES,
GLTF_TOP_NODES,
GLTF_TOP_MESHES,
GLTF_TOP_BUFFERS,
GLTF_TOP_BUFFER_VIEWS,
GLTF_TOP_ACCESSORS,
GLTF_TOP_ASSET,
GLTF_SCENE_NAME,
GLTF_SCENE_NODE,
GLTF_SCENE_EXTRAS,
// ...
};
I realised that god damn there are going to be a lot of states, and the functions are probably going to be fairly messy. I guess I bunch of them can be cut down by just storing the key, but that just adds a bunch of extra string comparisons everywhere. That's when I got the idea of just changing the function pointers.
Anonymous No.105557289
>>105554601
set rpath up for local shared object loading, bundle library
same way windows programs do it
Anonymous No.105557544
Any of you schizos worked with Qt before?
Anonymous No.105557660 >>105557693
>>105530074 (OP)
I added Text To Speech for 4chan threads

Here is a reading
https://voca.ro/16czryMpnexI

of the thread
https://ayasequart.org/g/thread/96520802

in op_and_op_replies mode. DFS, BFS, and OP only modes are available too.
Anonymous No.105557685
>>105530074 (OP)
Nothing. Just lamenting the loss of /prog/.
Anonymous No.105557693
>>105557660
The code lives here, btw
https://github.com/sky-cake/ayase-quart
Anonymous No.105557719
>>105555052
Maybe fix your project to be better than bloated tranny slop, and it will work fine on your obsolete hardware like it was built yesterday.
Anonymous No.105558475 >>105558780
mmap-sama, are you still here?
https://www.reddit.com/r/cpp/comments/1l89aft/when_is_mmap_faster_than_fread/
Sorry for posting r*ddit, but they say that mmap is almost always LE BAD for both performance and memory consumption (somehow) and you should use either conventional I/O instead, or io_uring or ring buffers. Is this true? Or they got it all wrong? There are too many different opinions that completely cancel each other out I can't figure it out.
Anonymous No.105558555
cleared last outstanding bug by deciding that it's WONTFIX
Anonymous No.105558780 >>105558860 >>105558927
>>105558475
io_uring requires fixed buffers and userspace caching. Where you will put those buffers into? A mmap?
Normal fread is always garbage due to not being OS level API.
Conventional I/O is same as io_uring, but now entirely synchronous with syscall overhead, double that if you need non-sequential access.
Anonymous No.105558860 >>105558869 >>105558873
>>105558780
>Normal fread is always garbage due to not being OS level API
But it provides automatic buffering over ReadFile/read() syscall. Or do I need to do manual buffering myself over read()?
Anonymous No.105558869
>>105558860
Why would you want extra copying?
Anonymous No.105558873
>>105558860
>But it provides automatic buffering over ReadFile/read() syscall
And how does its data end up in your buffer? Oh, that's right - another copy.

Sounds kinda retarded now, doesn't it.
Anonymous No.105558915
I'm trying to learn Qt.
Am I approaching this in the right way?
Assuming I want the text inside the dialogue box to be maintained.

Also what's the best way to learn. I've watched voidrealm's videos but I don't feel like shelling out money for a proper udemy course. I'm just trying to piece together things from the docs and example projects rn
Anonymous No.105558927 >>105558940 >>105559018
>>105558780
Another hot take

>mmap can potentially trash the virtual page cache depending on the access pattern. I usually find pread (which is thread safe) more robust and reliable than mapping the file, also you can open the file with O_DIRECT to bypass cache if you will only read data once.
Anonymous No.105558940 >>105558978 >>105559034
>>105558927
>mmap can potentially trash the virtual page cache depending on the access pattern
madvise(MADV_HUGEPAGE)
Anonymous No.105558978 >>105558990 >>105559062
>>105558940
Noted, thanks. What about the unpredictable page faults that they scream about? Does madvise solve this too?
Anonymous No.105558990 >>105559034
>>105558978
madvise(MADV_POPULATE_READ)
Anonymous No.105559018
>>105558927
Oh no, not my heckin virtual page cache when a cold page fault takes less time than reading from file directly off the disk...
Anonymous No.105559034 >>105559064
>>105558940
>>105558990
Neither of these are useful for file I/O.
Anonymous No.105559062
>>105558978
>unpredictable
Why would anyone need to worry about this even if it were true? (it isn't)
Anonymous No.105559064 >>105559073
>>105559034
Wrong.
Anonymous No.105559073 >>105559082
>>105559064
Excellent argument, Dunning Kruger, you changed my objective mind.
Anonymous No.105559082 >>105559096
>>105559073
Why would I need to change the mind of an idiot?
Anonymous No.105559096 >>105564452
>>105559082
Because that would change you from an idiot to a passable midwit. You're a retarded hugepagetranny, so you won't understand anyway, but here it does: huge pages don't share page cache with normal pages, you're wasting RAM and reading big blocks, virtual page cache is a non-issue and if you weren't a retarded nocodeshitting tranny, you'd know this.
Anonymous No.105559108
I think you are what they call "BTFOed".
Anonymous No.105559125
>huge pages don't share page cache with normal pages
Yes they do.
Anonymous No.105559131
>visual studio 2022
>try to call method
>typing . (dot) autocomplets the fucking suggestion.

How do I turn this cunt off?
Anonymous No.105559888
hugep***s
Anonymous No.105560056 >>105560292
>>105557265
I mean on the one hand yes it is excessive because you're right GLTF just ends up in a struct of arrays, but so is the effort you need to put in to pretend that you don't need hash tables to parse JSON. And what is the point of that effort anyways? GLTF is a fucking terrible scene format for runtime anyways so you need another layer after GLTF to put your data in anyways. I get that abstractions have a cost but unless you know EXACTLY what your data is going to be and it wont change you need some flexability.
Anonymous No.105560178
>>105556781
Nice bulge faggot
Anonymous No.105560292 >>105560650 >>105560708
>>105560056
>you need another layer after GLTF to put your data in anyways
What? Is this about how your in-memory representation of something isn't exactly the same as how it's serialized?
That's not a realistic concern at all.
All of the raw vertex data is storable in a GPU-ready format, so that seems good enough for my admittedly simple uses.

>but so is the effort you need to put in to pretend that you don't need hash tables to parse JSON
General purpose handling of JSON, sure. But I'm not trying to keep it general purpose. glTF is rigid enough that I don't need it, with the "flexibility" being if something is present at all, or just JSON being in different orders.
But man, trying to do it this way with a callback-based library is turning out to be a fucking mess, which yeah, isn't worth the effort. It's just turning into a fuckhuge state machine where control flow is jumping all over the place.

I'm going to look at some other libraries, and if I can't find what I'm looking for, just use json-c or whatever and build the tree.
Anonymous No.105560650
>>105560292
in my own json parser it’s mostly stateless and the only state is the reading position
for formats where the path to the value i want to extract is known i just do something like char *c = json_path_get_value(json, “path.to.value”);
for (char *v = json_array_first_value(c); v; v = json_array_next_value(v))
dothing(v);
Anonymous No.105560708
>>105560292
I like jsmn, but you'll end up needing to write your own tree traversal for it. Frankly, you should just use json-c, since it's mature, easy, and I guarantee your json parser isn't going to be your bottleneck. If it is, you need a redesign.
Anonymous No.105560804
Any hare enjoyers ITT?
Anonymous No.105561397 >>105562309
>have a Rust project
>one file contains a pair of complex decoder functions
>these handle the most common cases themselves
>also have ten large sub-functions that handle lots of weird edge-cases
>put the sub-functions into a separate file
>1.6x speedup
Anonymous No.105562309
>>105561397
>>105546368
Anonymous No.105563841
>LL parsers are LE BAD! b-because it just is goy! invest in LR instead
Just design your grammar correctly holy shit
Anonymous No.105564075 >>105564162
>>105530074 (OP)
Is there anything in Jetbrains settings where I can keep the fucking completion hints and stop the fucking right box from showing?
Anonymous No.105564162 >>105564195
>>105564075
why would you want just the first one, though? like, when do you need to type just a method name but without the parameters? not criticizing, just curious

not a Jetbrains user but seems tidy and ergonomic to have a list of function names and then all their overloads on a secondary list. i'd use this mode in Eclipse for Java
Anonymous No.105564168
>>105534880
>malloc
oh no
Anonymous No.105564195
>>105564162
Honestly it's just very distracting for me. If I know what method I want then the overloads on the side just waste space and attention.
Anonymous No.105564452
>>105559096
Yikes.
Anonymous No.105564683 >>105564829 >>105565823 >>105565915 >>105566397
So I made a first fit allocator to use alongside my arena allocator, for when arena allocation is not an option.
It's not a pure first fit allocator because it defaults to mmap for big allocations, it's really a very simple general purpose allocator.
The qeuestion is what do I call it? (the function prefix) I don't want to override malloc and it has a slightly different interface anyway.
Anonymous No.105564829 >>105564910
>>105564683
pack
Anonymous No.105564910 >>105564952
>>105564829
>pack
what? but why? this doesn't carry the idea that it's "general purpose" or that it's fine for any lifetime
I'm thinking that "global_" could be apporpriate
Anonymous No.105564952 >>105564976
>>105564910
malloc isn't general purpose either. It has the very specific purpose of providing individual lifetimes, which is a concept the hardware knows nothing about and has to be emulated in software.
Anonymous No.105564976 >>105565042
>>105564952
I know, there is no such thing and mine isn't either, that's why I quoted it. It is also made for sporadic individual lifetimes, it's not made for intensive use.
Anonymous No.105565042 >>105565106
>>105564976
Why not "hospital"? Lots of individual lifetimes in there.
Anonymous No.105565106
>>105565042
Or maybe "hood"? Lots of trash around that belongs to someone else.
Anonymous No.105565369
Zig uses the diminutive gpa for GeneralPurposeAllocator, this seems alright.
https://zig.guide/standard-library/allocators/
Anonymous No.105565823 >>105566898
>>105564683
>it's really a very simple general purpose allocator.
gpa

maybe aa or aua (augmented allocator)
Anonymous No.105565915
>>105564683
FirstFitAllocate
Anonymous No.105566397 >>105566898
>>105564683
alloc
Anonymous No.105566898 >>105566992
>>105566397
>alloc_free()
>>105565823
yep, that's what I chose
Anonymous No.105566992 >>105567112
>>105566898
unalloc
Anonymous No.105567112
>>105566992
dealloc
Anonymous No.105567119
Working on a cross-platform 4chan app
Anonymous No.105567602 >>105567736 >>105567778
So what complete retard came up with the idea of making malloc allocate memory via mmap if the requested size is over 128 KB?
>why is it retarded
Have you looked at the address malloc churns out? It's not page aligned. malloc wastes an additional page at the end because it INSISTS on adding its own state at the beginning of the allocation.

At what point will people realize that malloc was a mistake?
Anonymous No.105567736 >>105567760 >>105568520
>>105567602
>it INSISTS on adding its own state at the beginning of the allocation.
How else is it supposed to know the size of an allocation upon reallocating and freeing, genius?
Anonymous No.105567760 >>105567865 >>105568538
>>105567736
Not my problem.
Anonymous No.105567778 >>105567817
>>105567602
Large allocations are page aligned automatically.
Small allocations are within a pool that is page aligned.

Please don't get so angry.
Anonymous No.105567817 >>105567922
>>105567778
Are you paid to spread misinformation?
https://godbolt.org/z/qc3K59xPa

4K: 0x2c6ec2a0
2MB: 0x718b1abff010
16MB: 0x718b19bfe010
Anonymous No.105567865 >>105567871
>>105567760
retard
Anonymous No.105567871 >>105568107
>>105567865
You sound like a malloc user, which is the worst insult I can think of.
Anonymous No.105567922 >>105567951
>>105567817
CE is not using mmap, and please, like I said earlier, this is a vibe thread and you're killing it with your aggression.
Anonymous No.105567951
>>105567922
No one cares about your CE. Or your vibes, for that matter. I hope they all get killed.
Anonymous No.105568107 >>105568362
>>105567871
you complain about what malloc does but you didn't present a better solution
as usual, useless post, waste of time
Anonymous No.105568122
here we go
Anonymous No.105568362 >>105568483 >>105568520
>>105568107
Are you stupid?
Anonymous No.105568483
>>105568362
Has to.
He's defending malloc, after all.
Anonymous No.105568520 >>105568538
>>105568362
>>105567736
Anonymous No.105568538 >>105568702 >>105568915
>>105568520
>>105567760
Just don't use malloc. It's easy.
Anonymous No.105568573
>why yes I will take advice from a place full of proven retards instead of relying on industry standards developed over half a century
Anonymous No.105568596
>appeal to authority
Wow, you're retarded.
Anonymous No.105568676 >>105568693
New Rust book dropped: "Rust for Sȯyjaks"
/g/ has no excuses now
Anonymous No.105568693
>>105568676
>>105531239
Anonymous No.105568697
Are there middleman services that put your app up on google play so that google doesn't dox you to everyone?
Anonymous No.105568702 >>105568709 >>105568711
>>105568538
That's not what you said. You said that it was stupid for malloc to put metadata. So where is it supposed to put it and how does it looks up the metadata upon freeing?
Anonymous No.105568709
>>105568702
*to put the metadata before the allocation
Anonymous No.105568711 >>105568738
>>105568702
>That's not what you said.
>At what point will people realize that malloc was a mistake?
Anonymous No.105568738 >>105568746
>>105568711
You are avoiding to respond to the question again and changes the subject. I accept your concession.

you're not a schizo, you're a faggot
Anonymous No.105568746 >>105568764
>>105568738
You have your answer. malloc is hot garbage, and its users are retards. That includes you, so your judgement is so invalid on top of everything else it's actually makes me feel pity for you.
Anonymous No.105568764 >>105568784
>>105568746
No I'm not using malloc,
>your judgement is so invalid on top of everything
what judgement schizo? All I did was ask a question that you never answer.

take your meds and SHUT THE FUCK UP fucking little bitch
Anonymous No.105568784 >>105568862
>>105568764
>No I'm not using malloc
Why else would you defend it? Retard.

>what judgement
>schizo
Yeah, like that. Who cares what a retard like you has to say.
Anonymous No.105568862 >>105568882
>>105568784
>Why else would you defend it? Retard.
I was pointing out that what you said was idiotic, you dumb motherfucker.
>Who cares what a retard like you has to say.
Apparently you do since you reply to me.
Anonymous No.105568882 >>105568911
>>105568862
How would you know what I said, considering you didn't read the post to the end? Retard.

>Apparently you do since you reply to me.
I'll take any chance to publicly humiliate and insult you.

Retard.
Anonymous No.105568911 >>105568926
>>105568882
attention whore
Anonymous No.105568915 >>105568926
>>105568538
Ok, I will use _mm_malloc instead.
Anonymous No.105568926 >>105568933 >>105568935
>>105568911
Retard.

>>105568915
Retard.
Anonymous No.105568933 >>105568959 >>105569069
>>105568926
If it's good enough for Intel, it's good enough for me.
Anonymous No.105568935 >>105569069
>>105568926
>can't reply to a question because too retarded
>still answers because he likes attention
Anonymous No.105568959
>>105568933
no the anon whose vocabulary mostly consists of the word "retard" (some kind of projection) knows better than intel
Anonymous No.105569069 >>105569153
>>105568935
>so retarded it doesn't understand an answer if it's giving to it
>still replies because it's just so retarded

Retard.

>>105568933
Double retard.
Anonymous No.105569153 >>105569202
>>105569069
Yup, that's optimal allocation code, I use it all the time.
Anonymous No.105569202 >>105569229
>>105569153
Triple retard.
Anonymous No.105569229 >>105569250
>>105569202
Seethe, nocoder.
Anonymous No.105569250 >>105569273
>>105569229
>retard nocoder which is a retard with invalid opinions calls others nocoders
Classic.
Anonymous No.105569273 >>105569291
>>105569250
Post your allocator, you have 5 minutes.
Anonymous No.105569291
>>105569273
Retard.
Anonymous No.105569316
>registry dumber is high enough to look down on others
>not high enough to avoid his flight control system from telling him to retard the throttle
Anonymous No.105569328
You called?
Anonymous No.105569387
>.015s
Not bad for a toy that doesn't need to exist in the real world.
Anonymous No.105569399
I can see why other people think you're a retard.
Anonymous No.105569780 >>105570051
Imagine trying to prove how good you are at something by producing the absolutely most useless showcase for it
Anonymous No.105569813 >>105569869 >>105570051
How would a nocodeshitter like you know? You've never done anything in your life.
Anonymous No.105569869 >>105570051
>>105569813
how many people have used your registry dumper?
Anonymous No.105569882 >>105570051
>attempt to change the topic
Denied.
Anonymous No.105569914
ego shattered by the simplest of questions
Anonymous No.105569925
Yeah, you can tell "nocodeshitter" really hit a nerve.
Anonymous No.105569956
ad hominem don't hit anything, it's just noise
if anything, it proves complete lack of counter-arguments
Anonymous No.105569960 >>105570008
Is that why you were desperate to change the topic? LOL
Anonymous No.105569977
Anonymous No.105569995
>again desperate attempt to change the topic
The fun never ends.

For me.
Anonymous No.105570008 >>105570019
>>105569960
topic was proving proficiency with a useless implementation
insulting posters is not a topic
failing to answer an on-topic question by deflection or ad hominem is a form of steering away from the topic
Anonymous No.105570019 >>105570051
>>105570008
I know you're retarded and don't, but I want to know what you'll say: do you know what projection is and how it works?
Anonymous No.105570028
No, Ivan. *The* topic was that you being a nocodeshitter renders you utterly incapable of such judgement in the first place, and there is nothing you can do about it.

So simple.
Anonymous No.105570051 >>105570059
>>105570019
yeah, like the reply >>105569813 to post >>105569780
or reply >>105569882 to post >>105569869

those are some examples of projection
Anonymous No.105570056 >>105570143
>Ivan doesn't understand it's not projection if it's true
Anonymous No.105570059
>>105570051
If you know this, why are you responding then, moron.
Anonymous No.105570070
>implying he does
Anonymous No.105570143
>>105570056
people projecting always think with great conviction their projections are true - that's one of the defining points of it
so you only further confirm and validate it was, in fact, projection
Anonymous No.105570164 >>105570416
Still waiting for your implementation to prove you're not a nocodeshitter. 500 MiB, 10 seconds. Go.
Anonymous No.105570268
Please do not engage with the homeless schizos.
Anonymous No.105570279
When will you LEARN?
Anonymous No.105570416
>>105570164
you have made the mistake of thinking anyone cares about you throwing insults at others, especially for not engaging in writing such a useless program (useless because it has no users or usecases - feel free to prove otherwise). you're like the kid who tried to be the school bully but no one bought it and instead all made fun of him

if you took time to reflect how these threads have been going for the last months, you'd realize how it has backfired on you - no one ever engages in your "challenge", no one cares about being called a "nocodeshitter" or whatever by you, while you yourself have earned the label of "regdump schizo"
at this point the only kinds of engagement you can count for is more trolling and jabs at your futile workpiece
no one will really stop you from your endless insult replies, just be aware that you're not making a dent on anyone, no matter how hard you seethe at everyone
Anonymous No.105570437 >>105570515 >>105570777
Sorry, my currency of choice isn't empty words - only code. Which is why nocodeshitters like you are worthless to me.
>didn't even read two sentences of your post
Anonymous No.105570515
>>105570437
now post that again without crying
Anonymous No.105570524 >>105570546
See, Ivan, now THAT is projection.
Anonymous No.105570546
>>105570524
Your schizo behaviour of stopping replying to posts doesn't show that.
Anonymous No.105570550
Why change what works?
Anonymous No.105570777 >>105570823
>>105570437
So where/s the code? Post direct link to the repo.
Anonymous No.105570823 >>105570846
>>105570777
What, and have some nocodeshitter steal it without having to put any work into it? I have already provided enough proof of the existence of the code and its results than /dpt/s autistic wafflers have any right to.
Anonymous No.105570846
>>105570823
I see that you're severely mentally ill just from that snippet, don't post anything else, ever again, schizo.
Anonymous No.105570864
>another incompetent nocodeshitter with another strong opinion
Hold the presses.
Anonymous No.105570929
Good afternoon, Ada chads.
Reminder that basedlangs don't have a LOLITA.
Anonymous No.105570942
Good.