Thread #108226774
File: 1771929386415.jpg (106.1 KB)
106.1 KB JPG
What are you working on, /g/?
Previous: >>108194628
320 RepliesView Thread
>>
>>
>>
>>
>>
>>
File: 1770369153948136.png (256 KB)
256 KB PNG
>>108226868
Programming is autist-coded.
>>
>>
>>
>>
File: mycock.png (9.7 KB)
9.7 KB PNG
>>108226868
I do feel very agitated in the past few days.
But I have also started to eat more trash sugar again.
So I don't know. Maybe my hyperfocus is wearing off or I should really unironically quit bad sugar for good now. Tho I am craving hard again in the past days :(
Doesnt feels THAT good.
Thank you for reading my tweet
>>
>>
>>
>>
File: gamewiki.png (658.7 KB)
658.7 KB PNG
I am configuring a mediawiki site for cataloging video game cameos in movies and TV. So if a character is sitting on the couch playing a video game, I add the game to the film's wiki page and it generates a table in the game's wiki page automatically.
>>
>>
>>108227992
>NIGGA I'M GONNA LEARN SEE SHARP
c# is super gross. microsoft and unity is a shit pile. they're both garbage tier companies. there's never a usecase for c#. just do unreal engine or godot or lua or anything else for games. for web or scripting literally any other language is decent.
>>
>>108228491
do it with fossil instead: https://fossil-scm.org/
>>
>>108228491
Honnestly very cool anon, I hope you get to make the public and that it grows.
It's nice to have a wiki but you should also make a database right from the start so that it can be queried by date, game, movie, etc.. Like imdb, imcdb (Internet Movie Cars Database), tunefind, etc..
>>
>>
>>
File: VID_20260224_221035525-[00.00.000-00.25.946].webm (3.1 MB)
3.1 MB WEBM
>>108226774
my launcher is now fully featured i think. spent a few days refactoring all the stuff do do with building the app grid as it was pretty laggy kek
>>
>>108230508
>I'm gonna use it with Monogame to make funny little 2D games.
okay but just check this for one second. this is how you're gonna have to do animations. with xml ( ew gross)
https://docs.monogame.net/articles/tutorials/building_2d_games/09_the_ animatedsprite_class/index.html
this is how godot does it ( just ui fun ):
https://docs.godotengine.org/en/stable/tutorials/2d/2d_sprite_animatio n.html
and this is how love2d does it ( simply cute )
https://www.love2d.org/wiki/Tutorial:Animation
the choice is yours. but bros warn bros about xml.
>>
>>108232352
>https://docs.monogame.net/articles/tutorials/building_2d_games/09_the _animatedsprite_class/index.html
>XML
>Test Your Knowledge
SOVL
>>
>ask claude to create some sample data for testing
>creates fake users and customers with the names of my family, their surnames and the actual cities some of my family lives
>creates a test user with MY NAME and MY CITY but genderswapped
how the fuck did it know????
>>
>>
Write a program that reverses the words of input string:
Enter a sentence: you can cage a swallow can't you?
Reversal of sentence: you can't swallow a cage can you?
Programming in C: a modern approach chapter 8 project 14
For some reason this took me longer than I care to admit.
>>
>>108233348#![feature(iter_intersperse)]
fn main() {
let text = "you can cage a swallow can't you?";
let rev = text.find(['.', '?', '!'])
.map(|p| text.split_at(p))
.or(Some((text, "")))
.map(|(text, suffix)|
text.split(' ')
.rev()
.intersperse(" ")
.chain(Some(suffix))
.collect::<String>())
.unwrap();
println!("{rev}");
}
>>
>>108233348
>everses the words of input string
>you can't swallow a cage can you?
it says the function operates on a "string", but the test has it reversing the words of a sentence, preserving grammatical features that "string" does not at all imply.
typical C to be vague about types like this. Go be vague about the length of an array, jerk. Go be vague about whether a pointer is to mapped memory or not.
grug ocaml:let rev_words s =
let r = Buffer.create (String.length s) in
let j = ref (String.length s) in
for i = String.length s - 1 downto 0 do
if s.[i] = ' ' then begin
Buffer.add_substring r s (i + 1) (!j - (i + 1));
Buffer.add_char r ' ';
j := i
end
done;
if !j > 0 then Buffer.add_substring r s 0 !j;
Buffer.contents r
let () =
assert (
rev_words "you can cage a swallow can't you"
= "you can't swallow a cage can you");
assert (rev_words "yes" = "yes");
assert (rev_words "zero-length word: " = " word: zero-length");
assert (rev_words "is this stupid?" <> "stupid this is?")
>>
>>
>>108233450
this does however absolutely murder OCaml in performance in a very normal microbenchmark like 5000 consecutive reverses of a 10000-word, 93k byte string.
even I reuse a Buffer for all of that it's 950ms to 34ms.
>>
>>108233450
>#![feature(iter_intersperse)]
I don't know man.
Rust sounds, from the concept, like a cool language, but how would one know all these stupid features and require and shit like that? Why can't they just get rid of this stupid shit? No one ever understands when and why they are needed.
it's worse than gcc directives
>>
>have an idea
>start working on it
>realize even if you know what you're doing it still takes dozens if not hundreds of hours to make the most basic usable app
>claude is next to useless and hallucinates bullshit 60% of the time and the other 35% of the time it spits shit out that doesn't work
yeah like no wonder all of the people talking about "running 20-30 claude instances in a cluster" never produce anything lmao
>>
>>
File: 1749384253074648.png (63.8 KB)
63.8 KB PNG
Grok CLI soon, maybe
>>
>>
>>
>>108233628
It's a very simple thing to fix.#![feature(iter_intersperse)]
fn main() {
let text = "you hates google.com!";
let (text, suffix) = text.rfind(|c| !matches!(c, '.' | '?' | '!'))
.map(|p| text.split_at(p + 1))
.unwrap_or((text, ""));
let rev = text.split(' ')
.rev()
.intersperse(" ")
.chain(Some(suffix))
.collect::<String>();
println!("{rev}");
}
>>108234680
>Why can't they just get rid of this stupid shit? No one ever understands when and why they are needed.
Rust is not designed behind closed doors, you can just read about it:
https://github.com/rust-lang/rust/issues/79524
The feature is not that new so and it was about to be stabilized. However it is in conflict with itertools::intersperse.
https://github.com/rust-lang/rust/issues/88967
Every new change in Rust is being tested against all known source codes, and it turns out this would break some crates that rely on itertools. In order to fix this and potential future conflicts they need this feature:
https://github.com/rust-lang/rust/issues/89151
And that feature is about to be stabilized. It's in the final comment period:
https://github.com/rust-lang/rust/pull/148605
Once this gets stabilized, the stabilization of intersperse will begun, after which feature gate will no longer be necessary and you will be able to use it in the stable compiler.
Rust is just very cautious to not cause any breakages and to not stabilize halfbaked solutions. Any unaddressed concern bumps things back to the scratchboard. Fortunately things can progress independently so you do not have to wait for Rust++28 or have something bad being rushed out.
>>
>>108235444
>It's in the final comment period:
Oh, it's literally being released right now:
https://github.com/rust-lang/rust/issues/152802
>>
>>
>>
>>
>>
File: 1740935345190634.png (1.3 MB)
1.3 MB PNG
>>108233348let res = inputString.components(separatedBy:CharacterSet(charactersIn: " .!?"))
.compactMap { $0 != "" ? $0 : nil }
.reversed()
.joined(separator: " ")
return [".", "!", "?"].contains(inputString.suffix(1)) ? res + inputString.suffix(1) : res
>>
>>
>>108236268
>>108233628
oopsvar res = inputString.split(separator: " ")
let suffix: Substring = {
guard let last = res.last, [".", "!", "?"].contains(last.suffix(1)) else { return "" }
res.removeLast()
res.append(last.prefix(last.count - 1))
return last.suffix(1)
}()
return res.reversed().joined(separator: " ") + suffix//you can cage a swallow can't you? -> you can't swallow a cage can you?
//you hates google.com -> google.com hates you
>>
>>
File: 1770542417029208.png (15.5 KB)
15.5 KB PNG
>>108236455
what's trooncoded about swift?
>>
>>
>>
>>
>>
What's the fastest way of doing lots of small reads from a file on disk? Memory mapping?
I have a table of floats stored in row-oriented format and need to extract only a few columns out of 10000 and there's around 7000 rows. So I need to read through the rows and extract 5 floats from each one.
>>
>>
>>108233348#include <stdio.h>
int main(void)
{
char input_string[256];
char c;
int length = 0;
char punctuation = '\0';
printf("Enter text: ");
while ((c = getchar()) != '\n' && length < 255)
{
if (c == '!' || c == '.' || c == '?')
{
punctuation = c;
}
else
{
input_string[length++] = c;
}
}
input_string[length] = '\0';
int word_end = length;
for (int i = length - 1; i >= 0; i--)
{
if (input_string[i] == ' ')
{
for (int j = i + 1; j < word_end; j++)
putchar(input_string[j]);
putchar(' ');
word_end = i;
}
}
for (int i = 0; i < word_end; i++)
putchar(input_string[i]);
if (punctuation != '\0')
putchar(punctuation);
putchar('\n');
return 0;
}
>>
>>
>>
File: lain rat.jpg (714.6 KB)
714.6 KB JPG
fixedString input = "you can cage a swallow can't you?";
print(
"${[for (int i = 0; i < input.substring(0, input.length - 1).split(" ").length; i++) input.substring(0, input.length - 1).split(" ").reversed.toList()[i]].join(" ")}${input[input.length - 1]}",
);
>>
String input = "you can cage a swallow can't you?";
bool hasPunct = ["?", "!", "."].firstWhereOrNull((punct) => punct == input.substring(input.length - 1, input.length)) != null;
print(
"${[for (int i = 0; i < (hasPunct ? input.substring(0, input.length - 1).split(" ").length : input.split(" ").length); i++) (hasPunct ? input.substring(0, input.length - 1).split(" ") : input.split(" ")).reversed.toList()[i]].join(" ")}${hasPunct ? input[input.length - 1] : ""}",
);
>>
>>108233348#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sds/sds.h"
int main(int argc, char *argv[])
{
char *line = 0;
size_t size = 0;
sds *tokens;
int count = 0;
getline(&line, &size, stdin);
if(!line)
return -1;
tokens = sdssplitargs(line, &count);
for (int n = count - 1; n >= 0; n--)
printf("%s ", tokens[n]);
puts("");
sdsfreesplitres(tokens, count);
free(line);
return 0;
}
>>
>>
>>
>>
>>
>>108237799
all that you need in the terminal is OCaml.
behold!$ echo -e "some\ttab\tseparated\twords" | ocaml -I +str str.cma -e 'let tab = Str.regexp "\t" in In_channel.fold_lines (fun () line -> print_endline (Str.global_replace tab "\\t" line)) () stdin'
some\ttab\tseparated\twords
>>
File: pepe-meme-coinbase.jpg (344.9 KB)
344.9 KB JPG
Can you close this thread?AI will do everything
>>
>>
>>
>>
>>108238058
I prefer the second for nesting, but the first is almost always what will be expected of you, and for consistency expected throughout. Though in your example there would be no braces at all of course.
The only place this will differ is in function definitions, including main, where you will use the second.
>>
File: VID_20260225_192202374-[00.00.000-00.13.853].webm (2.4 MB)
2.4 MB WEBM
>>108237478
yes theres literally no better thing to have as a pape
>>
>>
File: Screenshot From 2026-02-25 13-16-48.png (1.9 MB)
1.9 MB PNG
>>108226774
My QT6 ffmpeg frontend:
https://github.com/orlfman/FFmpeg-Converter
Pic kinda related. My port to GTK / Libadwaita since I moved over to Gnome.
>>
>>
>>108236997
If you're only reading them once from a single file you might be better off using scattering APIs:
>https://manpages.debian.org/unstable/manpages-dev/io_submit.2.en.html
>https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileap i-readfilescatter
They reduce the amount of mode switches, and they can be executed in parallel.
>>
>>
>>108239590
Signature mismatch between libaio and kernel. io_submit is supposed to return the number of submitted entries or an error code (which are negative on Linux, thus long instead of unsigned long or size_t), but libaio, for whatever reason, clamps this down to a 32-bit int. The kernel itself returns a long, too.
>>
>>
>>108233348
In C++ this is just:#include <algorithm>
#include <iostream>
#include <print>
#include <ranges>
#include <string>
#include <string_view>
#include <vector>
int main() {
std::vector<std::string> sentences = {
"you can't swallow a cage can you",
"you hates google.com"
};
for (const auto &sentence: sentences) {
auto words = sentence
| std::views::split(' ')
| std::views::transform([](auto&& range) {
return std::string_view(range.begin(), range.end());
})
| std::ranges::to<std::vector>();
std::ranges::reverse(words);
std::string result;
for (auto&& part : words | std::views::join_with(' ')) {
result += part;
}
std::println("Reversal of sentence: {}", result);
}
}
>>
>>
>>108238824while (something) something_else();
Even simpler.
>>108239857
>just
>>
>>
>>
>>
>>
>>
File: agentic coding.jpg (228.1 KB)
228.1 KB JPG
>>108226774
Why are you guys forever "learning" and not doing anything useful in developing a functioning program of your own?
Just fire up a god damn opencode and let agents work for you.
>>
>>108239857
in comparison, this D gets 3.76ms.import std.stdio;
import std.algorithm;
import std.array;
import std.string;
void main() {
string[] sentences = [
"you can't swallow a cage can you", "you hates google.com"
];
foreach (sentence; sentences) {
auto words = sentence.split(' ').array;
words.reverse;
auto result = words.joiner(" ").array;
writeln("Reversal of sentence: ", result);
}
}
>>
>>
>>
>>
>>
>>
>>
File: pathetic.png (1.1 MB)
1.1 MB PNG
>>108233450
100% trash code.
>>108236941
>>108240084
Just admit you can't even solve it.
>>
>>108240196
???
I refused the punctuation with my solution here: >>108233608
the description says "reverse WORDS in a STRING", it does not speak of sentences with come with much additional structure.
>>
File: Zminok-2026-02-25-01.png (210.6 KB)
210.6 KB PNG
HELL YEAH, I just made a breakthrough with my REST controller after two weeks of sluggish progress. I'm going to implement it in my Fuze Mediaboard project.
Basically you add "patterns" which contain a View and a variable number of string or int args. The view function's args correspond to the ints in the URL. In future I'll make it support variable string args too.void testView(int numb) {
std::cout << "testView called! " << numb << std::endl;
}
Controller::addPattern(testViewTwo,std::string("thread"), 0);
Controller::matchPathAndExecute("thread/73"); // matches, calls testView with 73
Controller::matchPathAndExecute("pufferfish/wit/da/big/ass/lip"); // does not match
>>
>>
>>
>>108240196
my wife wold never call me pathetic and i did >>108237231
>>
>>
>>
>>
>>
>>
>>108240036
regardless of how long it takes for me to finish my projects, the end result is not going to be very useful, agent or not. paying some silicon valley faggots to finish these projects of mine faster would be insane use of money, when the only value IS the learning and that I have something fun to do
>>
>>
>low level computer "enthusiast" whatever that means
>have tried to learn python before but gave up relatively early on
>currently taking an intro to python course at my college
>the professor sucks
So far im doing ok but what worries me is I have trouble writing my own code. Like if im given an example and then have to replicate that example for a new scenario I can usually do it but sometimes she'll give practice questions and I don't even know where to begin even though I can understand the basics of the concepts she has taught. I think they call it inferential thinking but basically when given a problem how do I know what to use? Technically I could use a bunch of things a for loop, a while loop, do I need a break statement in this loop etc. she assigns work on codelab and I can get through those relatively easily (although this week's chapter is more challenging) and im afraid of not only falling behind but apparently our midterm is gonna be on pen and paper not a computer. Any tips for getting better at knowing how to proceed when told "wrote code that does XYZ"? again on codelab I can kind of figure it out but while in class I always struggle to even know where to begin on her "try this yourself" problems
>>
>>
>>
>>
a good option is doing CS50. Someone would recommend you jump straight into CS50P, I don't think that's a good idea since CS50 covers a lot of topics and touches on Python too. Seriously, if you dedicate 2months to CS50 you might get ahead of maybe 70% of your colleagues in your level at your college
>>
>>
>>108240743
was that a reply to my post >>108240669?
>>
>>108240536
>real employ-ability
Follow good practices and what feels good and you'll get a job. Uh, eventually.
>cracked, yet not a hipster
This is not a highschool, there are no cliques.
t. never coded a single line
>>
>>108240669
Which specific problems are you struggling with?
>I think they call it inferential thinking but basically when given a problem how do I know what to use?
Seems like you're just lacking the fundamentals and lacking practice.
You need to manipulate more data to learn how to think about all of this.
If I gave you an array of numbers, can you sum them up? can you find the maximal value? can you append all the number > 10 into another array?
>>
>>
>>
>>
>>
>>
>>
>>108233348import Data.Char (isLetter)
main = do
let s = "you can cage a swallow can't you?"
putStrLn s
putStrLn (reverseWords s)
reverseWords str = unwords (reverse (words ws)) ++ end where
(rend, rws) = span (not . isLetter) (reverse str)
(end, ws) = (reverse rend, reverse rws)
>>
>>108233348#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX 200
int main(void)
{
char s[MAX];
char *words[50];
int count = 0;
printf("Enter a sentence: ");
fgets(s, MAX, stdin);
s[strcspn(s, "\n")] = '\0';
char *p = s;
while (*p && count < 50)
{
while (*p && isspace(*p)) p++;
if (*p == '\0') break;
words[count++] = p;
while (*p && !isspace(*p)) p++;
if (*p) {
*p = '\0';
p++;
}
}
printf("Reversal of sentence: ");
for (int i = count - 1; i >= 0; i--)
{
printf("%s", words[i]);
if (i > 0) printf(" ");
}
printf("?\n");
return 0;
}
>>
>>108241336import Data.Char (isSpace)
main :: IO ()
main = do
let s = "you can cage a swallow can't you?"
putStrLn s
putStrLn (reverseWords s)
reverseWords :: String -> String
reverseWords s =
let (trailPunct, rest) = span isSpaceOrPunct (reverse s)
wordsReversed = reverse (words (reverse rest))
trail = reverse trailPunct
in unwords wordsReversed ++ trail
isSpaceOrPunct :: Char -> Bool
isSpaceOrPunct c = isSpace c || c `elem` ".,!?;:'\""
>>
>>108239857
>>108239992
oh I totally forgot until the Haskell entry that I was comparing 5k runs
this is actually 6x slower than Rust, with nearly 20x the branch misses
>>108241336
*** FOUR SECONDS ***
strace says that Haskell is polling stdout every single time it prints, with only an 8k buffer, so that doesn't help.
>>
>>108241336let tailpunct = Str.regexp "[\x00\x3F]+$"
let rev_words s = String.split_on_char ' ' s |> List.rev |> String.concat " "
let rev_words s =
match Str.full_split tailpunct s with
| [Str.Text s; Str.Delim tail] -> rev_words s ^ tail
| [Str.Text s] -> rev_words s
| _ -> assert false
let () =
assert (
rev_words "you can cage a swallow can't you?"
= "you can't swallow a cage can you?");
assert (rev_words "yes" = "yes");
assert (rev_words "zero-length word: " = " word: zero-length");
this is still much better than Haskell on most metrics, and Str a slow simple regex engine. The difference is small enough that Haskell can probably pull ahead with byte strings and and an optimized regex engine.
>>
>>
>>108241565
[\x00-\x3F] with a -
>>108241577
it's an obfuscated programming language designed to be difficult to implement, similar to Befunge, but not as fun.
>>
>>
>>
File: tard.jpg (2.6 KB)
2.6 KB JPG
>>108241137
>>
>>
>>
File: retard.jpg (46.3 KB)
46.3 KB JPG
>>108241137
>>
>>108233348
O(1) space, O(n) time, decomposed into simpler functions.static void reverse(char* p, char* e) {
for (int c; p < e; c = *--e, *e = *p, *p++ = c);
}
static void reverseWords(char* p, char* e) {
for (char* s = p;; ++p)
if (p == e || *p == ' ') {
reverse(s, p);
if (p == e) break;
s = p + 1;
}
}
static void reverseSentences(char* p) {
for (char* s = p;; ++p) {
int const c = *p;
if (c == '.' || c == '?' || c == '!' || c == ',' || !c) {
reverse(s, p);
reverseWords(s, p);
if (!c) break;
s = p + 1;
while (*s <= ' ' && *s) ++s;
}
}
}
int main() {
char text[] =
"you can cage a swallow can't you?\n"
"three plus six equals nine.\n"
"reporters cover whales exploding!\n"
"rise to vote, sir";
reverseSentences(text);
int puts(const char*);
puts(text);
}
>>
>>
File: 1770448536475176.jpg (278.2 KB)
278.2 KB JPG
Do you guys think a personal project can be useless, or is it more about what you learn during the process? I’m currently writing a game engine, but I have zero interest in actually being a game dev.
>>
>>108242117
The alternative is learning about the raw kernel interfaces and realizing that everything not matching those signatures is slop.
Both Windows and Linux support opening files via relative directory handles (RootDirectory in NtCreateFile/openat), cutting down on memory allocations and lookup time - yet how many libraries or languages expose that capability?
>>
>>108242141
do something that you're interested in. Getting any kind of job will help.
>>108242161
any language with convenient access to the C ABI can use them, it's mainly scripting languages that are living with 20 or 30 year old versions of the Unix API.
>>
>>
>>
I'm making a game in C++. My levels are created via XML files.
I have a certain type of object in my game that gets activated when the player collides with them. Some of them also have a second condition that must be met. So the player must collide with them, but also, their health has to be below a certain amount, or maybe they have to have a specific item in their inventory. Something like that.
How do I set that up in my XML? I guess I'd need something like
>parameter="health" comparator="lte" value="30"/>
I could then parse that in my C++ code, but with lots of different parameters, it'd probably get ugly real fast. Maybe I could use a map or something?
>>
>>
>>
>>
>>
File: cpp_vs_c.png (292 KB)
292 KB PNG
>they can graduate to cpp
We don't want to reinforce autistic patterns though.
>>
>>108242425
>unique_ptr
https://www.youtube.com/watch?v=xt1KNDmOYqA
>>
>>
>>
>>
>>
>>
>>108242498
If you think "every last aspect of a program" includes using proper interfaces, then I'm sorry, but you're autistic and in denial.
Which is even funnier because I agree with that statement in and of itself. It's why my opinions about compilers are so low.
>>
>>108242339
>I could then parse that in my C++ code, but with lots of different parameters, it'd probably get ugly real fast. Maybe I could use a map or something?
Write a S-expression parser, s-exps are much prettier to read and write.
Looks like you're trying to express rules that have 3 elements: the pair of object types the rule is concerning, a predicate (or a complex predicate made of several simple predicates connected by logical and or logical or), an action(collision-rules
((player object-A)
(<= (field player health) 30)
(action))
((player object-B)
(>= (field player strength) 80)
(action))
)
>>
File: 1770187119084260.png (140.5 KB)
140.5 KB PNG
https://www.youtube.com/watch?v=B2gmKy3pHkw
>>
>>
File: 1763024189850397.jpg (57 KB)
57 KB JPG
https://leetcode.com/problems/design-circular-queue/
>>
>>108244623
how'd you figure out the index + count method? My first instinct was to use a double linked list which worked, but was slow. I kept trying to make it work with just an array and using a start / end index which was a mess and kept failing.
>>
>>
>>108244637
>My first instinct was to use a double linked list which worked, but was slow
Linked lists are useless for most cases. Queues are often implemented using dynamic arrays.
>I kept trying to make it work with just an array and using a start / end index which was a mess and kept failing.
That's why. I also first thought of start/end cursors because it simplifies adding/removing to just one inc/dec, but then you have to deal with the pigeonhole principle. Basically:
In circular buffer it doesn't matter where you start, you can "rotate" everything with no change in observable behavior. The only thing that matters is where the end is positioned relative to start. For an array of capacity N, the end can end up in N different places(relative to start). But this is not enough to express all possible states a queue can be. A queue of capacity 3, can be: empty, 1-element, 2-element or full. That's 4 possible states, you can't encode all of them using just end cursor that has 3 possible states. This has to be mitigated by using some extra boolean, or you can just ditch end cursor for len counter which has no such limitation for practical usecases.
>>
File: 1772069598321432.png (216.9 KB)
216.9 KB PNG
>cheney gc implementation in c
>local pointers on the c stack need to be updated between allocations in case gc moves what they are pointing at
>if n rounds of gc occur before a c stack frame is reentered (say from a recursive call that allocates) those pointers may have moved n times
These pointers can only be reliably updated when n = 1 or n = 2, right? i.e. the program should die on following a moved pointer more than twice, as we've likely lost track of it
>>
File: 1768324026900530.png (1.6 MB)
1.6 MB PNG
>>108244679
>pigeonhole principle
funny name for something intuitive
in this case, not so intuitive...
anyways, how long have you been coding? I'm at around ~4 yoe but only started grinding leetcode a few months ago. I feel like a complete retard since I haven't had to deal with shit like linked lists or DP in forever. I saw you implemented a solution to basic calculator IV, I can't imagine how long I'll have to study before I'm able to come up with something like that on the spot.
>>
File: images.steamusercontent.jpg (163.1 KB)
163.1 KB JPG
>>108244783
>how long have you been coding?
Since I was a kid, maybe 20 years or so.
>I saw you implemented a solution to basic calculator IV, I can't imagine how long I'll have to study before I'm able to come up with something like that on the spot.
I never studied solving problems per se, or grinded leetcode. I mostly do it when someone post it here as a warmup before I start doing my actual job. I studied theoretical computer science and self-studied math, especially recreational kinds. I guess related to calculator, we did made compilers in university, but we just generated all the parsing code using bison+flex and didn't do any such high level optimizations so there was no overlap.
It's just the result of programming for so long in so many different technologies and maths, you do get a solid intuition eventually. I would pin a lot of my problem solving skills back to the thousands hours I spent playing gmod and pushing its in game programming to its limits. When you have a language that doesn't even have functions or continuity of execution you need to get creative. Also rich, diverse experience. There is probably no area of programming I haven't dabbled in, except for maybe FPGA and HFT. It's definitely not the first time I am implementing some queue.
>>
>>
File: 1772109815920924.webm (2 MB)
2 MB WEBM
>>108244775
I think the simplest way that preserves correctness is assigning local c variables from a global pool updated on each gc, to fully decouple the c stack from the garbage collector. It's slow but so is checking every variable before use in the current implementation
>>
>>108245748
pointers on the stack are a common problem, but with optimization pointers can also exist only in a register, and with pointers can also leave userspace entirely and exist only in kernel memory, which I've seen happen accidentally with epoll().
some simple D that demonstrates pointers in registers isimport std.stdio;
import core.memory;
class C {
~this() {
writeln("dtor");
}
}
void main() {
auto c = new C;
foreach (i; 0 .. 10000)
GC.collect;
writeln("end of main");
}
where the order of output changes depending on optimization, because at higher optimization the GC thinks that c has died before it goes out of scope.
>>
been doing some automation using playwright, and ran into a pretty challenging issue, .fill() is good at input fields and all that shizzle, but now im automating on a frontend with some disgustingly generated ui(kafbat ui), where when sending a message and needing to fill these "textarea" divs, .fill() can't grab onto them, and just throws an error
I kinda forced it by setting up a .click() on that area, then going for .keyboard.type(), but depending on the length of the entry(+10k lines json) it can take minutes for a single execution, and the plan would be to run this shit on thousands of json files and such, obviously not feasible
with .fill() being completely shafted, im running out of ideas, is there anything i could do besides somehow shitting the files one by one onto clipboard, then just comboing ctrl+v in there with .keyboard.type()?
>>
File: reverser2.png (59.9 KB)
59.9 KB PNG
>>108233348
>>
>>108244775
>>cheney gc implementation in c
>>local pointers on the c stack need to be updated
this is true for any GC that moves objects, not the cheney GC and all GCs need to be able to iterate over evey pointer to heap objects that are on the stack, otherwise everything pointed to only by the stack would be collected
>>if n rounds of gc occur before a c stack frame is reentered
>These pointers can only be reliably updated when n = 1 or n = 2, right?
What are you talking about? Either pointers on the stack are correctly updated or they aren't.
>>
>>
>>108246497
>What are you talking about? Either pointers on the stack are correctly updated or they aren't.
I was doing running updates like thisT *f()
{
// allocate local temporary
T *t1 = new()
// check if t1 has moved
t1 = update(t1)
// initialize t1 and push to gc root
t1->first = null
t1->second = root
root = t1
// list() allocates
T *head = list()
// check if t1 has moved
t1 = update(t1)
// protect head from gc
t1->first = update(head)
// create another local temporary
T *t2 = ...
// t1 and t2 are later removed from root
}
this works (I think, from testing) when list() doesn't cause more than 2 rounds of gc, as update() can only reliably follow t1 between the 2 spaces that cheney uses. For comparison decoupling temporaries from each c stack frame might look likeT *f()
{
T **t1 = new_local()
(*t1)->first = null
(*t1)->second = root
root = *t1
T *head = list()
(*t1)->first = update(head)
T **t2 = ...
}
t1 should point to the right place even when list() causes n rounds of gc as we only get the address (which may have moved n times) after t1 is dereferenced
>>
>>
>>108247029
Why would this garbage even work? Did you have a stroke while reading about forward references?
At this point, you're better off maintaining a parallel stack where you would all pointers to GC objects that the function has.
Precise GCs in C (both moving and non-moving) are an unreliable clusterfuck because you can't reliably walk over each stack frame. It's really only an option for VMs and for natively compiled language like Go where the compiler is aware that the code is using a GC so it can give the information of the final stack frame layout to the GC and it can compile extra code for dealing with write barrier (for generational GCs), code for safe points, etc..
>>
>>
>>108247633
>That's what the second example does
I'm certainly not talking about have 2 references for each object and checking/"updating" ... (fucking what ???) manually. What is this retardation?
If an object has been moved, the old pointer points to either a free space on the heap or to a new object that has been moved where the old object was.
>>
>>
>>108247697
>I'm certainly not talking about have 2 references for each object and checking/"updating" ... (fucking what ???) manually. What is this retardation?
If head were directly linked to root, nothing else could be linked to root later. t1 and t2 are essentially nodes in a linked list, and will be unlinked in the epilogue of f for gc
In the first example updating is necessary, as t1 holds ab address from new(), but that address may have changed if list() (which also calls new()) causes gc when the stack frame of f is restored. The retardation is pretty straightforward
>>
>>
>>108247905
>The retardation is pretty straightforward
I won't understand shit until you explain how and when garbage collection happens and more importantly what GC metadata you store in your objects and what data structures you're using for tracing and anything required by the GC
I have zero clue about update() does, what ->first and ->second points to.
>>
>>108248126
gc can occur on any call to new, and there's no metadata beyond what cheney demands. The body of update isT *update(T *a)
{
if (a->tag == MOVED)
return a->moved
else
return a
}
first = value, second = next as in a linked list. In the examples before t2 this structure has been created:root t1 nil
|_|_|->|_|_|->|_|_|
|
v
head
|_|_|-> ...
>>
>>
>>
>>
>>
>>
File: Screenshot From 2026-02-26 20-39-11.png (160.2 KB)
160.2 KB PNG
>>108238764
>>108239747
my gtk4 / libadwaita port is coming along nicely. i am very happy so far. under the hood is SO much better than my qt6 version.
i am really trying to make it look pretty.
>>
>>
>>
>>
File: Screenshot From 2026-02-26 21-50-15.png (70.7 KB)
70.7 KB PNG
>>108249622
what i like a lot about vertical is i can shrink the window down. everything flows vertical. if i make it horizontal bias then i would need a horizontal scrollbar.
idk. im gonna go with my autism.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>108251435
>emotional misread
>>108251358
>>
>>
>>108251804
>more emotional misread
>>108251358
>>
What other books should I buy? I currently have:
The C Programming Language (Brian W. Kernighan)
Structure and Interpretation of Computer Programs (Harold Abelson)
Compilers: Principles, Techniques, and Tools (Alfred V. Aho)
Introduction to Algorithms (Thomas H. Cormen)
Operating System Concepts (Abraham Silberschatz)
>>
>>
>>
>>
>>
>>
>>
>>
>>
File: 1744099934811029.gif (2.3 MB)
2.3 MB GIF
>>108252124
Found the imposter
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>108253167
OK, retard. You sound like you belong in a cage as well.
>>108253182
God, the autism ITT.
>>
>>
>>
>>
>>
>>
>>
>>108253473
for LLM replacement to happen, humans had to atomized and exploited to the level of not even missing what LLMs are missing, because what's missing is hardly experienced anyway. There was already no humanity from the call center, nor from FAANG "SWE" that do nothing but shit out code by rote.
>>
>>
>>108253508
The one about microkernels? Yeah, sorry, but only complete autists who steadfastly refuse to accept the realities printed into silicon since 1982 would actually be retarded enough to still adhere to such an architectural design.
Like, there are no excuses. In a proper society you'd be shot in the head, or at the very least put into a cage to protect normal people from your autism. No exceptions.
>>108253512
>humans
Autists were never humans, so stop confusing the two.
>>
>>
File: c8c8fc53a69f0560c0bc18ff141faa5e.jpg (1015 KB)
1015 KB JPG
>>108253526
He's a redditor that for some reason really hates "autism"
That type of person that thinks they are a global citizen, that socialization means pleasing complete strangers, etc
I bet he's also an western buddhist
>>108253546
I knew it
>>
File: 1771210814473215.png (293.8 KB)
293.8 KB PNG
>>108253473
Angloid self-annihilation was inevitable since the analytic engine, but don't think this solar system will be spared
>>
File: 1760866685648129.png (309.8 KB)
309.8 KB PNG
>can't even begin to understand the editorial for today's leetcode problem
>check the solutions tab
>first solution is made by some guy with a slavic name
>changes the default "Solution" class to a struct
>uses the ~ operator
>code is completely unreadable
>it works
>>
>>
So the BYTE* website that had a full archive of The Old New Thing with copies of all the comments that were lost over the years of MS fucking with their blogs is gone now, and all that remains on that domain is an AI slop content farm
>>
>>
>>
>>
>>
>>
>>
>>
>>108254772
>GC
What's wrong with it? It's optional. Most systems-level languages don't have a GC to begin with. In fact, D is probably the only language (aside from meme extensions) that supports both inline assembly and garbage collection.
>string templates
Elaborate?
>>
>>108226774
I optimized my rig, my computer is running beautifully, fast, low startup time, games running faster, fans cool, high performance, much integration, easy to use. Very responsive. I'm basically living life out here.
>>
>>
>>
>>
>>108233348import Control.Arrow
isPunct :: Char -> Bool
isPunct = (`elem` ".!?")
sents :: String -> [(String, String)]
sents "" = []
sents s = (sent, puncts) : sents rest'
where
(sent, rest) = break isPunct s
(puncts, rest') = break (not . isPunct) rest
revwords :: String -> String
revwords s = unwords $ uncurry (++) <$> parts
where
parts = first (unwords . reverse . words) <$> sents s
main :: IO ()
main = putStrLn (revwords "hello, world! this is my first sentence?")
-- world hello,! sentence first my is this?
>>
>>
>>
>>108254739
it's very thoroughly half-assed in core language design, implementation, and standard library, and even into the official docs that have terrible Google search. It's not actually a simple answer like "GC" or "Rust"; it's that anytime anyone tries to use D for anything, irritating deficiencies and bugs are encountered immediately. Instead of a metric like bugs per line of code, you have reported D bugs per feature, and due to the half-assed design you have spooky behavior and performance characteristics all over the language that's not even a reportable bug, like massive slowdowns from naively treating arrays like stacks, or from autodecoding more than you expect.
If D had gotten some popular kick in the pants like Ruby On Rails for Ruby, or corporate sponsorship, then these rough edges could've been ground down, and that was probably Walter's expectation: it doesn't have to be thoroughly designed if it can be iterated on in response to actual use like any open-source project.
Even so, it's still better for exploratory programming than some shit like Rust or a Jai-inspired language. The kind of programming people used to recommend scripting languages for.
>>
>>108254944
>string templates?
D templates are a better version of C++ templates, and relatively comfy. D templates are good enough to make you think that templates aren't such a bad way to do things.
What's probably meant by "string templates" is string mixins, and the pattern of building a string representation of code and then injecting it into compiled code. It's very lame and D has it instead of a macro system:void main() {
static foreach (dep; ["std.stdio"]) {
mixin("import " ~ dep ~ ";");
}
writeln("<-- not usable without `import std.stdio;`");
}
>>
>>
>>108255707import std.stdio;
struct Stack(T, string Name) {
T[] st;
void push(T x) {
int* orig = st.ptr;
st ~= x;
if (st.ptr != orig)
writeln(Name ~ " realloced!");
}
T pop() {
T x = st[$-1];
st.length--;
return x;
}
}
void main() {
Stack!(int, "a") a;
Stack!(int, "b") b;
foreach (n; 0 .. 100) a.push(n);
foreach (n; 0 .. 100) { b.push(n); b.pop; }
}
a reallocs 10 times.
b reallocs _100_ times.
>autodecoding
D's stdlib eagerly decodes strings into UTF-8 codepoints, which isn't free.
>>
>>108255385{-# LANGUAGE LambdaCase #-}
import Control.Arrow
import Data.List
isPunct :: Char -> Bool
isPunct = (`elem` ".!?")
sents :: String -> [(String, String)]
sents = unfoldr $
\case { "" -> Nothing; s -> Just s }
>>> (fmap $
break isPunct
>>> second (break (isPunct >>> not))
>>> (fst &&& (snd >>> fst)) &&& (snd >>> snd))
revwords :: String -> String
revwords =
sents
>>> fmap
(first (words >>> reverse >>> unwords)
>>> uncurry (++))
>>> unwords
main :: IO ()
main = putStrLn (revwords "hello, world! this is my second sentence")
-- world hello,! sentence second my is this
what could possibly be cool about the arrow instance for (->)?
>>
>>
>>108255853
if everyone who struck with the language for a bit spoke more positively about it, then there'd be second impressions and that'd matter more than some first impressions. People really want to go with every easy answer but the actual one of core dev laziness. Rust, with D's level of effort, would also have people asking why it didn't succeed.
if you go with betterC then parts of the language break which really have no business breaking.
if you go with mostly manual memory management while keeping the GC only for backup and rarely triggering collections, then the GC can still screw with you in mysterious ways (optimization causing a reference to be collected before it's out of scope), and neither RAII nor custom allocators can be used with any level of convenience.
D has 'real', a floating point type forgotten by time. D has default initialization but only for debugging purposes instead of a more thorough Zero Is Initialization idea. D lets you write f(x) as x.f - but only sometimes! There's a lack of thoroughness and not a lack of salesmanship.
>>
>>
>>
>>108255837
use arrow notation
or https://hackage.haskell.org/package/needle if it still builds (probably not sadly)
>>
>>
https://boards.4chan.org/v/thread/733936593#bottom" target="_blank">https://boards.4chan.org/v/thread/733936593#bottom
it's harmony day
>>
>>108256057
Tends not to work out that way.
The problem with C++ (and Rust) is that it ties itself in knots over making extra copies of things, and then goes a great amount of effort (and requires a lot of your effort too) to try to hide this. With varying degrees of success.
By contrast, C is more about "make it explicit and trust the programmer". Doesn't suit everything and everyone, but can do amazing stuff; awesome legendary hacks.
>>
>>>/v/733936593
it's harmony day
this is a opportunity that you're going to get for once in a very long time.
GO. THERE. NOW.
trust me it's something you don't wanna miss.
it's a custom thread, with flashing lights like a disco. just go there and see it for yourself if you don't believe me, it only takes a second
>>
>>
File: 2026-02-27 23-14-48_s.mp4 (2.6 MB)
2.6 MB MP4
>>108256322
Nice
>>
>>
>>108256295
Doesnt require any effort at all, just write simple types without ctor, copy ctor and dtor.
The only way to achieve c++ like performance in C is ungodly macro abominations or you need a code generator as a pre build step.
>>
>>
>>
>>
>>
File: file.png (332.8 KB)
332.8 KB PNG
>>108242214
>>108256474
Is it even possible to use the C ABI from C these days?
https://github.com/microsoft/win32metadata/blob/main/generation/WinSDK /RecompiledIdlHeaders/winrt/windows .security.cryptography.core.h
>>
>>
>>108256860
First of all, "C ABI" is a misnomer. C standard does not define any ABI. C ABI just means "whatever is the default (userspace) calling convention. It has nothing to do with C either, every syslang will use this ABI by default when talking to language agnostic libraries and such.
>>108256866
Yea, but in practice, if you want to do type punning you just disable strict aliasing rule using implementation specific means and just cast pointers.
>>
File: 1707802844075498.jpg (48.2 KB)
48.2 KB JPG
I am considering doing school so I can learn more about the patterns of the golden ratio.
I will need to compute things like the golden ratio digits past the 2^5 millionth one.
I am not sure how to achieve this with current technology.
>>
File: const_adds.png (39.9 KB)
39.9 KB PNG
>>108256057
1. If the compiler doesn't inline things for you, that's a compiler fuckup, not a language fuckup. At most you're getting the compiler to fail miserably with an error message, and that's that.
2. On the other hand aggressive inlining doesn't automatically equate to performance either. It does often, but not always, not automatically.
3. static inline in headers.
>>
>>108254720
>Do you have a few url examples that could be in the webarchive?
http://web.archive.org/web/0/https://bytepointer.com/resources/old_new _thing/index.htm
>qrd?
MS updates all their employee's blogs to have rounded corners, comments go poof
>>
File: 1654232932129.jpg (148.1 KB)
148.1 KB JPG
>>108257884
>patterns of the golden ratio
ToT
>>
File: Screenshot From 2026-02-27 19-37-25.png (931.9 KB)
931.9 KB PNG
>>108249763
https://github.com/orlfman/FFmpeg-Converter-GTK
>>
File: Screenshot From 2026-02-27 19-40-37.png (62.1 KB)
62.1 KB PNG
>>108258826
>>
>>
>>
File: 1754017863875791.png (31.9 KB)
31.9 KB PNG
hopefully there's less bit manipulation questions next month
>>
>>108258028
>http://web.archive.org/web/0/https://bytepointer.com/resources/old_ne w_thing/index.htm
good stuff anon, I hope most of the pages have been saved
>>
File: Screenshot From 2026-02-27 23-50-23.png (146.2 KB)
146.2 KB PNG
>>108258826
i hugely improved color correction. it now, can actually change RGB values.
>>
File: 1750460980140953.png (166.1 KB)
166.1 KB PNG
>30% acceptance rate
makes me feel a little better about myself
>>
>>
>>108260278class MyLinkedList {
private:
struct ListNode {
int val;
ListNode* next;
ListNode(int x) : val(x), next(nullptr) {}
};
ListNode* head;
int length;
public:
MyLinkedList() {
head = nullptr;
length = 0;
}
int get(int index) {
if (index < 0 || index >= length) return -1;
ListNode* curr = head;
for(int i = 0; i < index; i++) {
curr = curr->next;
}
return curr->val;
}
void addAtHead(int val) {
ListNode* newNode = new ListNode(val);
newNode->next = head;
head = newNode;
length++;
}
void addAtTail(int val) {
ListNode* newNode = new ListNode(val);
if (head == nullptr) {
head = newNode;
} else {
ListNode* curr = head;
while (curr->next != nullptr) {
curr = curr->next;
}
curr->next = newNode;
}
length++;
}
void addAtIndex(int index, int val) {
if (index < 0 || index > length) return;
if (index == 0) {
addAtHead(val);
return;
}
ListNode* newNode = new ListNode(val);
ListNode* curr = head;
for(int i = 0; i < index - 1; i++) {
curr = curr->next;
}
newNode->next = curr->next;
curr->next = newNode;
length++;
}
void deleteAtIndex(int index) {
if (index < 0 || index >= length) return;
if (index == 0) {
ListNode* temp = head;
head = head->next;
delete temp;
length--;
return;
}
ListNode* curr = head;
for(int i = 0; i < index - 1; i++) {
curr = curr->next;
}
ListNode* temp = curr->next;
curr->next = temp->next;
delete temp;
length--;
}
};
>>
>>108254944
>It's optional
aren’t like 90% of its libraries dependent on it? I don’t think it’s actually optional in practice. that’s like saying libc is optional when you can’t even get most c compilers to function properly without it
>>
>>
>>
>>
>>
>>
File: 1746609518099685.png (57.1 KB)
57.1 KB PNG
>does the question lead to an unsolvable paradox?
>just make the question illegal lol
I thought mathematicians were supposed to be the smart ones
>>
>>
>>
>>
File: 1745399638337206.jpg (67.8 KB)
67.8 KB JPG
>create a string
>write "the largest integer that can be stored in 128gb of memory plus 1"
>ram manufacturers go bankrupt
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>108263880
Send/Sync is how the borrow checker can reason about sharing values across threads.
>>
>>
>>
File: 1409901609892.jpg (42.5 KB)
42.5 KB JPG
>>108263982
>Rust pretends all variables are shared between threads, mutex and atomics don't exist
>Send/Sync role is precisely to express these things
>but borrow checker can't reason about it
>Send/Sync is how the borrow checker reasons about it
>but multiple mutable references within a single thread are still forbidden
???