[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 / qa] [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]


Old thread >>102005977
What are you working on, /g/?
>>
File: 1715166766819879.jpg (380 KB, 1157x1618)
380 KB
380 KB JPG
>>102019737
/dpt/ is a place of love, understanding, and inclusion. Let's have a nice thread, everyone. :-)
>>
The moment your code calls malloc/new you have lost. The only reasonable level of abstraction is the boundary to kernelspace.
>>
>>102019761
Shut up, pedophile.
>>
This thread is dead
Gen Z insects have killed all forms of online discussion
>>
>>102019795
You deserve nothing better.
>>
>>102019795
We can still talk about programming.
What are you up to anon?
I've been studying quite a bit.
>>
>>102019841
Everything relevant has been said already: >>102019781
>>
>>102019841
Embedded systems programming.
I wasted today on debugging a system hang/crash caused by removing an array from a completely different translation unit. Strangest chain reactions of seemingly unrelated problems I've had in the last year.
>>
File: 1711301912105751.png (280 KB, 1280x960)
280 KB
280 KB PNG
c++ is life, c++ is love
>>
>>102019889
At least it wasn't a retarded glitch.
The other day I was half asleep and had my debug stuff being drawn before the background.
As soon as I woke up the next day, I was like, oh well that was retarded.
>>
C++ has always been a catastrophe:
https://harmful.cat-v.org/software/c++/coders-at-work
>>
>still no work from the "my registry dumper finishes in 2 seconds" guy
Guess it wasn't complete after all.
>>
>>102020054
I haven't been following all that.
Is... is there a particular reason a registry dumper needs to be SANIC FAST?
>>
>>102020097
thats the only program he knows how to write
>>
File: 1716263291691834.png (1014 KB, 1396x1389)
1014 KB
1014 KB PNG
>another literal who opinionated blog article
don't care, still using C++ on critical embedded devices
>>
>>102020119
I wasn't sure what to expect, but I've been liking it so far.
>>
>>102019795
You can, you know, ignore the obvious bait instead of turning the thread into the shit-flinging monkey fiesta? It's not reddit, so you don't have to fight for upbotes or karma.
>>
File: 1713316146953264.png (181 KB, 321x339)
181 KB
181 KB PNG
>>102020134
that article is just opinion
>C++ is just an abomination. Everything is wrong with it in every way.
this for 5 paragraphs, whatever I guess
> It does a lot of things half well and it’s just a garbage heap of ideas that are mutually exclusive. Everybody I know, whether it’s personal or corporate, selects a subset and these subsets are different.
so far only valid criticism, I do this myself. But since C++17, the language naturally guides you into good practices
>more paragraphs from C boomers complaining about C++98
unironically a skill issue, and only because they wrote complex software with no prior experience in C++
I guarantee if they tried again knowing what they did they would have no complaints about C++
I'm blessed to grow up in a C++ only household, and I skipped C right to assembly for my low level education.
Can't imagine spending 20 years writing C, get handed a C++98 compiler and be expected to write good software
>>
>>102020097
When I started out with the program the goal was 90 seconds, which was about the time I had after boot to find out what triggered the ridiculous amounts of file I/O coming from the registry (it's driver database-related stuff). Then autism and the desire to remove even more telemetry took over, and now it's 7 seconds - and if there's someone who actually manages to beat those times, then I damn well want to know how they do it, because I probably know more about the registry kernel interfaces than the original developers.
>>
>>102019795
here was especially bad due to homework questions (which we don't even get anymore), maid schizo, xolatile schizo, and the other russian/eastern yuro schizo always blogging about avx2 and his dumper. gen z part doesn't help either
>>
>>102020210
>words words words
Do me a favor and trace malloc/realloc/free/memcpy calls in your average C++ program, will you? Images say more than a thousand words, after all.
>>
>>102020242
>russian/eastern yuro schizo
Putin is a tremendous faggot because he doesn't nuke Europe. Hope that eliminates that particular rumor.
>>
>>102020256
>irrational fear due to burning hand one time
Off the top of my head in the past month I used mmap and posix_memalign like once for a embedded Linux device. That's literally it.
If in the 1% case I need malloc instead of a static array it's very easy to create a RAII wrapper
Again, all the fear of C++ is legacy code written by C boomers
The code I write doesn't have this issue
>>
File: ntcreatefile.png (23 KB, 1038x724)
23 KB
23 KB PNG
>>102020415
>irrational fear due to burning hand one time
>one time
Wrong. It happens all the fucking time, and you'd know that if you just traced your fucking code like I've been saying for the last seven months. Textbook self-imposed immaturity.

>posix_memalign
Why? mmap already gives you page-aligned addresses.

>The code I write doesn't have this issue
Trace.
Your.
Fucking.
Code.
You.
Child.
>>
>>102020459
maybe this is a generational gap or something but you are starting to make no sense
we have tools to track allocations and they are necessary
in any complex software there will always be malloc
I'm so confused anon
>>
>>102020523
>we have tools to track allocations
When was the last time you used them?

>and they are necessary
Wrong again. Most of the time they're merely convenient, like when you need data of variable length for a particular task, only to discard it at the end anyway.
>what's wrong with that
The locks, the internal bookkeeping, the fact that for very malloc there needs to be a symmetrical free, that realloc is highly likely to trigger a relocation and a copy, and that you have absolutely no control over where your allocation will end up.

>in any complex software there will always be malloc
Wrong again. In fact it's so wrong I'll propose that software becomes complex BECAUSE of malloc.
>>
File: 1699033081450301.png (205 KB, 400x400)
205 KB
205 KB PNG
>>102020641
>When was the last time you used them?
only when I feel it takes a bit longer to run than usual
>Wrong again. Most of the time they're merely convenient, like when you need data of variable length for a particular task, only to discard it at the end anyway.
that's why a static array is desired 99% of the time
>The locks, the internal bookkeeping, the fact that for very malloc there needs to be a symmetrical free, that realloc is highly likely to trigger a relocation and a copy, and that you have absolutely no control over where your allocation will end up.
>Wrong again. In fact it's so wrong I'll propose that software becomes complex BECAUSE of malloc.
you can't demand every piece of software be written with embedded rigor
I try to minimize dynamic allocation, not avoid it
>>
I only write in OOP GC JIT bloatmaxx languages.
>>
>>102020711
>only when I feel it takes a bit longer to run than usual
So personal preference, not on objective reality. Honestly I can already stop here; you've already admitted to being irrational.

>that's why a static array is desired 99% of the time
If you're on a system with virtual address translation (and if you're on Linux you most likely are): WRONG AGAIN. Static arrays are static, they can't grow. With mmap you can reserve huge ranges of virtual address space that only have memory committed to them if you need them, and with madvise you can decommit them again. Even better: you can directly reserve large/huge pages that consume much fewer TLB entries on access.

>you can't demand every piece of software be written with embedded rigor
I sure can. Every cycle a program wastes on something that isn't strictly required on a task the user wants is proof of the programmer's failure.
>>
>>102020830
>I sure can. Every cycle a program wastes on something that isn't strictly required on a task the user wants is proof of the programmer's failure.
I kneel
>With mmap you can reserve huge ranges of virtual address space that only have memory committed to them if you need them
I didn't know mmap can be used to reserve virtual space, I only used it to map files
you are a wise sage anon and I thank you for teaching me
>madvice
Never heard of it and reading the man right now, where did you learn all this anon?
>So personal preference, not on objective reality. Honestly I can already stop here; you've already admitted to being irrational.
look I just like C++ and I still like it, but what you shared with me is really interesting and I will play around and see how I can utilize it
>>
>>102019781
>New

Nigga what how do you create an object??
>>
>>102020830
>>102020888
Ok I'm reading thought and if I understand correctly I can use MAP_ANONYMOUS, and like you mention MAP_HUGETLB to reserve larger pages, and for improved performance in embedded devices MAP_UNINITIALIZED
Anon that is really cool and I can already see my fad of the month
>>
>>102020991
That schizo isn't someone to look up to.
Using anonymous mmaps would only really be appropriate for buffers that are expected to be fairly large, and doesn't help at all with suballocation; not everything can be jammed into a static array.
It's far less of an issue these days, but on 32bit, you couldn't carve out huge areas of your address space and just not use it.tpyp
>>
>>102020888
>I didn't know mmap can be used to reserve virtual space, I only used it to map files
What did you think MAP_PRIVATE and MAP_ANONYMOUS are for?
>you are a wise sage
You're making me feel uncomfortable.

>where did you learn all this anon?
A decade or so ago I had worked on a Perl program that was taking 70 minutes to generate a CSV file. Turns out that appending strings caused the language to constantly reallocate and copy data to and fro. Back in the day I fixed the issue by appending field values into a line variable first before appending the line variable into the file buffer, which cut away 58 minutes of runtime.
>these days I'd recommend Convert::Scalar, but back in the day I wasn't aware of the package's existence

After that I traced malloc/realloc/free on VLC and thunderbird and was shocked by the allocation patterns. I then read the source code for glibc's malloc, learned about the syscalls, and have been using them ever since, with the only exception being the first multithreaded version of regger (which took 16 minutes before I got rid of malloc/realloc/free again).
>>
>>102020968
Define "creating an object".

>>102021037
>and doesn't help at all with suballocation
You can have multiple arenas at the same time. In fact that's how realloc works as well:
>new buffer size doesn't fit into the old arena
>allocate new arena
>copy data from old arena into new arena
>hope that the allocate knows what it's doing with the old arena, that is, either keep it around or return it to the kernel

>That schizo isn't someone to look up to
That's because your jealously is visible from the ISS.

>It's far less of an issue these days
Wrong. It's not just "less of an issue", it's the biggest advantage 64 bit CPUs with their 47-bit address space have - the ability to reserve huge swaths of virtual address space.
>>
File: ahegao keycaps.jpg (184 KB, 1475x865)
184 KB
184 KB JPG
my time is worth far more than CPU time. I'll use whatever programming language lets me create a viable product in as short a time as possible.
>>
>>102021118
So how long are you able to hold onto a job on average before you're exposed? Or do you just work with retards?
>>
>>102021037
I look up to whoever I want
I trust that anon because the CPU and man pages don't lie, and he in his free time just gave me a decade worth of experience condensed into a /g/ thread
what advice do you have?
>>102021118
I'm pretty sure there is a 2014 talk by Mike Acton where he casually complains about Word taking 30s to start
Nothing wrong with a get it working dirty prototype, but I value my time and my end users time
>>
>>102021118
you will do no such thibg
>>
>>102020415
>Irrational fear due to burned hand
Why did his hand get burned, then, if his fear is totally irrational?
Why can't you argue in support of C++ without making such a basic logic error?
>>
>>102020991
Oh, one thing:
Large/huge page support is dumb on most systems because kernel devs are stupidly afraid of swapping to mass storage, so large/huge pages are exempt from paging - meaning that they'll always (or at least until it's changed) reside in memory. That means that you have to allocate them in advance, either by kernel boot line ("hugepagesz=2M hugepages=16"), so that the kernel can reserve them as early as possible, or dynamically before runtime:
# echo "16" > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
>>
>>102021147
I'm a full-stack web and Android dev. People use my sites and apps because they work fine.
>>
>>102021244
>I'm a full-stack web and Android dev
What's your stack? If it includes the phrase "*CGI" you're like a little kid to me.
>>
>>102021150
>Word
Word is primarily written in C++, so it just shows that using a "high performance" non-GC language doesn't guarantee making fast software, at all.
Besides, if you use bloated shitware like Word, it's on you.
>>
>>102021244
Java or kotlin?
>>
>>102020830
Based mmap enjoyer. Syscall chads stay winning.
>>
File: 1538657878566.jpg (96 KB, 747x477)
96 KB
96 KB JPG
>>102020968
You don't need to create objects if all you do is larp on an anonymous anime addicts forum all day.
>>
You mean like a nocodeshitter?
>>
>>102021041
>I traced malloc/realloc/free on VLC
anon you gave me a project idea for the coming months. I want to write a mpv clone without use of malloc/new to learn more about private anonymous maps. I drank too much coffer today so I'm hella excited for no reason and I won't fall asleep unless it's staying up late coding.
c++ is life, c++ is love, but I may try C17 today :)
>>
I have been writing a rather crude C wrapper for tk but found out this already exists in C++.

Should I continue or just use the C++ version?
>>
>>102021327
just bee yourself
>>
>>102021322
That's gonna be interesting. If I remember correctly VLC uses Qt, which is such a mess that it had one separate malloc call for each font object, of which there were a couple dozen. Chances are that you'll not have any GUI whatsoever, just a canvas onto which to render the video.
>>
>>102021327
I have my answer.
Unless someone can come up with a good reason to justify this.

>but it's just 2ms
NO, no more. computer performance has actually gone backward because someones has said it's just a couple ms too many times.
>>
>>102021525
>someones
Everyone.
>>
File: 1722219092850.png (94 KB, 973x795)
94 KB
94 KB PNG
>>102021525
good job retard
>>
File: literally_the_same.png (10 KB, 956x250)
10 KB
10 KB PNG
>>102021525
But it's literally the same code, like, literally.
>>
>>102021753
>>102021797
Then why is it literally slower to execute?
>>
File: IDA_is_your_friend.png (3 KB, 1028x40)
3 KB
3 KB PNG
>>102021817
My guess: because there's some interprocess communication fuckery going on, and the thread just happened to not run at that time. Printing to console is not a good metric to measure anyway.
>>
>>102021849
Oh yeah, I should mention that another anon had drunkenly mumbled something about NtDeviceIoControlFile being deprecated or whatever in the last thread. Well, this is what its supposed successor is doing.
>>
>>102020830
>Every cycle a program wastes on something that isn't strictly required on a task the user wants is proof of the programmer's failure.
Based
>>
I wasted a cycle 5 years ago and still haven't recovered financially, emotionally, temporally
>>
>>102022171
As you should.
>>
Just look at where we are today.

>oh it's just an extra cpu cycle
>oh it's just an extra cpu cycle
>oh it's just an extra cpu cycle
...

Now everything is a bloated mess with a near 1 second response time.
>>
has anyone here done +Ma's riddles? i feel actually stupid trying to get the intro riddle
i solved the cipher but i can't figure out how to complete the ciphertext alphabet which i'm 90% certain i need for the real password
it doesn't seem like either alphabet is using a keyword, and it's not reversed or backwards, i don't think it's any sort of K2M cipher, so i have actually no clue what to do
i could brute force it but with only 6 letters to place that's just depressing
>>
>>102021817
If you only checked it once it's probably just luck of the draw, but if you do it thousands of times and the cpp one is significantly slower, I'd suspect it's because of differences in the standard lib code that runs before and after main.
>>
>>102019761
Keep talking, pedophile.
>>
>>102019761
Go pedophile, go!
>>
>>102022940
it was actually way easier than i thought and just a capitalization issue i'm gonna fucking rope
>>
My wrapper was just adding bloat and convulsion so I wrote a tcl_to_header program so I can just embed a tcl script into my C program.
>>
Hello, kind sir
Is there any real benefit to using reliable UDP (eg. Enet..) in the current year rather than TCP_NDELAY ?
>>
>>102025108
I don't know how Enet works, but typically reliable udp schemes can still be faster than tcp for time sensitive data. Tcp requires acks for every packet and has various other overhead. With udp you can do various tricks like sending redundant packets to preemptively cover lost ones and so forth that ends up being better for tcp when you have to send a steady stream of a bunch of tiny packets very quickly. Also keep in mind that jewgle is trying to move most of their stuff from tcp to udp (quic), so they obviously think it's better even for normal web traffic.
>>
>>102019761
literally none of thosr things are true kys
the only true statement there is "/dpt/ is a place"
>>
>>102019737
Have any anons here developed useful libraries for your language or framework of choice?

I've been working on one for a while. I think once it's finished and production ready, I will actually publicly publish it.
I believe it might actually be pretty useful for some people and have decent use cases and I've put a lot of dedication into it thus far. What justifies a library having its own website? I have good documentation and plan on putting together some diagrams and flowcharts even, and this is a network oriented library so its rather technical and I feel like it might be warranted.

>inb4 link repo
My real name is on it don't wanna dox myself sry
>>
>>102020119
>>102020210
>he doesn't know what cat-v is
larper alert
>>
>>102020242
>thread used to be full of people talking about their passion projects
>nocoders bullied them out of the thread
>now the thread is inactive because nocoders don't code
Who could have foreseen such unpredictable consequences of making the thread hostile and totally unusable for the people who were actually coding?

You can say whatever you want about xolatile and the maid poster, but they were both actively working on interesting projects and the quality of the thread has declined in value in their absence. One post from either of them was worth more than a thousand posts by the retarded reddit and /pol/ tourists who just come here to cry about "tranime".
>>
File: over.gif (2.75 MB, 245x263)
2.75 MB
2.75 MB GIF
>>102019737
We are 77 posts into this thread and the only code posted has been hello world (that people argued about)
>>
File: 1717312599561181.png (10 KB, 1107x46)
10 KB
10 KB PNG
>>102026230
Here's some code. It's a bookmarklet for getting around paywalls on news sites.
>>
>>102026476
Ctrl-W is faster
>>
>>102025461
Yes Anon, the libraries that I primarily use in production at work now are things I started developing in my free time for fun. It makes work a lot more enjoyable.
>>
>>102019737
mostly shell scripting. It's rare that I ever need to write a c program to do something. The last thing was an libav program that sped up a video based on similar frames, I tried a few different ways of computing similarity but I didn't really care to understand how frame timing n pts and sheiit so I keep passing frames. oh well filtered i guess.
>>
>>102020830
You're braindead.
malloc is much more portable and give much more control than mmap, in any nontrivial program you will just end up reimplementing malloc it's very easy to do considering a trivial malloc is like 20 assembly instructions.
>>
I need to handle RAWMOUSE input on loonix now.
>>
>>102026915
if you think portability matters you might as well use rust
>>
>>102027245
But rust is only portable to computers that are already running C
>>
>>102026915
>malloc is much more portable
>give much more control than mmap,
WRONG. WRONG. DEAD WRONG.
You have no way to control virtual address reservations with malloc, which is a real problem for Windows (which most people use, even if you're coping and seething about it) since it drives up the commit charge. You can test that yourself:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main(void)
{
void*ptr = malloc(16 * 1024 * 1024 * 1024ULL);
printf("%p\n",ptr);
Sleep(15 * 1000);
free(ptr);
printf("Done\n");
Sleep(15 * 1000);
return 0;
}

And that's a real bummer because you may end up allocating memory you never use, or even worse, end up constantly reallocating and copying old data because your buffer was too small.

Verdict: you're the hopelessly braindead one here. Please stop talking about topics you have no clue about, alright?
>>
>>102027316
exactly
>>
>>102026230
Here's my opengl main() for x11, enjoy.

int main() {
Display* display = XOpenDisplay(NULL);

int glxAttribs[] = {
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
0
};

XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), glxAttribs);
Colormap colormap = XCreateColormap(display, RootWindow(display, visualInfo->screen), visualInfo->visual, AllocNone);

XSetWindowAttributes winAttribs;
winAttribs.colormap = colormap;
winAttribs.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask;

Window window = XCreateWindow(
display,
RootWindow(display, visualInfo->screen),
0, 0, FRAME_WIDTH, FRAME_HEIGHT,
0, // border
visualInfo->depth,
InputOutput,
visualInfo->visual,
CWColormap | CWEventMask,
&winAttribs
);

XMapWindow(display, window);

#if FULLSCREEN
Atom state = XInternAtom(display, "_NET_WM_STATE", true);
Atom fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
XChangeProperty(display, window, state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&fullscreen, 1);
#endif

XkbSetDetectableAutoRepeat(display, true, NULL);
XSync(display, false);

std::thread glThread = std::thread(runOpenGL, display, window, visualInfo);

XEvent event;
while (control.run) {
XNextEvent(display, &event);

switch (event.type) {
case Expose:
windowWidth = event.xexpose.width;
windowHeight = event.xexpose.height;
break;
case KeyPress:
control.keyDown(XLookupKeysym(&event.xkey, 0));
break;
case KeyRelease:
control.keyUp(XLookupKeysym(&event.xkey, 0));
break;
}
}

printf("SHUTTING DOWN...\n");

glThread.join();

XFree(visualInfo);
XDestroyWindow(display, window);
XFreeColormap(display, colormap);
XCloseDisplay(display);

return 0;
}
>>
>>102027383
wont work on windows
>>
how do I handle the return type of a main function if I'm writing a compiler for a language that just returns whatever gets evaluated for last? can I simply print to stdout whatever I'm returning and always return 0, or should I work with a tagged union?
>>
>>102027416
Lol correct.
>>
>>102027347
>portable
>windows
Fuck off retard. Portability has always meant to computers. I don't give a fuck about operating systems.
>>
>>102027383
Have you ever looked at how much shit is being stored in one of these Display blocks? They just place that shit on the heap without you asking. Xlib is a complete mess, but then again so is the entire X11 protocol.
>>
>>102027449
>Xlib is a complete mess
Sure but what else am I gonna use, wayland?
And there's literally nothing wrong with the heap.
>>
>>102027475
using the heap is bad on widows
>>
>>102027475
Why not use XCB at least?
>>
>>102027448
>Portability has always meant to computers
Thanks for conforming your braindeadness. And you can shove your portability where the sun doesn't shine, seeing as your portability is a complete catastrophe that leads to horrifically bad code across the board.
>>
>>102027504
I was just reading about that I didn't realize it was faster low level native I thought it was just a wrapper around xlib.
>>
>>102027475
>And there's literally nothing wrong with the heap.
It sure is, if I want to bundle all relevant data into one arena, but can't because the original devs are completely braindead. But since you faggots all have ADHD you never read my links, do you?

https://www.rfleury.com/p/untangling-lifetimes-the-arena-allocator
>For example, if I load a level in my game engine’s level editor, and for each entity that is spawned some number of mallocs occur, and for each entity I spawn while editing the level some more mallocs occur, then I want to unload that level and load a different one, then there is no “free all of the memory I allocated for this level” button. Each malloc must receive its symmetric free, and so I must iterate all of the entities and free each result that was returned to me from malloc.
>>
>>102027540
XCB is overall a major improvement over Xlib in my opinion, both in usability and performance, especially if you leverage its asynchronous nature. Plus it feels nicer to use.
>>
>>102027488
>>102027578
The heap is unavoidable so it's a moot point.
>>
>>102027536
Horrifically bad code that according to you
>most people use
You think people would use good code. Seems your definition of good doesn't include usefulness.
FAGGOT
>>
>>102027594
>The heap is unavoidable
True, if you're a certified mouthbreather or use libraries from certified mouthbreathers. Anyone with a brain will let the caller decide where to write important output data.
>>
File: part_of_the_problem.png (397 KB, 828x683)
397 KB
397 KB PNG
>>102027605
>most people use
Yeah, and we've been reaping the rewards for that ever since.

>your definition of good doesn't include usefulness
malloc is about as useful as a cocaine addiction. Easy to get into, but boy, do you end up pain for it through the nose and back.
>>
>>102027642
I have zero problems making sure all of my mallocs have a matching free.
>libraries from certified mouthbreathers
Like opengl?
>>
>>102027680
>Yeah, and we've been reaping the rewards for that ever since.
dropbox is a billion dollar company.
A database and some crawlers and running wc -l on links made a trillion dollar company.
If your goal is autistic tinkering inside a local minimum then you will never have any blue ideas.
>>
>>102027698
>I have zero problems making sure all of my mallocs have a matching free.
Even if that was true (which I'll assume for the sake of argument), and even if you don't end up writing into the beginning of the next block due to a buffer overflow (because malloc stores its own state right next to user data, which, by the way, is impossible with raw pages, as their state is over in kernel land), it's still slow as fuck and enforces reusability through the same retarded and slow interface - on both Linux and Windows: >>102020256

>Like opengl?
Not only OpenGL - Vulkan does the same garbage.
>>
>>102027731
>he has ADHD and didn't read the linked article
Why do you assume a simpler memory interface is "tinkering"?
>>
>>102027781
>Vulkan does the same garbage.
Gee I wonder why, maybe try loading several gigs worth of model and texture data onto the stack and let me know how it goes.
>>
>>102027839
>he is an ADHD kid who didn't even make it one fifth through the article

>When an individual allocation doesn’t work on the stack, for whatever reason, the author of the codebase in question is often taught that the only other option is to use “heap allocation”, which to most people means “use malloc”. So, instead of using the stack allocator, they will switch to the extremely generic heap allocator, often being unaware that these are not the only two choices.

Oh, and by the way: I'm not talking about textures and models. I'm talking about pAllocator: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateInstance.html

>HE DIDN'T READ THE
ARTICLE EITHER BECAUSE HE'S AN ADHD KID
>>
>>102027781
>buffer overflow
scare word for memory communist's
>>
>>102027781
>>Not only OpenGL - Vulkan does the same garbage.
lmao so you're so fucking scared of malloc that you'd lock yourself out of using the GPU
every single vulkan implementation's also entirely unique, along with how that maps to a kernel mode graphics driver
if i really wanted to i could drill down into a vulkan instance handle and pull out amdgpu drm handles and control the device IOMMU directly
and if i really really wanted to i could just use mmap on the device file and write commands to the command buffers directly
good fucking luck with something like that though

>>102027899
oh my god you're just complaining about the replaceable default allocator not even not being able to do arenas for the entire GPU
>>
>>102027899
It literally doesn't matter, you're not creating new vulkan instances every frame in your hot loop.
>>
>>102027933
not with that attitude lol
>>
>>102027922
Total brain death confirmed.

>>102027932
>ANOTHER ADHD KID THAT DIDN'T MAKE IT ONE FIFTH THROUGH THE ARTICLE

>>102027933
Sorry, but you don't get to decide that.
>>
>>102027976
eat a potato, technologically
>>
>>102026001
The thread moves is cycles. The thread is inactive. People start talking about projects. It becomes active. Activity attracts trolls and shitposters. Trolls and shitposters ruin the thread for the people participating in it. Those people stop participating. The trolls no longer have anyone to troll so they move on. The thread becomes inactive. Repeat.

Each cycle takes about three years.
>>
>>102028016
You don't get to decide that either.
>>
>>102027976
did you?
for that matter, have you even used vulkan? pallocator is a pointer to an entirely user defined set of host memory management functions
you are free to return whatever memory you wish
not that that matters, oh no a global handle called malloc once
there's a far greater sin, much much more costly, your little arena nonsense works on the GPU you know
if you actually cared you would be using your drivers directly and manually managing your GPU's page tables, manually dispatching SDMA requests directly to the hardware queues
why don't you?
>>
>>102028169
This thread uses to have a friendly Vulkan expert called xolatile, but retards chased him away.
>>
>>102028169
>you are free to return whatever memory you wish
That's not the problem. The problem is the freeing part in an object that only knows ordered lifetimes, like a stack. And due to the reallocation part it's not like you can simply forget about these pointers either.

>a global handle called malloc once
>he's never heard of pfnReallocation

>if you actually cared
I'll just stop reading there, I don't need projecting nonsense from you.
>>
>>102025461
I wish. I have no useful projects or real problems to solve.
>>
>>102028282
>"It’s very common to have per-frame concepts in this scenario. For instance, you might be building a user interface every frame, or producing a batch of drawing commands. In such cases, it’s useful to have a lifetime that exists for the duration of a single frame."
I feel like that entire article basically boils down to this concept which is just a bad concept.
If you're allocating dynamic memory at all during runtime you are doing something wrong.
>>
>>102028426
It goes back to what I said:>>102027642
>Anyone with a brain will let the caller decide where to write important output data.
>>
>>102028468
No it doesn't, you're trying to avoid all mallocs because you want to allocate memory every frame.
Don't do that.
Do it at load time.
>>
>>102028494
>because you want to allocate memory every frame
Wrong. I have to *assume* I receive requests for allocations every frame.
>inb4 that doesn't happen
I just recently traced Factorio for Windows, a game that is considered to be well optimized. Wanna guess how many thousand calls to RtlAllocateHeap I registered?
>>
>>102028550
Yeah everyone does it, it's a terrible practice.
It's literally why garbage collection was invented.
>>
>>102028589
I was serious. You wanna guess?
Hint: I was running a fresh vanilla game, no mods, no nothing.
>>
>>102027429
Can't you make returning none integers from main an error?
>>
>>102021150
>I look up to whoever I want
he is retarded and lazy because he writes a lot of complicated code without benchmarking
>inb4 he posts the image of std::vector
it's natural for a beginner to write a lot of complicated code due to the belief of writing fast code, but the harsh reality is that performance is so fucked up, even after decades of experience you will still get it wrong (You thought that using 2x threads will give you 2x more performance? or hey you got 1.5x more performance from 2 threads, that must mean 8 threads will give 4x more performance, nope...), you need to have a PHD level understanding of how memory affects performance before you can make assumptions without doing a benchmark.
Anon is making a XY problem, he thinks malloc is slow (and of course all API's using malloc), but in reality malloc is pretty fast.
I copied the code from stackoverflow, https://stackoverflow.com/q/67943761.
https://godbolt.org/z/qo3zYxK43
first alloc took: 0.0041ms
second alloc took: 0.003
If you use a thread, the first alloc would take 10-20x longer
https://godbolt.org/z/M5dcEjYaE
first: 0.059322 milliseconds
second: 0.00344 milliseconds
But malloc is slow, relative to a push buffer or arena (a simple structure where you just move the pointer forward in a big array for allocation), so you could see a 100x speedup (3000 nanoseconds fast malloc vs 20~ nanoseconds) but you need to allocate that memory somewhere. Also 3000 ns is 0.000003 secs.
If you use static global buffer that still needs to gets malloced/mmaped during startup, stack memory is "free" but it is a finite resource.
Now lets test with mmap and with 65kb on a thread.
https://godbolt.org/z/5P8Wx6rbM
first: 0.02
second: 0.001
mmap: 0.012
if you do it on a main thread:
https://godbolt.org/z/r151GGKvd
first: 0.0106 ms
second: 0.00304 ms
mmap: 0.029901 ms
mmap can grow which could be fast, but if you are loading a 100gb file, you just load the file, and mmap isn't faster than fread for linear access.
>>
File: stil_not_much.png (10 KB, 700x350)
10 KB
10 KB PNG
>>102028725
>he writes a lot of complicated code without benchmarking
Loooooooooooooooooooooooooooooooool.
Sorry, didn't read further, I already know it's complete, unadulterated nonsense.
>>
>>102028762
posting benchmarking results mean nothing if you don't post code, but even benchmarks are synthetic compared to the performance of a real world program.
Actually code something then profile it (keep it short and simple, AKA KISS), then optimize it, compare performance, if it's not faster undo your optimization.
>>
>>102028606
Idk, a lot.
Factorio might be a bad example because it's literally a builder where you're constantly creating new objects so preallocating memory for all of that up front might be impossible who knows.
>>
>>102028828
>posting benchmarking results mean nothing if you don't post code
Yeah, go fuck yourself with a cactus. The last time I posted code I got nothing in return. Torturous murder for you and whatever sad remnants of family still attached to you is still too good a fate.
>>
>>102028850
50,000 per second whilst doing absolutely nothing. I literally launched a new game, left the flame animations run out, and stood there. And it got even worse with a Seablocks savegame ...
>>
>>102028713
yes, it's not that fixing the main to return int wouldn't work, but printing the return feels scuffed somehow, for example I'm not sure if it would constitute a problem for FFIs
>>
>>102028903
>50,000 per second whilst doing absolutely nothing
Seems unnecessary, I wonder what framework that game was made on or if it was built from scratch like that.
>>
>>102028947
I don't know what framework they use, but it's horrifically unoptimized. Loading in assets is done on a single thread, doesn't use sections (which would provide at least a 32-KiB readahead), and because they don't bother using NtCreateFile they eat memory allocations like crazy, too:

[000001F7EEC33F30|"\??\C:\Games\Factorio\data\base\graphics\entity\biter\biter-run-shadow-01.png"]
[000001F7EEC34A30|"\??\C:\Games\Factorio\data\base\graphics\entity\biter\biter-run-shadow-02.png"]
[000001F7EEC34A30|"\??\C:\Games\Factorio\data\base\graphics\entity\biter\biter-run-shadow-03.png"]
[000001F7EEC33E80|"\??\C:\Games\Factorio\data\base\graphics\entity\biter\biter-run-shadow-04.png"]
[000001F7EEC35740|"\??\C:\Games\Factorio\data\base\graphics\entity\biter\blood-puddle-var-main.png"]
[000001F7E2DD0CF0|"\??\C:\Games\Factorio\data\base\graphics\entity\blue-laser\blue-laser.png"]
[000001F7E2DD09D0|"\??\C:\Games\Factorio\data\base\graphics\entity\boiler\boiler-E-fire.png"]


[I:NtReadFile|00007FFE0D39AEE3] => [Handle: 0x0000000000000284][Length: 0x00001000|4096][Cycles: 31500]
[I:NtReadFile|00007FFE0D39AEE3] => [Handle: 0x0000000000000284][Length: 0x00001000|4096][Cycles: 34090]
[I:NtReadFile|00007FFE0D39AEE3] => [Handle: 0x0000000000000284][Length: 0x00001000|4096][Cycles: 29120]
[I:NtReadFile|00007FFE0D39AEE3] => [Handle: 0x0000000000000284][Length: 0x00001000|4096][Cycles: 28735]
>>
>>102029030
>NtCreateFile
Nobody is ever going to use that idk why you keep pushing it, and again, no one should be loading files from disk every frame.
>>
>>102028725
Actually I messed up the mmap code, I removed MAP_FIXED and mmap is the same speed as malloc (I got it working with 4096 but I didn't notice it stopped working at 65kb). But I think that means you must use the pointer returned from mmap (not important). I could make it work by calling mmap multiple times with smaller chunks if I needed that?.
The speed isn't faster or slower because I assume the memory page isn't activated until you touch it (malloc needs to touch the page to add the structure).
>>
>>102029082
>Nobody is ever going to use that idk why you keep pushing it
Very simple: because file system paths require a prefix ("\??\") for the kernel to be recognized as actual file system paths. Without that prefix the kernel will look into the NT namespace instead. Now, if you call CreateFileW, or fopen, or whatever API you use, then do you provide that prefix? Chances are that you won't.

CreateFileW doesn't know if there's space left at the end of the pointer that you've provided to shift the entire path by four characters, only to insert the prefix (UNICODE_STRINGs at least contain a member that specify how big the buffer is in total, together with the amount of valid bytes in the buffer), which means that the function has to allocate a buffer, insert that prefix into it, and then copy your path into it, wrap it into a UNICODE_STRING struct, wrap that into a OBJECT_ATTRIBUTES struct, and pass it to NtCreateFile, then free the buffer again. A lot of completely unnecessary steps if you just called NtCreateFile directly with the same object attributes, the same unicode string, and the same buffer: >>102020459

>no one should be loading files from disk every frame
Oh, they do that too, with sound effects specifically. Could've sworn I had a screenshot of that too, but I only have notes (in particular about data\base\sound\wind\wind.ogg).
>>
>>102029261
I guarantee you that NtCreateFile would not make a difference because most of the time spent is traversing the filesystem.
also it's very unlikely that factorio loads the wind sound from NtCreateFile repeatedly.
More likely that you mistaken ReadFile or something because that sounds like streaming audio more than opening a bunch of files during game play.
Opening a file is so expensive that it would create a noticable frame skip, but if factorio does it in another thread, it's 100% irrelevant because factorio is a single threaded game (for the game logic), any use of any threads is essentially free and unnoticeable by players.
>>
File: hard_data.png (128 KB, 1911x989)
128 KB
128 KB PNG
>>102029540
>I guarantee you that NtCreateFile would not make a difference because most of the time spent is traversing the filesystem.
I don't give a flying fuck what you can """""guarantee""""". If I assume 1500 cycles for the two heap allocations, retrieving the path data, and freeing all of that garbage again (which doesn't factor in any memcpys by the way), and then look at the average time it takes for NtCreateFile to finish, then that's about 20% overhead. Again, conservatively. And I didn't even factor in spatial locality.

If you want to disprove me, then I suggest you trace both NtCreateFile and CreateFileW at the same time (I won't because I already have my hands full with ntdll.dll). Don't even bother replying until you have hard data.
>>
Essence-of-live-coding Arrow FRP fsnotify seems to be catching all exceptions.
>>
>>102029676
Actually, trace CreateFileA too, considering the calls to RtlInitAnsiStringEx and RtlFreeUnicodeString it has to go through.
>>
File: 1718805348761532.gif (97 KB, 500x364)
97 KB
97 KB GIF
Hey, I hope this isn't too intrusive but if anyone has the spare time are you able to explain to me why this test case doesn't pass on leetcode 290?

var wordPattern = function(pattern, s) {
let map = {},
inverse = {};
// s = s.replaceAll('constructor', 'test')
s = s.split(' ')

if(pattern.length !== s.length){return false}

for(let i = 0; i< pattern.length; i++){
if(map[pattern.charAt(i)] !== undefined || inverse[s[i]] !== undefined){
if(s[i] !== map[pattern.charAt(i)] || pattern.charAt(i) !== inverse[s[i]]){
return false
}
}
map[pattern.charAt(i)] = s[i]
inverse[s[i]] = pattern.charAt(i)
}
return true
};

let pattern = "abba",
s = "dog constructor constructor dog";

wordPattern(pattern, s)


It passes all other tests and just simply changing the 'o' in 'constructor' to any other char returns the expected boolean value
>>
>>102030195
nvm I'm brain dead LOL
>>
>>102028905
I don't understand why you need to print the return value instead of returning normally
>>
>>102030195
>var wordPattern = function
why?
>>
>>102030563
because, at least in the codegen library I'm using, you need to be inside a function scope to build up your IR, so you need to start by defining your main function, with signature and all, and you can't go back and change it once you understand what the return type should be once you're done converting every node of your AST into IR. having said that I'm sure there's some workaround I'm missing, it's just that none sound good to me (for example I could wrap my entire code in a giantass main function at the parser step and run my typechecker on that, so that I'd know the global return type before the compilation phase, but I'm not sure that this is better than just printing my shit)
>>
>>102029676
>>102030009
write an actual project that matters instead of wasting your time with measuring random shit and acting like you understand anything.
>>
>Golang
>Under the hood, interface values can be thought of as a tuple of a value and a concrete type:
>(value, type)
>An interface value holds a value of a specific underlying concrete type.
>Calling a method on an interface value executes the method of the same name on its underlying type.
I know what those words mean individually and Ive used interfaces in Java and Swift, but what the fuck is this tutorial trying to tell me? I mean it probably doesn't matter and I can just use go interfaces without understanding how they work but I'm mad that I'm getting filtered by this explanation
>>
>>102031474
Actually I think I cracked it. Greentexting it has helped me unironically.This sentence makes sense to me "Calling a method on an interface value executes the method of the same name on its underlying type." and I can ignore all the other sentences as deranged babble.
>>
>>102031474
if i had to guess the "value" is a pointer to the instance and the "type" is a pointer to the vtable/dispatcher?
>>
>>102019737
any ideas for a project
>>
>>102031583
gpu accelerate something stupid
>>
>>102031540
I don't know c++ beyond the very basics but just did a brief reading on vtables and I think it makes sense now, thanks anon. So I guess to paraphrase it, an interface value holds both <thing> and the function that needs to be executed on <thing>. That makes sense.
>>
>>102031694
more the locations of the functions but yes, and vtables are a thing in any language with inheritance and dynamic dispatch, that's how you do it
>>
>>102019737
Python scripts to control various instruments over serial. I like using python for this because it's very portable. Only issue when controlling instruments over LAN is that for large datasets, recv() (in socket) returns different lengths across platforms. I found that on Windows in Spyder, it would return the entire specified length in bytes in one call, but on Linux it would return sort of random lengths around 14-20k per call. So for Linux I had to calculate the expected payload size and loop receiving 4K and appending it to a bytearray. Does anyone know how to write this properly?
I made an Arduino game where you had to guess the number on a 4-bit dipswitch. The Arduino would generate a random number by measuring ADC noise and it would blink the onboard LED at a rate equal to the distance between the dipswitch state and the answer in Hz, starting a new game when the value was found. In the case of an unchanged value on the ADC when a new game began, the ADC value was used as a seed to an LFSR to provide a pseudo-random sequence of numbers for future games, but it was possible to see all future answers by simulating LFSR state evolution for all seeds and comparing it to previous answers.
>>
>>102019737
can you use the using keyword in C++ to differentiate at compile-time between two types?
so like i have this
template <typename T> class something;
using lollmao = something<kek>;
using kekkoz = something<tnd>;
can i overload
print_classname()
to expand to print_nigger() and print_lmaos() for one class and for the other?
>>
btw print_classname is not a method, it is an inline function taking a pointer to an object
>>
>>102032025
templates don't "expand" to differently named symbols, they're not macros
but yes there's a lot of ways to differentiate between the two
i don't know if i would say they use the using keyword though
i tend to prefer this style
template<typename T>
void print_classname(something<T>* value){
if constexpr(std::same_as<something<T>, lollmao>){
}
//etc
}
>>
>>102032224
also the using keyword is just a typedef or in the case of using enum/namespace/class members a scope resolution thing
it's purely lexical
>>
it works
>>102032025
>>
>>102032224
sorry i didnt see the post

>purely lexical
gonna pipe into some code rq, -c worked but idk
>>
works as a new type in g++, idk whether typedef does that also
>>
>>102032378
something<kek> and something<tnd> are the different types, both instantiations of something<T>
both using statements (or typedefs) are just shorthand
>>
How do I make a top-left File tab as seen in Microsoft products such as Notepad in my own Windows program that is built using the Visual Studio Integrated Development Enviroment and C++ programming language?
>>
>>102032484
>how do i [entire project]
>windows
wew lad, how about you into-the-terminal first yeah?
>>
Implemented local variables and simple assignment for my compiler. Compound assignment operators next. Then if-statements soon getting soon.
>>
>>102032532
why did you copy the worst thing about gcc? use rbp as a normal register bruh
>>
>>102032484
a widgit toolkit like winui3, qt, imgui, the windows common controls library
there's some way to do the traditional windows ui through windows resource files
usually it's called something like a main menu bar
>>
>>102032578
I have no prior knowledge of assembly and am learning as I go.
>>
Well... After a well deserved break I decided I wanted to try again at making the site layout I truly desire. Changing the size and function was easy enough, creating new color schemes simple, even figuring out how to apply multiple themes was easier than expected considering last time, and with a little bit of stress I also remade the mobile version as well. It it so seemingly simple yet frustrating and idk why I do this to myself the reward is not that great. Oh wow you made a website woop dee fucking doo. And you'll make a video game after yeah doubt. I enjoy struggling I guess. Why... Oh why
>>
>>102032484
#include <windows.h>

#define IDM_FILE_NEW 1
#define IDM_FILE_OPEN 2
#define IDM_FILE_EXIT 3

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_FILE_NEW:
MessageBox(hwnd, "New File", "Menu", MB_OK);
break;
case IDM_FILE_OPEN:
MessageBox(hwnd, "Open File", "Menu", MB_OK);
break;
case IDM_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
const char CLASS_NAME[] = "Sample Window Class";

WNDCLASS wc = { };

wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;

RegisterClass(&wc);

HWND hwnd = CreateWindowEx(
0,
CLASS_NAME,
"Learn to Program Windows",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);

if (hwnd == NULL)
{
return 0;
}

HMENU hMenu = CreateMenu();
HMENU hFileMenu = CreateMenu();

AppendMenu(hFileMenu, MF_STRING, IDM_FILE_NEW, "New");
AppendMenu(hFileMenu, MF_STRING, IDM_FILE_OPEN, "Open");
AppendMenu(hFileMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(hFileMenu, MF_STRING, IDM_FILE_EXIT, "Exit");

AppendMenu(hMenu, MF_POPUP, (UINT_PTR)hFileMenu, "File");

SetMenu(hwnd, hMenu);

ShowWindow(hwnd, nCmdShow);

MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}
>>
If you're writing a small program in C less than 1000 lines is it ok to just organize your code with header files?
>>
File: git.png (11 KB, 767x216)
11 KB
11 KB PNG
did you know you can just spoof commits on previous dates with a --date flag? I wonder if I'm more employable now (yes im aware my random distribution absolutely sucks ass lmao)
>>
>>102032834
yea sure
1000 would probably be pushing it for a single file project but i don't see why you can't keep it single translation unit
be careful about duplicate symbols
>>
>>102031929
Maybe some higher protocol like http or mqtt is more consistent across platforms.
>>
Realistically, how big is the stack on my x64 windows 10 pc? By "stack" I'm talking about whatever rsp points to
>>
>>102019737
im learning how to code today :)
>>
>>102033210
whatever you set it to, stack size is set by the linker (presumably it's in the PE headers somewhere)
it's usually almost always the default which is pretty small, don't remember how big
>>
>>102032872
... no i did not, thank you for sharing that information
>>
>>102033238
don't
>>
>>102033302
what should i do instead
>>
I found a scheme interpreter written in Forth running in Julia. Very impractical, but still very fun to mess with and appreciate
>>
How this make u feel?
>>
>>102032872
Most people just don't give a fuck. Especially as having very large numbers of commits in a day is a sign of either doing entirely trivial things or shit going horribly wrong (often with CI).
>>
    XEvent event;
while (control.run) {
XNextEvent(display, &event);

switch (event.type) {
case Expose:
windowWidth = event.xexpose.width;
windowHeight = event.xexpose.height;
break;
case GenericEvent:
if (event.xcookie.evtype == XI_RawMotion) {
printf("PROCESSING RAW EVENT...\n");
XGetEventData(display, &event.xcookie);
XIRawEvent* rawEvent = (XIRawEvent *)event.xcookie.data;
printf("RAW VALUES: %f\n", rawEvent->raw_values[0]);
XFreeEventData(display, &event.xcookie);
}
break;
case KeyPress:
control.keyDown(XLookupKeysym(&event.xkey, 0));
break;
case KeyRelease:
control.keyUp(XLookupKeysym(&event.xkey, 0));
break;
}
}


>xinput2
>memory allocation just to get event data that's nested within another event
>requires an additional library
Holy shit there has to be a better way.
>>
>>102032579
>>102032810
Thank you so much, I sincerely wish you the best. I didn't expect real people to give an actual helpful answer... Thank you. I'm trying to do things on my own without having to rely on libraries and other people's work but I keep getting stuck and don't know how to properly build things from scratch, I just don't see how people manage to make things happen with something as simple as strings and numbers, I just don't understand the low-level software (Architecture? Design?)...
>>
>>102030195
(defn word-pattern? [pattern s]
(let [words (str/split s #"\s")]
(and (= (count words) (count pattern))
(= pattern (-> (zipmap words pattern) (map words) str/join))
(= words (-> (zipmap pattern words) (map pattern))))))

(assert (= true (word-pattern? "abba" "dog cat cat dog")))
(assert (= false (word-pattern? "abba" "dog cat cat fish")))
(assert (= false (word-pattern? "aaaa" "dog cat cat dog")))
(assert (= true (word-pattern? "abba" "dog constructor constructor dog")))


>>102030593
that's part of the template on the website
>>
>>102033795
much shorter:
(defn word-pattern? [pattern s]
(let [words (str/split s #"\s")]
(-> (zipmap pattern words)
(map pattern)
(zipmap pattern)
(map words)
str/join
(= pattern))))
>>
>>102033734
Use Qt if you're going with C++.
GUI libs do the WinApi or the Xlib bindings for you or the Wayland protocols for you so you don't have to.
>I just don't see how people manage to make things happen with something as simple as strings and numbers
They search for WinApi and read the Microsoft docs. Or ask ChatGPT now.
>I just don't understand the low-level software (Architecture? Design?)...
It's shit. It's what you had to use when you didn't have all the Electron webshit.
>>
>>102033734
write for linux
>>
>>102030195
>>102033795
>>102033959
In J this is just
   word_pat =. *./@:(f~ , f=.{{x (1 = #@~.)/. y}}) ;:
'abba' word_pat 'dog cat cat dog'
1
'abba' word_pat 'dog cat cat fish'
0
'aaaa' word_pat 'dog cat cat dog'
0
'abcd' word_pat 'the J programming language'
1
>>
>>102019737
I had to use Java and Python in school, but I'm not good enough at programming for it to matter as far as "prior experience" goes. I found some fairly recent textbooks from a friend getting rid of them, so which should I do first?
>Learning C++13 in an hour a day
>Programming Rust
>Starting Out With Python
>>
>>102019737
    ".byte 0xEF\n\t"    //machine code for "OUTd    %%eax,%%edx\n\t"

thank you GNU binutils.
There are a bunch of issues with the x64 assembler, might contribute if the architecture of binutils doesnt get in the way of per-arch optimizations.
>>
>>102034300
leetcode in c++, then write some terminal shit in linux.
>>
>>102034288
   word_pat =. *./@:(f~ , f=.(1 = #@~.)/.) :: 0 ;:
'aabb' word_pat 'dog dog cat'
0
'aab' word_pat 'dog dog cat cat'
0
>>
>>102023922
After hours of finger blasting my arsehole my tcl_to_header program can now handle multiple line tcl statements.

>what if...
Not my problem.
>>
>>102034288
I prefer array langs with funky symbols like APL and Uiua
>>
>>102034514
What's a tcl?
>>
>>102034514
>>>102034514
>>>>TCL_FUNCTION_SIGNITURE
anyway that code is so fucked with statics it doesnt even look like C.
>>
>>102034593
tcl is the scripting language required to use tk the last gui toolkit on Linux.

>>102034596
I have no idea what you're crying about.
>>
File: iGPSkeAiYa.webm (242 KB, 350x684)
242 KB
242 KB WEBM
I'm writing an app that display my current Jira tickets as WoW quests. It's a native app too, no electron
>>
>>102034697
Lol nice.
>>
>>102019737
Any math chads here?
What's wrong with my {c}ode? the volume is giving the wrong answer.
>>
How long until I memorize all the basic concepts in java? I haven't programmed in a year and I was still a beginner back then. My long term goal is to build a program that is considered advanced. How long will this take if I dedicate 3 hours a day everyday?
>>
>>102035198
Ignore me. I am dumb. I just simplified 4/3 to 1.33333
>>
>>102035198
>>102035226
you are dumb but not for the reason you think (though simplifying it was the right answer)
4 / 3 is integer division, the result is 1
it it doesn't become promoted to floating point until you multiply it by PI
4. / 3. would have worked
4. / 3 would have worked
>>
I have neglected dpt for many months. I may do what I don't normally do and ask for help sometime
>>
>>102035226
doesnt c have constexpr now? in cpp it would make sure the literal fits into the type
>>
>>102035198
>>102035226
Do
#define M_PI 3.14159265358979323846

or include math.h and use M_PI.
>>
>>102033715
There is, but it involves speaking xinput2 over the raw socket.

... which is actually yet another thing that's completely retarded about the protocol: rather than communicating via shared mappings and semaphoring signals back and forth you have to read and write with a socket. The MIT retards had no concern for scalability whatsoever.

>102031253
>angry nocodeshitter noises
>no trace
>>
>>102034352
I'm too dumb to know if this is a meme answer jsyk
>>
>>102035813
.NET is C#'s backend
it's not really its own thing
sure, powershell and F# run on it, but wherever you see requirements like that they mean C#
>>
>>102035892
Doesn't Unity use .Net so if I already know unity scripting, I should I know .Net?
>>
>>102036183
it uses mono, which is wine's reimplementation of the legacy windows exclusive version of .net, .net framework
so yes and no
you're really far behind actual C# and changes to C# best practices but i think there's a lot of shitty enterprise codebases still stuck on .net framework
>>
>>102019761
Go fuck yourself pedophile.
>>
>>102019737
refactored core structures and allocations stuff, compiled those 1300 or so lines
then i expanded memory management functions, rewrote boot for the 3rd time to accomodate the pools just growing with a pagetree just for them instead of silly config shit
now i need to figure out what the problem was for the kernel to be inserted as the "root module" so i can do my funi recursion for disk io / networking / whatever through the standard interface instead of pathnames through a fucking config
>>
File: QJwDkTZ7.jpg (310 KB, 2048x1151)
310 KB
310 KB JPG
MS no longer recommend electron for windows development, they recommend React native
https://learn.microsoft.com/en-us/windows/apps/get-started/?tabs=windows-forms%2Crnw
>>
File: 1704649841662246.jpg (47 KB, 602x900)
47 KB
47 KB JPG
>read clean architecture and learn about FP
>Apply what the book told me
>My efforts when from 4-5 days to 1.5 days of effort to finish the same shit.
>>
What lang/framework can I use to quickly bolt together a GUI to allow non-devs to create data for an application? MS access seemed to be what I want but the form builder is cancer and I don't strictly need a proper database, storing everything in JSON objects for example would be much easier to manage
>>
>>102036911
godot
>>
File: framework.png (14 KB, 604x280)
14 KB
14 KB PNG
>>102028947
>>102029030
Oh, look, guess they use std::filesystem internally. See, this is what I'm talking about when I say that
>you can shove your portability where the sun doesn't shine, seeing as your portability is a complete catastrophe that leads to horrifically bad code across the board

But I suppose this is just the way ego defense mechanisms work for the brainfucked sepple masses. All the time they're telling themselves that they're doing something productive, that the standard is already highly optimized, and that at the very least they're no tinkertrannies is time they could've used on writing actually good abstractions so that their code runs on a $3-per-month machine rather than a $3000-per-month one, and yet they don't do it.

... now I get why they don't run tracers either. They don't WANT to know the truth. They want to keep everything as ambiguous as possible so that they claim they're not just a bunch of imposters. That'd also explain why they're so mad at me, because I drag their incompetence into the light for everyone to see.
>>
File: shimygrab.png (1.65 MB, 3000x4000)
1.65 MB
1.65 MB PNG
>>102019737
question: how do i get the bash terminal to parse a filename with a file extension to a C program? argv[2] gets whacked with a null argument when i try this and it's annoying me.
>what are you working on
cli tool to build .xml slideshows on the MATE desktop because writing in html is a humiliation ritual
>>
>>102037236
>the bash terminal to parse a filename with a file extension to a C program
What?
>>
>>102037236
Maybe use quotes to ensure that the entire filename (including the extension) is treated as a single argument.
>>
>>102037236
how do you call your application?
If there are spaces you need to escape them in terminal or input the filename in "".
>>
File: shimyeat.jpg (1.52 MB, 1607x1289)
1.52 MB
1.52 MB JPG
>>102037512
>>102037405
it's
./main -d file.png
, first part i don't have an issue but the period makes the second argument return a null value
>>102037509
doesn't work
>>
>>102037615
are you using optarg or are you parsing the -d flag yourself?
Because otherwise the argv[2] should just contain "file.png".
>>
File: shimy!!!!.jpg (294 KB, 810x674)
294 KB
294 KB JPG
>>102037658
the -d flag is parsed myself, i didn't know there was a specific library for parsing launch arguments. seems like i'll look into optarg() then.
>>
Today is discovered that windows 11 use react native in for online functionality
https://devblogs.microsoft.com/react-native/rnw-settings-win11/
>>
>>102035201
>basic concepts
what do you mean by that
syntax? a day, probably
OOP? it'll either click with you or not. or it will but after a long time
standard library apis? no one learns all of that, instead you learn reading docs
>a program that is considered advanced
by whom?
programs don't get ribbons or badges
>>
>>102037729
>the -d flag is parsed myself
Sounds like you are fucking up something there.
If you print the argv[2] before you do any parsing it should print the filename.
Otherwise there is some encoding problem with the filename or something else is corrupted in your system.
>>
>>102037025
>guy who spends all his time poking and prodding other people's programs calling others tinkertrannies
the irony
>>
>>102028903
>50,000 per second
That's pretty low, that's less than 1000 per frame
>>
One guy asked me if I could do a small customization for their windows application.
Basically change one image for a specific client.
Now doing that is easy, I assume it's c# project.
But if they are going to distribute that new build I will need to get certificate to sign it, otherwise windows is going to nag every time someone tries to install it?
>>
>>102036911
dart/flutter
>>
>>102038338
>reading comprehension: 1
Try to read that post again, maybe with someone of age this time, and then maybe you'll realize who's calling who a tinkertranny, and, even more importantly, if that's a good or bad thing.

>>102038371
>he actually thinks that's low
>>
>>102038568
That's very low, given the average malloc is about 60 nanoseconds, that's using a grand total of 0.0003% of your frame time
>>
>>102038578
What is an "average malloc"? One that is satisfied with memory already mapped into userspace alone, or one that has to trap into the kernel? One that uses non-VEX-prefixed SSE instructions, thus requiring expensive state recovery using vzeroupper (and yes, Factorio does just that)? One that requires old cache lines or address translations to be evicted? Where do you have this number from?
>>
>>102038636
Someone measured the time mallocs and frees took in Doom 3 and that was the average
>>
>>102038651
Which malloc implementation exactly? On Windows most mallocs (and Factorio is no exception) go through HeapAlloc to RtlAllocateHeap, which has all sorts of locks, branches, and cache evictions.
>>
>>102038683
the regular Windows C runtime
>>
File: rtl_allocate_heap.png (34 KB, 1440x758)
34 KB
34 KB PNG
>>102038696
So the RtlAllocateHeap one, then. The one jumping all over the place so hard they even do software prefetching. I've said this before in the /egg/ thread, but memory allocation has side effects *outside* the function call, as well: >>102029030
All these different paths in different locations? Yeah, these smash through your cache no problem. You should've written "at least 60 nanoseconds".
>>
>>102038726
>memory allocation has side effects *outside* the function call
Like what?
>>
>>102038338
this is embarrassing, for you.
>>
>>102038744
Cache and TLB evictions. Stuff that was previously sitting comfortably in the caches being written back to main memory, only for it to be reloaded back. The devs not enforcing the location where their objects are being allocated from has been one reason why Factorio does so many things in the same thread, too: https://factorio.com/blog/post/fff-215

>Each thread has its own copy of the page, but whenever something is changed, the other copies of the same page need to be invalidated and updated. This means that the threads are invalidating each others cache all the time, which slows the whole process so much that it is slower than the non-parallel solution.
>>
>>102037844
actually ended up finding out what i did wrong, the parsing itself was correct but I had screwed up something else in my program
>>
>>102019737
>What are you working on, /g/?

Chess-based strategy game. It's fun to work on something like that DESU
>>
>>102038816
Coincidentally I've had something similar happening with the first multi-threaded version of regger, too, which took 16 minutes to finish (the first single-threaded version "only" took 8). These days the single-threaded version takes 28 seconds and the multi-threaded one 7.
>>
File: absolutely_disgusting.png (90 KB, 1903x970)
90 KB
90 KB PNG
>>102038864
(Fuck, I still have a screenshot to prove it!)
>>
>>102038816
That's a different problem really not related to the amount of times they're calling malloc
>>
>>102038899
Who said it was related to the amount of malloc calls? The point was to show that malloc has side effects outside the boundaries of a call.
>>
>>102038918
>>102038816
By that logic, NOP has side effects.
>>
>>102038933
It certainly does, which is why some programs will run faster if optimized for size.
>>
>>102038918
It's a problem that could be solved regardless of what malloc you're using if you organized your memory differently
>>
>>102038954
Why use malloc at that point, then?
>>
>>102038933
the more nops the more breakpoints lol
>>
I quit my job, and have some spare time to burn. I already have some hobby projects in the works, but I feel like doing something silly first. any ideas? I've been thinking about adding video recording to ScummVM.
>>
>>102038971
The usual strategy is to alloc your own big blocks of memory using malloc and then work with those
Doesn't really matter what malloc you use to do that
>>
>>102034234
Thank you for your answer. I'm trying to figure out how to do things on my own because eventually I won't have a library or a framework that would do the work for me, how do people approach these problems by themselves?
>>
>>102039026
you read the specification and implement it
>>
File: small_fry.png (130 KB, 1911x989)
130 KB
130 KB PNG
>>102039009
>The usual strategy is to alloc your own big blocks of memory using malloc and then work with those
Which is very clearly not what's happening.

>Doesn't really matter what malloc you use to do that
Wrong. You also want an allocator that doesn't trigger copies upon reallocation.
>>
>>102039082
Like I said before, the things you're talking about are operating in the range of 0.001% a frame, they don't matter
>>
>>102039100
Wrong again. You keep forgetting that those 50,000 happened during a fresh vanilla game: >>102028606

It was much worse with a running factory in Seablock.
>>
>>102039128
>You keep forgetting that those 50,000 happened during a fresh vanilla game
and they took 0.001% of the frame time. What's your point?
>>
>>102039133
>and they took 0.001% of the frame time
Make it ~4-5%.
>>
>>102039154
Where did that number come from?
>>
>>102039159
I'll tell you once you tell me where your 60 nanoseconds come from.
>>
>>102039166
https://www.forrestthewoods.com/blog/benchmarking-malloc-with-doom3/
>>
>>102039179
>doom3
Doesn't count, not even a real game
>>
>>102019737
My mental health.
>>
>>102039179
wtf i love malloc now
>>
malloc tranny is still going? this nigga discovered arena allocators and now acts like xhe's enlightening us with the gospel. post bussy next time fag, would actually increase /dpt/ quality at this point.
>>
>>102039179
I already posted my source: >>102028903
The total time the CPU spent in both HeapAlloc and HeapFree amounted to ~150 million cycles per second, and with 3,5 billion cycles per second that's a total of 4.2% of a second spent in there.
>>
>>102039360
>The total time the CPU spent in both HeapAlloc and HeapFree amounted to ~150 million cycles per second
I'm not seeing that information
>>
http://arxiv.org/pdf/1205.5991

Am I retarded or does (1.2) make no sense? p is a function that only takes positive numbers, but the very first term (n=1, k=1) gives p(0) + p(-1).
>>
pdf malware
>>
>>102039386
Wrong. You see HeapAlloc start at 23,736,683,157 and end at 23,833,250,876 while the time shows 04:37:44 (the second at the time of measurement) for a total of 96,567,719 cycles, and you see HeapFree start at 12,687,011,176 and end at 12,732,086,883 for a total of 45,075,707 cycles, which together are 141,643,426 cycles. And the second didn't end there.
>inb4 can't you generate a better chart
Once I've fixed this damn bug in NtDelayExecution, sure.
>>
>>102039557
Everything you're posting is without context
Is each entry a frame? is it 40 million mallocs a frame?
>>
>>102039638
>Everything you're posting is without context
Wrong again. You can clearly see that each entry represents 10000 calls for each function (39,850,000 => 39,860,000 => 39,870,000), and that the amount of cycles increases steadily, and that they all happen within the same second.
>>
>>102039399
https://math.stackexchange.com/questions/35080/upper-limit-of-summation-index-lower-than-lower-limit
>>
>>102039708
I don't live inside your head bro, there's no context on any of the numbers you're posting (nor how you measured them)
Present the relevant information, don't make me bring up a calculator
>>
>>102039748
if you were complement you would be able to red minds
>>
>>102039748
>nor how you measured them
rdtsc before and after the actual call.
>don't make me bring up a calculator
Sounds like a (you) problem, as in, (you) wanted the raw data.
>>
>>102039818
The raw doesn't mean anything, because there's no time period given
>>
>>102039834
I'm not interested in time periods, but raw cycles: >>102020830
>Every cycle a program wastes on something that isn't strictly required on a task the user wants is proof of the programmer's failure
>>
>>102039853
You said 50 million cycles per second, but now you're not interested? Is what you posted one second?
>>
>>102039853
users dont know what they want
>>
>>102039886
This is a pointless waste of time.
>>
>>102039907
If you want to measure something you need to do way more than one second you idiot
>>
>>102039939
>implying
>>
>>102039948
Not implying, stating
Mr Hackerman here thinks he can critque other people's code because he's captured an entire second of operation time
Lmao
>>
>not stating, making up
I feel so sorry for the people around you.
>>
>>102039996
I didn't make up the discipline of statistics, midwit-kun
Measure it properly then come back and report your findings
>>
>lose an argument
>proceed to reply but without mentioning the post you're replying to
classic
>>
>>102040026
They think it makes them look cool
>>
daily reminder that qa lost.
>>
>malloc is bad
>why?
>it just is
>what should I use instead?
>unsupported, undocumented and closed source kernel APIs
>has anyone actually done this?
>yes
>who?
>me
>can i see it?
>no
>do you have any proof?
>89302740923 02938409283409 23094820938402938 4029384029384029834 02398402938402983402983 4029384 0293
a summary for those who are just joining
>>
>(you) didn't measure properly
Anything else the voices in your head scream at you?

>classic
This, but unironically.
>>
File: page_sizes.png (14 KB, 1278x410)
14 KB
14 KB PNG
Whoops, looks like you already posted some of the excepts from your voices:

>unsupported
Your reality must be a very frightening place. Let me assure you that, in the real world, they are supported juuuuuuuuust fine.
>undocumented
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory
>closed source
Which differs from malloc on Windows ... how, exactly?

>can i see it?
What are you offering in return?
>>
Need help with a binary search tree removal in C. In the case of both a left and right child node present. You can either choose to replace the current node with the largest value in the left sub-tree or smallest in the right-sub-tree, stuck between these two choices, which one should I go for? Also is the code okay?

 
int Remove_Node(Node* Tree, int Value) {
if (Tree->Data == Value) {
if (Tree->Left == NULL && Tree->Right == NULL) Tree->Data = -1;
if (Tree->Left == NULL && Tree->Right != NULL) Tree = Tree->Right;
if (Tree->Left == NULL && Tree->Right == NULL) Tree = Tree->Left;
if (Tree->Left != NULL && Tree->Right != NULL) {
Node* temp = Tree->Left;
while (Tree->Right){
//
}
Tree = temp;
}
return 0;
}
if (Tree->Data > Value) {
if (Tree->Left == NULL) return 1;
Remove_Node(Tree->Left,Value);
}
if (Tree->Data < Value || Tree->Data == Value) {
if (Tree->Right == NULL) return 1;
Remove_Node(Tree->Right,Value);
}
}
>>
>>102040417
yeah but what are you working on?
>>
File: that_error.png (8 KB, 398x256)
8 KB
8 KB PNG
>>102040459
Right now? Pic rel. I wasn't exactly kidding about NtDelayExecution.
>>
>>102040417
>NtAllocateVirtualMemory
use VirtualAlloc to not trip antiviruses nigga
>>
>>102040430
rng and do 50%
>>
>>102040482
is that sysadmin or programming?
are you developing the game or a mod?
>>
>>102040484
Like I care what snake oil has to say.
>>
>>102040503
Programming. I use the game as testing ground for a kernel tracer.
>>
>>102040506
you would if you were shipping things to users lil bro...
>>
>>102040549
My users are usually smart enough to not require snake oil. Your comment says a lot about yours, though.
>>
>>102040560
>dumb users and smart users
ngmi bro
>>
>>102040593
Let's say "the type of users who're not mad about telemetry because they know how to remove it".
>>
>>102040560
>My users
you mean yourself
>>
>>102040640
I'm not the one with the voices in my head screaming at me though.
>>
>>102040654
what do the voices tell you?
>>
>>102040667
Again, I don't have any.
>>
>>102019737
struggling with foreign key constraints when creating a resource from a client because Go doesn't have a null value
>>
>>102040915
0
>b-but
(yourtype)0
go_compiler -w
>>
File: brainfuck-in-odin.png (1.27 MB, 1762x6916)
1.27 MB
1.27 MB PNG
>>102019737
Trying to improve my brainfuck interpreter in Odin



[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.