[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: 1728371121745.png (130 KB, 1024x512)
130 KB
130 KB PNG
Welcome to the Daily Programming Thread. What are you working on, /g/?
Previous thread: >>102688861
>>
Hi sisters! Does anyone have any experience with flatbuffers? Any point in using them over protobufs?
>>
>still clang
>declspec naked doenst work
>attribute preserve_none doesnt work
>register variables work half-baked
>decide to look through the source code for these mystical attributes
>download and extract
>extracted source is 1.7 GB and almost blows up the ramdisk
>aliased_global, aliased_global_2, and global_alias_2 all only generate warnings
>no_sanitize("undefined") only applies to functions, Objective-C methods, and global variables

what a complete waste of anyones space and effort
if you ever wondered why clang allegedly compiles faster than gcc its because it only supports half the shit anyone is interested in. Never mention clang again, Ill rip you to shreds
>>
>>102729080
wikipedia says flatbuffers provide faster and zero copy deserialization at the cost of more complex handling code and less supported operations
>>
>>102729320
i will continue to, and there's nothing you can say that will stop me
and hey there's always writing a clang plugin and just adding the feature yourself
>>
>>102729367
no proper register variables => no calling convention extensions.
which is no issue in gcc (has broken linker comments and TLS emulation bs though), but in clang? fucking impossible. you had one job and fucked it up. there is no recovery from that
>>
i dont know how to structure my program
>>
>>102731288
You don't write programs, you write interfaces and implementations
>>
>>102729473
Fuck this is even worse the longer i think about it
I either get no register use or register use plus register preservation which is two bytes on eithere nd
cant nop them after compilation too becausee i never know how long a function is. what kind of morons are working at clang that they dont include such a simple thing?
>>
File: soon (tm).png (75 KB, 1692x808)
75 KB
75 KB PNG
>>102729025
Took a while to get the audio working smoothly without COM, but so far it's mostly operational.

AES and PGP implementation is coming along. Key generation works excellently, re-made the key profile feature which will save all your keys + their settings and place them into a single compressed file. Server side implementation for AES is fine.

It's a challenge of getting the PGP signing properly implemented into the UI in a way the ensures authenticity. It's a text field, so you can't select the messages individually as a single object and click 'check signature' very easily. So maybe a unique ID for PGP signed messages, and then a custom dialog that grabs message by unique ID so you can verify signature. Still at the drawing board on this.
>>
; vec4_projPos.z = ROUND(vec4_projPos.z);
mov TMP_0.xy, ZERO_ONE ; TMP_0.x = 0.0
; TMP_0.y = 1.0
mov TMP_1.xy, vec4_projPos.zz ; TMP_1.x = vec4_projPos.z
; TMP_1.y = vec4_projPos.z
add TMP_0.xy, TMP_1.xy, TMP_0.xy ; TMP_0.x = vec4_projPos.z
; TMP_0.y = vec4_projPos.z + 1.0
flr TMP_0.xy, TMP_0.xy ; TMP_0.x = floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
mov TMP_2.xy, TMP_0.xy
mul TMP_1.y, NEGONES ; TMP_1.x = vec4_projPos.z
; TMP_1.y = -vec4_projPos.z
mul TMP_0.x, NEGONES ; TMP_0.x = -floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
add TMP_0.xy, TMP_0.xy, TMP_1.xy ; TMP_0.x = vec4_projPos.z - floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z) - vec4_projPos.z
cmp TMP_0.x, lt, lt, TMP_0.y
ifc cmp.x ; decimal is closer to floor than to ceil
mov vec4_projPos.z, TMP_2.x
.else ; decimal is closer to ceil than to floor, or is 0.5
mov vec4_projPos.z, TMP_2.y
.end

Is there any way I can simplify this? Here's details on the instruction set:
https://github.com/devkitPro/picasso/blob/master/Manual.md#supported-instructions
https://3dbrew.org/wiki/GPU/Shader_Instruction_Set
>>
>>102733745
and now with better formatting:
; vec4_projPos.z = ROUND(vec4_projPos.z);
mov TMP_0.xy, ZERO_ONE ; TMP_0.x = 0.0
; TMP_0.y = 1.0
mov TMP_1.xy, vec4_projPos.zz ; TMP_1.x = vec4_projPos.z
; TMP_1.y = vec4_projPos.z
add TMP_0.xy, TMP_1.xy, TMP_0.xy ; TMP_0.x = vec4_projPos.z
; TMP_0.y = vec4_projPos.z + 1.0
flr TMP_0.xy, TMP_0.xy ; TMP_0.x = floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
mov TMP_2.xy, TMP_0.xy
mul TMP_1.y, NEGONES ; TMP_1.x = vec4_projPos.z
; TMP_1.y = -vec4_projPos.z
mul TMP_0.x, NEGONES ; TMP_0.x = -floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z)
add TMP_0.xy, TMP_0.xy, TMP_1.xy ; TMP_0.x = vec4_projPos.z - floor(vec4_projPos.z)
; TMP_0.y = ceil(vec4_projPos.z) - vec4_projPos.z
cmp TMP_0.x, lt, lt, TMP_0.y
ifc cmp.x ; decimal is closer to floor than to ceil
mov vec4_projPos.z, TMP_2.x
.else ; decimal is closer to ceil than to floor, or is 0.5
mov vec4_projPos.z, TMP_2.y
.end
>>
File: 1713473100930.jpg (158 KB, 1280x1280)
158 KB
158 KB JPG
>tfw rust is looking pretty fucking sexy and convenient
>but the community is fucktarded
>packages plagued with npm-itis
>omega bloated llvm behind the scene
Fucking hell even if you do it right and ignore the so called "good practices" where you're supposed to write unreadable incantations just to avoid a simple little unsafe and pretend there's no community it still feels wrong.
>>
>>102733891
forgot a parameter on the muls
>>
>>102734234
because it is, rust is not formally correct like ADA and putting it in cars and kernels is the worst blunder of the 21th century
>>
>>102735915
>formally correct like ADA
what does this mean? may i see it?
>>
>>102736501
maybe with a security clearence
>>
>>102736636
is rust such a threat that you have to make up lies?
>>
if movies:
flag = False
for movie in movies:
for actor in data["actors"]:
if actor in movie.text:
for staff in data["staff"]:
if staff in movie.text:
link = "https://www.amazon.com" + "/".join(movie.a["href"].split("/")[:-1])
if "DVD" in movie.text:
print(f"WARNING - DVD {id}")
data["links"].append(link)
flag = True
break
if flag:
break
if flag:
break
>>
>>102729025
Making a web game in php (scifi strategy game).

Working on implementing buildings, being able to build them, get resources from them etc.
>>
these c++ modules basically work the way I always thought headers should have worked
>>
if 'xolatile' is still reading these threads, you really need to bug test your shit, your 'xarbon' program outputs a 20x20 blank image no matter what I try, and if you're going to try to show it off online then make sure people can just download it and compile it, without having to go through your gitlab and hunt down your special snowflake custom libraries that for some stupid reason aren't included and aren't mentioned in the readme. Basically, stop being a coder bro
>>
>>102737263
Did you really download and compile a random namefag's malware?
>>
>>102736983
>in PHP
I'm really curious how you go about doing the graphics for such a thing. I'm fairly novice with PHP and don't do much webdev stuff. Are there libs like raylib or something for graphics rendering?
>>
>>102737463
It's gonna be text based primarily. Graphics will be there to support it.

I know Raylib has been ported to PHP, but it's not the goal to create a 2d/3d world.

I do, however, want to play around with three.js at some point to generate planet models embedded on the page (and be able to rotate it with the mouse because why not), complete with shaders and effects and whatnot to make it look cool.

After making a brief prototype I've put it back on the backlog for now, though.
>>
File: 1722757689306008.png (33 KB, 706x264)
33 KB
33 KB PNG
I don't get it, isn't std::vector just a pointer to some data allocated on the heap under the hood? Wouldn't passing by value just copy the pointer which would still be pointing to the same data?
>>
>>102736681
ADA is used in real shit like planes and guns that a joke hobbist academic language will never touch
>>
>>102737633
c++ is """smart""", when it realizes it's being copied it copies EVERYTHING
>>
>>102737723
Write a single line of Ada. I'll wait. Show us how great it is, considering I see you shilling it in every thread.
>>
if it just copied the pointer you would double-free because there would be 2 copies of the vector and the destructor would call delete/free for each copy.
Of course the way how it's actually implemented is that it has a copy constructor which allocates and copies the data instead of copying the pointer.
This is why the old C++03 style of passing strings
(const std::string& str)
is depreciated, now you just use std::string_view, or const char* or if you are making a constructor in a class, you would use std::string like this:
struct test
{
std::string m_name;
//explicit prevents you from doing: test A = "test";
//as a way of constructing the class when there is only ONE parameter
//this is also how std::string str = "test"; is constructed,
//since everything in "" in your code file is a char* C-string.
explicit test(std::string name)
: m_name(std::move(name)
// use a comma to add more members
{}
};

This code is the best way of initializing the string because you can use C string (AKA any text in your code, std::string will be allocated using the C-string constructor but it will be moved into the member variable using the move in the constructor), but you can also optionally move strings into the class to avoid a copy (you construct a string, lets say from std::getline(str), then you don't need the string anymore, so you just std::move(str) that into the class constructor).
>>
>>102737633
no, because that would be stupid, you'd cause a double delete of the backing pointer when both destructors triggered
std::vector has a non-defaulted copy constructor and copy assignment operator that perform a deep copy as well as a move constructor/move assignment operator that just transfers the pointer over and leaves the other vector in a valid but undefined state
move semantics are kind of complex
if you're learning from something actually worth learning from it'll probably mention them and rvalue references (references to a temporary) later on
>>
>>102737633
This stuff is just so fucking hideous. I blame C++ for keeping me from getting into programming much sooner. I had a book "teach yourself c++" and the digital mars C/C++ compiler and windows 2000, I struggled with that for a while and gave up. Then didn't try again for a few years until I found a language that didn't suck balls and then quickly started programming all kinds of fun projects. Now Im fluent in C and every time I see C++ it's always nonsensical and awful looking, like, what the fuck are they doing with the shift operators. How is that contrived bullshit supposed to be nicer than just using printf()? Fuck C++ and fuck bjarne soupstroup
>>
Is it a stupid idea if I've been thinking about rewritting a certain webapp I made in Django but in Go or C++?
>Why in Go?
I want to learn another language popular in webdev that is not Python in order to increase my chances of getting an actual job soon and also separate myself from python jeets and Go seems like the white man's choice
>Why in C++?
I actually would prefer to avoid webdev alltogether and so I'm learning C++, except I can't think of any projects other than rewritting a past project. Hmm, now that I type this out it sounds quite contradictory.

Ugh I just feel lost.
>>
>>102738093
why do C programmers get so triggered by using the same symbol in different contexts?
operator overloading, in particular the additional meanings consistantly used by the C++ standard library, is far from a problem for code readability
being bother by something like template metaprogramming i'd understand but
do you complain about redirection in bash using > and >>? or pipes using |
>>
SO MANY SPECTRE MITIGATION WARNINGS

I DO NOT CARE
>>
File: file.png (619 KB, 976x850)
619 KB
619 KB PNG
>>102736833
has_actor = [movie for movie in movies if any(s in movies.text for s in data["actors"])]
has_staff = [movie for movie in has_actor if any(s in movies.text for s in data["staff"])]
>>
>>102738067
ment to reply to >>102737633
But I will admit the string reference isn't connected to your problem, but it's a good introduction into the issues related to trying to avoid redundant copies in C++, with a very common object (std::string) that get's copied.
Thankfully 50% of the time it doesn't matter in terms of performance matter because std::string has small string optimization (no memory gets allocated using a fancy trick if you use less than 15~ letters), so before you prematurely optimize your code to avoid copying strings, just remember sometimes it doesn't matter, and if you used const std::string&, I am 100% certain the allocation gets optimized away on every compiler, using std::move is technically more precise to what you want your code to do, other than that it technically doesn't matter (I think it's sloppy).
>>
>>102738238
Using any is a known anti-pattern.
>>
>>102738277
eli5 me
>>
>>102738182
>why do C programmers get so triggered by using the same symbol in different contexts?
Because Japanese are terrible programmers, too.
>>
>>102738332
How come? Aren't they like a beacon of humanity, technology and progress?
>>
>>102738372
No, they're the beacon of crunch. Monkeys on typewriters and all that.
>>
>>102729025
Is there more to optimizing software other than reducing the amount of instructions being run.
>>
>>102738372
xenophobia towards non-japanese brands and IBM
>>
File: pbbg.png (519 KB, 1920x1080)
519 KB
519 KB PNG
>>102736983
>>102737463
>>102737505
early wip
>>
>>102738431
these games were kino
>>
>>102738402
Oh my word, yet. Register renaming, instruction size, individual instruction speed (https://uops.info/table.html?search=loop&cb_lat=on&cb_tp=on&cb_SNB=on&cb_IVB=on&cb_HSW=on&cb_ADLP=on&cb_ADLE=on&cb_ZEN2=on&cb_ZEN4=on&cb_measurements=on&cb_doc=on&cb_base=on), memory references, memory speed, cache sizes, cache utilization ...
>>
>>102738450
Still are. There's a whole (niche) community dedicated to building, playing and sharing these kind of games.
>>
>>102738402
It all depends on the project and good planning.
First you need to pick the fastest to prototype and easiest language to solve your problem as quickly as possible.
>>
>>102738402
yes, considerably more
managing all the other hardware resources
also depending on what you're doing and how the most optimal implementation could have more instructions, considerably more so even, not less
>>
>>102738093
>fuck bjarne soupstroup
2 lewd 4 /g/
>>
>>102729025
Java bros... our response?
>>102729320
no shit? clang is still good enough for me though and it's still a better "dev compiler" than gcc at least in terms of modern features like jump to definition, code completion, inline macro expansion, etc. really can't do shit without it desu. for releasing shit, let some downstream cuck worry about it.
>>102736636
what screening level and access program do I need? also pretty weak that your proof of correctness is considered a national secret free from academic scrutiny.... you sound like a schizo retard.
>>
>>102738015
with Ada.Text_IO;
use Ada.Text_IO;

with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;

procedure Main is
function Ack(M, N, P: Integer) return Integer is
begin
if P = 0 then
return M + N;
elsif P = 1 then
return M * N;
elsif N = 0 then
return M;
elsif P > 2 then
return Ack(M, Ack(M, N - 1, P), P - 1);
else
return -1;
end if;
end Ack;

Count : Integer := Ack(4, 20, 69);
begin
Put_Line("OP just sucked " & Integer'Image(Count) & " cocks, in a row");
return;
end Main;
>>
>>102729320
>extracted source is 1.7 GB and almost blows up the ramdisk
weaksauce potato user
>>
>>102738561
>Java bros... our response?
Not everything needs a "response"; let the swine wallow in their excrement, don't join them.
>>
File: 1719207707544432.gif (1001 KB, 220x220)
1001 KB
1001 KB GIF
>>102738593
Don't need a response if you throw exceptions all day.

throw new Tantrum("REEEEEEEE!");
>>
File: file.png (29 KB, 339x119)
29 KB
29 KB PNG
>>102738569
>>
>>102737723
are you going to show us how ada is "formally correct" or are you going to cement your place as a liar who is not worth listening to?
>>
>>102738561
>clang is still good enough for me though
Sorry I have standards
>>
>>102738894
not anon but I use clang for ubsan to detect unsigned integer under/overflow and I use clang tidy for narrowing conversions (you need to manually enable this, this also has a lot of false positives you need to handle).
So essentially every time I need to narrow a value, I use // NOLINT
If the value overflows / underflows while casting and it's intentional, I use a static_cast, this disables the warning and it disabled ubsan's under/overflow check.
In short this is a roundabout way of implementing the feature rust has, and I can't use -Wcast (or whatever it's called) because GCC errors are harder to supress than clang-tidy errors (push/pop vs NOLINT+NOLINTNEXTLINE), since I have like 200 suppressions (opengl has a lot of narrowing / casting you can't really avoid, but if an overflow/underflow did happen, that's an error I want reported)
>>
>>102738989
Thats nice
but if it doesn't compile its worthless to me
>>
>>102739029
sorry when I said errors I meant warnings.
>no I am talking about missing features
#ifdef __clang__
???
>>
>>102739219
Features my code literally cannot function without. Im not gonna fucking bother with fucking ifdefs
>>
>>102739252
what are you doing that would require specific features from GCC?
I assume you are doing something with assembly, but every piece of assembly code I have ever seen always has a #ifdef NOASM option so that the person making the assembly can measure if their assembly is exactly the same speed as compiler optimizations + futureproof for most architectures.
Like i looked up declspec(naked), but maybe you could use __attribute__((naked))?
The only thing I could come up with is maybe you are making a JIT compiler similar to luajit.
>>
>>102739364
mapping nonvolatile registers to variables to add parameters to functions not present in original calling conventipon >>102716872
i KNOW what is happening on instruction level and what i want to do, which is saving up on redundant tls lookups, clang is just too garbage to do it
>__attribute__((naked))
not available for amd64
>>
>>102739451
specifically i have registers with values i want to expose to callees so that callees dont have to look up the vlaues themselves because the caller already does it, but i cant pass those values normally because i cant touch parameter registers or stack, so register variables it is
the registers are always the same, theyre always nonvolatile, the functions just need to KNOW about them
>>
>>102739451
That sounds fast and all, but I don't see the excuse for why you can't just ifdef it.
I would ifdef it just to benchmark.
And I think you don't need to use the TLS provided for you, thread local storage is just a convenience, it just works even if it's a bit dirty, I'm sure there is an alternative way for whatever you are doing.
>>
>>102739739
because the moment i do it with gcc i have to account for emulated TLS which requires a different kind of lookup which is also much much slower than native TLS
this isnt just about speed but also about codesize, this lookup happens a couple thousand times. every byte saved are a couple thousand bytes saves

>And I think you don't need to use the TLS provided for you
Wrong
>>
>>102739778
>Wrong
signals?
>>
>>102739885
Don't exist on windows, and it needs to be synchronous
>>
>>102739899
I feel like if you are accessing the TLS often you might as well just make it a god object (carrying the data you need from the TLS into the function parameter) and deal with having one less register for all the functions that need to carry it.
Maybe if you had a poorly designed callback or signal (or on windows, an exception handler callback?), you may "need" a TLS, but other than that, it sounds like a want, and it's not faster, but it's probably uglier I admit (but it depends, I would not call this pretty >>102716872).
>>
>>102740026
>into the function parameter
>>102739540
> i cant touch parameter registers or stack
>>
man, chatgpt is really useless as a language tool, no matter how you prompt it it gets languages, versions, and concepts all mixed up
>>
>>102738431
This is really cool. I would play this once it's finished.

Do you think you'd use three.js for a gps or mapping system of the planets, or just for visual aesthetics?
>>
h
a
s
k
e
l
l
>>
>>102739540
>i cant pass those values normally because i cant touch parameter registers or stack, so register variables it is
you writing your own calling convention? that's unusual
>>
>>102737183
yes except they actually don't work
>>
White man?
>>
>>102741581
extending
>>
File: damn_it_feels_good.jpg (12 KB, 320x180)
12 KB
12 KB JPG
>roll own memory allocator because autistic
>roll own cstrings assembler lib because autistic
>roll own c++ stdlib because autistic
>force all of the above into prod at work and use exclusively in my own code
>everyone else uses framework slop
>project releases, automated crash reports start rolling in
>tens of thousands of crashes, hundreds of unique stack traces
>mfw 0% of them are in my lib
>>
>>102744007
But anon, don't you know that you've spent ten times the amount of effort and time of your fellow colleagues? That's what /g/ told me, so it must be true.
>>
File: sc.gif (732 KB, 498x346)
732 KB
732 KB GIF
>completely new to coding
>learning basic javascript stuff
ok this is not too hard
> guide starts talking about utf-16 enconding
i am clearly too stupid to attempt this
>>
>>102744243
funny thing is I actually enjoyed doing all those things
>>
>>102744596
If programmers understood character encodings we wouldn't have so much mojibake. You'll learn.
>>
I have to fix a bug in a legacy codebase written for .NET 2.0 and found this monstrocity

lock(queueLock){
queue.Enqueue(data);
Monitor.PulseAll(queueLock);
}

//somewhere else
lock(queueLock){
while(queue.Count == 0){
Monitor.Wait(queueLock);
}
result = queue.Dequeue();
}
[/spoiler]
There is a deadlock that freezes the ui, and only comes up on one pc in a very specific situation, and only if compiled in Release mode - and I am 90% sure this causes it

However the way I look at it it shouldn’t work at all, ever. Why does it only cause a deadlock sometimes?
>>
File: 1699015546093647.png (1.21 MB, 1290x1363)
1.21 MB
1.21 MB PNG
Imagine listening to autistic rambling of your coworkers.
>>
>>102744712
Why wouldn't it work? It looks like a very standard use of a monitor. Data is enqueued with the lock down, cond var is triggered. Consuming thread waits on cond var until data count is gt 0, then dequeues with lock still down. The only problem I can see is that "Monitor.PulseAll" is called before releasing the lock, but that's not going to cause any serious issue it just means that any woken thread in Monitor.Wait will have to wait a while longer for the producer thread to drop the lock before he can reacquire it. That an I guess it seems kind of weird that they're only pushing one data but waking all waiting threads (why not just wake one).
>>
How do I make chatgpt/canva do what I want? :( I need it to fix my code but it doesn't understand and this is due for work tomorrow. Fuuuck.

Brutal letdown when it says "I know exactly what you're after, don't worry!" and then still gives me garbage.
>>
File: shiiiet.png (481 KB, 865x610)
481 KB
481 KB PNG
>>102745066
>How do I make chatgpt do what I want?
shit nigger if you could answer that you could save the world
>>
>>102745100
lol, fuck
>>
>>102745040
I am not familiar with how classic Monitors work, that’s why it looked weird to me. I normally just use SemaphoreSlim
Thanks for explaining it
>>
>>102744712


a pulseall is sent after a thread has checked the condition but before it calls wait at the other place. this results in the thread entering the waiting state without knowing that a pulse was sent
>>
>>102745165
desu I'm not super familiar with the .NET/cshart implementation, but that's how monitors/condition variables typically work. (that is to say, the "wait" function usually unlocks the lock for you while waiting and doesn't expect you to wrap the wait call in an "unlock" block or whatever, which is I assume what you were missing that made you think that code would deadlock).
>>
File: war_face.png (994 KB, 1225x679)
994 KB
994 KB PNG
>debugging data race
>single crash dump
>repro rate less than 1/100,000
>no symbols assembler only because I was too lazy to save debug symbols
>notice linked list manipulation
>find matching spot in source
>notice that there will be a single access to critical data from the destructor of an object that dies outside the scope of the lock
>another bug fixed
I live for this shit guys, it's like people who like playing vidya on the hardest settings.
>>
>>102745191
The assumption is that Wait is implemented in such a way that that cannot happen (it'd be pretty useless otherwise).
>>
>>102736833
This code is bussing. Also Lua, Julia or something I've never heard of?
>>
>>102741254
Not sure yet. I do want some sort of map system, but undecided on the final implementation yet.

I'm thinking to start with a list of coords of PoIs first, then move to a hex grid later once scope allows. Not sure yet either on the technical details of that, whether it's HTML elements or a canvas layer. 3js seems overkill for it, unless I go balls to the walls and make it full 3d
>>
>>102745703
Can you express this in code?
>>
I hate refactoring.
So many things to keep in mind, so much work already done, and so much left to do.
>>
>>102738402
microprocessors are akin to an engine in a car, there are a bunch of different things that can bottleneck performance within and you have to diagnose what parts are worth optimizing. reducing instruction counts won't help you if your code is full of unpredictable branches, large dependency chains, or if your different execution units are unavailable for work. it is maybe 30 or 40x more complex than just "reducing number of instructions".
>>
>>102738151
Just do it, it looks good for your portfolio
>>
File: 172777869345195749.png (15 KB, 512x512)
15 KB
15 KB PNG
Is it kino?
>>
>>102745467
python
>>
Currently doing the C# Players Guide book and having fun. My first 1 month with programming are good.
>>
>>102745392
https://learn.microsoft.com/en-us/dotnet/api/system.threading.monitor.pulse?view=netframework-2.0
>The Monitor class does not maintain state indicating that the Pulse method has been called. Thus, if you call Pulse when no threads are waiting, the next thread that calls Wait blocks as if Pulse had never been called. If two threads are using Pulse and Wait to interact, this could result in a deadlock.

I mean, that seems to be the case according to this. a missed wake up means you miss it. it's probably what OP's bug is. he has to set a time out on the .Wait call so he can retry it. At least in futex world, I would use some kind of time-out period on waiting. OP should be using the 3-arity Wait method with a time out, not the 1-arity one that seem to block forever: "Releases the lock on an object and blocks the current thread until it reacquires the lock."
>>
>>102744607
can confirm. Doing your own STL turned out to be pretty comfy.

>t. doing old games(VC++6) binary injecting library
>>
File: 1724326649041638.jpg (29 KB, 475x482)
29 KB
29 KB JPG
>>102745700
>create some default planets with some faction lore
>make a few high-level NPCs you can interact with that have some actionable autonomy like trading and stuff, and use a local language model to play their role so there's always unique interactions and conversations
>create an algorithm to procedurally generate new planets
>your game now will always provide a unique experience with infinite expansion
>charge a $2.99 monthly subscription for players and add leader boards
>>
Could someone help me solving this?

I figured the dice is binary so
A = 11110 = 30
E = 11010 = 26
H = 10111 = 23

But no idea how to go from here
>>
File: uh.png (161 KB, 481x305)
161 KB
161 KB PNG
>>102747429
forgot image
>>
>>102747441
Whats this for Anon?
>>
>>102747465
A puzzle in some local magazine
You can potentially win a switch

But I'm just wondering what the thought process should be

For example original in ASCII
A = 65
B = 66 etc

Here
A = 30
B = 29

It's probably basic math but not sure
>>
>>102747489
or perhaps base64 with some different table mapping

The full string is:
aYGbGPgyhAP80QX8m+hA4Dngapo=
>>
>>102746946
No no, you're misunderstanding how a monitor/condition variable works. Yes, it will miss a wake if the waiting thread waits after wake has been called. However, the way the code in >>102744712 is written guarantees that will never happen. The only way for a thread to start waiting is for it observe the queue being empty with the lock down, and because the unlocking of the lock that happens inside the Wait call is "connected"/"atomic"/however you want to call it with respect to the start of the wait itself, there's no opportunity for a producer thread to jump in, add data, then call wake, until after the thread that saw an empty queue has already started waiting. The code anon posted is a basic bitch textbook example use of condition variable (minus the minor issues I mentioned in >>102745040, which are only perf problems and wouldn't cause a deadlock).

>At least in futex world, I would use some kind of time-out period on waiting. OP should be using the 3-arity Wait method with a time out, not the 1-arity one that seem to block forever
No no no. It's sloppy concurrent programming to use a timeout unless you actually want a timeout. Don't use timeouts to avoid deadlocks just because you're too lazy to actually figure out what's deadlocking.

Anon's deadlock problem must stem from something other than the code he posted, or from some other unusual circumstance (for example, multiple waiters waiting in a loop, he pushes two datas expecting both threads to exit the wait, and one thread manages to lap the other thread and eat both datas such that by the time the other thread wakes up the queue is empty again so it keeps waiting, etc.)
>>
>>102747429
Is the result supposed to be an actual word?
>>
>>102744800
This cancerous shit is making it's way into codebases now? Jesus Christ I already tell people to fuck off when they send me these through texts. I guess once it gets autotranscribed and summarized by chatgpt it could be ookay.
>>
>>102747861
>>102745040
Correction: I looked up the documentation for "Pulse" and "PulseAll" and apparently you are supposed to call those with the lock down:

>The Pulse, PulseAll, and Wait methods must be invoked from within a synchronized block of code.
>Only the current owner of the lock can signal a waiting object using Pulse.

This appears to be a result of how they've implemented the internal queuing and is a C# oddity. In pthreads/c++ stdlib/whatever other condition variable implementation, it's usually better to call wake after releasing the lock (to allow the woken thread to reacquire the mutex immediately). See: https://stackoverflow.com/questions/17101922/do-i-have-to-acquire-lock-before-calling-condition-variable-notify-one
>>
>>102744800
>7 seconds of garbled hindi
>>
>>102744800
>I don't have time to write a 3 seconds reading phrase so I'm going to do a 5 minutes listening rambling spergout
HANG all normalfaggots.
>>
>>102744712
Update, the problem was something else entirely, this code works fine
>>
>>102744800
Copilot, sum this comment up for me
>>
>>102747886
yes probably
>>
File: puzzle.png (35 KB, 1465x678)
35 KB
35 KB PNG
>>102748234
Is there anything more to this puzzle or is the b64 string and the 3 dice all there is? I started working on it but not really seeing anything, I think you're right about the binary thing since the positions of A, E, and H match up, but not really seeing much else yet...
>>
just wrote a book worth of comments just to have a slightest chance of understanding my code in 3 months' time. do you comment much, /dpt/?
>>
>>102748571
My boss has an autistic hatred of comments and believes “the code should speak for itself”. He gets into fights with engineers and statisticians working in other departments for making math comments or explaining their formulas
So I dont write any at all
>>
>>102748607
There's well-known instances in which the compiler produces shit code unless you use specific constructs that everyone else reading the code for the first time will be utterly confused by.
Your boss sounds like he's one of the retards who think compilers will always emit the best code, even if he's provably wrong. If he doesn't see reason seeing this code he can't be helped, he's holding you back, and you should leave .
>>
>>102746598
fuck slack
>>
>>102748838
The opposite actually. His boss sounds like someone who's been around since before the 'sufficiently smart compiler' meme, and was moved to a management position in that time period too.

Also barely any shops are doing assembly analysis, or particularly care about the compiler outputting the best possible code. At most they care when the compiler starts shitting the bed and inventing bugs in otherwise fine code.

His boss is a retard for hating comments (assuming anon isn't lying on the internet, which he probably is) but there are a lot of people still in the workforce who were around when compilers were actually reasonable and reliable things.

The dipshits who believe in the sufficiently smart compiler science fiction tend to be the kind of retards who can't read code for shit in the first place, and entirely rely on comments and documentation.

What was causing the difference between value in the address in the dump vs the debugger view?
>>
>>102748571
Try to comment as little as possible. Currently have an average of a little more than one comment per 20 lines of code. Comments really shouldn't be necessary for a majority of code, or you're doing something wrong.
>>
Do you guys use AI to your day-to-day programming stuff?
>>
File: this.png (3 KB, 676x84)
3 KB
3 KB PNG
>>102749667
>What was causing the difference between value in the address in the dump vs the debugger view?
You mean "value in instruction vs. value in memory"? This.
>>
Reposting in this thread since its more relevant

>>102749463
>>
>>102750139
>adding a "LIMIT" to the sql query
Why would you think that?

Why would ANYONE think that? How *COULD* anyone think that seeking to a specific dataset is like LIMIT?
>>
>>102750443
Just in case I'm dealing with a bona fide retard here:
>LIMIT
Limits the dataset AT THE SERVER. The SERVER, upon processing the query and selecting the rows to send to you, WILL STOP WORKING based on the range you provide it with. The data not selected IS NEVER SENT TO THE CLIENT in the first place.
>seek
The server has sent the client the data, and now the client wants to jump around in it. The server did still select and send all the data.

I swear to god, PHP programmers ...
>>
File: file.png (297 KB, 1300x1108)
297 KB
297 KB PNG
learning advanced linear algebra to write machine learning stuff
>>
>>102750443
>>102750509
>Just in case I'm dealing with a bona fide retard here
>I swear to god, PHP programmers ...
kek, the reason I ask this is because the way our system works is that EVERYTHING is a server call. Almost every piece of Javascript we use is literally just jQuery ajax calls to the server. So when you want to display a list that has pagination, you are only showing the amount that you have indexed. Want to see the next set from that list? clicking the pagination buttons fires a server call to retrieve that next set. You are assuming that the server is called rarely and that once it is done you are just using the client to jump around that set but that is not the case here. Yes you are right its retarded, I know but that is how they built their entire system.
>>
>>102748838
what exactly is the issue in your image? just seems like endianness
>>
>>102748571
>>102749733
I personally try to comment as much as possible. It doesnt hurt and it saves so much time if you are writing meaningful stuff. Also helps prevent so many bugs and errors when you force yourself to explain why you are doing something instead of coding by the seat of your pants. The "code should speak for itself" meme is retarded because it can never explain the original writers actual intent or context when writing said code.
>>
File: movabs.png (3 KB, 720x60)
3 KB
3 KB PNG
>>102750752
There's nothing wrong with the code in the image. What is wrong is that the compiler, when using single character writes, was unable to inline said writes and encode them directly into the instruction, but instead placed a reference to memory instead. x64 supports 64-bit immediate operands in mov instructions (movabs). The code shown in the image generates the code in picrel; previously it didn't.
>>
>>102751353
// set x to 10.
// After this line, x will contain 10. x will NOT contain the value it had prior to this line. Luckily x was uninitialized before this line, so it did not have a meaningful value that we overwrote.
// The name x was chosen because it's a generic mathematical variable name.
x = 10;
>>
>>102751580
why don't you just make an issue or write to mailing lists

or in case of meme compiler like MSVC complain about it on Microsoft and they will make a fix in around 5 years or so
>>
>>102752068
Because I don't care enough to report it if the fix is that simple.
>>
>>102750080
>This.
Please tell me that's decompiled code and not your actual source.
>>
>>102752843
That's actual source code.
>>
File: 1717465037392298.png (43 KB, 853x613)
43 KB
43 KB PNG
is this true? how come I've never seen anybody do this?
>>
>>102729025
Can any fellow Rust troons tell me if there is any downside to using Rayon any time I need to do something concurrently? I've only just transitioned (to rust) and it seems a bit too good to be true.
>>
>>102752033
you forgot to explain what type it is and what cases it changes types (and why)
>>
Exploring the deepest darkest corners of C and uncovering compiler bugs in the process
>>
>>102753482
That's easy. I once did it on accident.
>>
>>102753035
The context switches and lock mechanics must be insanely bloaty.
>>
>>102753500
>once
lucky bastard
>>
Today I programmed the first USEFUL thing I've ever done. I made a 3 line python script to toggle the nums lock key on and off every 5 minutes, so I don't have to jiggle my mouse to keep the green status on Microsoft Teams at work.
>>
File: isildur.gif (56 KB, 640x266)
56 KB
56 KB GIF
>>102753500
>Please submit a full bug report
>>
>>102753880
Well, OK, more than once. I just haven't figured out the problem because I haven't cared enough yet.
>>
>>102751580
why are you presuming this is a bug, rather than some sort of optimization? are you certain it's not trying to reduce i-cache or pressure on different execution units?
>>
>>102753979
>why are you presuming this is a bug, rather than some sort of optimization?
1. Because the moment I used the *(uintXX_t*) syntax the compiler suddenly realized that this was an operand it encode directly into the instruction. If you look closely it didn't need to; all I asked for was dereferencing various pointers of various data lengths.
2. The instruction itself is dirt simple and introduces no latency at all (occupies any port for much shorter than one that has to fetch the data even from L1: https://uops.info/table.html?search=mov%20r64%2C%20i64&cb_lat=on&cb_tp=on&cb_SNB=on&cb_HSW=on&cb_ADLP=on&cb_ADLE=on&cb_ZEN2=on&cb_ZEN4=on&cb_measurements=on&cb_base=on)
3. Other compilers manage the optimization as well.
4. If GCC would be concerned with reducing instruction bloat they should look at their branch optimizations first.
>>
>>102750589
serious question, beyond the rules of matrix operations like multiplication, addition, inverse, and determinant what exactly is there to know? name drop a couple of useful things so I can look them up x
>>
>>102754094
go outside
>>
>>102754399
>t. mallocist
>>
>>102754399
Why would I want to risk meeting you?
>>
>>102729025
They don't see pound? What?
>>
>>102754494
C-Sharp.
>>
>>102754228
pseudo-inverse matrix
matrix factorization
projections
singular value decomposition and principal component analysis

determinants are not useful in practice afaik, they are theoretical tools because the computation is inefficient compared to factorization + gauss-jordan.

linear algebra goes deeper than you usually see in undergrad, even in math bachelors. I'm studying this stuff on my own after a math bachelors
>>
>>102755387
I remember in college they wanted me to compare
https://en.wikipedia.org/wiki/Jacobi_method
and
https://en.wikipedia.org/wiki/Gauss-Seidel_method
and wanted me to conclude that GS was always better because muh less flops because faster convergence only to BTFO them with a parallel implementation of Jacobi for the given problems because
>However, unlike the Jacobi method, the computations for each element are generally much harder to implement in parallel, since they can have a very long critical path, and are thus most feasible for sparse matrices. Furthermore, the values at each iteration are dependent on the order of the original equations.
>>
>>102755568
what was the course called? numerical linear algebra?
>>
radbg on linux when
>>
why that niggerish fucking nigger xlib defines shit like None or Always without a namespace
>>
What is the naming convention for static functions? I would like to omit the name of a source file from a function, but I also want to make sure that the static function is not confused with another function in the future.
>>
>>102755761
Investigation of numerical methods, but I am in Argentina, so don't look for it.
>>
>>102754228
you can take derivatives of vector expressions. This is a deep magic which I have no comprehension of, but when you have zT A z and you take the derivative you get 2 A z. spooky.
>>
>>102754525
They've been saying C-Pound this entire time.
>>
I'm trying to get into functional programming, why does it feel like so many of these concepts are extremely simple but explained in the most verbose, inaccessible ways possible? Or am I just an idiot? It reminds me when I was new to programming looking at tutorials and people always drop words they think you're just supposed to know but don't know yet
>>
>>102756303
>why does it feel like so many of these concepts are extremely simple but explained in the most verbose, inaccessible ways possible
Because retards write retarded longwinded analogies. The alternative is dumping incomprehensible category theory math notation on you. When they should be just giving you an example, leaving it at that and moving on.
Like explaining pointers to a freshman that can't grasp computer architecture so memory address is just gobbledygook to him.
>>
>the virgin std::abort vs. the chad intentional nullptr dereference
>>
>>102756303
I like FP but this is the thing about it that I hate the most. "Monoid in the category of endofunctors" is a meme because of this but some retards unironically think that's the correct way to explain it to a noob.
>>
>>102753500
Compiler bugs are fun, especially when they're reported against totally the wrong function in the wrong source file due to inlining/LTO composing the problem together from different pieces. There's some sort of achievement for triggering them I guess!
I remember fixing that (at least for my code) by moving one character from a file to another one. lol
>>
>>102755889
namespaces
i namespace almost everything with 1-3 letters namespace
like those static functions are a layer around some library (say X11) i namespace everything with X_ etc.
i dont namespace some things that are used everywhere (math operations, memory operations, allocations)
>>
made part of my program (argument parser) into a reusable library and I hate looking at it
>>
File: msvc.png (161 KB, 1625x1080)
161 KB
161 KB PNG
>>102756567
I know that feel Anon, oh lord I do. Just went through my hobby project and made pic rel, which is only a fraction of my collection. Finding clang or gcc bugs on the other hand is kind of like catching rare pokemon or something.
>>
>>102758114
I trust msvc more than whatever schizo wrote all that
>>
>>102754094
utf16 schizo anon is one of my current favorite /dpt/ posters, never change anon.
>>
File: tehe.jpg (65 KB, 800x800)
65 KB
65 KB JPG
>>102758142
>>
any good "modern c++" repos? I want to see how people are using these module things
>>
>>102758203
>c++ modules
gross
>>
wtf does TFD_TIMER_ABSTIME do in timerfd?
i dont get it
what do I set if i want to have timer that goes off every 500 ms?
>>
>>102758203
>how people are using these module things
Step 1 - instead of a header, make a module interface
Step 2 - there is no step 2
>>
File: this_2.png (2 KB, 590x64)
2 KB
2 KB PNG
>>102758146
My most recent proof-of-concept version (started a couple months ago, but didn't really have a need to finish it because no one here has ever gotten close to 10 seconds and reported it) foregoes the UTF-16 buffer and writes everything straight to UTF-8 buffers. Naturally - since this is Windows - UTF-16 => UTF-8 conversions are still required, but they're much more spatially local now and use vector instructions in the most simple cases (target string is simple ASCII). Run time didn't change much though, because the program is still spending over 90% in kernelland.

Naturally that also affected these instructions, but I found it disingenuous to post code that wasn't actually used productively yet. Hexdumping got easier and harder at the same time due to lack of certain vector instructions that are available for 2-byte words, but not single bytes.
>>
File: copyrignt.png (21 KB, 607x510)
21 KB
21 KB PNG
>>102758339
Me finding out this nonsense (back in May) was actually testing the vector converter, that's how long I haven't worked on it.
>inb4 what am I seeing here
An ASCII copyrignt [sic!] notice of an audio driver which the devs inserted into the registry using UTF-16 interfaces. Because the registry assumes UTF-16 internally it produces this beautiful mojibake.
>>
>>102758339
Does the registry differentiate between "wide text but only contains ascii range characters" vs. "wide text that contains non-ascii characters" or so you have to examine each string to find out which conversion routine to use?
>>
>>102758717
>Does the registry differentiate
As far as I can tell no, not even internally. Examination for ASCII-convertable UTF-16 sequences is stupidly easy though using AVX:
>generate 0xFF80 sequence in mask register (vpcmpeqw with itself + vpsllw/left shift)
>generate a zero register (vpxor)
>AND the input sequence with the mask register
>compare generated mask with zero register (vpcmpeqw)
>compare comparison mask with zero register a second time (sets all words that had but a single bit set in the 0xFF80 range to 0xFFFF)
>create MSB mask in GPR (vpmovmskb)
>count trailing zeroes (tzcnt)
>if CF == 0 the sequence contains one or more non-ASCII-convertable bytes starting at the position that the GPR indicates
>>
File: reg_sz.png (3 KB, 322x156)
3 KB
3 KB PNG
>>102758820
Forgot picrel.
>>
>>102737633
what font?
>>
i write code in every language like its C and i never bother learning any language specific gimmicks because i use alot
is it worth maining a language and learning all its gimmicks?
i never had a job yet so idk but i think eventually ill have to do that because my job would require it...
>>
>>102758820
yeah I guess you're right that would probably be faster since once you figure out you don't need to do a proper conversion, you've already got the data to narrow/output loaded into the register. I was imagining something dumb like looping through the entire string looking for a non-ascii byte before deciding to call one of two routines which you then go back and execute from the beginning, but you could just do it word by word and only fall through to the slow path for individual words that need it that'd probably be better.
>>
>>102754494
C-Octothorpe
>>
is copilot actually any good?
>>
File: hugepages.png (82 KB, 1000x570)
82 KB
82 KB PNG
>>102760005
Why don't you ask it how to use large or huge pages in file mappings, and compare it to this answer?
>>
>>102760071
I like how it says things it doesn't mean because it'll forget in 2 tokens.
>>
Just finished completely extricating Bullet Physics from my game engine. What a piece of shit. Characters and objects falling through terrain meshes. Forums: hurr are your triangles wound correctly are your normals pointing outward? YES NIGGER THEY ARE.
>>
>>102748291
No that's all
>>
>>102760080
Literally me
>>
What's the best 5th-7th gen game console to make homebrew for
>>
G++ is a garbage compiler but i *need* function overloading, also
>doesnt do macro name overloading
>>
>>102760893
you can try clang++
>>
File: run_away.png (39 KB, 1631x335)
39 KB
39 KB PNG
>>102760954
ARRRRRGH!
>>
>>102761012
What are you trying to do?
>>
>>102761020
Not me: >>102729320
>>
>>102760096
Based. Roll your own physics engine Anon.
>>
>>102760254
Seriously? Damn, I thought about it a little bit yesterday but there's so little info to go on. The dice thing doesn't really tell you anything beyond "there exists a 32 bit sequence...". I thought about maybe like, rotating the dice, like if you flipped them on their sides then what letters would they correspond to, then tried mapping the b64 letters to those letters, but it was still garbage at all four "orientations".
>>
>>102761318
* 5 bit not 32 bit, I meant 5 bit/32 different possible 5 pip patters.
>>
>>102761325
OOH nevermind lol I think I got it, just a minute
>>
>>102761350
>>102760254
Nope, stuck again. I thought I'd gotten it because I realized the dice is probably hinting that you should split the b64 into 5 bit groups, since it's 20 bytes long @ 8 bits that's 160 bits total = exactly 32 5 bit groups. There's a pattern of 00000 groups that looks like they'd correspond to spaces, so I figured I'd gotten it, but decoding according to the ordering I posted in >>102748291 (with space = 00000 and the last 5 groups just numbered as 1,2,3,4, and 5) gives you this string:
MF YVFGXFJB G5FQ W4IWZB 2 24 ZTZ

Seems like it might be a substitution cipher but online solvers didn't give me anything. Is the puzzle aimed at people who speak a language other than English by any chance?
>>
My programming language of choice is better than your programming language of choice for these very niche reasons, suck it chuddy
>>
>>102729025
>movq %1,%%rdi
>:"+r"(ignore),"r"(ourguy/*char* */)...
>register edx being used in movq
is my compiler retarded? x64 here, i know elf or something supports only getting addresses below 32bits from mmap but wtf really?
>>
g++ btw

also happens on 3 other lines with void* while some other lines just work???
>>
>>102761952
>no codetags
>doesn't explain what he wants to do
You're the retard here.
>>
>>102756303
Asking someone their opinion on FP would be a good litmus test for whether or not they're willing to learn anything remotely outside of their comfort zone.
>>
>>102761987
Sorry, I just have no interest in generating gigabytes of garbage per second.
>>
>>102760582
no
>>
>>102761976
>give me all your info goy

yeah i should just throw my phone away, see on the darkweb or not, latter meaning you were never worth anybody's time
>>
What can Scala do better than Python?

Asking for real - can use scala on my current work project but need to find a reason
>>
>>102762107
both are slow, if you had any competence toud be using c
>>
>>102762153
What I lack in competence I make up for in employment
>>
>>102762360
Isn't it the low skill jobs that should be afraid of AI the most?
>>
How much time should I spend prototyping and how much time should I spend designing
>>
>>102756303
That's exactly correct. Even something like a functor is extremely simple but obtusely explained.
>>
i don't want to work as a code monkey anymore, but i don't want to give up the comfort of remote and flexible work

what do
>>
>>102762984
> Doesn't want to Code
> Wants the Benefits from Coding
Don't go into tech in the first place
>>
lambda calculus
reduce ::
(Eq ref, VarTerm ref a) =>
( NonRedEx (Lambda ref (Combinatory a)) ->
Lambda ref (Combinatory a) ->
Lambda ref (Combinatory a)
) ->
Lambda ref (Combinatory a) ->
Lambda ref (Combinatory a)
reduce givenReduction = \case
Term x -> Term x
ref :\ i -> go . bracketAbstraction ref $ i
x :$ y ->
case go x of
Term K :$ m -> go m
Term I -> go y
Term B' :$ p :$ q :$ r -> go $ p :$ q :$ (r :$ y)
Term C' :$ p :$ q :$ r -> go $ p :$ (q :$ y) :$ r
Term S' :$ p :$ q :$ r -> go $ p :$ (q :$ y) :$ (r :$ y)
Term B :$ p :$ q -> go $ p :$ (q :$ y)
Term C :$ p :$ q -> go $ p :$ y :$ q
Term S :$ p :$ q -> go $ p :$ y :$ (q :$ y)
Term Y -> go $ y :$ (Term Y :$ y)
nonRx -> givenReduction (NonRedEx nonRx) y
where
go = reduce givenReduction
>>
>>102763668
lamdumb calculus
fuck your combinators, all my homies use nominal sets or de brujin representation
>>
>>102763949
I'm going to iterate on this implementation after introducing pattern matching. At the moment I'm going with combinators because the reduction strategy and bracket abstraction is so simple. But I'm not going to stick with Turner's combinators forever of course.
>>
File: file.png (19 KB, 527x256)
19 KB
19 KB PNG
>>102763668
>
Lambda ref (Combinatory a) ->
Lambda ref (Combinatory a)

>
Lambda ref (Combinatory a) ->
Lambda ref (Combinatory a)

??????????????????????????
>>
>>102766415
What's the problem?
>>
>>102766485
what the fuck does that even mean?
math nerds should keep their shitty abstractions to their head, and papers, not computers.
>>
>>102743993
>extending
So? It's still "write your own" just not "from scratch".
It's not something I can help with; I've never felt the need to dive that low.
Or rather when I do I just write the asm completely instead of trying to get the compiler to do it for me there. Using the stack pointer as a general purpose register is a bit too exciting for compilers (due to non-trivial non-local correctness constraints).
>>
>>102766584
Did you want me to explain it or were you just having a negative reaction to something you didn't understand?
>>
>>102766957
>Or rather when I do I just write the asm completely instead of trying to get the compiler to do it for me there
>>102739778
>a couple thousand times
>>
>>102766996
Enlighten me on that weird syntax, why do you have to do "expression -> same expression" not just once, but twice?
>>
>>102767108
It's arrow notation for a function. The terms between arrows are types so an expression like Int -> Bool describes the type of a function that takes an Int and returns a Bool. Since any function of n parameters can be turned into n functions of 1 parameter, you can chain these arrows together. String -> Int -> Bool is the type of a function that takes a String and returns a function that takes an Int and returns a Bool. In this case my function is one that reduces Lambda expressions which is why the signature has basically Lambda -> Lambda, because it takes a lambda expression and turns it into a smaller one. The reason this happens twice is because my function also takes another function as an argument and uses this function to reduce non reducible expressions further.

So in the function definition, you see the parameter givenReduction which is that given function which has a type
NonRedEx (Lambda ref (Combinatory a)) -> Lambda ref (Combinatory a) -> Lambda ref (Combinatory a)


Without getting into the weeds of type vars, typeclass contraints and other things, that's why.
>>
>>102761987
I mean, I like to use functional style in imperative languages. Sometimes you don't need to track state everywhere if you just pass it as an argument. And testing becomes easier. Other than that, I don't care about fp langs.
>>
>>102762107
If you like the jvm or need to use java libraries that don't exist in python then use it.
>>
>>102736501
Nta but look into SPARK / GNATprove.
>>
>>102738093
I live Bjarna for being a giga normalfag filter.
Same thing happened to me but via a C++ project by a Jew - I was too powerful to be filtered by Bjarne alone, they had to cart out Ben Goertzl for me.
>>
>>102767739 (cont.)
Ref: https://github.com/opencog/atomspace/blob/master/opencog/atoms/base/Atom.h
>>
>>102737633
If instead of changing a value you appended more stuff to the vector beyond its capacity to force it to reallocate, the second parameter would be pointing to invalid memory? Is it making a copy of the whole vector for the first parameter? Then I guess it wouldn't matter.
But what if the first parameter was also reference? Would the second be invalid then?
>>
>>102758993
Blue Waffle sans serif
>>
File: safety.png (143 KB, 753x402)
143 KB
143 KB PNG
Your safe C++.
RUST BTFO
>>
>>102767271
That was helpful, but is there a way to improve the syntax or declare it in a clearer way? there's no way you can parse that function in your brain and understand it first glance, it's too much variables to hold in your memory.
>>
>>102768235
You get used to it.
>>
>>102768265
>skill issue
understandable
>>
>>102768218
What is ^/a
>>
>>102768235
You can make synonyms or wrappers
type Age = Integer

f :: Integer -> Integer
f x = x + 1

g :: Age -> Age
g x = x + 1

can call
f 1
g 1


newtype Age = Age Integer

h :: Age -> Age
h (Age x) = Age (x + 1)

can call
h (Age 1)
cannot call
h 1

Synonyms let you exchange one type for another to shorten signatures.
Wrappers allow you to abstract a type to give it more semantic meaning.

For example, a lens can be represented by a function that takes a getter and returns a setter:
type Lens s t a b = forall f . Functor f => (a -> f b) -> s -> f t

so you don't have to write
(a -> f b) -> s -> f t

all over signatures and just do
Lens s t a b
>>
Name one thing that isn't easy to do in C.
Pro tip: you can't.
>>
>>102768218
>>102768321
template<class T, lifetime A>
class slice_iterator
{
T* p_, end_;
T&<A> const __phantom_data;
public:
slice_iterator([T]&<A> const s) noexcept
: p_(as_pointer(s)), end_(as_pointer(s) + s.length())
{
}

optional<T&<A> const> next() const
{
if (this->p_ == this->end_) { return optional::none(); }
return optional::some(&<A> const this->p_++);
}
};

fixed
>>
How do you manage tokens properly with API calls?

With each Get, Post and Delete request I have to put in a header with the bearer token. And I have each API endpoint call in each different function so all my function essentially has a token flag I need to specify everytime I call the function I need a token.

So this feels like I'm repeating myself over and over.

Another question is how do I manage my token expiriring during the script running? If its long running the token expires and the data returned is either nothing, which ruins data or it throws a nasty expection.

below are just 2 examples of this out of many.
function download_drive_item {
param(
[parameter(Mandatory)] [string]$drive_id,
[parameter(Mandatory)] [string]$item_id,
[parameter(Mandatory)] [string]$token,
$error_action = $false
)

$uri = "https://graph.microsoft.com/v1.0/drives/$drive_id/items/$item_id/content"
$headers = @{Authorization = "Bearer $token"}

try { return Invoke-RestMethod -method GET -Uri $uri -headers $headers } catch { if($error_action) { throw $_ } else { Write-warning $_ } }
}

function upload_file {
param (
[parameter(Mandatory)] [string]$file_path,
[parameter(Mandatory)] $file_content,
[parameter(Mandatory)] [string]$drive_id,
[parameter(Mandatory)] [string]$token
)

$uri = "https://graph.microsoft.com/v1.0/drives/$drive_id/items/root:/$file_path`:/content"
$headers = @{Authorization = "Bearer $token"}

[void](Invoke-RestMethod -method PUT -Uri $uri -headers $headers -body $file_content)
}
>>
>>102768453
Extending calling conventions: >>102743993
>>
Is there a good replacement for std::vector that has a nicer interface, like method chaining and things like that.
>>
>>102769121
write a compiler config file retard
>b-but mikkerzeft
kys
>>
>>102729025
make is not executing all of my recipes even with -B, what do?
>>
-d output shows its not even being considered D:
>>
>>102770355
>what do?
learn to read
-B means make all the targets listed on the command line
>>
Why does opening 1000 concurrent connections with aiohttp seem to rape my own connection despite my network usage not spiking? How do I open up an optim number of connections?
>>
>>102770584
>why does linux not allow 1000 concurrent connections
idk install gentoo
>>
I don't have to worry about performance, because I'm writing in C. C is so fast that I can write it any way I want.
>>
>>102768395
If
a -> f b
is a setter so is
s -> f t
. The caller hasn't picked f. It might get, set or modify, depending on the choice.
>>
>>102771838
You can always run faster... optimize better.
>>
>>102768569
>T&<A>
>[T]&<A>
Excuse me what? This isn't C++
>>
File: 1712811080697045.jpg (48 KB, 975x975)
48 KB
48 KB JPG
been reading a lot of c++ repos and none of them are using any of the fancy shit that 99% of the books are dedicated to they literally just use it in the most naive way possible I think I was bamboozled
>>
>>102758114
>msvc
shitty meme compiler
>>
Imagine getting filtered by MSBuild
>>
I have C++ code that is passing polymorphic objects back and forth with a C library as void*s (specifically, as callback closures in the nats C client).
I want a way to make sure that a closure I get back actually points to an object of the correct type before using it that way. My current idea is to store the hash of a fixed string (the class's name) as a data member of each object and then check that that member has the correct hash when I cast the closure to a the class pointer type.
Is this a good approach?
>>
>>102772231
MSVC can't optimize basic shit
>>
>>102772399
skill issue
>>
>>102772471
of Microbloat developers, yes.

Clang and GCC do way better job at optimizing things, from basic stores to vectorizing complicated loops
>>
>>10277255
>vectorizing complicated loops
nta but in my experience that hurts the performance more often than improve it
>>
>>102770339
>moving goalposts
>concessions have been accepted
>>
>>102772571
It depends on vectorizing cost model. In GCC and clang it defaults to 'cheap', so it's okay in the most cases
>>
>>102772399
lol

lmao

just every AAA video game title
>>
File: hero_data.png (18 KB, 1100x610)
18 KB
18 KB PNG
>>102772606
It can't even optimize smaller ones. Never could, and you would know that if you weren't about as competent as the average game dev.
>>
>>102772156
>bamboozle
I'm not impressed with the size of their cognitive loads either.
>>
>>102772643
l2code
>>
>>102772653
Don't tell me, sweaty. Tell the retards who think compilers can do wonders.
>>
>>102772643
>hero_data
wait, are you doing HoMM reverse engineering?
>>
File: read_file_overhead.png (59 KB, 954x1218)
59 KB
59 KB PNG
>>102772726
Warlords Battlecry 2. That one has been bothering me for twenty years ... turns out the little shits "encrypted" (/obfuscated) their save files, and did so by loading every single byte via syscall.

Every.
Single.
Byte.

Should I mention that the call has some userspace overhead, too?
>>
File: read_file_overhead.png (110 KB, 1110x2274)
110 KB
110 KB PNG
>>102772843
Whoops, my bad, that one's ReadFileEx.
The real ReadFile is here.
>>
They don't see hashtag?
>>
>>102768235
you can when you've done haskell for a while, it tells you quite a lot about the function
>>
can I just ai assisted decompile any program I want back into human readable source code yet
>>
>>102772994
Why don't you try that out yourself? Can't be worse than what IDA produces here.
>question: how and why is NtTerminateProcess called twice here?
>>
>>102773075
I ran an old 90s game through a decompiler a while back and it just gave me thousands of pages of nonsense and I gave up
>>
>>102773088
Machine code doesn't know anything about your abstract structures. It only knows about registers, offsets, memory accesses, and syscalls, the rest is for you to figure out.
>>
>>102773163
actually it had a lot of names preserved
>>
>>102773220
Preserved, or merely extrapolated?
If the decompiler knows that the program requires ReadFile to run and will look for its call address into its own dedicated IAT entry, then the decompiler also knows that the values put into registers and stack are arguments, and, based on the calling convention, which arguments they are exactly. That doesn't mean these things are preserved - the attention span of a decompiler barely outlasts a function scope.
>>
File: 1536443756186.png (113 KB, 270x270)
113 KB
113 KB PNG
Hello /dpt/,
Using C++, I've been trying to pass down a pointer to a singleton, from a singleton to it's member objects, said member objects having member objects that need the singleton pointer too. The receving member pointers seem to become invalid (and/or garbage data) at some point in the hierarchy and I don't really understand why. I tried to look into the "Pass by value/reference" of C++, but using double pointers are only relevant when allocating on the heap, no?
I am still very bad at programming in general and I was looking for either a design pattern that could accomplish what I am trying to do or a way to make the indirection stay valid.
class Singleton {
Singleton() {
a = A(this);
}
A a;

}

class A {
A(Singleton* s) {
singleton_ptrA = s; // Copied pointer?
b = B(singleton_ptrA);
}
Singleton* singleton_ptrA = nullptr;
B b;
}

class B {
B(Singleton* s) {
singleton_ptrB = s;
}
Singleton* singleton_ptrB = nullptr;
}

Ignore the absent forward declarations, didn't want to clutter the tags. What would be the proper way of doing this? Thanks for your help.
>>
>>102773986
what hellish scenario is this? it doesn't help that you abstract your actual problem into "A"/"B"/"Singleton", from which no one can even point out higher-level issues, which if solved might remove your original problem
>>
I inherited a Python codebase written in strict object oriented style. Basically every single would-be if-elif-else block or a dictionary lookup is replaced with a factory class and a handful of associated branch classes.
Is there a single redeeming quality about this approach, or should i just replace it all with if/switch or lookup-table style branching?
>>
>>102774784
normally you don't need factories for everything

if it makes sense to abstract the logic of deciding which implementation of a class or interface you need to instantiate into a separate unit, you can use a factory.
if you only need a new instance of an object, just create a new object directly.
>>
>>102774784
Classes in (especially in Python) are fucking terrible, that said It's a huge waste of time to rewrite that unless you're specifically told to do so
>>
File: one_byte_per_syscall.png (81 KB, 1411x457)
81 KB
81 KB PNG
>>102772843
>every single byte via syscall
they literally did the meme
>>
File: file.png (689 KB, 1918x910)
689 KB
689 KB PNG
>>102774784
>https://youtu.be/WcAWZGyB32U
just write simple procedural code
>>
>>102775778
Compiler devs are at fault for this: >>102754094
>>
>>102775407
every line editor does that though
>>
>>102775848
Line editors are interactive. Save game loading functions are not.
>>
FUGGIN UPS TOO DUMB TO DELIVER MY NEW FPGA
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

How tf should I kode like that?????
>>
>>102775778
Glad there are at least some people in the comments that see through the trivialness of the example
>>
File: 1727426727542641.gif (812 KB, 250x250)
812 KB
812 KB GIF
Move semantics are hard. The things you do for performance...

I think I should just become an java icon instead
>>
File: primer_malloc_3.png (701 KB, 1920x9950)
701 KB
701 KB PNG
>>102776084
They are? Never noticed.
>>
>>102776084
>an java
is this like the programmer equivalent of an heroing
>>
>>102776457
Absolutely.
My brother took a Java job back in 2021, and I haven't heard from him since. He might as well be dead to me.
>>
File: PXL_20241011_145905931.jpg (2.33 MB, 4032x3024)
2.33 MB
2.33 MB JPG
IT'S HERE BROS!!!! (Microchip Polarfire SoC discovery board with quad core RISC-V CPU and 95k logic element FPGA)

Lets start some S E R I O U S hardware-software-codesign!!!
>>
I want to send a document showcasing the diff from a bunch of files in a local repo. Is there something that can neatly format them in markdown or pdf? I want to avoid publishing the code on github
>>
>Was going to research some info on the sims 1's file formats
>remembered that there was some specific info only on some now defunct website (any other info online is only releated to sims online really)
>"hey, I know, I'll use the wayback machi--"
>wayback machine is down
Fuck my life
>>
File: 1702222417709953.png (165 KB, 1000x540)
165 KB
165 KB PNG
>>102776891
I used to work with a board like this and the tooling is some of the worst out there. Have fun using a big bloated IDE that hasn't had a UI update in 15 years.
I would have gotten a board with a reverse engineered bitstream so you can at least avoid the OEM tools.
>>
>>102777028
I know that microsemi is really really fucking bad. But it was just the cheapest board available with a hard CPU, which is even GNU+Linus capable.
It looks like parts of it are reversed. For other FPGA dev I usually use lattice or xilinx
>>
>>102777028
>Siddharth Chandrasekaran
SIR
>>
>>102777072
You can run linux on a soft RISC-V CPU
>>
>>102776536
>>102776457
>He was such an java, to abstract it all away. We miss the pointers so, That you should know, And we honor them this day.
>>
File: 1704007249379925.jpg (351 KB, 1200x872)
351 KB
351 KB JPG
>friday night, sipping beer on tokyo subway last train, listening to loud dubstep music while using phone to vpn + rdp to home pc -> different vpn to company network -> rdp again to pc at work -> VS remote debugging switch aarch64 assembly, something something living the dream
>>
>>102776109
regarding CPUs and return address how does it and the security shit you get now work with CPS/coroutines
i.e. cases where you literally don't want to return to the calller
>>
File: score.webm (2.85 MB, 1280x720)
2.85 MB
2.85 MB WEBM
>>102777028
>>102777192
Yes, I know. I just wanted to play around and I have a project in mind, since it has a raspi header.
Right now having problems getting the fucking tool to work on ubuntu because it somehow can't find the license. Top fucking kek m9.

I want to make my LED matrix a bit better/cooler. I already made it working with an artix 7 fpga, self-made risc-v cpu and then did most data shit on a different computer.
I also have one of these bitches here:
https://github.com/hzeller/rpi-rgb-led-matrix/tree/master/adapter/active-3
And since that library is kinda shit for newer raspis I want to get that hat working with the new board. If that works out, then I could probably scale that bitch up big time.

webm related
>>
>>102777555
At least on x64 there's no way to store RIP separately, so there's assembly involved. You may want to look at an example implementation of green threads in C/assembly: https://c9x.me/articles/gthreads/code0.html
>>
>>102777586
Kek, only took me about an hour to boot that fucking shit
>>
>>102774364
The program itselft contains a map that contains entities that contains OpenGL quads and AABBs.
>>
MOVE OVER

>>102778837
>>102778837
>>102778837



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