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


File: potential-guacman.gif (7 KB, 192x192)
7 KB
7 KB GIF
Welcome to the Daily Programming Thread. What are you working on, /g/?
Previous thread: >>102966547
>>
does it dramatically increase the size of my binary if I link every file to all the libraries I'm using?
>>
File: soon(TM).png (43 KB, 968x1048)
43 KB
43 KB PNG
>>103007187
client and server AES working flawlessly now
server now has more commands and better help pages for those commands, admin can make and delete rooms as well as toggle between public and private mode (where private means only whitelisted users can join)

I thought the voice was working and it kind of is but the quality is absolute ass for some reason and I think there's a hanging thread causing some error where you can't change the mic easily after joining a server and talking, so I got to fix that too
>>
>>103007193
Can do. Depends on the libraries.
But you could have just checked that yourself instead of asking here.
>>
File: antioxidant.png (140 KB, 825x3574)
140 KB
140 KB PNG
reminder, rust shills will never recover from this
>>
Thoughts? I was think I could improve this. I use the hashmap to make sure I don't add dupes.
int PreloadIconThemes(const char *theme)
{
IconTheme *icon_theme = LoadIconTheme(theme);

if (icon_theme == NULL)
return -1;

if (themes_map == NULL)
{
themes_map = HashMapCreate2((void*)UnLoadIconTheme, NULL);
themes_names = DArrayCreate(8, free, SearchThemeNameCmp2, NULL);
}

HashMapInsert2(themes_map, theme, icon_theme);
DArrayAdd(themes_names, strdup(theme));

if (icon_theme->parents->size != 0)
{
for (int i = 0; i < icon_theme->parents->size; i++)
{
char *parent = icon_theme->parents->data[i];
if (HashMapGet2(themes_map, parent) != NULL)
{
continue;
}

if (PreloadIconThemes(parent) != 0)
continue;
}
}

return 0;
}
>>
in C++ how do I create a map on a class of that classes own functions?
class MyClass {
public:
MyClass();
private:
enum class ID { A, B };
std::map<ID, std::function<void()>> mapping;

void foo();
void bar();
};

MyClass::MyClass() {
mapping[ID::A] = foo;
mapping[ID::B] = bar;
};

this doesn't work. I can't make foo & bar static because they are going to be using members of the class
>>
>>103007187
>What are you working on, /g/?
Currently reading Memory as a Programming Concept in C and C++
and thinking about how Go allows for multiple return values.
Hypothetically, that should also be possible in C,
as space for the return values is preallocated in the activation frame.
Anyway, so I'm currently making some abominations, trying to wrangle C
into accepting anonymous struct return types.

#include <stdint.h>
#include <stdio.h>

struct { int32_t a; int32_t b; } testFunction() {
return (typeof(testFunction())){ .a = 1, .b = 2 };
}

void main() {
typeof(testFunction()) c = testFunction();

printf("a: %d, b: %d\n", c.a, c.b);
printf("c: %lld\n", *((int64_t *)&c));
}

The typeof hack I got from: https://stackoverflow.com/questions/27858240/a/27858557
>>
>>103008086
#include <map>
#include <functional>

class MyClass {
public:
MyClass();
private:
enum class ID { A, B };
std::map<ID, std::function<void()>> mapping;

void foo();
void bar();
};

MyClass::MyClass() {
mapping[ID::A] = std::bind(&MyClass::foo, this);
mapping[ID::B] = std::bind(&MyClass::bar, this);
};


This should compile. You could also use a lambda which captures "this", that would probably be less readable but returns more useful error messages as compared to std::bind
>>
>>103007193
>g++
use --ffunction-sections and -LTO, tells the compiler to separate all functions into elf sections and to the linker to optimize out functions with duplicate code (templates) (by the way doesnt optimize away unused functions it seems), you dont have to worry about anything else
>>
>>103008104
multiple return values breaks ABI and since the Golang compiler uses memory local variables like all others there is not even a point, it is just syntax sugar, just use pointers to the returned variables, NASA makes all of their functions void and returns everything through pointers because avoiding casting or forcing a shit ton of boilerplate is le good apparently
>>
File: primer_malloc_3.png (701 KB, 1920x9950)
701 KB
701 KB PNG
Doesn't feel right not to. This is /dpt/ after all.
>>
>>103009502
post is way too long
>>
>>103009553
Then get medication for your ADHD.
>>
>>103009502
post is not long enough
>>
>>103009847
4chan has a limit of 10,000 pixels. It couldn't be longer if I tried.
>>
good evening
i hate XML
that is all
>>
>>103009867
use a smaller font
>>
>>103009888
Then people would be complaining even more about unreadability.
>>
>>103009894
good
>>
>>103009900
For whom?
>>
>>103009905
all of us
>>
>>103009920
Unfortunately (for all of you) I want people to read it.
>>
>>103009934
what will that accomplish
>>
>>103009934
noone cares about your dogshit lowelo retard opinions, autistic fuck
>>
>>103009943
A minor uptick in code quality across the board and a major uptick for my ego.
>>
get a load of this guy he thinks education works
>>
>>103009950
How would you know that? Are the voices in your head screaming at you again?
>>
>>103009970
look at the shit you wrote up, then accuse someone of being schizophrenic again, unaware autistic bot
>>
>>103009986
You're free to write up your own post if you dislike mine that much.
>>
i still dont know if i want my codebase be in C or C++
pros of C++
>function overloading
>raii for defer-like
>constexpr (probably doesnt matter tho)
>dont have to do the voodoo incantation for definition structs
>auto
pros of C
>can actually use designated initialization (could use tcc to get even faster compile times)
>faster compile times
>simpler to parse
>no function overloading so clangd doesn't kill itself on wrong function signatures
>'im programming in C' is cooler 'im programming C'
hmmmm
>>
>>103010377
>raii for defer-like
Don't. RAII is of the devil.
>>
>>103010377
>>auto
C23 has C++-like auto now, but it's far less "useful" because the C type system doesn't produce std::experimental::vector<std::chrono::timestampe::const_integer_type>::const_iterator<std::im_tired_of_this_bit> shit.
It's more of a thing to exist inside of macros.
>>no function overloading
C11 _Generic basically provides that, but it's not something people really do, because function overloading provides very little value.
>>
>>103010429
Function overloading provides little value on its own but it's very powerful in combination with templates/SFINAE
>>
File: malloc primer 4.jpg (133 KB, 1067x1280)
133 KB
133 KB JPG
>>
>>103010500
What's the alternative?
>>
>>103010486
i like it for math stuff (which i dont do often tho)
and for shit like StringFrom and IsValid
>>
>>103010377
>voodoo incatations
desu the only reason to use C++ are namespaces, something akin to consteval to generate functions with slight immediate-operand differences would be a godsend for certain projects
>>
File: malloc primer 4.5.jpg (280 KB, 1600x1920)
280 KB
280 KB JPG
>>103010510
>>
*without having to call them, like being able to generate them by initializing an array with pointers to them
>>
>>103010510
in 90% cases arena
in rest of the 5% arena allocator with free list (linked list of free nodes)
in the other 5% you just directly use mmap or virtualalloc and skip the malloc if you need malloc-like behaviour
https://www.rfleury.com/p/untangling-lifetimes-the-arena-allocator
https://www.youtube.com/watch?v=TZ5a3gCCZYo
>>
>>103010538
>in 90% cases arena
You can use arenas with malloc. This isn't about individual lifetimes, but about malloc.
>link 1
>link 2
Nobody read those.
>>
>>103010538
>linked list of free nodes
how about a bitmap of free blocks?
>>
>>103010556
>You can use arenas with malloc
are you sure
>>
>>103010510
Please stop engaging with the malloc schizo.
>>
>>103010564
You're repeating the sins of malloc now. Don't think in blocks or individual objects; think in program phases. Think multiple stacks.
>>
its a good thing c lets you control where the stack is allocated
>>
>>103010570
Yes. But you shouldn't.

>>103010573
Can't. He's me.
>>
>>103007187
just wrote 2 C programs to complement the webshit i am working on in like 1-2 hours, this language makes me so productive its incredible, FUCK it is nice not being one dimensional
>>
>>103010556
i read them and they were very useful
>>
okay i think im changing my codebase to c23
>>
>>103010703
He doesn't describe the PROT_NONE hack and the reserve-high/commit-low pattern though.
>>
>>103010717
>PROT_NONE hack
Speaking of, I found a guarantee that Linux won't count this against your process if you have overcommit disabled.
>https://www.kernel.org/doc/Documentation/vm/overcommit-accounting
>
How It Works
------------

The overcommit is based on the following rules

For a file backed map
SHARED or READ-only - 0 cost (the file is the map not swap)
PRIVATE WRITABLE - size of mapping per instance

For an anonymous or /dev/zero map
SHARED - size of mapping
PRIVATE READ-only - 0 cost (but of little use)
PRIVATE WRITABLE - size of mapping per instance


Also, who ever would have thought that this line of code was the culprit calling malloc(1) this whole time? Turns out it does a heap allocation for each entry in the directory. Rust's "high quality" stdlib is a joke.
>>
File: FindNextFileW.png (176 KB, 1448x3467)
176 KB
176 KB PNG
>>103010869
>PRIVATE READ-only
So effectively what virtual address space allocation is already doing, only with PROT_NONE instead of PROT_READ. And you want it to be PROT_NONE just in case you forgot to commit the memory, because accidentally reading such pages should trigger a reliable segfault.

>Rust's "high quality" stdlib is a joke.
Which system again? Because this might be a wrapper issue, see FindNextFileW over on Windows.
>then again they should've just done their own wrappers with better memory management
>>
>>103010591
it doesn't though?
>>
when should you make another function / a bunch of different functions instead of just allowing a variety of options to be passed to a function via a struct?
>>
>>103010994
Depends on the circumstances and your system. On 64-bit Windows the first four parameters are always passed on via registers (six on Linux) - if you promise the compiler not to modify them (const) and the parameters are the same (AND the compiler is smart enough to not clobber these registers during a function, which is not a given at all), then passing them by value is by far the fastest way.

Alternatively if you have more arguments than register arguments (meaning they spill onto the stack), then push instructions are smaller and faster than movs (however now you're relying on the compiler to generate push instructions, and they don't always do that. Not even often. Not even usually). Meaning that on average it's better to use a struct.
>>
>>103010977
>And you want it to be PROT_NONE just in case you forgot to commit the memory, because accidentally reading such pages should trigger a reliable segfault.
Indeed, and since PROT_NONE mappings are more restrictive than PRIVATE READ-only, it's makes sense that it also doesn't count against overcommit.
>Because this might be a wrapper issue, see FindNextFileW over on Windows.
This is Linux, where Rust calls glibc's readdir function which doesn't perform any allocations per directory entry. Instead, the culprit is this innocent looking line of code in the Rust wrapper for it, which copies glibc's perfectly fine string to the heap.
>https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/fs.rs#L787
>>
>>103011087
Is it fixable?
>>
>>103011065
This answer so obviously has absolutely nothing to do with what the other anon was asking.
>>
>>103010717
what hack and what pattern?
>>
>>103011152
Yet you didn't answer the post with what the voices in your head were screaming at you was the proper question. Curious.
>>
>>103010717
>PROT_NONE hack
you mean you initially make the arena with something like
>mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>
should I use MADV_HUGEPAGE with memory arenas or just don't bother with ti?
>>
>>103011125
Basically no, since the API for read_dir assumes the returned DirEntry struct contains the filename as a heap allocated string. Changing it to be a reference to the temporary one returned by glibc would introduce a ton of self-inflicted lifetime problems and be an API break.
As a bonus, depending on what function you call to get the heap allocated string out of DirEntry, you might end up making ANOTHER allocation.
>>
>>103011206
You can if you want, but Linux will likely use them anyway if you commit in 2 MiB aligned chunks if your distro has transparent huge pages enabled (look in /sys/kernel/mm/transparent_hugepage/enabled).
>>
>>103011206
Depends. THP are OK if you have no idea how big the chunk of memory you're dealing with is going to be and the mapping is sufficiently big, but they're not going to be as effective as huge pages allocated via mmap.
>why?
Because of alignment. mmap doesn't know that you're going to use madvise on the pages later on, so it'll just churn out whatever pages with the smallest alignment it can find, which may be utterly unsuitable for 2-MiB or 1-GiB pages - which means that you'll still end up with a bunch of small pages at the beginning and end of your mapping (unless you're lucky enough for mmap to get the alignment just right, which is unlikely).

On the other hand, if you know exactly how much memory you'll need, then just allocate it through mmap and ignore madvise.
>>
>>103011065
that's cool, but when should you make another function / a bunch of different functions instead of just allowing a variety of options to be passed to a function via a struct?
>>
>>103011256
>so it'll just churn out whatever pages with the smallest alignment it can find
This is incorrect. mmap naturally returns 2 MiB aligned addresses if your mapping is 2 MiB or larger, at least when I've tested it.
>>
>>103011352
>at least when I've tested it
It's been admittedly some time since I've tested it myself - we're talking pre-COVID.
>>
>>103007187
>What are you working on, /g/?
(print 'cat-pun)
>want to make a cat rpg
>also want to learn programming for its own sake
>write a function to roll dice (in lisp)
>don't know what to do next
Should I just blindly fallow a tutorial? I don't know what to study to make what I want.
>>
>>103011578
you probably want to make a 2d tile-based RPG.
i'm sure there's plenty of repos in whatever l*sp you use.
>>
>>103010538
ok this is irritating because everything I've found on arena shows them using malloc to create the arena in the first place
why can't I just say unsigned char ARENA[65536] and call it a day?
>>
>>103011777
because if you do it on stack if you can only create limited of them
65k is too low
and with arenas you can abuse virtual memory (take from os terabyte of memory and lazily allocate it)
literally just look up mmap (tsoding has a vid on it) and replace call to alloc with call to mmap
>>
>>103011789
also if you create them on stack you are essentially making thread local arenas
you could do them with static but then other points apply
>>
>>103011789
ok well why can't I do the same thing with the stack? arena[1tb] or something memory is memory aint it?
>>
>>103011789
furthermore the whole arena concept doesn't explain how you avoid the need to reallocate memory within that arena, what if I create a list and realize later I have to expand it, then I'm right back where I was since I added something to the arena after my list and now I have to move the whole thing only now I'm basically rewriting all the built in commands to do it instead of trusting the compiler?
and why can't I just use std::vector<>?
>>
>>103011796
see >>103011795 and stack is usually limited in size so if you want to make portable software you probably shouldn't do it unless you know your program won't use more than few MiB of memory
>>103011811
yes in that particular situation you would have to reallocate but in most cases you can either calculate the exact size or put a reasonable upper boundary if you can't, you could do is a "chunked linked list" where you combine an array and linked list (something like List<T[256]>) it makes indexing not so free but maybe it doesn't matter depends on the case
>and why can't I just use std::vector<>?
just because you primarly use arenas in your program it doesn't mean you can't use other allocators
but why arenas are nice is say you have a function that allocates 4 vectors you will have to then remember to free all of them (sure you can use raii, but then you add complexity of raii+malloc to your program and arenas are more performant) with arena its just one call to free EVERYTHING (no matter how complex) in that function
(also just instantiating std::vector in your program will probably double your compile time)
>>
whenever a cppcon speaker says slop I assume they're from /pol/
>>
>>103008052
> Instead of Sway -- use Hyprland.
Why? Sway is written in C, and Drew isn't even a part of it anymore. It's also way superior to Hyprland.
>>
>>103011811
>furthermore the whole arena concept doesn't explain how you avoid the need to reallocate memory within that arena
>>103009502
>Of note is that Linux has a mremap syscall whose semantics remind a lot of realloc - but unlike realloc it doesn't perform a copy from older data to a new bucket, but instead *moves* the underlying mapping into another region of the virtual address space so that can be more easily extended if applicable *without actually copying anything*. I would highly advise against using this interface, firstly because it's a syscall, secondly because altering the page table requires other locks to be gotten (remember what I said about locks protecting your page table?), thirdly because any relocation destroys the "absolute pointers that never change" pattern, fourthly because Windows doesn't have a VirtualReAlloc or something similar to emulate the behavior, but fifthly and most importantly: it's really fucking useless, isn't it, what with that 16 TiB virtual address space reservation?
>>
>>103012718
Write this in a stupid static website or even a pastebin and I'll read it.
>>
>>103012731
Shit meant this
>>103009502
>>
>>103012718
Pt. 2.
>and why can't I just use std::vector<>?
>Well, it works by looking up if malloc has placed another bucket right next to the end of your particular bucket in the meantime. If there isn't, then realloc can just resize the thing in place, buf if there is ... well, it probably won't take too kindly if realloc gave its memory to some old new allocation. Chances are, in general, pretty high that realloc won't be able to resize your bucket without moving it someplace else entirely, which is called "relocation". Relocations are expensive. They're usually done by first allocating a new bucket with the new size, then memcpying the old data from the old bucket into the new bucket, and then freeing the old bucket. Hopefully you didn't have any dangling pointers on that old bucket, because that bucket's gone now. It should be noted that memcpy, even if it's a well optimized version (and it's not on Windows, I can tell you that), will still thrash your CPU caches, with the amount of damage done depending on how much data it copied (unless it's the kind of memcpy that does non-temporal shit. Non-temporal shit bypasses the cache. As in, even if it's already in the cache it's still going to bypass the cache. Which is retarded.)

>what if I create a list and realize later I have to expand it
If you need an item that remains forever expandable you're better off using a separate arena. It's not like you're exactly losing anything either, considering that the alternative is to rely on realloc and its bucket placements again.
>inb4 multiple arenas are too complicated
They certainly beat having to keep track of every single fucking bit of memory allocated by malloc, don't they.
>>
>>103012731
Pastebin doesn't like my schlock, so:
https://lainsafe.kalli.st/files/17301866764995.txt
>>
It seems to me like << and >> syntax is the worst possible way to introduce a programming language, yet it's how every C++ book starts out.
>>
Learning swift!
>>
File: 1718481489231840.jpg (13 KB, 142x250)
13 KB
13 KB JPG
>>103013113
then why's it taking you so long?
>>
>>103012916
Absolutely. There is a reason no other language does that.
>>
>>103012916
I just like how in bjarne's books he talks about modules as just the standard way to do things then makes like a footnote reference about how in the ancient past c++ programmers used to use things called "headers"
>>
>>103012689
His coomer buddy emersion is still part of Sway though.
>>
File: stroustrup_is_a_crybaby.png (59 KB, 1174x436)
59 KB
59 KB PNG
>>103013665
I'm still surprised people listen to Stroustrup at all. The man has no credibility whatsoever and has been a malefactor to software development for decades.
>>
>>103007187
why are guis still not a solved problem
>>
>>103013750
It's called WPF, chud.
>>
>>103013759
last time I fucked with wpf I got filtered, every little thing is like 8 billion levels of indirection
>>
>>103013759
no its not
>>
>>103013720
c++ is fine, it's devs who think they're obligated to use every feature the language contains in every project that's the problem
>>
>>103014197
Yeah, fortunately features like RAII are so easy to avoid ...
>>
>>103013836
WPF is frustrating, and it doesn't get attention anymore iirc. I'm not a webdev but I've been taking classes and I'm starting to get the idea we need a styling and GUI framework that can work similarly to CSS/JS frameworks but for native application development.
>>
>>103014197
if you aren't overloading EVERY operator for EVERY class, your doing it wrong
>>
>>103014749
This. () is problematic and a code smell. Everything must be done as an overload.
>>
>>103014854
>not overloading ()
every object should do something when called, even if it just plays a funny noise because I'm so random xD
>>
>>103014854
>overload
Worst thing created in programming.
>>
>>103014975
you don't understand, you can save like 10 key presses
>>
alright time to build my music player in rust. What library should I use? I'm thinking either dioxus or gtk4rs but gtk will limit me to desktops only. I'm targeting cross platform, maybe even mobile later because everything fucking sucks on mobile.
Also I'm probably gonna abandon this in a month anyway so whatever.
>>
>>103015249
>my music player
>What library should I use?
Typical rustard.
>>
File: jukebox_new.png (66 KB, 1099x929)
66 KB
66 KB PNG
>>103015249
>he doesn't have a simple Perl script that just generates a bunch of HTML for all folders in a directory
You won't last a single week.
>>
>>103015180
>10 key presses
In exchange I got 10 headaches and 10 bugs.
>>
>>103013750
because font rendering and localisation isn't solved either, and nobody wants to deal with whatever the fuck utf-8 wtf-16 are
exclude text and you can make a gui in 10mins
actually, maye text offline rendering is the answer.
>>
>>103015364
lol? the things you listed aren't problems, the biggest pitas about guis are designing for radically different display sizes and dpi
>>
>>103015401
>the things you listed aren't problems
lol, lmao even
text rendering on glyph shaping is a huge problem on its own, with patents to avoid even
some europoors complain that their name is permanently broken for government websites because glyphs that look the same are not stored in the same way, and somehow registrations does not use the same glyphs as the search function.
>radically different display
>phoneposting
lmao, use flutter
>>
>>103012916
ngl, shit like
cin >> x
still looks retarded to me even though I know what's actually going on, visually it's like writing 1 = x
>>
How can I learn about data/file transfer protocols, I would like to learn more about them (rules and general knowledge) but don't know where to go (or what to search).
I just joined a tv channel as a dev and they do a lot of this shit but I don't know more than regular http request/response.
Would like to learn about FTP, SFTP, etc...

Also, any book that tackles this subject but also more other concepts related to backend development. Ngl, I graduated from a shit school where we didn't study CS the right way. I need to fill a lot of holes right now in terms of knowledge (Like, I have no idea why u always have to open/close a connection when we make an FTP client. Maybe it's just like that but why? I need to know that kind of stuff.
>>
>>103015580
>I have no idea why u always have to open/close a connection when we make an FTP client
Maybe software development isn't yours. You're supposed to learn that shit by yourself.
>>
>>103009455
>multiple return values breaks ABI
I don't see how, especially when these values are wrapped in a consistent struct.

>it is just syntax sugar
In essence, yes. I'm just trying to return unnamed structs.

>just use pointers to the returned variables
... no.
If I can find usage for this type of return type,
then I'm dead-set in taking advantage of it.

>NASA makes all of their functions void and returns everything through pointers
>because avoiding casting or forcing a shit ton of boilerplate is le good apparently
Okay, after rereading this part several times,
I think I understand, what you're trying to say.
I am indeed slowly warming up to the idea
of preallocating the required memory before running a function.
With that I am flexible in how memory management is handled,
which includes appeasing the wishes and wisdom of the malloc schizo.
>>
File: 1720049135183932.png (121 KB, 759x218)
121 KB
121 KB PNG
hey kid, you want to hardcode some unicode strings?
>>
>>103013113
I wish that shit wasn't ass to use outside of macOS
>>
>>103016046
Has it gotten ever better on MacOS?
https://www.splasmata.com/?p=2798
>>
>>103016015
just changing the c++ standard doubles compilation speed of my project so im stickign to c++11
>>
sirs how do I learn about computer graphics so I can make my own UI libarary and not use stinky QT or other dogcrap crap?
>>
Listen up, former C++ brethren! I've had it with your memory leaks, your segfaults, and your godforsaken `new` and `delete` dance. Rust has shown me the light, and I ain't going back!

I'm done trading my sanity for pointers that could be null or not. I'm done battling undefined behavior that hides behind a veil of silence. I'm done with compile-time errors that make you question your existence.

Rust's got static guarantees, no manual memory management, and safety checked at compile time. It's like C++ grew up, learned some discipline, and stopped setting fire to its own hair!

So, you can keep your C++, with all its sharp edges and hidden dangers. I'm embracing Rust, one lifetime at a time. And if you don't like it, well... You know where the door is.
>>
>>103016015
what the fuck is that? an explicit string per letter? what the actual fuck
>>
>>103016312
Use C, be an adult.
>>
>POSIX 2024 released
>they still didn't fix hsearch
portable bros, it's over...
>>
>>103015259
why are you triggered.
>>103015283
I don't have such powers, I only know web tech
>>
>>103008052
when i first started learning programming, the teachers started with teaching C#, it wasn't till i had already learned it that i discovered c and c++, but that bad foundation threw me off so bad that it took me years to recover.
i finally learned some C, had they started me off on C/assembly, i would've understood programming way better than how they set me up.

now i avoid meme languages like the plague, idgaf if it's rust, python, other newer languages or any scripting languages, if they were any good, they wouldn't need to build off of C, yet they're all based off of C and add their own quirk.

c for basic programming, c++ for games, assembly for bare metal, bash for scripting and php for web development.

i dont need and i wont submit to new meme languages, create new libraries, have them become retroactive with C, and keep polishing C

there's no need to create newer languages, what they need to do (if they want more developers) is develop a new method of teaching programming and cs, that's more intuitive and easier to grasp (it's possible), or let the industry die in the west (since they're already killing it)

tl;dr
if it aint broken (it isn't)
dont fix it. (also, stop messing with linux, retards adding system.d and all the security risks involved with that)

stahp
>>
yeah man. I am learning to use the debugger. wish me luck.
>>
File: cpp_is_garbage.png (44 KB, 1532x932)
44 KB
44 KB PNG
>>103016633
>c++ for games
Don't.
>>
>>103016633
You literally don't need anything else than Python + Rust
>>
File: dust_allocations_2.png (159 KB, 1677x827)
159 KB
159 KB PNG
>>103016701
Why would anyone want to spend 25% of their runtime in memory management on a good day? You'd have to be earth-shatteringly incompetent.
>>
>>103016666
>c++ for games
>Don't.
>devil digits
you wont trick me twice satan
>>
File: hero_data.png (18 KB, 1100x610)
18 KB
18 KB PNG
>>103016798
Why would I lie to you?
>>
>>103016844
>>Why would I lie to you?
>two 4's
>for is shin in japanese
>shin is death
>44 is double death
you're trying to kill me, that's why -_-
>>
File: sepples_insanity.png (19 KB, 1448x697)
19 KB
19 KB PNG
>>103016890
Yes, but that has nothing to do with C++ being garbage.
>>
>>103016798
he is not wrong, C# with unity is better if you want people to mod your game if your game ever got successful.
>decompilation is not modding
true, and there are good reasons to add in scripting, such as sandboxing and preventing viruses.
But with unity decompilation people essentially have the power to modify every bit of code in your game, and pretty much any example of a game with amazing modding support made in the past 20 years uses C# or Java because bytecode is basically open source without comments compared to compiled languages like C++.
Modders can take the liability of viruses because they are the ones hosting the website and moderating the mods (of course, only if your game was popular enough to have a community like that on it's own).
The best part of unity is that you don't need to do anything to prepare, minecraft needed special code to support modding (the first version of minecraft was harder to mod, the developers had to make changes to make the game more flexible), but unity forces your game to use ECS, standard formats, triggers, and other lego-like tools and that opens up your game to be easy to mod (modders can essentially use unity).
And also a reminder that more than 90% of developers use unity and unreal
https://steamdb.info/tech/
And the only recent solo indie game (a game coded by 1 person) that blew up on steam without a engine like unity is balatro which was made with lua in love2d.
C++ is for engine devs, not for games.
>>
File: ue.jpg (112 KB, 899x925)
112 KB
112 KB JPG
>>103017118
>And also a reminder that more than 90% of developers use unity and unreal
Just for the record UE uses C++ , and you yourself admitted it's one of the most used engines
Not that I give two fucks about language wars, just pick whatever you want, but it's definitely used.
Also UE's C++ is kind of like C#
>>
>>103017162
Holy fuck I didn't mean to save that screencap as a jpg that hurts my eyes
>>
>>103017118
>C++ is for engine devs
Then why is it never used for good engines? Why does it fall apart the moment you actually look at what the code is doing?
>>
>>103017187
pretty much every engine uses C++, what do you mean by good engines?
>quake, doom, etc
honestly I was hoping you would pick straws by picking one of the 3 games that were popular
with scripting that were made before 2013 or something, but those games are old as fuck, and those games are not made by a single developer (small group, but I don't think anyone making a game engine on 4chan is actually working in a team, not even with an artist or music guy).
>>103017162
I don't know the % of unreal games that use C++ or Blueprints, last time I remember looking at tutorials, all of them were in blueprints and C++ was treated as a secondary language that you could optionally use (probably for performance).
>>
*ahem* cave story was coded entirely by one person in C++ with SDL2. *ahem*
>>
File: ntclose.png (35 KB, 1130x950)
35 KB
35 KB PNG
>>103017249
>pretty much every engine uses C++, what do you mean by good engines?
Engines that actually know what the functions they're calling do. That don't have to go through layers upon layers of bullshit that waste millions of cycles on random bullshit like copying temporary objects only to keep some incompetent Pajeet's code from imploding in on itself. Engines that don't load a single byte from a file per syscall, engines that don't query the same file information over and over again because some asshole thinks that this shit is going to be cached someplace. Take your pick.
>>
>>103017301
such as?
>>
>>103017324
I don't fucking know! You (or whoever wrote >>103017118) started farting through his face about how C++ is for engine development, and I want to know what good engines out there (with the qualifications I've listed) use C++.
>>
>>103017351
none
>>
>>103017368
Would that be because C++ is not a very good language for engine development?
>>
>>103017390
It's your qualifications, why are you asking me?
For me, C++ and C and rust are equal because I care about modding. If the language is compiled, you can't really mod it without adding a scripting element, but the problem is that you always add limitations, such you can't mod rimworld to go to space, the developers need to modify the engine to add that.
>>
>>103017454
>It's your qualifications, why are you asking me?
Because those are not very high qualifications. Knowing the system you develop for and structuring your code is absolute engine baseline; no advanced stuff like vectorization, memory management, and cache utilization is in there. If there are no C++ engines out there that reach even that baseline, then why the fuck do you (or whoever wrote that post) claim that C++ "is for engine devs"?

>If the language is compiled, you can't really mod it without adding a scripting element
Wrong. How, do you think, did I gather the information I post screenshots about?
>>
>>103017390
>>103017454
from doing a quick search
>unreal
>unity
>godot
>game maker
>cry engine
all are written in c++ and either c# or some scripting language, seems like c++ is good enough for engine development.

the way i figure, if they're written in c++/c#, the best option would be to learn c++ or c#, if they're written in some obscure language, i dont think that engine should be adopted (unless you like suffering)
>>
>>103017545
>all are written in c++ and either c# or some scripting language, seems like c++ is good enough for engine development.
Do they reach the absolute baseline? Or are they just a bunch of slop made by people who have no idea what they're doing?
>>
>>103017535
I honestly don't even know what your baseline is, why don't you read the source code of unreal or godot?
>>
File: movs_movs_movs.png (59 KB, 990x444)
59 KB
59 KB PNG
>>103017623
>I honestly don't even know what your baseline is
Are you completely retarded?
>>103017301
>>103017535
It's right there, you incompetent motherfucker.
No, you know what, don't bother replying, you have so much no idea what you're talking about it's not even funny anymore. Spare us all your incompetent drivel and just go.
>>
>>103017579
they're in the top for engines used in game development, so....maybe?
i know unity was shitting the bed recently, and so was godot, but they've been around for at least a week.
i know the unreal engine has been around for more than a week, and it's been used for a lot of games, like godot and unity.

your guess is as good as mine though.
>>
>>103017660
Why are you asking us when you can just find out yourself?
Do you like being ignorant of information, people here on 4chan are very inaccurate about the information they give, it's always better to doubt word of mouth and either read the truth or run a test and compare concrete solid evidence instead of assuming everything, since all assumptions are wrong until proven.
>>
>>103017535
Because 95% of serious game engines are done in C++, see Wikipedia. The "C engines" are either github hobbies made with SDL2 or 30 year old pixel dungeon crawlers from defunct companies.
>inb4 use raylib
>>
File: unity_player.png (27 KB, 702x966)
27 KB
27 KB PNG
>>103017674
So I just looked at the UnityPlayer.dll that Oxygen Not Included installed (don't really have any other game that uses Unity, and there's no way in hell I'm going to sully a perfectly good machine with their gunk). Just looking at their imports confirms that they don't reach the basest of baselines. Anyone who's ever looked at FindNextFileW would know as much: >>103010977

So much for that.
>>
>>103017829
So there's really no language out there for engine development? What a surprise.
>>
>>103017267
and it was fucking shit, nice example idiot
>>
>>103017836
that's what happens when you (generally speaking) leave your game development to a third party library.
once you start developing with their system, you're stuck with it until you migrate or rebuild your own engine from scratch, which is what developers should be doing desu, at least for the critical parts
>>
>>103017854
I await your game engine or your unreal port after you finish speeding up your registry dumper from 7 seconds to 6.666666 seconds.
>>
>>103017946
>third party library
That's not really my issue. My issue is that the third party doesn't know what it's doing either on the basest of baselines. I'm not expecting some ingenious memory management strategies with multiple memory pools and highly optimized traversal algorithms that avoid cache evictions.
>>
>>103018038
I accept your concession.
What confused you about "don't bother replying", by the way?
>>
File: 1729210901547369.gif (1.62 MB, 448x598)
1.62 MB
1.62 MB GIF
>>103015249
>>103016458
>rustroon is a webshitter
every single time
>>
>>103018054
You have no game engine baseline.
I accept YOUR concession.
>>
File: create_allocation.png (131 KB, 1894x988)
131 KB
131 KB PNG
>>103018099
>You have no game engine baseline.
Oh, well, you know.
>>
>>103018132
A registry dumper is not a game engine.
>>
>>103018041
>I'm not expecting some ingenious memory management strategies with multiple memory pools and highly optimized traversal algorithms that avoid cache evictions.
i guess neither were they
>>
>he is so completely out of his depth he doesn't even know what NtGdiDdDDICreateAllocation does
>thinks it's got something to do with registry dumping
I accept your concessions. Plural. Now go away.
>>
>>103018145
i think he's showing you his baseline, not his game engine....but i'm retarded so i dont know
>>
>>103018184
Work in progress, admittedly, but at least I'm moving forward.
>>
>>103017908
>cave story was shit
huh???
>>
>>103018173
You think you're so funny disparaging the work of thousands of people who actually shipped products because you're a retarded schizo afraid of malloc. Kill yourself at your earliest convenience. Leave your concession at the desk.
>>
>>103016080
>Coders are constantly balancing trade-offs. Raw performance isn’t always the priority, because you have to conceptualize, code, iterate, debug, extend, refactor, share, ship, maintain, and support. One team’s acceptable trade is another team’s hell stew.
But you're not ready for that conversation.
>>
>>103018283
Amen.
>>
Does /dpt/ have opinions on annotating syntax with comments?
I've only encounter this in Lua when configuring my editor.
But I imagine this is (at least somewhat) common in dynamic languages.
I wanted to hear perspectives on it since I mostly use static typed languages where this kind of thing is implicit/forced.
>>
>>103018489
>annotating syntax with comments
you mean like javadoc?
>>
>>103018547
Yes. In this case (the gif) shows annotating Lua with it's parameter types.
>>
>>103018489
The guys at Svelte moved to jsdoc from typescript.
It was more painful for them to maintain a typescript build system rather than enforce a (previously existing) linter.
I don't mind them but they are effectively comments. Won't please the static crowd because they want them enforced with no escape hatches and won't please the dynamic crowd because it's extra typing and it constrains them, all variables are any for them, waiting to morph.
>>
>>103018489
inferior to genuine typeless languages
>>
>>103012837
Very interesting read. Still using malloc though.
>>
>>103018994
enjoy your layoff
>>
File: 1709458168364708.gif (8 KB, 200x260)
8 KB
8 KB GIF
>>103019025
Joke's on you I'm already unemployed.
>>
File: lisp horse.jpg (12 KB, 271x186)
12 KB
12 KB JPG
>>103018869
>>103018984
Thanks for the insight. That's what I was assuming.
I'm in the static crowd so I'm of the opinion good types and exposing that information to things like linters and editors is a boon.
At the same time, I've flirted with the idea of trying functional languages where everything is just an abstract list.
This intermediate indeed doesn't seem that useful unless you enforce it upon your whole codebase, but at that point why not just use a typed language.
Things I'll be considering.
>>
Nothing is preventing you from using unsafeCoerce# and Any# everywhere in your Haskell code
>>
>>103019172
I mean, I never used it, but isn't it what safe haskell is for?
>>
>>103019172
Yes there is. The fact that I don't and never will use haskell.
>>
>>103019218
You will use Haskell.
>>
>>103018489
seems silly desu, either do proper static typechecking or embrace the dynamism and do it like Malli and Spec in Clojure which actually let you do useful things with the data definitions you create instead of just getting hints and warning from your editor.
>>
File: malli.png (257 KB, 394x800)
257 KB
257 KB PNG
>>103019297
>search Malli and Spec in Clojure
>2D girl logo
I'm convinced already.
>>
>>103018238
>2d pixelshit
>furshit
>cuckoldry
>dragons
>girl has scars
>unrealistic guns
>unkillable characters
it was literally r*ddit the game
>>
Please save me from C#.

It's not nearly as verbose as Java, has good async, good C interop, large standard library, reasonable syntax, but I just don't want to be tied to M$. The language itself is great, but the Mono ecosystem is basically completely dead
>>
>>103019618
c# has a borrow checker, found that out the other day, literally heratbreakibg
>>
>>103019626
Why does it need it for? It's garbage collected.
>>
>>103019644
who the fuck knows
>>
>>103017836
Wait so what's so bad about FindNextFileW?
>>
>>103019618
the language sucks
>>
>>103011777
you can.

>>103011789
you know he's not talking about something that lives on the stack
>>
>>103019605
yeah ok but it's an example of a game made by one person in C++ without a game engine. c'mon man don't be so dense, if some random jap can make a full breadth game in C++ then that means C++ is alright when it comes to game dev. unless you wanna tell me that it's written like shit, well then that's another thing entirely.
>>
how come gcc ignores -fno-strict-aliasing? I'm compiling the example here https://stackoverflow.com/questions/754929/performance-benefits-of-strict-aliasing
void f(unsigned u)
{
unsigned short* const bad = (unsigned short*)&u;
}

int main(void)
{
f(5);

return 0;
}

and both -O2 -fstrict-aliasing and -O2 -fno-strict-aliasing produce the same retarded binary
same thing happens when compiling the entire executable and when removing main and compiling only to main.o with -c
0000000000000000 <f>:
0: c3 ret

any clue?
>>
>>103020091
The function f does literally nothing. Of course GCC optimizes it out.
>>
>>103019354
>Other times, we use a map as a homogeneous index. In this case, all our key-value pairs have the same type. For this use case, we can use the :map-of schema.
Mallil has bad technical writing. Index usually means the same thing as key, so a "homogenous index" should only need a consistent key type whereas a "homogenous map" is what they're trying to describe. It's written like fiction where you lose points for the same word twice.
>>
>>103020140
damn of course, thanks. I tried it on a hashtable file and it did produce different functions so that's good enough for me, I'm going to use it now just in case.
>>
>>103019618
Please give me good sources to refresh C# to a professional level. I know the language to an extensive degree but I'm still getting rekt by non-coding shit
>configuration (IOptions, IOptionsSnapshot)
>containerization
>(Azure) devops
>other middleware
I've spent the last 6 months doing configuration shit and I'm at my wits' end.
>>
>>103019100
>I've flirted with the idea of trying functional languages where everything is just an abstract list
The problem with that is that it's very easy to make a system that performs like shit that way, and much harder to make a fast one.
"But it's just a performance optimization, and those don't really matter."
Yeah, until they really do; going an order of magnitude faster is transformative in practice, because humans are not scale-invariant in temporal terms.
>>
>>103020441
a struct is an abstract list, retard
>>
>almost any interesting combination of type system features makes type inference impossible and type checking often undecidable
>>
Is there a better way of doing this in a makefile? This string will appended to the tarball's name.
ARCH := $(shell uname -m)

ifeq ($(ARCH), i686)
ARCH := x86
else ifeq ($(ARCH), i386)
ARCH := x86
endif
>>
File: 1699743728676488.png (457 KB, 3840x2064)
457 KB
457 KB PNG
>>103016080
Actually I lied it's not bad with CMake
You can hack together bidirectional interfaces to C without too much fuss
Hopefully more libraries start going with this system instead of using godforsaken SPM
>>
>>103020787
you might not kwnow this but make uses mallco
>>
>>103019605
>furshit
>dragons
Sounds good to me
>>
>>103019100
It's a trade off.
With dynamic languages you can quickly prototype and adapt to requirement changes, giving you development speed.
The performance of dynamic languages won't easily scale, because you need types to let the compiler know where to optimize.
With static languages you need more typing and more ceremony, but you can encode more invariants. So when the project grows to a million lines of code, you change something and the compiler lets you know what broke. You trade development speed for maintainability (future development speed).
Which is why projects start as Python or Javascript as a proof of concept and then migrate to (or incorporate microservices in) Java, Go, C++ or Rust.
Still, you can do a lot with a dynamic language, Balatro uses Lua and Don't Starve uses Lua too.
>>
>>103018283
You mean incompetent retards? Yeah, I have absolutely no issues doing that, because they haven't done so themselves. And considering how butthurt you are you seem to be one of these incompetent retards.

>>103018438
>Raw performance isn’t always the priority
Wrong. Every single cycle that your program runs needless is yet another sign for how incompetent you are.
>>
>>103020935
>The performance of dynamic languages won't easily scale, because you need types to let the compiler know where to optimize.
The biggest thing that static languages are better at is working with unboxed values. That's a huge win. They also have better predicted branches, but that's less impactful than you might think (at least going by my measurements, which is why luajit and pypy are disappointing; they can't unbox things even in the best case).
>>
>>103020791
CMake has Swift support!??

I did know it has C# support (Windows only), but I didn't know about Swift
>>
>>103020787
I feel like you should be using autotools instead for whatever you're trying to do here, but you do you
>>
>his language doesn't expose registers and stack pointers
for what purpose? why the fuck can't you craft a call convention of your own for your specific code and libraries? why can't you reserve specific registers for your own use?
just by exposing registers and stack pointer you get stackfull coroutines for literally free
>muh portability
literally every relevant cpu architecture have those things
>muh ABI
you only have to respect the OS specific ABI WHEN YOU NEED TO ACTUALLY CALL IT

literally why the fuck do we have tens of layers of abstractions on top of each other, each with their own garbage? that's how we have trash like typescript built on top of js built on top of more trash holy shit I hope for every wasted power and cpu cycle the ones who made such decision burn in hell eternally.
>>
>>103019950
Read the fucking decompiler output?
>locking and unlocking file handle
>internal memory allocation of a big chunk of memory (not entirely sure what the code checks, but it can vary from 4 to 64 KiBs)
>RtlSetLastWin32Error has a bunch of branches and can trigger EtwEventWrite, which is a heavy chonker
>plenty of copies and conversions to turn FILE_FULL_DIR_INFORMATION/FILE_BOTH_DIR_INFORMATION structures into WIN32_FIND_DATAW structures, for no reason other than backwards compatibility
>>
>>103021063
>Autotools
Dude, I'm trying to stay sane. Autotools is the biggest POS build system out there.
>>
>>103021078
Haskell sisters we are being called out
>>
>>103021106
You don't NEED registers, just trust the RTS, it's 50k lines of C.
>>
>>103021085
>Read the fucking decompiler output?
I use Linux.
desu, I thought your problem was gonna be using a fucking glob to list the files in a directory. Though I'm not surprised they couldn't even do that right.
Though the large memory allocation is not so bad. It's likely a buffer for NtQueryDirectoryFile, which is way better than making a full syscall for every directory entry.
>>
>>103021100
To be honest, if you use `autoscan`, it's not *that* complicated. It's just that it doesn't have a lot of beginner-friendly documentation. It's not as scary as people make it out to be. It's not any less complicated than CMake, just has slightly weirder syntax
>>
>>103020935
I propose Naughty Dog's Game Oriented Assembly Lisp as a counter example where in this specific anecdote, LISP intermixed with assembly on hot paths, ended up being more than sufficiently performant on an R3000 MIPS @33MHz. I guess better than Sony's own first party APIs which I presume where C.

Moreover, while interpreters may have less optimization potential(?founded), I'd imagine the difference in programming paradigms, allows for different optimization potential on the programmer's side.

Consider a hypothetical language, in where generalizing, memoizing, parallelizing, are effortless.
Programmers are more likely to utilize these patterns in the same amount of time or less, than it would take to accomplish the same in other languages.
>>
>>103021125
Haskell is a low level systems language so it should let me modify registers
>>
>>103021139
>Lisp
not good enough for games
>>
>>103021158
Objectively good for games as exemplified by Crash, Jak, etc.
https://opengoal.dev
>>
>>103007765
This looks cool anon. I hope to make something like this but I also want to add file sharing Limewire or Soulseek style to my program.
>>
>>103021166
so are they still uisng it?
>>
>>103021139
GOAL Lisp was interpreted? if so that's very lame. even if you think there's a gains with dynamic typing, interpreting doesn't give you shit
>>
>>103021135
>I use Linux.
So? The relevant functions are all colored in pink, and fortunately NT's naming scheme is very verbose with what a function does.

>I thought your problem was gonna be using a fucking glob to list the files in a directory.
Basest of baselines. My expectations are really just that low.

>Though the large memory allocation is not so bad
But it is, especially if you use arenas and have plenty of bytes available.

>which is way better than making a full syscall for every directory entry.
The two are not exclusive.
>>
>>103021078
You can allocate non-volatile registers with GCC.
Far as I know it's the only compiler which allows you to do that - VS and clang are happily eating glue still.
>>
File: file.png (64 KB, 986x497)
64 KB
64 KB PNG
>>103021194
I'll let the engineers speak for that.
https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp#Uses

Emphasis
>Note, however, that these issues aren't really technical problems, they're social ones.

>>103021196
GOAL is compiled. It still offers dynamic features to debug while running.
>>
>>103021166
I don't care about who or what uses the code.
The only thing I care about is how it translates into instructions, and there's nothing about that there.
>>
>>103021250
>The only thing I care about is how it translates into instructions, and there's nothing about that there.
The source code for the interpreters, tools, documentation, and everything are linked in the post.
What do you mean nothing about it is there? We're talking games, but you're playing games.
>>
>>103021268
>just search for it yourself bro
No.
>>
>>103009986
He didn't wrote it or if he did, he's spamming it. I've seen it before.
>>
>>103021284
Search for /what/?
The evaluator source code? What are you asking for.
>>
>>103021284
>>103021294
I'll just assume you meant this
The source:https://github.com/open-goal/jak-project/tree/master/goalc
Overview: https://github.com/open-goal/jak-project?tab=readme-ov-file#goalc
>>
>>103021294
>What are you asking for.
An analysis of the binary code that the compiler generates. I have little trust in game developers and their statements with regards to toolkits and code quality.
>>
>>103021328
Would it be sufficient to build hello world and look at the output in either their disassembler or yours?
>>
File: what_the_actual_fuck.png (42 KB, 1076x952)
42 KB
42 KB PNG
>>103021340
No. I go out of my way to post real-world examples of the fuckups I find for a reason.
>>
>>103021216
>GOAL is compiled
right
>It still offers dynamic features to debug while running.
nice. static languages that allows you to run flexible code when you need and where it doesn't matter, like in macros and/or in compile time execution, is a powerful combination
>>
>>103021352
Oh you're that schizo. I don't want to talk to you.
>>
>>103021421
I accept your concession.
>>
>>103020376
I've mostly been using C# for writing little UIs and scripts that I would have written with Python and PyQt instead. I come from a C++ background, I have no clue about webshit. But C# has everything I would want to have in C++ when it comes to writing GUI user applications.
>>
>>103021139
I don't know if GOAL counted as "at scale" or the game requirements were toned down to meet the performance provided.
I don't know how SBCL would perform at scale (meaning: attending millions of requests like amazon, or medium, like Twitter, or "smaller", lichess) because I can't think of examples. You can heavily optimize SBCL and rewrite things to achieve even more speed. Being compiled to machine code helps a lot.
I don't recall people saying "we ditched Common Lisp because it was slow" either.
>I'd imagine the difference in programming paradigms, allows for different optimization potential on the programmer's side.
It does, Javascript is very difficult to optimize because (among reasons) objects can be anything.
>Consider a hypothetical language, in where generalizing, memoizing, parallelizing, are effortless. Programmers are more likely to utilize these patterns in the same amount of time or less, than it would take to accomplish the same in other languages.
Yes but there are trade offs. Usually to obtain free memoizing and free parallelizing you need immutable data structures. You get Clojure and Haskell this way, with their respective caveats.
GOAL applies here too: they had to have a compiler targeting the PS2 specifically and restricting themselves to performant subsets of code or assembly when the need arose, to pay for the cost of having an effortless scripting language you liked.
>>
File: malli exchange.jpg (838 KB, 1053x1999)
838 KB
838 KB JPG
>>103020237
>Malli has bad technical writing
yes it's written by Finns who barely speak English, so the documentation isn't great. but the library is pretty fun to use, especially when you're already used to writing websites in Hiccup syntax
>>
kek i just realized I wasnt initialized a single of the mutexes with the pthread_initI was using in my program instead was only zero initializing everything but it looks like locking and unlocking still works but I guess every single lock was the same lock
>>
>>103022230
Any sane mutex implementation would just be zero init anyway.
>>
surprisingly, i now use APL on a daily basis
>>
>>103021216
manager brain claims another scalp
>>
again instead of doing work in my job i was fiddling with my own c codebase and ricing my neovim
>>
while (atomic_load(buf[i].state) == BUSY);

is this a bad idea?
how else do you wait for an atomic variable to change value?
>>
>>103022045
What colorscheme is this? Fifty shades of poop?
>>
>>103022911
use an actual concurrency model so you don't have to fiddle around with things that are error-prone
>>
>>103016393
each unicode character has an official name, now you can write those characters using that name instead of the actual codes
>>
>>103022952
it is a dead simple program though
>>
>>103022978
Even if busy waiting is what you actually want, you still probably want to add a "relax" intrinsic there that issues a pause/yield instruction instead of just wailing on that variable as fast as it possibly can. "_mm_pause()" on msvc, "asm volatile ("pause\n" : : : "memory")" on gcc/clang x86, or "asm volatile ("yield\n" : : : "memory")" for arm ought to do.

But most likely you don't want to busy wait and rather you should be sleeping until the value changes to avoid wasting cpu. Use a mutex + condition variable to do that. The only times you really want to busy wait are when contention is very very very rare, or when you cannot sleep for whatever reason. Usually busy waiting will be slower.
>>
File: 1716166845021258.jpg (529 KB, 2048x1536)
529 KB
529 KB JPG
On visual studio, trying to step through some CRT disassembly, the fucking debugger keeps trying over and over again to search for multiple source files (which I don't have) after EVERY INSTRUCTION. I don't care about the source files I just want to step through the assembly, but every time I step to the next instruction it pops up multiple "searching for source..." windows which I have to click cancel on before it will allow me to step again. Anyone know if there is any way to fix this?
>>
>>103021169
Thank you.
File sharing is on the to-do list as an optional feature. I'm thinking something along the lines of an optional private tracker feature for server operators. Still in the drawing board for this.
>>
>>103023063
yeah thrd_yield() seems to work
>mutex + condition variable
that's slower than the single threaded version
perhaps I don't need multithreading at all
>>
File: 1713556388329649.jpg (97 KB, 1080x1331)
97 KB
97 KB JPG
my entire program is a constexpr
>>
>>103023502
thrd_yield is a syscall which is a step up from the single instructions I was suggesting, but yes that would also prevent the thread from hammering on that memory location as fast as possible.
>that's slower than the single threaded version
>perhaps I don't need multithreading at all
yes, multi threading is only going to give you a speed up when you have enough parallel work to do that it outweighs the cost of starting threads (or divvying out jobs to a thread pool) and synchronizing them, etc. Anyhow, I'd be a bit surprised if a spinning wait + thrd_yield was faster than both a single threaded version AND a mutex+cond var version, since usually spinning (with or without yielding the thread) is slower than doing it right.
>>
>>103023542
>constexpr
Bloat. No program's purpose is to process constant data, and if what constant data there is would benefit from preprocessing then you could just make that part of your toolchain instead of part of your source code.
>>
>>103023710
>I'd be a bit surprised if a spinning wait + thrd_yield was faster than both a single threaded version AND a mutex+cond var version,
I'm not confident either of my multithreaded versions is 'right'
but aren't thrd_mutex_lock, thrd_cond_wait, thrd_cond_signal, thrd_mutex_unlock all syscalls?
>>
>>103023961
On Linux at least, mutexes and stuff only produce a syscall when there is contention on the lock. If only a single thread locks and unlocks a mutex, it's extremely cheap, and basically just boils down to setting an atomic integer.
The underlying syscall is https://man7.org/linux/man-pages/man2/futex.2.html , which you don't really need to know, but it's kind of interesting to learn about.
I don't know how Windows' mutexes work.

>>103022911
Spin locks are only really useful in some extremely specific situations, which usually involves real-time scheduling (which I'm 99% sure you're not using).
>>
>>103023961
As the other guy said, mutex/cond var shouldn't produce a syscall unless they actually need to in order to make the thread sleep. This is definitely true on linux (it uses futex like the other guy said) and ought to be true on windows if you use the right kind of mutex. Windows has KeyedEvent and the newer WaitOnAddress which are both similar to futex, and the newer Windows mutex implementations (e.g. SRWLock) use those APIs. I'm not so sure about the older CRITICAL_SECTION, that might make a syscall every time. I'm also not sure which API msvc's std::mutex uses.

Anyway that's all low level details that isn't really important, what's important is understanding *why* mutex+cond var would be better than spinning with yield, even when both end up making syscalls. The reason is that, say your program has 2 threads A and B, A is waiting on the variable and B is about to set it. Let's say these threads are running on 2 cores simultaneously, and thread A checks the variable and sees that it's not set. With the loop + yield implementation, thread A will then call thrd_yield, which will go into the kernel and check if there are any other programs waiting to run on that core. Let's say there is some other unrelated program X, then thread A will forfeit the rest of its time slice and X will start running. Meanwhile thread B running on a different core sets the variable. Now thread A has to wait until X and whatever other programs might be waiting in the scheduler's queue finish running, before it can hop back in and check the variable again. Compare this against the cond var implementation. In this case, thread A sees the variable is not set, then goes to sleep on the cond var. The OS may start running some other program X on thread A's core while A is sleeping, but as soon as B sets the variable and wakes A, the OS will make an effort to get A running again in a timely manner (perhaps by moving it to another core if the old one is now in use, etc.).
>>
always seems weird to me how strings are always treated like magic by compilers and programming languages
>>
>>103024124
Also compare against my original post here >>103023063 where I suggested pause/yield (the instruction, not the syscall). In this case, thread A never goes into the kernel and just keeps checking the variable over and over, albeit with a brief stall (due to the pause/yield instruction) between each check. This is a busywait/spinlock, and is generally not something you want to do since it wastes cpu time and eats up a core that could be used for something else, it's only useful if you really need to avoid making a asyscall/sleeping/suspending the thread for whatever reason. (note that "yield" the instruction (which is the arm version of x86 "pause") and "yield" the syscall are two different and unrelated things)
>>
>>103023986
>>103024124
I simplified it to this http://0x0.st/X0Dm.zip
unzip and make
the actual program is not much different, one thread reads and queues task descriptions the other carries out tasks and prints results
>>
>>103018994
Care to explain why?
>>
>>103021139
>Programmers are more likely to utilize these patterns in the same amount of time or less, than it would take to accomplish the same in other languages.
This article has been the strongest form of propaganda to me personally https://paulgraham.com/avg.html
There's power in realizing that even if compiled languages like C are objectively faster in terms of raw throughput, that's only the case in the most optimal program. The average LISP program is likely to be orders of magnitude simpler, so even though each segment of the code executes slower in isolation, as a whole process it's executing less code less often overall. That is to say executing no code will always be faster than executing optimal yet unnecessary code, and calling cached generalized code is usually faster than being forced to call out to bespoke regions.
>>
>>103021216
I think the fact that they stopped using it when they first got acquired but then started using it again anyway (despite the fact it's now in the hands of C++ programmers who couldn't care less about LISP), says something about its merits.
>>
>>103024266
>average
>likely
>usually
Just admit you have no idea what you're talking about because you never analyzed different outputs.
>>
>>103024287
Those words are written expressly to convey the subjectivity of the matter. It's not generally true, you must measure your implementations to compare and different workloads on different interpreters and host systems will matter/change the results.
I feel like a moron having to explain this, I just got trolled.
>>
>>103024312
That's hilarious, considering your post sounds like something GPT would produce.
>>
>>103024331
I'm not sure what part is funny, and your remark about robots isn't nice. This is 4chan not English class, excuse me for not writing properly in a casual setting.
>>
>>103024341
>I'm not sure what part is funny
That both you and GPT sound incompetent.
>>
>>103024357
Did something I say offend you somehow? Why are you being rude to me?
>>
>old programming conference talks
>comfy
>programming conference talks from the past 5-10 years
>some indian guy in the audience repeatedly interrupting with irrelevant basic programming questions, often getting audibly angry because he can't understand the topic/answers
>>
>>103024362
You mean something other than the vacuous space in your post?
>>
>>103024375
To be honest I don't think paragraph form reads much different than continua style in this context. If you have advice on how it would be rephrased please let me know.

This article has been the strongest form of propaganda to me personally https://paulgraham.com/avg.html
There's power in realizing that even if compiled languages like C are objectively faster in terms of raw throughput; that's only the case in the most optimal program.

The average LISP program is likely to be orders of magnitude simpler, so even though each segment of the code executes slower in isolation, as a whole process it's executing less code less often overall.
That is to say executing no code will always be faster than executing optimal yet unnecessary code, and calling cached generalized code is usually faster than being forced to call out to bespoke regions.

--

Yeah I think this format breaks unnecessarily between concepts. It would have to be rewritten I think.
>>
File: 1720928573080300.jpg (122 KB, 482x427)
122 KB
122 KB JPG
bjarne's not looking so good these days, they better back him up to AI before he segfaults so we don't lose his wisdom forever
>>
>>103024432
they should just cut off and preserve his legs instead
>>
>>103024197
>Synchronizing on every value
You should probably look into using a ring buffer.
>>
File: short_bjarne.jpg (48 KB, 473x505)
48 KB
48 KB JPG
>>103024495
This already happened while he was alive.
>>
>>103024124
I am not part of this discussion but it is a topic I was wondering about. I appreciate everyone in this chain for breaking down and explaining this.
>>
>>103024570
like fill up the buffer then wake up the other thread?
isn't it the same as doing it in a single thread?
or should I copy the buffer and let the first thread fill it up again while I'm processing the previous contents?
>>
>there are people in this very thread who don't check every addition for overflow
>>
>>103024732
And proudly so.
>>
>>103024732
I just use big enough integer type for my calculations
>>
>>103024732
I think in a typical application, if any number ever got big enough to overflow the actual problem lies somewhere else and not with the addition itself
>>
File: 1725809693671347.gif (853 KB, 220x220)
853 KB
853 KB GIF
>>103024761
>developers in the 80s
>"why would anybody ever need to count higher than 256?"
>>
>>103024634
hobbjarne
>>
>>103024768
apparently there's even 4-bit microcontrollers, whatever the fuck that means

https://archive.org/details/bitsavers_sharpdataBomputersDataBook_31076011/page/n127/mode/2up?view=theater
>>
>>103024732
Lazy composable streaming of precision is where it's at. Fuck modular arithmetics with manual checks, fuck saturated arithmetics (unless you exploit hardware support, hardware support is cool), fuck bigints, fuck everything with floating points. Especially fuck everything with floating points. Points were never meant to float.
>>
>>103024732
don't you mean carry?
https://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt
>>
>>103024808
>The processor in Barbie typewriters that can encrypt is a 4-bit microcontroller.
https://en.wikipedia.org/wiki/4-bit_computing

>encrypted Barbie typewriter
>>
>>103024872
Barbie confused authority and hierarchy.
>>
>>103024893
>all cops deserve to be tortured to death, and if society devolves into anarchy, so be it
Better?
>>
>>103024872
>wow barbie, that's a really cool opinion
>*shoots barbie*
>anybody else refuse to consent to my authority?
>>
>>103024872
>encrypted Barbie typewriter
lel. I bet 10yo girls would have find this stuff fascinating in a toy.

I myself was searching about the hardware specs of a the "Harry Potter Hogwarts Labyrinth" toy I had. Turned out to be a "Tiger electronics" toy and I found the website of a dude decapping and photographing chips of similar toys with the mention of the Sharp chip. The Sharp SM83 used in the GameBoy is in the same Sharp data book btw, the 1996 version contains its instruction set.
>>
>>103024927
>from your behind: "sure"
>blasts a new orifice into your cranium
>all sorts of interesting matter spills out
Shall not be infringed.
>>
>>103024943
uhhh, chud, sounds like you just used force to derive your authority, hypocrite much?
>>
>>103024947
That's a good point! I'm sure future generations will be all about it, and not about your spaghetti all over the floor.
>>
>>103024727
>copy the buffer and let the first thread fill it up again
ok tried this, faster than single threaded and doesn't randomly take twice the time
I think I understand why mutex+cond is better
>>
>>103024962
Or you could swap buffers, like a swap chain.
>>
>>103024943
>from the television: "infamous white supremacist 'anonymous' just assassinated the president, also we found child pornography on his pc"
>nukes you from orbit
>military general: "tragically I must now assume the role of president, I trust there are no objections?"
Oh no.
>>
>>103016666
Rustranny seething hard per usual.
>>
>>103024975
>nukes
As long as it kills many others I'm OK with it.
It's also going to be a blast once my dead-man switches activate - OCB is going to be a joke compared to this.
>>
File: 1728065404379153.png (365 KB, 680x676)
365 KB
365 KB PNG
>>103024980
Is that Rustranny in this thread with us right now?
>>
>>103025010
It's important to document the collapse into clown world so future generations won't repeat our mistakes.
>>
File: 1725029355827335.jpg (781 KB, 1000x1000)
781 KB
781 KB JPG
>>103025016
What if we want future generations to repeat our mistakes?
>>
new thread
>>103025159
>>
>>103024933
Hell yes.
>>
>>103007187



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