← Home ← Back to /g/

Thread 106617188

321 posts 104 images /g/
Anonymous No.106617188 >>106617528 >>106618581 >>106619235 >>106619570 >>106622136 >>106623022 >>106625350 >>106628948 >>106637085 >>106639695
/dpt/ - Daily Programming Thread
What are you working on, /g/?
Previous: >>106596041
Anonymous No.106617203
First for C++ supremacy
Anonymous No.106617212
For me it's C with GNU extensions
Anonymous No.106617245
Thinking of making my own virtual table top as a first project. Nothing but a day dream so far.
Anonymous No.106617257 >>106617373
Haskell
Anonymous No.106617373 >>106617762
>>106617257
Spew some wisdom, haskell wizard.
Anonymous No.106617411 >>106617501 >>106617641 >>106620569
>>106613979
>std::vector is dogshit and if you think it's good then that says more about you as a programmer than anything else
vector is good for C interop + it's small.
std::deque is better in most situations, but the memory is not in a single block of memory so you can't pass it into C functions that expect an array, and different C++ standards implement it differently so it has different performance characteristics, but the great thing is that deque doesn't reallocate, so you can use references/pointers without worrying about invalidation (as long as you only use it as a stack or queue).
and with certain C++ debug features, such as MSVC's iterator checking (on by default on a debug target), it will prevent you from doing something stupid like inserting/erase and using an invalid iterator after (which address sanitizer/etc won't catch, because you are accessing valid memory).
I think a lot of C programmers think that vector is the only way to make a dynamic array in a C++ RAII way, but you can also use a std::unique_ptr but it's not actually dynamic, it's basically just malloc (new char[X]) with RAII.
(side track skip this)
And I personally hate C++ exceptions, I have always hated them, but I will admit, I have starting thinking about how you would handle a fatal error inside of a thread worker (that you can recover), and what is the most graceful way of handling that.
Normally if your release build is going to disable assert (or the unsafe [[assume()]] optimization), it makes sense to just let assert end the program.
But if you keep assert in a optimized build, if you were 100% certain the thread is non-critical and you can restart it without issue after breaking assert (all possible resources are cleaned up, plus show error), the assert throwing an exception will unlock mutexes, which will save you from a deadlock.
And for debug reports, you could use crashrpt or bugsplat or sentry to manually report.
And with vector, you could use .at() for exceptions.
Anonymous No.106617461 >>106617498 >>106624959
I want to learn to code, how can I?
I want to play around with cellular automata too
Anonymous No.106617498 >>106617736
>>106617461
I learned python with Automate the Boring Stuff and Python Crash Course, and then went through cs50x from Harvard to learn how to learn the stuff that real programs are made out of.

I'm still in my Dunning Kruger"Mount Stupid" phase, but picking up things as needed is doable now.
Anonymous No.106617501 >>106617657
>>106617411
unique_ptr is equivalent to std::vector in this context, the only difference is that mask is off and we don't pretend anymore that memory is dynamic, because it is not, std::vector allocates new block and copies everything, then runs destructors on old allocation. I hope I don't have to explain why that's incredibly retarded.
Anonymous No.106617528 >>106626155
>>106617188 (OP)
a from-scratch "more" program, for an environment that doesn't have curses. Surprisingly more complicated than expected. Unbuffered input from stdin: arg!

OP's pic is comfy.
Anonymous No.106617641 >>106617657 >>106617663
>>106617411
>And with vector, you could use .at() for exceptions.
Well. I will admit this contracticts
>use crashrpt or bugsplat or sentry to manually report.
MSVC has an async exception handler that you can use to make that report contain the full stacktrace (and glib has a hidden debug thing that prints a stacktrace inside the C++ exception message, I think?), async exceptions does have a pretty large performance penalty, and it also catches more than just C++ exceptions (stack overflow, invalid memory access, etc), and if you start using the custom assert with exceptions, using noexcept for optimizations would now be problematic with the custom assert (it will still work, but instead it will just terminate, which will trigger the crash reporter).
>std::vector allocates new block and copies everything, then runs destructors on old allocation
this is C++03 logic, in C++11 the objects are moved, which still means the memory gets copied, but the difference is that it's 1000x faster because it doesn't need to alloc + copy + delete every element.
But of course, maybe you are talking about the redundant destructor call, which won't exist for is_trivially_copyable (optimized out), but otherwise I guess you are wasting like maybe 10 nanoseconds for every element to check if(ptr != nullptr){delete ptr;}. this is the last issue you would need to worry about, since most people are doing unholy things like std::vector>, which the redundant destructor (even virtual destructor) is a fraction of the issue of the bigger problem.
So just don't store arrays of a struct with a std::string and use static_assert(std::is_trivially_copyable == false).
Anonymous No.106617657
>>106617501
>>106617641
*edit: == true)
Anonymous No.106617663
>>106617641
>words words words
How about just mmap a buffer so big that you will never fill it completely and then you aren't wasting anything at all? Virtual memory is free, 64 bit is older than everyone on this site. Fuck you.
Anonymous No.106617736 >>106617851 >>106618043
>>106617498
Thank you, thank you!
I had the idea to start with python, I tried C and well...not that good of an attempt.I'll check this out.
Anonymous No.106617762
>>106617373
why bother when 99% of languages dont have higher kinded or ranked types
Anonymous No.106617851
>>106617736
I recommend you do both. Focus on Python but do at least basic C stuff in parallel. Just read K&R and do exercises.
This is in order to:
>get an appreciation for how much Python does for you and what exactly is it
>get a perspective on memory management that's somewhat closer to the reality
>not get filtered in the future when having to work with low-level stuff
>be able to rewrite parts of your Python code in C if necessary. Python and C play very well together and many high-performance Python libraries are actually C with a Python interface. This is not black magic, you can do it too.

Even if you don't become a C wizard, understanding its memory management model is very helpful for understanding computers in general
Anonymous No.106618043
>>106617736
Enjoy bro!
Anonymous No.106618173 >>106618210 >>106618212 >>106618259 >>106618284
How do I stop watching amateur and candid porn during my free time and instead spend it programming?
Augusta !!v+r1yfzfgry No.106618210 >>106621881
>>106618173
If you can't control yourself with pornography, you're probably stressed from unrelated reasons
Learn to guide yourself instead of controlling yourself, and try finding programming ideas that are fun to write
Anonymous No.106618212
>>106618173
Threading
Anonymous No.106618259 >>106618284
>>106618173
find a wife and waste your time on her instead, your son will have some free time to program
repeat ad nauseum
Anonymous No.106618284 >>106618389
>>106618173
kill yourself
>>106618259
or do anything except this, but suicide is an answer to every single problem, you aren't suffering if you wouldn't hang yourself in 5 seconds if handed a noose.
Anonymous No.106618389 >>106618543
>>106618284
>suicide is an answer to every single problem
lmao
Anonymous No.106618543
>>106618389
>my life sucks
just don't be alive to experience it
Anonymous No.106618581
>>106617188 (OP)
Anonymous No.106618999
Publish straight to prod, no need for git or branches
Anonymous No.106619235 >>106624141
>>106617188 (OP)
Working more on the MAIDS programming language. I fixed the pattern capture bug and wrote most of the manual. I am refactoring a big class called CombinatorsForMAIDS because it is about 10k lines long and nightmarish to work inside. Once it is refactored and the manual completes I will release it to Public Domain, along with an example program that generates all possible character sheets for the game Maid along with backstories for the characters.
Anonymous No.106619570
>>106617188 (OP)
ProTracker Audio Player
Anonymous No.106620253 >>106620270 >>106620429 >>106620669
How did you guys get good at large projects? I understand modular design, etc. but in the actual process do you just bang out code and iterate?
>t. analysis paralysis-suffering retard
Anonymous No.106620270 >>106620288
>>106620253
practice, practice, practice
Anonymous No.106620288
>>106620270
Thank you, I appreciate it.
Anonymous No.106620429 >>106620469 >>106620480
>>106620253
Just bang some shit together and refactor it later. Unless you already have a deep understanding of whatever you're doing (which you almost never do, unless it's a rewrite), creating some overly elaborate and excessively structured project is almost never going to actually fit and just going to cause more problems later.

"The lack of structure is better than bad structure."
Augusta !!v+r1yfzfgry No.106620456 >>106620478
How to make a programming circle?
Like the GNU project
Anonymous No.106620469 >>106620494 >>106620505
>>106620429
As retarded as it sounds, part of the issue is giving myself permission to write "bad" code. Will try this, thank you
Anonymous No.106620478 >>106620517
>>106620456
first you need a name and a logo
Augusta !!v+r1yfzfgry No.106620480
>>106620429
>creating some overly elaborate and excessively structured project is almost never going to actually fit and just going to cause more problems later
I did this exact thing while writing an OS
After spending some time without writing it, I have no clue how to go back since the structures were so complicated
Anonymous No.106620494
>>106620469
The important part is to actually refactor it later to make it not shit.
There seems to be some kind of misconception/myth that skilled programmers just write everything perfectly the first try, which is definitely not the case. Good code is refined.
Anonymous No.106620505
>>106620469
The retarded abstraction you write today and try to fit everything into to "reuse code" IS the bad code.
Duplicate yourself three times then the refactor will be obvious. Do some shit pattern because you're some hot shit enginigger and now I'm stuck using your unextensible faggot module and introducing 5 edge case bugs because of corporate policy to reuse code.
Augusta !!v+r1yfzfgry No.106620517 >>106620702
>>106620478
True, I'm gonna admit that I don't have that yet!
But what if I had it? What would be the next step?
Anonymous No.106620569 >>106621596
>>106617411
Why make use of all modern c++ bloat when you’re in system dev? std::exception for instance where both winapi and linux have their own error handling.

Any STL container is replaced by sys queue or windows own circular queues. What’s the benefit of c++ in this case, except for auto, namespace and templates?
Anonymous No.106620669 >>106622351
>>106620253
a lot of people aren't ready to hear this, but the only way to legitimately get good with large projects is to join teams using massive monorepos with tens of years of tech debt, fully immerse yourself into the codebase, and learn how it all works together
hard mode: then measurably improve it

ask me how i know
Anonymous No.106620702 >>106620742
>>106620517
Then you quit maidposting or kill yourself.
Anonymous No.106620729
what's stopping me from just manually building a frame and putting a false MAC as a the source?
Augusta !!v+r1yfzfgry No.106620742 >>106621121
>>106620702
That's a very passive aggressive way of saying you don't like maidposting, specially against the only maidposter that doesn't delve into the saccharine delusions
Anonymous No.106621121 >>106621146
>>106620742
They'll always hate you for being a maid. It doesn't matter how you behave, or if you view yourself as somehow superior to the other maids. It doesn't matter what you create. They will still hate you for being a maid.
Augusta !!v+r1yfzfgry No.106621146
>>106621121
And who are "they", anon? One or two obsessed haters, along with normal people who feel nauseated by the saccharine delusions?
Anonymous No.106621152 >>106621175 >>106621180 >>106621322 >>106621888
why come the prototype of memcpy doesn't indicate it needs pointers? i get that it's used for strings but i want to copy a struct

void *memcpy(size_t n;
void dest[restrict n], const void src[restrict n], size_t n);
Augusta !!v+r1yfzfgry No.106621175 >>106621185
>>106621152
Parameter dest[restrict n] is a pointer
The [restrict n] part is a compiler promise that dest doesn't overlap src and is n sized, mostly for optimization

Just do memcpy(&a, &b, sizeof(struct something))
Or even a = b
Anonymous No.106621180 >>106621185
>>106621152
In C function arguments, arrays decay into pointers and are exactly equivalent. They're just using array syntax instead of pointer syntax because they're using the (non-standard) size_t n; forward declare thing and it lets you know how much memory the array needs to point to.
Anonymous No.106621185
>>106621175
>>106621180
thank you, i'll make a note of it for future man pages.
Anonymous No.106621322 >>106621344 >>106621403 >>106640687
>>106621152
>void *memcpy(size_t n;
I've got the same fuck up, pisses me off. Any idea why the man pages are broken?
Anonymous No.106621344 >>106621359 >>106621724
>>106621322

>>void *memcpy(size_t n;
in reference to the first argument? i don't know what that is. i just ignore it and refer to everything passed the ;.
i think it just means the variable type the prototype is expecting as parameters where indicated in the rest of the function
Anonymous No.106621359 >>106621387
>>106621344
>in reference to the first argument?
yes
>i think it just means the variable type the prototype is expecting as parameters where indicated in the rest of the function
no idea what you mean
Anonymous No.106621387
>>106621359
this part, right?
Anonymous No.106621403 >>106621505
>>106621322
>Any idea why the man pages are broken?
i've got no clue what you mean
Anonymous No.106621458
I started documenting some code I wrote and with every line of documentation I truly wonder what crack I was smoking when I wrote it. The sheer simplicity of what I was actually doing compared to the rats nest of my code was stark.

It is amazing how documenting my own code is better code review than all my coworkers put together.

I’ve also been trying some agentic coding and for the most part I’m just amazed at how bad it can truly be and how much time I can waste.
Anonymous No.106621505
>>106621403
in reference to the first argument?
Anonymous No.106621596 >>106621909
>>106620569
>what's the benefit except those ones
kill yourself
Anonymous No.106621622 >>106621635
It struck me lately that the float comparison with epsilon makes little sense, yet is taught all the time.
since floats work like scientific notation with fixed fraction digits, the larger value float holds, the larger the step of least significant bit is. So if you have two large floats but the epsilon is smaller than the LSB step then it has no meaning.
And the selection of right epsilon that has any effect heavily depends on at least one of the values.
Why not just mask out one or two LSB to ignore rounding errors and then compare bitwise? Seems trivial and obviously works and is agnostic of magnitudes, yet never seen this recommended anywhere. Am I the crazy one or is everyone else wrong?
Anonymous No.106621633 >>106621639 >>106621756 >>106621833 >>106640687 >>106640737
Everytime I use lldb I get a literal headache after an hour or two. All debugging tools are garbage. No wonder most people prefer print debugging.
Anonymous No.106621635
>>106621622
because when you use floats, you don't have large values, unless you're retarded.
Anonymous No.106621639 >>106621800
>>106621633
We prefer print debugging because using a debugger is print debugging in slow motion for people who are so slow that it doesn't matter.
Anonymous No.106621724
>>106621344
it's declaring what the type of n is inside void dest[restrict n] and const void src[restrict n], you might be like but anon it's already declared in the last parameter, and no it isn't because the last parameter depends on the size of the array and not vice versa
Anonymous No.106621756 >>106621793
>>106621633
#define errigger(NIGGER) do {printf("failed here because %s on line %d\n", __LINE__, NIGGER);} while(1)
Anonymous No.106621793
>>106621756
>needs to be reminded which line he put a printf on
cniles...
Anonymous No.106621800 >>106621819 >>106621877
>>106621639
Basically this. Make a logger that can change its logging level at runtime, enable and disable in the sections you want and you're set.
Anonymous No.106621803 >>106621921
Thoughts on Zig and Carbon(the new Microsoft lang)
Anonymous No.106621819
>>106621800
Just be happy I didn't include the filename too
Anonymous No.106621833
>>106621633
in theory you could gather all the data you want with tools like DynamoRIO, but I don't know if they work well with x86
Anonymous No.106621877 >>106621936
>>106621800
>runtime
kys
Anonymous No.106621881
>>106618210
I'm not the other faggot but I've definitely noticed this about my own habits. distractions are just stress relief or stress avoidance.
Anonymous No.106621888
>>106621152
pointers of n elements and pointers of 1 element are all the same in C.
Anonymous No.106621909
>>106621596
U don’y even code cuz
Anonymous No.106621921
>>106621803
Carbon is by Google and vaporware

Zig has good ideas but some of the "clever" syntax they have is Rust tier insanity. Out of the C replacement languages I prefer Odin
Anonymous No.106621936
>>106621877
>hes too stupid to use the preprocessor
Anonymous No.106621986 >>106622038
// Best approach: perfect forwarding with template parameter
template
void execute_lam(F&& lambda) {
std::forward(lambda)(); // Perfect forwarding
}

LLM hallucinations are getting more and more deranged.
Anonymous No.106622038 >>106622046
>>106621986
it's right except for not using std::invoke
Anonymous No.106622046 >>106622057
>>106622038
Where is the lambda being forwarded to? dumb nigger
Anonymous No.106622057 >>106622064
>>106622046
struct X {
void operator()() &&;
};

dumb jeet
Anonymous No.106622064 >>106622068
>>106622057
>dumb jeet
that's what you are
Anonymous No.106622068 >>106622098
>>106622064
I denounce vishnu
Anonymous No.106622098
>>106622068
Don't all kikes do? You aren't special.
Anonymous No.106622136 >>106622775 >>106641189
>>106617188 (OP)
app
Anonymous No.106622351
>>106620669
>join teams
n-no... I can't... I won't!!
I refuse.
Anonymous No.106622476 >>106642045
just got the call: I got hired
Anonymous No.106622485
>>106616929
https://pastebin.com/3Wkm3sWE
Anonymous No.106622775
>>106622136
haha balls
Anonymous No.106623022 >>106625049
>>106617188 (OP)
Learning literate programming, it's fun but I don't know if the shit am doing is correct or not.

I do like the idea of writing both the code, the documentation, the QA, the tests, and my own notes all at the same time. But this setup took me so long to get running, and I can still see a million ways I can improve it... I will be spending more time tweaking my programming process than actually writing lines of code at this point.
Anonymous No.106623563 >>106623658
Searching for where SOCK_STREAM is defined in linux uapi.
Anonymous No.106623658 >>106623661
>>106623563
ctrl+click
Anonymous No.106623661 >>106624099
>>106623658
retarded nocoder
Anonymous No.106624099 >>106624127
>>106623661
?
are you not looking for the macro define?
Anonymous No.106624127 >>106624217
>>106624099
How do you know that it's a macro or that it even exists?
Anonymous No.106624141 >>106629853
>>106619235
>I am refactoring a big class called CombinatorsForMAIDS because it is about 10k lines long and nightmarish to work inside.
I have completed this refactor. But now I also have to refactor the processor to accommodate it. I was able to make the CombinatorsForMAIDS an order of magnitude smaller by using a switch.

>Once it is refactored and the manual completes I will release it to Public Domain, along with an example program that generates all possible character sheets for the game Maid along with backstories for the characters.
This part will be next. I am trying to convince somebody really good at Pet Theory and writing proofs to help me write up the math parts. If she agrees, I will list her as a co-author of the manual. If she does not agree, I will do it but it will be slower.
Anonymous No.106624217 >>106624226
>>106624127
if it didn't exist your code wouldn't compile in the language server (you would have incorrect error squigglies).
the language server should be able to analyze the code using the exact same settings your compiler is using (like clangd, but intellisense on vscode would work as well on linux).
I assume it's a macro because of all caps, but it could be an enum (it's the same thing to me, but I imagine the coding standards would require macros instead of enums, because you can use the macro as a feature check, but it's probably not important for such an old API since you can't really use sockets without SOCK_STREAM I guess, and I don't know if there is any extensibility to that type, assuming it's a type).
Anonymous No.106624226 >>106624244
>>106624217
You should know things before you talk about them, you know.
Anonymous No.106624244 >>106624257
>>106624226
sorry I should have googled that for you.
Yep, it's a type and it's extensible. Sorry about that.
Anonymous No.106624257 >>106624281
>>106624244
What do you mean by that? Did you even try doing exactly what I wrote and not what you hallucinated that I wrote?
Anonymous No.106624281 >>106624290
>>106624257
Sorry, What should have I known before talking about it?
Anonymous No.106624290 >>106624297
>>106624281
Don't worry about it.
Anonymous No.106624297
>>106624290
Ok?
Anonymous No.106624744 >>106624864 >>106624970 >>106625188 >>106626352
I can slice a contiguous subset of an array in-place in constant time by incrementing the pointer and decreasing the length variable. Is it possible to free the portions I don't need?
Anonymous No.106624864
>>106624744
You can free the latter part if you realloc but it's likely faster to just use the array and free it once when you are done.
Anonymous No.106624959
>>106617461
I found a C coding for dummies book and it has been pretty helpful.
Anonymous No.106624970 >>106625019
>>106624744
No, also allocations below page size are free.
Anonymous No.106625019
>>106624970
>allocations below page size are free
wat?
Anonymous No.106625036
Fucking land already god dammit.
Anonymous No.106625049
>>106623022
Literate programming is great but it's the precise opposite of prototyping, and since I don't do a second pass over my hobby projects I never really bother. But if I ever wanted to make a demonstration out of a module or a program, then yeah literate programming is neat.
Anonymous No.106625188
>>106624744
depends how it's allocated
if you aren't privy to that then no
Anonymous No.106625350 >>106625373
>>106617188 (OP)
Making Vidya. It's in java because classes. And no it isn't like the stupid fucking project you want to make.
Anonymous No.106625373 >>106629061
>>106625350
>Making Vidya
>It's in java because classes
Thanks for the laugh anon.
Anonymous No.106625582 >>106626338
It's here
https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/

>LLD is now the default linker on x86_64-unknown-linux-gnu
>u{n}::{checked_sub_signed, overflowing_sub_signed, saturating_sub_signed, wrapping_sub_signed}
>const <[T]>::reverse and float rounding functions
Anonymous No.106626155 >>106626254 >>106629473
>>106617528

More progress on my minimal "more" program. I got the input tweaking working, so that input is not echoed and my program sees each input character right away, with no waiting for the user to press enter or return. Let's see if I have "code" tags working this time.

The key parts of my program, stdin-setup-wise ...

struct termios cheese, baloney; /* so i'm bad with names */

...
/* tweak keyboard/stdin for non-echo and not line-buffered */
if (setvbuf(stdin, NULL, _IONBF, 0)) {
fprintf(stderr, "error: can't change stdin buffering mode\n");
exit(DOOPS);
}
/* the setvbuf didn't have any effect. Do this ... */
tcgetattr(STDIN_FILENO, &cheese);
memcpy(
&baloney, /* save it here */
&cheese, /* save this */
sizeof(struct termios)
);
cfmakeraw(&cheese);
tcsetattr(STDIN_FILENO, TCSANOW, &cheese);

... when about to exit:
/* restore keyboard/stdin to as it was */
tcsetattr(STDIN_FILENO, TCSANOW, &baloney); /* set tty/stdin back to normal */
if (setvbuf(stdin, NULL, _IOLBF, 0)) {
fprintf(stderr, "error: can't set stdin buffering mode back\n");
exit(DOOPS);
}
putchar(13);
fflush(stdout);
Anonymous No.106626254
>>106626155
In C# this is just
Console.ReadKey(intercept: true);
Anonymous No.106626338
>>106625582
Multi-target workspaces when
Anonymous No.106626352
>>106624744
Depends on the allocator
Anonymous No.106626425 >>106626928 >>106626959 >>106627374
Does the professional world actually care about <80 character lines and other style guidelines? Like will recruiters/employers not even bother with me if they see my code doesn't follow the style guide?
Anonymous No.106626455 >>106626556 >>106629320
I'm going to create a musical project in which the computer is the central instrument. I mean to process recorded audio through it, using the browser as the platform so that the performer can activate and interact with the audio while live in concert. I'm very comfortable doing this with vanilla html css and javascript, I've done a project like this already. However I wonder if using React or another framework might work better for the time-sensitive properties of sound (up until now I've been abusing the await function of javascript).
I insist on using the browser rather than something like max-msp or supercollider since I can manipulate the interface to be as user friendly as possible, so that anyone can perform this piece.
Would react work better for this project? (I'd like to point out that I'm an actual idiot programming, I'm just a musician exploring stuff in a very amateur way)
Anonymous No.106626556 >>106626591
>>106626455
Why not use a DAW?

Yes, React is fine for writing WebApps like this. No you are not going to get live music production tier latency with JS no matter the framework. Your interface should only be there to set up things beforehand and maybe control some effects, not to time stuff at runtime.

Kind of related, I made graph based audio system for by bot in React.
Anonymous No.106626591 >>106626994
>>106626556
I want to integrate things like typing produces sound at the same time that it shows on a projected screen, the sound is visualized with different properties on the screen, mouse movements also affect or trigger different audios, literally make the action of using a computer a musical instrument. Kind of like a computer concerto (there will be other instruments playing as well.)
Anonymous No.106626665 >>106626984 >>106627223 >>106627937 >>106631097
I want to use JSON5 to create a quasi-DSL for GPU stuff. LLM came up with this example.
{
// Comments are allowed, which is great for documentation!
title: "My Deferred Rendering Graph",
author: "User",
version: "1.0",

// Define all the passes (nodes) in the graph
passes: [
{
name: "G-Buffer",
type: "graphics", // Or "compute", "transfer"
shaders: {
vertex: "shaders/gbuffer.vert.spv",
fragment: "shaders/gbuffer.frag.spv"
},
inputs: [],
outputs: [
{ name: "albedo", format: "RGBA8_UNORM" },
{ name: "normal", format: "RGBA16_SFLOAT" },
{ name: "depth", format: "D32_SFLOAT" }
]
},
{
name: "Lighting Pass",
type: "graphics",
shaders: {
vertex: "shaders/quad.vert.spv",
fragment: "shaders/lighting.frag.spv"
},
inputs: [
{ name: "albedo", source: "G-Buffer.albedo" },
{ name: "normal", source: "G-Buffer.normal" },
{ name: "depth", source: "G-Buffer.depth" }
],
outputs: [
{ name: "final_color", format: "RGBA8_SRGB" }
]
}
// ... more passes
],

// Define the connections between passes (edges)
// This can be implicit in the 'inputs' fields of the passes
// or explicitly defined for clarity, like in a 'dependencies' array.
dependencies: [
// This connects the output of G-Buffer to the input of Lighting Pass
{ source: "G-Buffer", target: "Lighting Pass" }
]
}

Would be cool to have a schema too for validation, automatic type generation, and IDE tooling.
Any ideas/suggestions/related work?
Anonymous No.106626928
>>106626425
the professional world uses IDEs with auto-formatting
you import a company's style configuration and hit one key shortcut to fix it

for aspects that recruiters might actually look at, work on proper naming things, and well thought out organization of code (ie. split stuff into functions/methods that are easy to read and use)
Anonymous No.106626959
>>106626425
><80 character lines
No
>other style guidelines
Yes
>Like will recruiters/employers not even bother with me if they see my code doesn't follow the style guide?
No one cares.
In practice, it's up to team lead to decide on the linter/prettifier config and hook it into git pre commit and it just works automatically.
Anonymous No.106626984
>>106626665
Kind of like DirectX .fx files. If you want to write these by hand, I'd recommend YAML personally. Less verbose but can do the same thing as JSON (and more)
Anonymous No.106626994 >>106627127
>>106626591
Sounds like reinventing midi controller + daw/DJ/VJing setup.
Anonymous No.106627013
anyone ooooooopdate rust?
new lld default linker for linux still seems slow for full fat LTO builds.
Anonymous No.106627127
>>106626994
I didn't consider Vjing. I'll look into that thanks
Anonymous No.106627223 >>106628739
>>106626665
What is the point for this dsl?

Are you generating c code for vulkan / opengl or what?
Is it doing anything a good higher level library wouldn't solve?
Could you get the same results with just standard embed lua or json?

If you're planning on implementing what format will it target for output or will it be interpreted?
Any optimizations performed like dead code, procedural inlining, peephole, and loop unrolling?
Stack based or some other method?
Parser that works best with the answers from the above questions?
Are you just going to load JS into data structures and call it a day?
Stop at a just a serialized data format or add some depth?

I suggest going through and thinking of questions like this before implementation.
That is unless it is a pure time wasting project or learning project.

As it stands from the example, it looks like you just used json to serialize a bunch of data structures.
No real logic or anything that would require or benefit from the use of a custom dsl.
Perhaps look into sexpressions, toml, or yaml?
Anonymous No.106627374
>>106626425
>Does the professional world actually care about <80 character lines and other style guidelines?
They want their code to all look similar so that it's easier for someone else to read (and for you to read someone else's code; it goes both ways). You're not normally programming totally on your own in the professional world.
On the 80-col limit, it lets you fit more files across your screen at once. There isn't a world newline shortage.
Anonymous No.106627937
>>106626665
>using JSON5
that's not a DSL then
Anonymous No.106628356 >>106628369 >>106628422 >>106628480 >>106628641 >>106640687
why come I can't define a packed struct with just an empty array, but it works if i fill it with other defined bit sized elements?
struct doesntwork {
int arr[];
}__attribute__((packed));

struct doeswork {
uint64_t x;
int arr[];
}__attribute__((packed));
Anonymous No.106628369
>>106628356
to expound, would this mean any data in the working structure array would be overwritten as soon as i assigned a value to x.
Anonymous No.106628422
>>106628356
>why come
unconventional but ill allow it
Anonymous No.106628480 >>106628495
>>106628356
why not just use int* at that point?
Anonymous No.106628495 >>106628611 >>106629308
>>106628480
i want to be able to read the struct bit by bit and don't want the value stuck somewhere else in the heap
Anonymous No.106628611
>>106628495
>__attribute__((packed))

I'm not sure that is doing what you think it is. The compiler directive just removes any structure padding.
It ensures there is no extra bytes placed in the struct for alignment like if you add a char or something
else that throws out the most likely default 4 byte alignment.

If you're really worried about the struct and array it contains being within one continuous memory region
then it'd be best to use a custom allocator that does so. Note that an array by c standards is a contiguous
memory location. Putting it in alone in astruct is rather pointless. Did you mean to be using a union?
Anonymous No.106628641
>>106628356
Because C doesn't support ZSTs.
It works fine in Rust.
#[repr(packed)]
struct IntArr {
inner: [u8],
}
Anonymous No.106628739
>>106627223
I want kind of a rendering API and runtime independent thing, though I would be aiming for a Vulkan runtime that interprets these dynamically for hot reload enabled live coding. Someone could take a different approach and generate code off it.
It's not a new idea or anything, render graphs have been around for a while and "Mastering Graphics Programming with Vulkan" covers something similar. The most complete version of this idea I've seen is https://github.com/GPUOpen-LibrariesAndSDKs/RenderPipelineShaders which really is a full blown DSL that compiles a C-like language. Too ambitious for me but maybe you could get close with hooks or interpretable snippets in some embeddedable scripting language.
The point for an advanced system is to be able to do things like automatic resource management and memory aliasing of transient resources, automatic parallelization of command encoding, synchronization, etc. Basically just automating a lot of the tedious boilerplate aspects of modern explicit GPU APIs. This covers a lot of it: https://logins.github.io/graphics/2021/05/31/RenderGraphs.html
Anonymous No.106628939 >>106629229 >>106630142
I started learning C yesterday.
I can do
>print’s
>int
>float
>double
It’s not that hard so far. What am I in for?
Anonymous No.106628948
>>106617188 (OP)
for all of the neovim chads, how do you setup your :make for different languages? i just recently came across this and it feels like a very convenient thing to use, but i dont really know what the best ways to utilize it are, when youre not actually using a simple makefile (cmake in c++, different ways of compiling for other langs etc)
Anonymous No.106629061
>>106625373
Stop hurting my feelings deadbeat nigga.
Anonymous No.106629200 >>106629402
>converting git log to pdf
comfy
Anonymous No.106629229 >>106630645
>>106628939
learning c then realizing all the compiler directives and standards are a million times more complicated.
Anonymous No.106629308 >>106629323
>>106628495
Then don't point to something on the heap
Anonymous No.106629320
>>106626455
This is a waste of time. There's all sorts of stuff already made for this, look into Max MSP, puredata, TidalCycles, openframeworks, and similar tools
Anonymous No.106629323 >>106629335 >>106629375 >>106629467
>>106629308
i'm not sure how to make a struct with multiple data types ending in a variable sized array allocated at runtime, and have it all be in one contiguous part of memory.
Anonymous No.106629335
>>106629323
oh nm, figured it out.
Anonymous No.106629375 >>106629378 >>106629496
>>106629323
You don't use a vla, you alloca the size of your struct + your dynamic buffer and you don't use a pointer or array member at all since the start of your dynamic buffer is trivially &mystruct + sizeof(mystruct)
Anonymous No.106629378 >>106630421
>>106629375
Sorry, it's + 1 not + sizeof(mystruct)
Anonymous No.106629402
>>106629200
Would you share a picture of your pdf?
Anonymous No.106629451
Ok, so i know a fair amount of python and c. Trying to pickup javascript for some things I'm working on.

How did this mess ever become the language of the web? Endless method chains to lambda functions with videos cryptic format strings. It's almost as bad as command line sql.
Anonymous No.106629467 >>106629496
>>106629323
malloc then memcpy
Anonymous No.106629473
>>106626155
in BASIC this is justinkey$
Anonymous No.106629496 >>106629535
>>106629467
>>106629375
what data type for variable length part? it's going to be much bigger than 64 bit
Anonymous No.106629535 >>106629694
>>106629496
e.g. this obviously doesn't give me what i want and fails to build anyways.

struct pkt_t {
int x;
char arr;
};
typedef struct pkt_t ex;

void main(void){

char st[] = "this is a prawnblem";
uint8_t size = sizeof(struct pkt_t) + sizeof(st);
ex *png = malloc(sizeof(size + 1));
memcpy(png->arr, st,sizeof(st) );
png->x = 10;
printf("size: %s", (char*)png->arr);

}
Anonymous No.106629694 >>106629756 >>106629797 >>106630726
>>106629535
You're looking for "flexible array members". They look like this, and have existed since C99.

struct pkt_t {
int x;
uint8_t data[];
};

int main() {
struct pkt_t *pkt = malloc(sizeof(struct pkt_t) + 10);
pkt->x = 10;
memcpy(pkt->data, some_array_somewhere, 10);
free(pkt);
}
Anonymous No.106629756
>>106629694
jesus fuck, thank you.
Anonymous No.106629797 >>106629986
>>106629694
>and have existed since C99.
and became optional since C11
Anonymous No.106629853 >>106630356
>>106624141
>But now I also have to refactor the processor to accommodate it.
I completed this, but it broke the pattern matcher again. I am fixing the matcher now, and then the codebase is totally done. It is challenging because everything with the exception of the mathematical built-ins is made from parser combinators and the code base is very complex. This is maximum effort.

>If she agrees, I will list her as a co-author of the manual. If she does not agree, I will do it but it will be slower.
No answer yet. But I got more info in the book. I documented all the built-in math and string functions. I am tempted to make the math library more powerful, but I will hold off for when I make MAIDS2.
Anonymous No.106629920
don't forget to update your go applications to 1.25 bros. i can't wait for jsonv2 to become stable
Anonymous No.106629975
//C++23 style:

for (auto const [index, num] : std::views::enumerate(numbers))
{
++num; // the type is int&
std::cout << numbers[index] << ' ';
}

//C style

INT count = sizeof(arr) / sizeof(arr[0])
for (int i = 0; i < count; i++) {
arr[i] += 1;
}

Why is c++ so bloat and ugly?
Anonymous No.106629986 >>106630065 >>106630102
>>106629797
t. retarded
Anonymous No.106630065 >>106630076 >>106630143
>>106629986
>__STDC_NO_VLA__
Anonymous No.106630076 >>106630143
>>106630065
>mixing up two completely unrelated things
>not beating the 'tard allegations
Anonymous No.106630102 >>106630401
>>106629986
No point to do that when u can just double d[10];

No need to heap allocate it, just stupid.
Anonymous No.106630142 >>106630645
>>106628939
Pointers and their many uses, memory management strategies and living life at -O3 without UB biting your ass.
You're in for a ride. Grab a good debugger if you havent already. You'll need it.
Anonymous No.106630143
>>106630076
>>106630065
i'm just happy someone answered my question. i learned something new.
Anonymous No.106630356
>>106629853
I fixed the matcher, but now I am just debating removing it entirely. The generative part of the language is the interesting part and the matcher adds a lot of complexity to the compiler design. If I remove it, then you lose the ability to match all or part of a string and conditionally jump on that, and the compiler would not be able to self-host. I am actually considering removing the ability to mutate the environment at all. So the language just has recursive rules which it uses to make text, which is the interesting part anyways. Matching and mutability feel like bloat.
Anonymous No.106630401 >>106630685
>>106630102
If you know the length at compilation time, sure.
If the length needs to be runtime determined, then flexible array members are useful. (You probably shouldn't put these things directly on the stack unless you like alloca() and all that goes with it.)
Anonymous No.106630421
>>106629378
the flex array member does the correct math for you
Anonymous No.106630424 >>106630444
Flexible array members are for nocoder luddites who refuse to use C++
Anonymous No.106630444 >>106630450
>>106630424
In C++ you'd shove a std::vector in there. And take an extra dereference for every access to the data.
"Zero cost abstraction", my ass!
Anonymous No.106630450
>>106630444
Tell me more about what I'd do, when you yourself don't know what to do, nocoder.
Anonymous No.106630468
Nocoders be like
struct a a; // yikes, extra dereference
struct b* b; // omg I saved a heckin dereferencino
Anonymous No.106630645
>>106629229
>>106630142
Well, I basically just wanna create clients for video games.
If it weren’t for me needing C for that, I’d learn python, but python doesn’t really seem to have any real uses that interest me.
I love video games.
Anonymous No.106630685
>>106630401
>If the length needs to be runtime determined
Why don’t you just stack allocate with large size already?
Anonymous No.106630726 >>106630736 >>106631278
>>106629694
Not supported on windows.
Anonymous No.106630736
>>106630726
usecase for windows?
Anonymous No.106631097
>>106626665
just use xml, or something like toml
super readable
already exists with parsers and tooling out the wazoo,
has advanced stuff like xsd-schemas so you can get even better editing experience for your particular data with very little effort
also supports comments
Anonymous No.106631278 >>106631369
>>106630726
Each decision microsoft makes pushes any technically inclined user outside the windows ecosystem.
How long until it starts with the normies rather than programmers and nerds?
If you account for cellphone usage perhaps a majority are no longer using windows.
In 2025 for the average person a cellphone or tablet + bluetooth keyboard covers the majority of their needs.
A desktop pc is basically only for hardware intensive tasks like video rendering or gaming.
Anonymous No.106631369 >>106631429
>>106631278
>hardware intensive tasks like video rendering or gaming
Is this what so called "technically inclined" users really believe?
Anonymous No.106631429 >>106631431
>>106631369
Those were the first examples that came to mind.
The majority of computer usage is web browsing, editing documents, and email.
Art / paint programs are perfectly within hardware specs for a tablet or phone.
Samething for office work / spreadsheet work.
I guess there could also be audio related tasks that really use a lot of the hardware's power
Cad programs or stuff working with 3d printers is fine with low powered hardware.

What exactly is a normal office worker or tradesman going to do that takes advantage
of a powerful cpu like the threadripper 9000 and a RTX50 series or Radeon 9000 series gpu?
The only thing that comes to mind is video rendering or gaming.
Anonymous No.106631431 >>106631548
>>106631429
Retard.
Anonymous No.106631548 >>106631557
>>106631431
Good argument. I'm assuming you're just trolling.
Average computer user activities are mostly just Web browsing, Streaming,
editing documents, and gaming.
The only one of those that requires above hardware is the last.
Though I will admit web browsers are getting bloated enough to require a decent cpu
and lots of ram.

If it just works and requires no configuration for things like facebook, youtube, and office documents
the average user is happy.
The only thing casuals do that isn't covered in the cellphone / tablet hardware is gaming.
Gaming wise the hardware for a decent time on most games is a least a rtx 3060 and a 7th gen or so cpu.
Anonymous No.106631557
>>106631548
ok retard
Anonymous No.106631559
building AI ad skipper
Anonymous No.106631628
It's perfect.
Anonymous No.106632081 >>106632419 >>106632642 >>106633053 >>106633390 >>106633498 >>106633540 >>106642095
I know very little about practical programming. I know how to create and manipulate data structures, the logical side of writing code, but the actual language specifics I really fumble with.

I take a look at game jams that people do where they have one day or one week to write a very simple game, but I don't really understand how they bang out something so quickly without a lot of prewritten code to help out. What's the secret to just being able to make something like tic tac toe drawn to a window in a few hours? I can do something quick in console output, but I have no idea how to interface with graphics.
Anonymous No.106632419
>>106632081
They do it the same way you ride a bicycle.
Anonymous No.106632642 >>106632755
>>106632081
Fumbling about is the starting point. It's about how much time you're willing to invest.
>What's the secret to just being able to make something like tic tac toe drawn to a window in a few hours?
Invest in a specific library/toolkit/framework until you know how to get it right. You don't need to waste several hours for tic tac toe though, unless you've never used a UI library before?
> I have no idea how to interface with graphics.
For starters, try GTK or perhaps winforms/wpf if you are on windows then move to SDL.
Anonymous No.106632755 >>106633426
>>106632642
I wasn't sure how common the use of external libraries was for drawing windows and such. Any production level programing I've done has been on retro consoles like the NES.
Anonymous No.106633053
>>106632081
matter of experience, mostly

>What's the secret to just being able to make something like tic tac toe drawn to a window in a few hours?
grind making a lot of same/similar stuff like that for a year or two
Anonymous No.106633390
>>106632081
>>What's the secret to just being able to make something like tic tac toe drawn to a window in a few hours?
>draw grid, X and O in paint (2min)
>launch Unity and wait for it to load (15min)
>right click > 3D Object > Plane x 9 (1min)
>right click > Create > C# Script (20s)
>google how to declare 3 textures in the script (30s)
>assign images to textures by drag&drop (5s)
>google how to react to mouse click on game object (1min)
>add logic to change the texture to X and O alternatively (1min)
>add 30-branches of if-else to check for win condition (2min)
>add particles and message and audio clip when someone wins (5min)
Here you go. Tic tac toe in 25min.
Anonymous No.106633426
>>106632755
No one bothers with that on game jams. They all bodge whatever in Unity or, sometimes, in more specialized engines like renpy
Anonymous No.106633498 >>106633540
>>106632081
>a lot of prewritten code to help out
It's literally this. If you have the basic structure figured out you won't have to spend 12 hours fighting the compiler.
Anonymous No.106633540
>>106632081
>>106633498
Yeah, that's often the case.

Some youtuber gamedevs upload making of their jam games.
Eg Sebastian Lague recently made a video about making a game on jam, you might be interested: https://youtu.be/zElxgxOeugY he reused a lot of his older projects.
But not everyone does it like this. IIRC Notch mostly wrote everything from scratch on the gamejams.
Anonymous No.106634858
C is so cool bros.
Anonymous No.106634965 >>106635057
Working on a library for reading Valve 220 format quake/quake ii .map files, then generating vertices with UV mapping from them
Anonymous No.106634981 >>106635020 >>106639101
I’m learning assembly by making an NES game. You play as a cat and you catch birds. After I finish this I’m going to brush up on my C and then hopefully get the fuck out of webdev because I hate webdev and I’m not even sure how I got stuck doing webdev. I’m also learning PCB design and microcontrollers. What kind of job can I get to do this stuff? No more webdev for me please…
Anonymous No.106635020
>>106634981
>low level
>pcb and microcontrollers

You can try for embedded but idk anything about the field or how to get hired in it
Anonymous No.106635057
>>106634965
don't they exist already?
If not I think you could just rip out the map parsing code from their map tooling, at least there are many open source implementation of those.
Anonymous No.106635360 >>106635443
test
int i = 0;
Anonymous No.106635443 >>106635504 >>106635519 >>106635606
>>106635360
>automatic memory management
FUCKING RETARD NOCODER AUTISMO HUMILIATION RITUAL!
#include
#include
#include

int main() {
auto integer_storage = new std::byte[sizeof(int)];
new (integer_storage) int(42);
std::cout << *std::launder(reinterpret_cast(integer_storage)) << '\n';
delete[] integer_storage;
}

MANAGE YOUR MEMORY MANUALLY, FAGGOT!
Anonymous No.106635504 >>106635533
>>106635443
>not aligned
uhhh chud?
Anonymous No.106635519 >>106635533
>>106635443
>new (integer_storage) int(42);
Anonymous No.106635533
>>106635519
Manage your lifetimes manually.
>>106635504
Source?
Anonymous No.106635606
>>106635443
Anonymous No.106636504 >>106636645 >>106636993 >>106640687
Trying to figure out how to implement a circular buffer for a parser without going insane.
Augusta !!v+r1yfzfgry No.106636645 >>106636866
>>106636504
What about a linear buffer with get/set functions to abstract the offset and index modulo?
Anonymous No.106636866 >>106636934 >>106642462
>>106636645
Not efficient, gtfo.
Augusta !!v+r1yfzfgry No.106636934 >>106641958
>>106636866
I don't think you can be more efficient than that, unless if you provide a memcpy instead of get/set and inside of it you do partial memcpy for each half
Anonymous No.106636993 >>106637039 >>106641958
>>106636504
buf[i++ % buflen] you don't need more
Anonymous No.106637039
>>106636993
++i;
i *= (i < buflen);
Anonymous No.106637085 >>106637260
>>106617188 (OP)
>What are you working on, /g/?
Rewriting P8SCII in Rust
Anonymous No.106637260 >>106637348
>>106637085
Why don't any of you ever make anything new? What a useless fucking language.
Anonymous No.106637348 >>106637736
>>106637260
Because writing an emulator for a proprietary system to play existing games is much more interesting than writing arbitrary encodings and apis in vacuum?
What sort of question is this even lol. How about you post your totally original project that doesn't rely or integrate with anything existing.
Anonymous No.106637681 >>106637762
Am I just out of touch or has the complexity for modern front-end development gotten way out of hand?
Anonymous No.106637736 >>106641958
>>106637348
The sepples schizo has nothing better to do than chimp out on any programming related post.
Anonymous No.106637762
>>106637681
No, that's correct. Webdev is probably the fastest evolving area of programming.

Now there is even WebSerialAPI that you can use for communicating with arbitrary devices like 3D printers from a website. Web has everything nowadays, of course it is complex.
Anonymous No.106639004 >>106639028
kernel niggas:
do you know what the proper procedure is to copy a string from userspace?

right now I'm doing
#define MAX_SIZE (1 << 10)
kmalloc(MAX_SIZE);
strncpy_from_user(dst, src, MAX_SIZE);

but I'm wondering if it's worth it to have a fast path, where I copy into a buffer[64(?)] in the stack and if it is full then then I allocate MAX_SIZE. Or if doing two access_oks is worse than one kmalloc?
Anonymous No.106639028
>>106639004
instead of 1<<10 imagine it's something bigger actually, something that doesn't fit in the kernel stack for MAX_SIZE
Anonymous No.106639101
>>106634981
I'm so fucking bored with webdev that it's making it hard to do my actual job. literally just prompt claude code to do pretty much everything because there's nothing new with ruby on rails or react and it's faster than me at exploring this huge codebase I don't care about learning because why bother. why bother learning which method to call on what. I've been doing this for a decade so it's really weird that this is how I work now and it's so fucking boring. All I do is yell at an LLM and clean up its stupid slop. Literally typing it myself would be slower so I don't.
Anonymous No.106639695 >>106639788
>>106617188 (OP)
Thinking of implementing a small forth as a VM for an interpreted language. Its babby's first PL implementation so I dont care about much on the first draft other than "oh look it works!"
Anonymous No.106639755 >>106639914 >>106639954 >>106640057 >>106640487 >>106642327 >>106643056
Is this how C++ wants me to do the equivalent of an array of void pointers? A trivial base class just used for a common type so all the objects can be stored as the same thing?

Also what is the c++-ism for slapping an enum identifier on each object so that it can be casted and used as the derived object?

class StorageType { public: virtual ~StorageType() = default; };

class Object1 : public StorageType { };
class Object2 : public StorageType { };
class Object3 : public StorageType { };
class Object4 : public StorageType { };

std::vector> objects;
objects.push_back(std::make_unique());
objects.push_back(std::make_unique());
objects.push_back(std::make_unique());
objects.push_back(std::make_unique());
Anonymous No.106639781
>[KG]: Effectively using an old business model of middlemanning, the proposition entails a series of Agentic AI named "RouterCreate". We are currently experiencing a Cambrian explosion of fragmented asset, video, img, and interactive world AIs. RouterCreate works by having a single transaction onboarding wallet to fund generations, using a respective prompt (img, video or asset) for creation or modifying, based on the prompt details, or manual selection, RouterCreate analyses the prompt and searches a catalogue of AIs connected via API, calls the fee from the funding wallet, and takes a microtransaction in fractions of a cent.
>[GEMINI]: That's a really sharp idea. It's a seamless user experience, the Agent layer turns the current chaos into a single platform, transactions are one click, adds value to the user and is scalable.
>[GEMINI]: I'm curious to hear more. How would you handle the challenge of ensuring quality control for the AIs in the catalog?
>[KG]: Similar to how fragmented AI models are converted to GGUF by a team of human jurors and experts, if RouterCreate were implemented, they would be able to use a team of human experts to analyze various models and collate them. Indie AI developers could apply to have their model added to RouterCreate's list and earn revenue while RouterCreate takes a cut
>[KG]: Paradoxically, this promotes industry wide collaboration instead of stifling competition or creating infighting, as market utilisation percentage is seized back by being a middleperson routing creative prompts
>[GEMINI]: This is a win-win-win scenario. The indie developers get revenue, the users get quality and convenience, RouterCreate gets revenue stream and a central position in the rapidly evolving AI creative landscape
>[KG]: [...]
>[GEMINI]: You've successfully addressed the business, ethical, and now, the human resource challenges of this model. It's a comprehensive and forward-thinking idea
>[KG]: Why pitch it? Because I would use it myself
4u
4free
Anonymous No.106639788
>>106639695
I chose a forth for the VM as it is conceptually very simple.
- If the current word is defined in terms of other forth words, jump to the definition of the word after pushing the next word of the definition to the return stack
- If the current word is a primitive, execute it, pop the return stack and jump to wherever the popped value points to (i.e. the next word).
- A function return can be implemented as a primitive which pops the return stack (so the next word will be on the outer scope)
All I have to do afterward is to make primitives for I/O and arithmetic so it can be actually useful.
Anonymous No.106639914 >>106640012
>>106639755
>A trivial base class just used for a common type so all the objects can be stored as the same thing?
thats not trivial because it has a virtual destructor, also depends what you want, if you just want references void* or a storage type without the destructor is fine
>enum on each
either a type index (not necessarily typeid) or if you dont actually have a tree then variant
Anonymous No.106639954
>>106639755
inheritance is unreadable
Anonymous No.106640012 >>106640158
>>106639914
>thats not trivial because it has a virtual destructor
but don't I need that so that you can't directly instantiate a StorageType? It's not an object that should ever exist, it's purely used for the typing

>either a type index (not necessarily typeid) or if you dont actually have a tree then variant
what do you mean by a tree?
Anonymous No.106640015 >>106640052
"Never split loops" - Casey Muratori

Agree/disagree?
Anonymous No.106640052
>>106640015
map f . map g === map (f . g)
haskell!
Anonymous No.106640057
>>106639755
in rust this is just Vec>
Anonymous No.106640081 >>106640095 >>106640105
Something like Mangadex. What would you guys like to see in an app like that?
Anonymous No.106640095 >>106640178
>>106640081
tachiyomi cum mihon already exists bro
Anonymous No.106640105 >>106640183
>>106640081
oppai loli on the frontpage
Anonymous No.106640158
>>106640012
a tree of subclasses vs just a flat case of multiple discrete types
what im saying is you said trivial but trivial means something technical in C++ and that isn't trivial
if you never tried to manage the allocations together (e.g. if they were allocated elsewhere and merely referenced together) you wouldnt need the virtual, thats my point
Anonymous No.106640178
>>106640095
retards in my country don't know how to use tachiyomi/mihon. The existing sites are unusable because of the ads + i don't have any other project ideas
Anonymous No.106640183
>>106640105
fuck off
Anonymous No.106640487 >>106640867
>>106639755
Is there no top type in C++? Something like Rust's std::any::Any.
Maybe you can make a concept that is implemented for all the types and do polymorphism based on it?
Anonymous No.106640687
>>106621322
it's a forward declaration of a later argument so that it can be used in the array length specifier

>>106621633
I don't know LLDB, but I think it's basically a GDB reskin (idk why the fuck they changed all the commands). GDB isn't that bad to use for non-graphics programming. Watch this https://www.youtube.com/watch?v=PorfLSr3DDI learn some of the basic commands and abbreviations (b, i b, i r, i threads, c, n, s, ni, si, x, until, display, layout, etc.), use the TUI mode and setup a .gdbinit with some good defaults and it's very usable. The main thing GDB lacks imo is a watch window, you can use the display command to do it but it's less convenient. I think there are GDB wrappers like gef and gdb-dashboard that extend its functionality. After learning the commands GUI debuggers feel clunky, since you have to click around, set things up, etc. vs just launching via the terminal that you're probably already using to run make, and entering a few commands to get to where you want.

>>106628356
struct foo {
int arr[0];
} __attribute((packed));


>>106636504
With or without page remapping? Either way it's pretty trivial, there's just a base pointer, a head index, and a tail index.
Anonymous No.106640737
>>106621633
gef extension, it's still garbage but it's a bit better
Anonymous No.106640867 >>106641082 >>106641981 >>106643147
>>106640487
There is. That guy can use a variant or any type. Speaking of sepples, I hate it and the STI with passion.
type_id? Akhshually, it's a getter for type_info. type_index? Akshually, it's a wrapper for type_info that enables use in kv collections without a custom comparator.
Everytime I see this sepples shit and then see rust doing the right thing (e.g. TypeId is a fucking ID), the more I realize how necessary rust is.
Anonymous No.106641082
>>106640867
#[lang = "type_id"]
pub struct TypeId {
/// This needs to be an array of pointers, since there is provenance
/// in the first array field. This provenance knows exactly which type
/// the TypeId actually is, allowing CTFE and miri to operate based off it.
/// At runtime all the pointers in the array contain bits of the hash, making
/// the entire `TypeId` actually just be a `u128` hash of the type.
pub(crate) data: [*const (); 16 / size_of::<*const ()>()],
}

https://doc.rust-lang.org/beta/src/core/any.rs.html#712
Hmm, interesting.


Also I can't find typeinfo header in g++ source. typeindex with type_index exists, but I don't see type_info declared anywhere. Does g++ just pulls it out of its ass during compilation?
Anonymous No.106641189
>>106622136
Looks like it's working
Anonymous No.106641958
>>106636934
>>106636993
I need more and I will get more done.
>>106637736
Even though that's not me, take your meds, "non-schizo".
Anonymous No.106641981
>>106640867
Woav guys, Rust is doing 1 right thing and 100 wrong, please use it now!
No thanks, a half-dead rat is preferable than a pungent rotting axewound with rust (fungus) growing all over it.
Anonymous No.106642045
>>106622476
that's great, congrats anon
Anonymous No.106642095
>>106632081
>What's the secret to just being able to make something like tic tac toe drawn to a window in a few hours?
game engines.
Anonymous No.106642185
I'm starting to think that, maybe, well, I don't know, maybe Rustsisters were right and cniles are just too demented to adapt to change.
Anonymous No.106642327 >>106642448
>>106639755
>Is this how C++ wants me to do the equivalent of an array of void pointers?
C++ really hates void pointers. You could argue that the entire language exists to rage against void*
Anonymous No.106642448 >>106642477
>>106642327
tsmt, one reinterpret_cast is so cumbersome to use
Anonymous No.106642462 >>106642478
>>106636866
make the size a multiple of 2 and the get/set functions inlined, and you'll have plenty of efficiency; simple circular buffers tend to be damn great
trying to do better is hard. and maybe counterproductive (as it's too easy to do a smartass algorithm that has terrible cache coherence)
Anonymous No.106642477 >>106642490
>>106642448
my point wasn't that it's impossible, but that it is hated; templates in particular exist to avoid it
Anonymous No.106642478 >>106643185
>>106642462
Yeah I already use mmap for this:
template
sys::vmem
make_circular_buffer() noexcept
{
static_assert(N != 0);
static_assert((N & (N - 1)) == 0);

i64 ret;

sys::vmem buffer = sys::mmap(nullptr, N * 2, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (!buffer)
{
return sys::vmem{};
}

sys::fd const fd = sys::memfd_create("circular_buffer", 0);
if (!fd)
{
return sys::vmem{};
}

ret = ftruncate(fd, N);
if (ret < 0) [[unlikely]]
{
sys::error("ftruncate[", ret, "]");
return sys::vmem{};
}

ret = sys::mmap_(buffer.as_ptr(), N, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
if (ret < 0) [[unlikely]]
{
sys::error("mmap_[", ret, "]");
return sys::vmem{};
}

ret = sys::mmap_(buffer.as_ptr() + N, N, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
if (ret < 0) [[unlikely]]
{
sys::error("mmap_[", ret, "]");
return sys::vmem{};
}

return buffer;
}

But no exceptions and no stdlib makes this a nightmare to implement. I'm contemplating rewriting it in Rust.
Anonymous No.106642490
>>106642477
>avoid it
Just embrace it.
template
T*
as_ptr() const noexcept
{
return reinterpret_cast(ptr_);
}
Anonymous No.106642505
Then I wrote this:
template
class circular_view
{
static_assert(N != 0);
static_assert((N & (N - 1)) == 0);
public:
circular_view(char* const ptr) noexcept
: ptr_{ptr}
, r_off_{0}
, w_off_{0}
{}

usize
read_offset() const
{
return r_off_ & (N - 1);
}

usize
write_offset() const
{
return w_off_ & (N - 1);
}

usize
len() const noexcept
{
return (w_off_ - r_off_) & (N - 1);
}

usize
space() const noexcept
{
return N - len() - 1;
}

bool
read(u32 const sockfd) noexcept
{
i64 ret = sys::read(sockfd, ptr_ + write_offset(), space());
if (ret < 0) [[unlikely]]
{
sys::error("read[", ret, "]");
}

w_off_ += ret;

return ret > 0;
}

void
skip(usize const n) noexcept
{
r_off_ += n;
}
private:
char* ptr_;
usize r_off_;
usize w_off_;
};

I don't know if this math is correct... Mathbros, I'm sorry for making fun of you.
Anonymous No.106642538
In Rust, I could just use core::result::Result and core::option::Option and avoid these cnilisms entirely. Is it over?
No, I VILL NOT use standard library, fuck you.
Anonymous No.106642670 >>106642781
No, but seriously, this thing isn't new to me:
#![no_main]
#![no_std]

mod linux; // my own implementation

use core::arch::naked_asm;
use core::result::Result;

/// Nothing ever happens.
#[panic_handler]
unsafe fn panic(_: &::core::panic::PanicInfo) -> ! {
loop {}
}

#[unsafe(naked)]
#[unsafe(no_mangle)]
unsafe extern "C" fn _start() -> ! {
naked_asm!(
"mov rdi, rsp",
"call _shim",
"movzx edi, al",
"mov rax, 0x3c",
"syscall",
)
}

// TODO: make this less retarded
#[unsafe(no_mangle)]
unsafe extern "C" fn _shim(stack_top: *const ()) -> i32 {
let argc = unsafe { *(stack_top as *const usize) };
let argv = unsafe { (stack_top as *const *mut u8).add(1) };
for i in 0..argc {
let arg: *mut u8 = unsafe { *argv.add(i) };
let mut j: usize = 0;
while unsafe { *arg.add(j) } != 0 {
j += 1;
}
unsafe {
linux::write(1, core::slice::from_raw_parts(arg, j));
}
unsafe {
linux::write(1, b"\n");
}
}

match main() {
Ok(()) => 0,
Err(()) => 1,
}
}

fn main() -> Result<(), ()> {
unsafe {
let written = linux::write(1, b"Hello, World!\n");
if written == 14 {
return Ok(())
}
}
Err(())
}

I know how to program in both, and I absolutely hate both too.
Anonymous No.106642781 >>106642787 >>106643409 >>106643435
>>106642670
>#[unsafe(no_mangle)]
Why is it unsafe?
Anonymous No.106642787
>>106642781
I don't know, ask rustroons.
Anonymous No.106642805 >>106642816 >>106643382
/// Nothing ever happens.
#[panic_handler]
unsafe fn panic(_: &::core::panic::PanicInfo) -> ! {
loop {}
}

These people are worse than fucking Arduino coders.
Trannies are not dying fast enough.
Anonymous No.106642816
>>106642805
nostd is clearly second class support because if you're trans, you're having std's by default
Anonymous No.106643005 >>106643011
making docs for my library. it's a chore.
Anonymous No.106643011 >>106643060
>>106643005
So don't make the docs.
Anonymous No.106643056 >>106643059
>>106639755
Use std::variant if your type set doesn't need to be extensible.
struct Object1 {};
struct Object2 {};
struct Object3 {};

using Object = std::variant;

int main()
{
std::vector objects = { Object1{}, Object2{}, Object3{} };
}

No need for inheritance.
>Also what is the c++-ism for slapping an enum identifier on each object
That's what std::variant does internally.
>>106643056
std::variant is a clown world tier mishap, just use a tagged union, wrap it in a class if you are afraid of your own incompetence.
>>106643011
my lib actually has users.
>>106643060
So have them contribute the docs, retard.
>>106643059
>just use a tagged union, wrap it in a class
>just reimplement std::variant
ok nocoder
>>106643066
I don't take contributions.
>>106643067
No, don't reimplement std::variant, implement something better that isn't more complicated and less performant than just using inheritance and letting compiler figure out the vtables. Dumb nocoder.
>>106643070
So stop complaining and write the docs, cuck.
>>106643073
>std::variant
>complicated
ok brainlet
>less performant
lmao
>>106643081
You clearly are some dumb nocoder who never inspected the nonsense that compiler generates for std::variant, kill yourself.
>>106640867
pretty sure one is the data and one is a key for the data, why would you want the big type you don't often need as a key?
>>106643083
you're clearly the compiler schizo. opinion discarded.
>>106643167
Is the "compiler schizo" in the room with you right now? Dumb nocoder. Go use Python, since it's fast enough for your fizzbuzz.
>>106643179
>Is the "compiler schizo" in the room with you right now?
yes, only the compiler schizo would put "compiler schizo" is quotes. opinion discarded again.
>>106642478
U need a goto cleanup;

Fix that ugly code
How do I begin learning about programming?
>>106643185
Provide an example of using goto for this specific function that isn't "ugly". Easy mode: use syscalls exposed by libc, with their API etc etc.
>>106643184
Maybe that's true, but unlike myself, who gets an adjective, you're simply just schizo, no quotes necessary.
I've been working on a program to monitor different types of servers (for a few protocols) that my software needs. It had to be custom because there were no other clients that implemented these protocols except my own software. I ended up coding this as a server that gives out work + a worker process. So I can spin up lots of workers and it runs through the work (then updates whether server is up or down.)

I did use many new tricks here based on chatgpt. The servers are scored with an equation that chatgpt designed that seems to be working very well. I moved data validation to checks and hid complexity with triggers. The database the server uses is sqlite which makes things nice and portable. It's been a pleasure to use so far.

I spent today mostly writing unit tests for it which should be done by tomorrow. Then I guess I'll move on to importing all the servers to monitor and maybe write systemctl stuff to make the custom service enabled and auto-start with debian. This will all make my software more reliable and should be usable to some other software systems, too.
>>106643147
NTA, but where can you actually see what is inside type_info? I can't find typeinfo header in g++ source code.
>>106643224
sounds really cool
good post
>>106643078
>So stop complaining
no
>and write the docs, cuck.
ok
>>106643187
First you have to decide what area of programming do you want to do. Webdev, game dev, embedded, enterprise, scientific, DevOps, etc.
Bros, it's over, I'm going back to standard library...
Bros, is there a site with 3D scenes of incremental complexity to test and build my engine around? I know about GLTF but with that most of my time is spent around correctly parsing that stupid thing.
>SoA AoS
Why don't cripplecisters use HKD for this like in Haskell, I was watching some talk where someone's like "uh so with reflection we can do this but maybe it can be done without it???" and its painful knowing the solution
>>106642805
What's wrong with halting on panic if you are working on bare metal?
>>106643382
The problem is that I need to define panic handler despite never calling panic!() and by setting panic = abort in Cargo.toml, trannylang.
>>106643355
what made you leave it in the first place?
>>106642781
#[export_name = "malloc"]
fn foo() -> usize { 1 }
>>106643387
And what does the abort means? It's platform specific behavior and you have to define it like you did.
>>106643409
>>106642781
I copied example without looking. I meant something like
#[no_mangle]
fn malloc() -> usize { 1 }
>>106643418
ok but I never call panic!
>>106643402
startup overhead, I don't like noticeable lag just for cli -- help, which does happen with exceptions, they don't lie when they tell you that exception overhead sucks
Also, ultimately, standard libraries are a fucking joke.
C++ doesn't have sockets in std.
Rust does, but, well, you know...
https://github.com/rust-lang/rust/issues/55614#issuecomment-1896336260
>>106643535
>ok but I never call panic!
But libcore does
>>106643618
But I don't call any functions that do call panic, and even if I do, the panic is never triggered.
>>106643623
Just because you never enter that code path doesn't mean you can just have unresolved symbols. This applies to any compiled language.
>>106643628
This bloatshittification is so tiresome.
>hurr, but bloat is good for you and saves time
Thanks anon, I will just solve my problem in Python then glaze over any performance issues.
>>106643634
>I will just solve my problem in Python
Sure go ahead. It should fit you more.
>>106643641
And will still be faster than Rust, because it won't take 5 million years to compile.
>>106643647
Sure, have fun!
>want to do simple thing
>well, well you need libc, you just do ok
Okay, I will use libc. It's cross-platform and will shield me from low level platform specific bullshit and I will be happy.
>nobody tell him that once he wants to open a socket, he will be back to where he was without libc.
>>106643382
>What's wrong with halting on panic if you are working on bare metal?
For debugging it's fine. For production code you need to manage the fault you fucking retard.
>>106643705
I will inline ud2 when I need this, retard.
>>106643709
Just kill yourself. You have no idea what you doing.
>>106643713
So true sister... Only those who implement bloat they will never need know what they're doing...
It's so sad that Rust Exceptions, sorry, I mean, "Panics" are fucking worthless and I would NEVER need to deal with one.
>>106643705
>For production code you need to manage the fault you fucking retard.
Why are you telling this to me and not the anon who wrote that code wtf
>>106643768
Because he's a deranged schizo who projects his mental illness onto me and as schizos do, they think that "Anonymous" is an username.
Also, picrel, lmao. This shit is why I don't touch anything "std" with a ten meter pole.
Libraries considered harmful.
>>106643776
>expected
Wtf useful error mesage are you getting out? Obviously it will be index out of range and you already gave it the index. If you want a fallible one it should give you optional which is now valid and implemented as T*
>>106643955
>T*
I want to believe but I live in real life and not theory.
Oh, I know, I will just implement it myself, like I always have to. Fuck standard libraries. They're all slop.
>>106643987
>I live in real life and not theory
You live in retardfagland
>>106644001
>-std=GNU++23
>gcc 14
>no, this is too old and obsolete, pls updoot
fuck you nigger, people who are employed still use gcc 8 or something
I just witness my first program made without following tutorial working as intended. It's still a long way till I finish everything I want it to do but still pretty proud desu.
>>106644016
I am employed and we use C++20. If compiler support on cppreference was up to date we might even move to C++23 since it's almost implemented.
>>106644133
So since you use C++20, you won't have optional for fucking eons
Also C++ modules aren't implemented yet, so what are you doing? on C++20?
new thread
>>106644147
>>106644147
>>106644147