Thread #108561805
File: 1775604739786667.jpg (181.5 KB)
181.5 KB JPG
What are you working on, /g/?
Previous: >>108540878
357 RepliesView Thread
>>
>>
>>
>>
>>
File: 1755949419937218.png (127.2 KB)
127.2 KB PNG
CPP = C Plus Power
>>
>>
>>108561805
I'm learning discrete math since I heard it's used with programming. I have basic programming experience, and so far barely seeing any similarities outside of logic.
Are these stupid fucking digraphs important?
>>
>>
File: daddy cool.gif (2.7 KB)
2.7 KB GIF
Honest question, if I use claude code on a codebase that has a lot of slurs in the comments, will I get banned or will claude refuse to work with me? I'm considering showing claude my personal project which is quite large, and there are a lot of politically incorrect comments like for example "// workaround for gay Windows bug, fucking M$ diversity hire niggers..." and so on.
>>
>>
>>108561805
I’ve been messing around seeing if I enjoy coding. Now it’s time to make another project but I don’t even have any ideas that strongly attract me. I guess I’ll just make Snake or a Sudoku solver or something.
>>
>>
File: superc.png (496 KB)
496 KB PNG
>>108562142
now I want to invent a new programming language
>>
File: 1771448611664555.png (242.7 KB)
242.7 KB PNG
I just want an ai that can teach me how to program real good not one that programs for me
>>
>>
>>
>>
>>
>>
>>
>>
>>108563032
Maybe you already included some library that for some reason defined UNICODE as having some specific value and you don't want to just blindly redefine it? I would hope most library authors wouldn't be that retarded, but you never know.
>>
>>108562789
Just learn assembly.
>>108562756
Input sourcing is asking the question *where* your parameters are coming from - which becomes really important the moment you're dealing with NUL-terminated strings because the strings you're feeding to your functions may not be NUL-terminated at all. They may be part of other strings, part of read-only data, part of some network data (say, HTTP) ...
If you want to use such strings without out-of-band data (i.e. string length parameter) you have to do it in-band (i.e terminate them yourself).
To terminate them you first have to allocate memory (or have some scratch memory ready), copy the string from source to target (hope you're not evicting your caches), terminate the string, pass it to the function that only expects terminated strings, and then release the memory again (or keep it around for future use).
... whereas with out-of-band signalling all you need to do is have a pointer point to the data and tell the function how many bytes you want read.
>>
#include <winsdkver.h>
#define _WIN32_WINNT 0x0A00
#include <sdkddkver.h>
>VCR101: Macro can be converted to constexpr
It literally can't though. Is there a way to suppress these 1-off editor warnings in Visual Studio or do you just ignore the squiggly lines? I know you can globally suppress them with a pragma, but that sounds bad.
>>
>>
>>
>>
>>108563303
https://uops.info/table.html
https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions?v iew=msvc-170
https://agner.org/optimize/optimizing_assembly.pdf
Ghidra or IDA or both.
x64dbg.
>>
>>108563288
>>108563229
Yes but the VCR warnings are garbage. I get similar warnings when using gMock macros. The real issue is the 100s of fake warnings mask the few true warnings that you want to see.
>>
>>
>>
>>
>>108561805
How do you guys inspired yourself to code something?
At this point, I don't code, I just chatGPT it for my work 99% of the time. so like at this point I'm not even a "programmer" anymore. it's suck.
any books?
>>
>>108563222
>Input sourcing is asking the question *where* your parameters are coming from.
The only time I have ever had to deal with non-null terminated strings is when I am parsing strings.
But the thing is that the memory is usually already copied. If I use rapidjson, it has it's own stack buffer for everything. And it supports in-situ parsing (destroys the string), but printing errors is nice, and that's the main reason I don't destroy the string (but if it's a file, I can just read it again).
I don't trust hand parsing because rapidjson has embarrassed me with my own binary parser (I wrote a json/binary wrapper, but rapidjson was so fast, it made the binary parser pointless, my binary parser WAS faster and 1000x smaller, but not fast enough for me to be happy with, I might as well use flatbuffers or zpp::bits, AND I was using rapidjson in a very non-optimal way where every single variable would store it's location for rich debugging info, so it would have probably been even closer in performance if I just used it raw).
So if you use a library for parsing known formats, null termination isn't an issue, since all formats will give you null terminated strings for you (either on a stack, or in-situ).
>>
>>108563566
>But the thing is that the memory is usually already copied.
Cool, so let's just copy it *again*, because, y'know, cache invalidation and locality ain't real!
>rapidjson was so fast
Have you looked at *why*?
>>
>>108563525
ikr you're forced into AI, and if even if you try to get it to teach you or debug things for you it'll just write everything for you. Feels like the parallels that CAM manufacturing had back in the day.
>>
>>108563587
>*why*?
{"test":[0,1,2,3,4]}
was not that slow compared to
(error check) 4bytes (error check) 4 bytes (etc)
I'm not saying that my code was super slow, I think my code was at least 2-10x faster, but that's not acceptable when I wrote RJ to be SUPER SLOW. I don't even want to talk about how much time I wasted trying to make the error messages super pretty and accurate to match the exact line column of the file.
The whole parser was thrown out at the end because the API was too flimsy and not retard-proof enough. I can't store generic arrays of elements, I needed to set the size and do that weird IsReader/IsWriter logic so parsing is done in one function, but it's just not worth it (even if I split the function).
But I know that rapidjson will get 100x slower the second I start using more identifiers / objects instead of one big array. The binary parser would ignore identifiers (the identifier is just a sanity check for json).
>>
>>
>>108563650
OH, I just remembered that rapidjson does not use null terminated strings, because I was not using the normal API (I need to use callbacks to get the errors in the correct location). If you used it normally you would get null terminated strings. And the normal API uses a hash lookup I think, like a normal json API (You can't actually modify the json files in an editor, it's basically binary with redundant sizes, I wanted to use it as a pretty way of printing the binary data).
But I could have implemented rapidjson as a pseudo binary format, just a big json array, and it would have been fine in terms of performance.
but there are better ways.
>>
>>
>>108563834
http://6502.org/users/obelisk/6502/reference.html#INC
>>
>>
>>
>>108563867
DX12 uses DXGI, not GDI. You only need an HWND, not an HDC - and as such an independent DC is superfluous.
>>108563883
Instruction table telling you how many cycles certain instructions take on different CPUs. Makes you appreciate certain optimizations more (like using LEAs instead of MULs).
>>
>>108563932
>DX12 uses DXGI, not GDI. You only need an HWND, not an HDC - and as such an independent DC is superfluous.
yet google results is full of people saying it's still relevant in dx12 regardless of whether you're using gdi or not
>>
>>108563980
What's the rationale supposed to be? It only helps speeding up GetDC and ReleaseDC calls (by not doing anything). If you're that worried, hook these two functions, then see how many times they're actually called.
>>
>>
>>
>>108563834
I like my code beautiful. If you get out of ring 0, it's not beautiful anymore. Don't get greedy
https://www.youtube.com/watch?v=mWNd2EubXVk
>>
>>
>>
>>
>>
>>108563525
>inspired
Your thoughts might inspire you or spark interest. But the act of starting to code can only be done by pure force. You have to force yourself to do it. Doesn't matter if you want to or not.
If you don't force yourself, it's not happening. Joy comes from the act of doing it. Not from the thought of the act
>>
>>
File: bluray.jpg (31.4 KB)
31.4 KB JPG
It's the same shit every fucking day.
> Start to kode happily
> Hit a not obvious bug
> Get lazy and spiral around
> Get annoyed by AI and search for the bug myself
> AI was on the wrong fucking path all the time.
last prooompt:
> I found the bug and it was really easy to solve. Very easy. The easiest bug. Tremendous bug. Great bug.
> Now it's your time to shine and prove me that AI ain't trash. Can you find the bug or can't you?
> Here is the original source with the bug still included. It's very easy to solve. Where is the bug?
> If you can find it, then i will like share and subscribe again. Otherwise I won't. Go.
>it still couldn't find the bug.
Unsubscribed and trashed. It just costs way too much time. Tfw fell for the Ads way too long
>>
>>108564876process(clk, rstn)
variable tmp_sio_out : std_logic_vector(7 downto 0);
variable idx_v : integer;
begin
if rstn = '0' then
elsif rising_edge(clk) then
ack <= '0';
case curr_state is
when ST_IDLE =>
sio_oe <= '0';
csn_i <= '1';
[...]
if req = '1' then
[...]
if we = '1' then
wdata_reg <= wdata;
cmd_data_reg <= SPI_QUAD_WRITE;
else
cmd_data_reg <= SPI_QUAD_READ;
end if;
curr_state <= ST_CMD;
end if;
when ST_CMD =>
csn_i <= '0';
sio_oe <= '1';
[...]
when ST_ADDR =>
[...]
if bit_cnt = 0 then
if we_reg = '1' then
bit_cnt <= 3;
sio_oe <= '1';
curr_state <= ST_WRITE;
else
bit_cnt <= RD_WAIT_CYCLES-1;
-- sio_oe <= '0'; WRONG!
curr_state <= ST_WAIT;
end if;
end if;
when ST_WAIT =>
sio_oe <= '0'; -- based
[...]
when ST_WRITE => [...]
when ST_READ =>
when ST_ACK => [...]
end case;
end if;
end process;
If anyone wants to know:
The sio_oe signal going low had to be moved from ST_ADDR to ST_WAIT such that the last addr nibble will still get output on the next clock cycle.
>>
>>
>>
>>
>>
>>
>>108561805
I made an Iterator for Lists in MAIDS, to see if I could do it, but I am not sure it is actually useful, because everything I can do with the iterator, I can also do with recursion and I think the recursive code looks nicer and is easier to understand, and MAIDS has TCO anyways. I also wrote a random number generator in MAIDS which is nicer than the one from my last example and works for arbitrary ranges of integers passed to it as arguments.
I would upload a screenshot of the IDE to show the Iterator, but I appear to be currently blocked from uploading images? Hopefully that stops soon.
>>
>>
>>
File: ss+(2026-04-09+at+16-27-53).png (60 KB)
60 KB PNG
>>108565999
My xfce DE comes with a task manager as well.
>>
File: 1754953050325654.png (161.1 KB)
161.1 KB PNG
finally added thumbnails to my filemanager
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
File: 00007-1065024305-1boy, solo, upper body, portrait_BREAK in the style of (psk_1.3) _.png (1.6 MB)
1.6 MB PNG
>>108563503
>Token seller! I am going to program and I want your strongest tokens!
> My tokens are too strong for you, prompter!
>>
>>
>>
>>108568080
>I get what pointers are
>what are some actual use cases for them?
If you get what they are, I don't understand why you'd be asking such a question.
Indirection. Lots and lots of indirection.
For reading or changing a value way over yonder.
To place all of your resources in one spot and only refer to it.
They're memory addresses.
>>
>>
Came across this codebase today.
If their abbreviated prefix wasn't sketchy enough,
I'm just loving their error codes!
https://github.com/kkos/oniguruma
https://github.com/kkos/oniguruma/blob/master/src/oniggnu.h
https://github.com/kkos/oniguruma/blob/master/src/regerror.c#L49
>>
>>
>>
>>
>>
>>
>>
>>
File: 1753883428220220.png (254.5 KB)
254.5 KB PNG
why does goto exist when you can just make a loop or nested function
>>
>>108568080
>what are some actual use cases for pointers?
Talking about THAT THING RIGHT THERE, and not some other thing.
In theory, you could instead use indices into an array of them. That would work the same sort of way, if you sort of squint and and ignore a few details. (You can think of pointers as indices into a gigantic array the size of all your memory.)
If your language has references, they're pointers plus some pinky-swear promises around what operations you can do with them.
>>
>>
>>
>>
>>108568641
because breaking out of nested loops can be extremely retarded.
https://www.geeksforgeeks.org/go-language/go-goto-statement/
Usage is quite common in go
>>
>>108568668
>The break and continue keywords are basically just gotos
No. Not at all.
A colleague at cagie said the same.
But continue and break are syntactically well defined. It is 100% clear where you will jump then.
Goto relies on the human doing the right thing. Even tho both jump to a predefined position they are quite different to me, grammatically speaking
>>
>>
1.1 The Basic Principle
(...)
Keep it Simple
As the number of capabilities you add to a program increases, the complexity of the program increases exponentially. The problem of maintaining compatibility among these capabililties, to say nothing of some sort of internal consistency in the program, can easily get out of hand. You can avoid this if you apply the Basic Principle. You may be acquainted with an operating system that ignored the Basic Principle.
It is very hard to apply. All the pressures, internal and external, conspire to add features to your program. After all, it only takes a half-dozen instructions; so why not? The only opposing pressure is the Basic Principle, and if you ignore it, there is no opposing pressure.
(...)
The Basic Principle has a corollary:
Do Not Speculate!
Do not put code in your program that might be used. Do not leave hooks on which you can hang extensions. The things you might want to do are infinite; that means that each one has 0 probability of realization. If you need an extension later, you can code it later - and probably do a better job than if you did it now. And if someone else adds the extension, will they notice the hooks you left? Will you document that aspect of your program?
The Basic Principle has another corollary:
Do It Yourself!
Now we get down the the nitty-gritty. This is our first clash with the establishment. The conventional approach, enforced to a greater or lesser extent, is that you shall use a standard subroutine. I say that you should write your own subroutines.
(...)
But suppose everyone wrote their own subroutines? Isn't that a step backward; away from the millenium when our programs are machine independent, when we all write in the same language, maybe even on the same computer? Let me take a stand: I can't solve the problems of the world. With luck, I can write a good program.
Programming a Problem-Oriented Language
https://www.forth.org/POL.pdf
Chuck Moore, June 1970
>>
>>
>>
>>
>>
>>108568641
There are some edge cases where avoiding goto makes a mess for no real reason and not all languages have continue, ways to leave outer loops or need to manually clean up a mess.<<Restart>>
if System_Call = -1 then
if errno = EINTR then -- Interrupt, not a real error
goto Restart;
end if;
-- Actual errors here
end if;
>>
>>
File: 1745719995956854.png (28.3 KB)
28.3 KB PNG
I stand with Goto-san
>>
>>108568816
In the real case, it can be done asint ret;
while ((ret = syscall(...)) == -1 && errno == EINTR);
// Less tersely
do {
ret = syscall(...);
} while (ret == -1 && errno == EINTR);
if (ret == -1) {
// do something with errno
return;
}
But yes this still can get messy and goto can lead to much easier to reason about code, e.g. you jump back even further rather than just this 1 syscall.
>>
>>108568896
https://hackage-content.haskell.org/package/mtl-2.3.2/docs/Control-Mon ad-Cont.html#v:label
>>
>>
>>108569026
Yeah, it's always possible to avoid it, but sometimes it's way more readable not to.
It's just peak reddit to make an unreadable mess just because retards start convulsing and screeching "muh Dijkstra".
Knuth wrote a decent amount on it and gave a whole lot of algorithmic examples.
>>
File: VID_20260410_061618_562.mp4 (2.5 MB)
2.5 MB MP4
>>108561805
>What are you working on, /g/?
https://gitgud.io/ZekeRedgrave/ZEKETK/-/blob/master/UnixOS/Main.C?ref_ type=heads
Working on Basic Mouse Event Function
>>
>>
class MyClass {
public:
MyClass(const std::string &a) : a(a) {}
MyClass(std::string &&a) : a(std::move(a)) {}
const std::string a;
};
am I really expected to do this shit just to copy a string? isn't it going to be kind of cancer if I have 2 or more strings as I'll need to make 2^n permutations of constructors to handle all cases?
>>
>>
>>
>>
>>108569454
You can just use (std::string a), but technically speaking, it is not the same assembly generated(due to the destructor), but it's very likely your constructor will be inlined with optimizations so it doesn't matter, and the overhead is like a few nanoseconds (just comparing if the pointer is valid).
see around 20 minutes (unique_ptr isn't that much different than std::string)
https://www.youtube.com/watch?v=rHIkrotSwcc
>>
>>
File: 1774077726442840.png (59.7 KB)
59.7 KB PNG
>>108569617
>Make GUI program
>Using React
>Look inside
>Just web browser with bloated.js libraries
Bruh.... You can make your UI Toolkit in C from scratch and only cost less ram usage
>>
>>
>>
File: 1775697813036193.jpg (153.5 KB)
153.5 KB JPG
>>108569169
>>108569569char state[3];
FILE *mouse = fopen("/dev/input/mice", "r");
fread(state, 1, 3, mouse);
>>
File: 1765946705691926.jpg (9.3 KB)
9.3 KB JPG
>try to ask ai for help
>it just agrees with everything I say even when it's wrong
>>
>>
File: 1747717239632509.png (435.4 KB)
435.4 KB PNG
waow
>>
>>
>>
>>
repo maintainer is asking us to switch to migrate to another library because the new one is "maintained" and the old one is not.
The library we're using has worked without issue for at least 5 years and hasn't been patched in 4 years. The new library has been getting commits daily. As in the new library is unstable and broken. This is what managers consider "alive" and "healthy", I'd rather stick with the dead thing that didn't move at all and just worked.
>>
File: 1771273125792543.png (107.7 KB)
107.7 KB PNG
>>108570000
N-NOOOOO MY STREAK NOOOOOO
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>108570516
>do you know how easy it is for copilot to translate a program from the old api to the new one?
Yeah, right - because suddenly being able to use directly handles totally doesn't change the entire way userspace handles file paths and memory allocations.
>this is what vibe coders actually believe
>>
>>
>>
>>
>>
>>
>>
>>108568080
you probably come from a language which does pass-by-reference for objects by default, i.e. you are used to being able to write code like this:void ChangeFoo(Foo foo)
{
foo.bar = 4;
}
Foo myfoo;
myfoo.bar = 3;
ChangeFoo(foo);
//myfoo.bar is now 4
but in many low level language function arguments are pass-by-copy that means the above code would not actually change myfoo.bar's value (foo would be its own unique copy that gets initialized upon the function call & deinitialized afterwards). Pointers (& references) are the language construct that enables you do get that "referencing" behavior again. That is their usecase.
>>
>>108569454
i think you are looking for something called perfect forwarding here:class MyClass
{
public:
template <typename T>
MyClass(T&& str) : a(std::forward<T>(str)) {}
const std::string a;
};
std::string str{"this string is copied"};
MyClass foo{str};
MyClass bar{ std::string{"this string is moved"} };
>>
>>108569454
>>108571672class MyClass {
public:
MyClass(std::string a) : a(std::move(a)) {}
std::string a;
};
>>
>>
> Computers are small networks of interconnected devices on asynchronous networks that communicate with each other at their own time and pace. That's how they work. Every single computer has different devices talking to each other from different clocks. These clocks are not synchronized. Even if they had an error of one part per million. That's a bit per second per megahertz. We have way more than that actually going on.
t. Dan Kaminski
THINK ABOUT IT!!! IT'S CRAZY!!!
I'll post this on facebook too to spread awareness
>>
File: Screenshot_20260410_100502.png (904.2 KB)
904.2 KB PNG
noooooooooooooooooooooooo.
>Want to build self-hosted computer
>Try to settle for existing stuff first (neorv32 risc-v cpu)
>It's too fucking complex. It's good, but too professional
>Have already 2 working not pipelined risc-v CPUs
>Now God tells me to work on my last risc-v cpu with classic 5 stage pipeline that killed me a few weeks ago because of some bugs
o-o-okay mr. god. I'll do it. Just for you.
>>
>>
>>
>>108571792
>Realistically, how puritanical should I be about OOP?
structure of your logic? yes. if you half-ass it, you'll get all the typical issues with "OOP" most people complain about
coding practices? not that much
>Do I need to divide every function into its own class and get perverted with inheritance and interfaces?
no, just keep relevant things in their own scopes
>>
>>108571792
https://web.archive.org/web/http://number-none.com/blow/john_carmack_o n_inlined_code.html
>>
What do you do when you have too much kode and turd on your compter?
You know exactly which project you want to work on but all the kode keeps your head spinning and overthinking.
I just want to delete everything to work on that project.
I should find a way to keep my computer clean so that I can focus on one project at a time
>>
File: 1751280254883546.png (39.2 KB)
39.2 KB PNG
uhhhhhhhhhhhhhhhhhhhhhhhh
is it really as easy to crash windows as the msdn says it is?
>>
>>
>>
>>108572061
Yes, but it's not fun. I wish i could just vibe code an AI app in javascript.
I am a little on the fence. I found this other guy that apparently did vibe code a bit and had a similar goal like me.
He did just copy the bare minimum neorv32 libs into his project
https://gitlab.com/gatemate/pc/software/dos/-/blob/main/include/soc/ne orv32.h
Maybe i should do that too. Tho the autism says it's bad to go the same route someone else already went down, but on some days i should maybe just keep myself sane. So lets try this.
Tho this guy didn't write his own fucking compiler. I will. God and terry will smile down at me, if I can pull this off and make it self-hosted
>>
File: 1768395483651545.jpg (24.7 KB)
24.7 KB JPG
>>108571792
I shove as much shit into each class as I can until I need to reuse code
>customwebview
>customwebview.expansionbutton
>customwebview.zoomcontrols
>customwebview.savetoPDF()
>customwebview.createdirectory()
---figure out at this point that im going to have to reuse some of this shit---
>move expansionbutton and zoomcontrols to "webpagedisplayutilities"
>move createdirectory() to "localsystemfilemanagerutility"
>>
File: meirl.jpg (8.5 KB)
8.5 KB JPG
>>108572135
>getUser
>getUser2
>getUserById
>getUserByName
>getUserByName2
>getUserNameById
>>
>>
>>108572155
>Car car = new Car()
>>
>>
>>
>>
>>
>>
>>
>>
>>108572463
>literal bikeshedding
Well, yeah? The whole project is all about farting around and conjuring problems.
>>108572466
That would be cheating, I don't want to become too productive.
>>
>>
>>108572070
if you go out of your way to avoid OOP in an OOP language, you'll end up with just a bunch of procedural code with extra syntactical overhead (ie. "why do I have to put everything in a class?! I just want some functions"). the trick is to design your program logic around objects and not just use procedural solutions with "OOP" syntax shoehorned over it
also don't fall for the "you must use a plaintext editor and compile from terminal" trap; you're not going to get better at programming by doing things the extra tedious and error-prone way. an IDE makes a lot of actions effortless and it's a tool you will eventually have to use anyway, so you might as well get used to it early
typical counter-argument: "hurr but then you don't know how the code really works" - especially a newbie doesn't need to bother with that, given the first programs will be just simple exercises. it's fine if it just compiles and runs within the IDE. it's much better to start with full focus on writing actual program logic, and look into compilation details only when it becomes relevant
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>108572624
>bro your embedded assembly just tripped my antivirus
Every program I've ever written in MASM and FASM, no matter how benign, has caused Windows Defender to go fucking apeshit. I don't know how it knows.
>>
File: 1763882219866115.png (136.8 KB)
136.8 KB PNG
procedure Increment(I: in out Integer)
with Global => null,
Depends => (I => I),
Pre => I < Integer'Last,
Post => I > I'Old
is
begin
I := @ + 1;
end Increment;
>>
>>
>>
public class CounterService {
private int counter;
public CounterService(int initialValue) {
this.counter = initialValue;
}
public synchronized void incrementCounter() {
this.counter = this.counter + 1;
}
public int getCounter() {
return this.counter;
}
}
CounterService counterService = new CounterService(0);
counterService.incrementCounter();
int i = counterService.getCounter();
>>
>>
>>108572586
>OOP is so dumb. I'm a functional bro all the way. No need to couple data and the methods that operate on it behind an interface using a pre-defined compile time hierarchy.
>object.Map()
>object.Filter()
>object.Reduce()
>object.ToString()
>>
>>
>>
>>
>>
>>
File: 1758188083150583.png (1010.2 KB)
1010.2 KB PNG
>>108572739queries
.grouped {
[$0[2], $0[0] % $0[2]]
}
.mapValues {
$0.map { ($0[0] / $0[2], $0[0] / $0[2] + ($0[1] - $0[0]) / $0[2], $0[3]) }
}
.reduce(into: nums) { [mod = 1000000007] (nums: inout [Int], element: (key: [Int], value: [(l: Int, r: Int, v: Int)])) in
element
.value
.reduce(into: Array(repeating: 1, count: nums.count / element.key[0] + 1)) { (products: inout [Int], query: (l: Int, r: Int, v: Int)) in
zip(
[query.l, query.r + 1],
[query.v, String(mod - 2, radix: 2).reduce(1) { $0 * $0 % mod * ($1 == "1" ? query.v : 1) % mod }]
)
.filter {
$0.0 < products.endIndex
}
.forEach {
products[$0] = products[$0] * $1 % mod
}
}
.reductions { $0 * $1 % mod }
.enumerated()
.map {
($0 * element.key[0] + element.key[1], $1)
}
.filter {
$0.0 < nums.endIndex
}
.forEach {
nums[$0] = nums[$0] * $1 % mod
}
}
.reduce(0, ^)
this melt's the proceduralfag's brain
>>
>>
>>
>>
>>108572695
You would if you drank.
>>108572739
Reminder that compilers are too dumb to evaluate the state of an object at compile time and are much better at optimizing function parameters.
>doesn't mean they're perfect
>>108572901
>erotic novel
Just stop.
>>
>>
I am slowly putting together the routines to cache and write back blocks to the PS2 memory card that should make writing and updating data on the card more robust, I think.
But I'll have to refactor/strip out a lot of the old code soon.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
File: 1753897006557987.png (225.2 KB)
225.2 KB PNG
>>108573810
>>
>>
>>
>>
>>
>>108574230
Not anything specific. I am just looking into possibilities how I could leverage them while gaming and asking if anyone is already doing something like that. If I should name one particular use case, It would be nice if I could use an agent to translate games on the fly.
>>
>>
>>
>>108571684
it will create a copy of a temporary (and I explained why it's not an issue in the other post), but if the value is an rvalue (it uses &&), it will construct the temporary using move semantics, and then you move the temporary into the member value (and the temporary gets destroyed).
I think it might be possible for the temp destructor to be completely optimized away, because I did not open this up in godbolt to check it out (if you look at the video I posted, the reason why the destructor needs to be checked is because it's needed to check for a bug related to not knowing if the funciton will move the value or not, but if it's all inlined, even if the constructor was forced to be non-inlined defined in a DLL or TU, it might still inline it, but of course if you constructed the rvalue outside the constructor and explicitly std::moved it in, that empty shell will probably have a pointless destructor call because it can't tell if the constructor moved the object or not).
And generally, I don't think people should care about the destructor of temporaries, the destructor could potentially catch bugs, and it's in the range of a few dozen nanoseconds at most (as I already explained).
The reason (std::string a) is good, is because unlike (const std::string& a), it will not make a copy for const char* conversions (aka, string literals, technically you can add a ""s suffix so that std::string&& works), const & strings will absolutely allocate memory (BUT in many cases, it wont due to inlining, or small string optimization, but it's very easy for functions to not be inlined so we should avoid const & strings).
Also I believe std::forward is identical to std::move, std::forward is mainly for when you have a const or volatile variable, because then you NEED to create (const std::string&&) and (volatile std::string&&) (both) but this isn't an issue, a const std::string&& is just a copy. And I believe it could make a temp destructor (but templates are usually inlined).
>>
>>
>>108574612
>the destructor could potentially catch bugs
*nevermind, I was wrong, the destructor is 100% pointless. it wont catch anything. But I still don't think it matters enough until you actually have a situation where the temp destructor actually has a measurable overhead.
>>
>>
>>108574612
>Also I believe std::forward is identical to std::move
std::move unconditionally casts to an rvalue, std::forward<T> casts to an rvalue if T is an rvalue, so std::move is like std::forward<T&&>
(i think, maybe not, dunno)
>>108574694
probably depends what you're doing
>>
File: Screenshot_20260410_201517.png (35 KB)
35 KB PNG
hmm, in theory this CPU is good, but for hacking around and stuff it's just too professional.
I tried again but it's just too much effort.
Also I got triggered by their comment now.
Why would you make that header 86 characters long?
It makes no sense. There is enough space to get it down to 80. What the fuck man. Time to use something else
>>
>>108575126
Yes, you are right, also I was wrong about const && working with lvalues, it's only for overloading binding order stuff for rvalues.
I think it's possible (std::string a) is optimized away due to copy elision (even with forcing inlining off), but I don't know.
But I can't really make any assumptions about if there are any temporary copies being made with redundant destructors, until it's tested in godbolt.
>>
>>
>>
>>
>>
File: 1771229641672.png (842.4 KB)
842.4 KB PNG
>>108561940["i::\"" add(i, "1") "\";"];
>>
>>
>>
>>
>>
>>
>>
>>
>>108574612
you've definitely got a wrong understanding of move semantics & rvalues but pointing it out exactly where & how you are wrong in all that text is too time consuming for me (it seems like you've built up a big intuition on your own based on assembly output). I just wanted to let you know. Go lookup how perfect forwarding works & why it is needed. The biggest thing to know with move semantics is that there is no such thing as a rvalue type - rvalue is a category. So for example this statement
>but if the value is an rvalue (it uses &&)
is wrong
>>
>>
>>
>>
>>
>>
>>
>>
File: cleaning house.webm (420.6 KB)
420.6 KB WEBM
>>108576443let succ n f x = f (n f x)
one f x = f x
in
succ one
>>
>>
>>
>>108578122
implicit conversion rules. b = 255, a = -1, you then perform a comparison and both values get cast to an int and then compared. if you wanted to compare the representation rather than the value then you need to ensure they both use the same representation first (both signed or both unsigned). so (unsigned char)a == b or since you care about the raw value, and then you should have used %u in the string format to match the representation to print
>>
>>
File: 1775847333011567.jpg (27.9 KB)
27.9 KB JPG
>>108578122
I get different resultschar a = 0xff;
unsigned char b = 0xff;
printf("%x\n%x\n%x\n", a, b, a == b);
ff
ff
1signed char a = 0xff;
unsigned char b = 0xff;
printf("%x\n%x\n%x\n", a, b, a == b);
ffffffff
ff
0
arm32 wants to do sign extension real bad
>>
File: 1595158700493.png (1.3 MB)
1.3 MB PNG
>>108577917succ(*x)::
[*x "::\"" add({*x}, "1") "\";"];
>>
>>108578583
Sign extensions have been a pain for me on the PS2 as well.
Sometimes they are handy, but more often they're unexpected.
But a char is supposed to be just one byte, right? Even if the registers sign extend, why would it return a 32bit result?
>>
File: 1766739183385404.png (327.1 KB)
327.1 KB PNG
maybe if I chug like 500mg of caffeine tonight I can lock in for 10 hours straight and code a minimum viable prototype I can use for my application
>>
File: 714bffb6eac2a72622e897a0d2f7ff15.jpg (131.2 KB)
131.2 KB JPG
>>108578634
I've enjoyed your ps2 posts, the signed keyword is likely responsible altho signed a = 0xff is also ff on this architecture
>>
>>
>>
>>108578726
>>108578726
Just thought about it a bit, chars are probably stored as words for arithmetic purposes and the values clamped to 0-255 or -128-127.
>>
>>
>>
>>
>>
>>
>>108579524
It's probably better that I focus on the rewriting before hardware compatibility.
There's a good chance that whatever I do to fix it now either won't survive the rewrite or something else will need fixing afterward.
>>
>>
>>
File: 1774388555825821.png (30.4 KB)
30.4 KB PNG
I am so locked in right now
>>
>>
>>108577215
They don't even manage that. Y'all heard that story about that faggot app that was allegedly vibe-coded, and then it turned out he had to hire an actual programmer?
>and to top it off they used AWS
>because no one knows how to write scaling code anymore
I so hope the Strait will remain closed forever. We need that energy crunch so fucking bad.
>>
File: python.jpg (21 KB)
21 KB JPG
>>108561805
>What are you working on, /g/?
Learning Ada 2022 (tm) rn.
>3.1.3 Function calls
> An important feature of function calls in Ada is that the return value at a call cannot be
ignored; that is, a function call cannot be used as a statement.
> If you want to call a function and do not need its result, you will still need to explicitly store
it in a local variable.
Wow, I fucking love Ada now. Why are you're languages not as based as Ada?
Afk getting some shasta
>>
>>
>>
>>108580326
Let's take it back!
https://www.youtube.com/watch?v=pZa9BLJmziQ
>>
>>
>>
>>
>>
File: Screenshot_20260411_103245.jpg (385.4 KB)
385.4 KB JPG
> What are you working on, /g/?
I finally get decent level of intuition how to structure heavily monadic Bevy code (with many layers of Option/Results that depend on previous Option/Results). Rust actually makes this comfy. There's even limited monadic syntax with ? operator for fns returning Option, but also just general presence of very well though out methods like "inspect" that clearly communicates attaching side effect to unchanging value is really cute.
>>
File: finish-setup.png (5.1 KB)
5.1 KB PNG
>>108580475
Finish Setup
Sounds based, but vscode is triggering me. Sorry
>>
File: cattle starter pack v2.png (239.6 KB)
239.6 KB PNG
>>108580528
Picrel
>>108580410
Not using AI is never a mistake, it's actually a benefit.
>>
>>
File: 1522883311355.png (90.5 KB)
90.5 KB PNG
Why don't you fucking troll cretins go to /vcg/ to fester with eachother? /dpt/ is for actual programmers.
>>
>>
>>
>>
>>
>>108580536
https://chatgpt.com/share/69da02a3-facc-8328-a0ad-021705c83f25
I'm far from optimizing stuff at that level. And before that I will need to do some basic things like ensure proper instancing everywhere possible and buffered shader uniforms. Godot would probably be enough for me if they had component composition based model and Blender-first approach where all components are configured on Blender side, like I do with Skein here. So yeah, my biggest reasons to use Bevy is Skein and the fact that BGE is unusable since Blender 4.
>>
>>
>>
>>
File: 1749719081930498.png (290.2 KB)
290.2 KB PNG
>tripfag vs aibabies
>>
>>
>>108580731
who cares? you're a boomer. Your brain is calcified. Zoomers don't read books. We don't need them, we have the internet. Even if there were any good books, you wouldn't be able to use any of the information within them. You either find the info online or you're useless.
>>
>>
>>
File: 1775550863869552.png (721.7 KB)
721.7 KB PNG
>>108580735
>We don't need them
>>
>>
>>
>>108580775
>heh, we flooded the country with brown people and now your generation is mentally retarded
>clearly this is a reflection on the white youth and not the change in demographics we brought about in order to secure the future of our taco tuesdays
>>
File: mpv-shot0001.jpg (103.2 KB)
103.2 KB JPG
>>108580533
https://i.4cdn.org/wsg/1775897688000825.webm" target="_blank">https://i.4cdn.org/wsg/1775897688000825.webm
>>
File: 1773345933235760.png (157.6 KB)
157.6 KB PNG
>>108580775
They're also proud of it.
>>
>>
>>
Coolio. Trying to build a simple risc-v assembler with Ada now. I think I get the project flow now.with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Tokenizer is
function TokenizeLine(Line: String) return Vector is
TokensOut: Vector := Empty_Vector;
Token : Unbounded_String;
begin
for I in Line'Range loop
if (Line(I) = ' ') or (Line(I) = ',') then
if Length(Token) > 0 then
TokensOut.Append(To_String(Token));
Token := Null_Unbounded_String;
end if;
else
Token := Token & Line(I);
end if;
end loop;
-- append last token
if Length(Token) > 0 then
TokensOut.Append(To_String(Token));
Token := Null_Unbounded_String;
end if;
return TokensOut;
end TokenizeLine;
end Tokenizer;with Ada.Text_IO; use Ada.Text_IO;
with Tokenizer;
use Tokenizer;
use Tokenizer.String_Vectors;
procedure Hasm is
S : constant String := "addi x1, x1, 5";
tokens : Vector := Empty_Vector;
begin
Put_Line("Hello, World!");
tokens := Tokenizer.TokenizeLine(S);
for t of tokens loop
Put_Line("token: " & t);
end loop;
end Hasm;
> ./hasm
> Hello, World!
> token: addi
> token: x1
> token: x1
> token: 5
>>
>>
One of the fun cool things I have now from working with the PS2 memory card communications is a way to wipe the super block in a memory card, allowing it to be formatted again by the PS2 (which wipes all the data).
>>
File: 1758541567135686.png (87.2 KB)
87.2 KB PNG
I am having nightly meltdowns trying to figure out obscure OOP shit and how to make structs and classes communicate with each other in SwiftUI
holy fuck, is any of this even worth it?
>all views are structs instead of classes, apparently this has a massive performance boost and prevents memory leaks
>but you still need classes to manage the data for the views
>this leads to a bunch of problems, because now you need to make variables publishable or whatever the fuck and have observers to tell the app when to rebuild all of the view structs
>the fun part is when you have multiple classes being passed around views to try and coordinate all app changes
My current challenge:
- Have a bar at the top of my app (it contains a search bar, back button, settings, etc).
- Depending on which view you're in, the layout changes
- Trying to communicate the correct layout back to the topbar when you're like 7 views deep in the hierarchy is a nightmare
https://developer.apple.com/documentation/swiftui/stateobject
>>
>>
>>108581020
Based, but
>I have to cast Unbounded_String to a String.
To_String is just a function in the Strings.Unbounded package and will allocate stack memory for the conversion.
Casting in Ada is done with Unchecked_Conversion or overlays.
>>
>>
>>
>>108580761#include <stdio.h>
int main() {
unsigned long long jq = 13131343217747L;
do { fputc((((jq&0xf)+0x1)^0x2)+0x65,stdout);
} while(jq>>=0x4);
fputc(0xA,stdout);
}
anon, it's for you, again.... anon... they said it must happen again and you are the chosen one. take your time but don't be late, anon
>>
>>
.align 32
;; seconds, minutes, hours, day, month, year
rtc_cache:
dc8 0, 0, 0, 0, 0, 0, 0, 0
.align 32
RTC_get:
addi $sp, $sp, -56
sd $ra, 0($sp)
sd $s0, 8($sp)
sd $s1, 16($sp)
sd $s2, 24($sp)
sd $s3, 32($sp)
sd $s4, 40($sp)
sd $s5, 48($sp)
jal CDVD_wait
ori $s1, $zero, 0xEE ; get all time values
li $s0, CDVD_STATP
sb $s1, ($s0)
li $s0, CDVD_SCMD
ori $s1, $zero, 0x08
jal CDVD_wait
sb $s1, ($s0) ; send command and wait
li $s0, CDVD_RESULT
li $s2, rtc_cache
ori $s4, $zero, 0x08
RTC_get_loop:
lbu $s1, ($s0)
ori $s3, $zero, 0x04
beq $s3, $s4, RTC_get_loop
addi $s4, $s4, -1
andi $s3, $s1, 0x07
andi $s1, $s1, 0x70
srl $s1, $s1, 1 ; multiplied by 8
srl $s5, $s1, 2 ; multiplied by 2
add $s1, $s1, $s5
add $s1, $s1, $s3
sb $s1, ($s2)
bne $s4, $zero, RTC_get_loop
addi $s2, $s2, 1
;; the year is two digit, so let's add 2000 to it
lh $s1, -1($s2)
addi $s1, $s1, 2000
sh $s1, -1($s2)
ld $ra, 0($sp)
ld $s0, 8($sp)
ld $s1, 16($sp)
ld $s2, 24($sp)
ld $s3, 32($sp)
ld $s4, 40($sp)
ld $s5, 48($sp)
jr $ra
addi $sp, $sp, 56
CDVD_wait:
addi $sp, $sp, -16
sd $s0, 0($sp)
sd $s1, 8($sp)
li $s0, CDVD_STATP
CDVD_wait_loop:
lbu $s1, ($s0)
andi $s1, $s1, 0x80 ; busy if top bit set
bne $s1, $zero, CDVD_wait_loop
nop
ld $s0, 0($sp)
ld $s1, 8($sp)
jr $ra
addi $sp, $sp, 16
Getting RTC time and converting from BCD into format used in memory card.
>>
>>108581589
Honestly, I should probably be checking for the data available bit after waiting, but worse that happens is I get garbage out.
What may actually be prudent is a form of timeout in the wait loop like I have when reading the controller.
>>
>>
>>108574452
Yeah I suppose that is one obvious use case for it. I was more of thinking how I could make the AI agent into a conversational partner while I am gaming. I said my one use case would be translating but ultimately I was thinking of what are the the ways I could hook an agent into games. So I was wondering have anyone else here though the same and if they have, in what ways have the utilized them? Maybe in the future games could expose some clear APIs that agents can use. Or do they already?
>>
File: lp53id75ig3a1.png (2.6 MB)
2.6 MB PNG
>>108581556
I'm already using Haskell, in my heart.
>>
>>
>>
File: 1773155632561555.gif (3 MB)
3 MB GIF
my code got complex enough to where the simplest solution was to make a custom stack class and give it a bunch of methods
all of those hours grinding leetcode are return dividends
>>
>>
>>
>>
>>108582084
I give a fuck downto stackalloc vs heap level, but not further than that, at least in foreseeable future. The first thing I will be optimizing is instancing and passing data to shaders. That's already a lot of work. And in terms of SIMD, most of it lives in dependencies of physics libraries I believe. So I use rapier3d, and it uses nalgebra, and that's where SIMD math is.
>>
File: c73219bd00d31b9e6586ebb49804075c.jpg (167.5 KB)
167.5 KB JPG
>yeah bro arrays and pointers are the same in C
okay, explain this#include <stdio.h>
int main() {
int array[10];
int* pointer = array;
printf("sizeof(array) = %d\nsizeof(pointer) = %d\n", sizeof(array), sizeof(pointer));
return 0;
}
the output of this when compile and run issizeof(array) = 40
sizeof(pointer) = 8
someone explain to my dumb brain what's happening here? why does sizeof work differently for arrays and pointers?
>>
File: Screenshot_20260411_163103.jpg (40.9 KB)
40.9 KB JPG
>>108582228
https://www.reddit.com/r/rust/comments/y023fu/comment/irrgsnl/
^ old blogpost with some simd-powered lib benchmarks, nalgebra might be one of the best
>>
>>
>>
>>
>>
>>108582299
>Your array is equivalent of struct with 10 int fields in this case
Is that what the compiler is doing under the hood?
So you're telling me when I doint a[10];
It gets allocated on the stack, but when I doint* a = (int*) malloc(sizeof(int) * 10);
It gets allocated on the heap, correct?
>>108582383
That was my point, I thought arrays and pointers are the same but apparently for things like sizeof they are treated differently
>>
>>108582270
>pointer is 64bit = 8 bytes
>array is 10 32bit numbers = 40 bytes
It works differently because C knows that you are asking the size of an array in the first one and the size of the pointer in the second one.
>>
>>108582299
sometimes they are the same ;)
>>108582270
also, young anon, check out this cool way to pass params between function calls#include <stdio.h>
void f(int a[], char *id) {
size_t s = sizeof(a);
}
void p() {
int *a; char *id; size_t s;
printf("f::sizeof(%s) = %d\n", id, s);
}
int main() {
int arr1[8], *arr2 = arr1;
f(arr1, "arr1");
p("arr1");
f(arr2, "arr2");
p("arr2");
return 0;
}
>>
>>108582465
sorry, forgot to remove params from p#include <stdio.h>
void f(int a[], char *id) {
size_t s = sizeof(a);
}
void p() {
int *a; char *id; size_t s;
printf("f::sizeof(%s) = %d\n", id, s);
}
int main() {
int arr1[8], *arr2 = arr1;
f(arr1, "arr1");
p();
f(arr2, "arr2");
p();
return 0;
}
>>
>>
>>108582270
>>yeah bro arrays and pointers are the same in C
anyone who tells you that is a brainlet retard that has no clue.
People just pass array as pointers to functions and then oh boy, it suddenly behaves like a pointer. CRAZY!!!
>>
>>
File: 1660320444392.gif (831.7 KB)
831.7 KB GIF
>>108561805
Next thread:
>>108582544
>>108582544
>>108582544
>>
>>108582419
>It gets allocated on the stack, but when I do
> It gets allocated on the heap, correct?
More like, in second case it's guaranteed to be allocated on heap, but in first case it might be allocated on stack, might end up completely in registers alone, or somewhere else. It seems C standard says that it is guaranteed to never allocate that on heap, but it never says it will allocate on stack, but in practice there's usually no other choices other than stack and registers on most architectures, and registers will only fit small arrays.
>>
>>108582270
arrays "decay" to pointers
when in the scope of their declaration, a compiler can tell a bit more information about an array, as evidenced by the sizeof results. but the instant you leave that scope (e.g., by addressing or dereferencing it, by casting it, by passing it to a function, etc.) the array will "decay" into a pointer and become indistinguishable from one