[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1771929386415.jpg (106 KB, 1200x1200)
106 KB
106 KB JPG
What are you working on, /g/?
Previous: >>108194628
>>
>>108226774
unbased and gae. Why are you gae?
>>
>>108226814
Cocks are delicious.
>>
>>108226829
I have to admit, that's true.
I am not really gay, but sucking a huge dick is a lot of fun. I do it regularly
>>
I'm carving your mother with my pork chisel if you catch mi drift.
>>
>I'm sharing this general with autists and faggots and autistic faggots
>>
File: 1770369153948136.png (256 KB, 735x656)
256 KB
256 KB PNG
>>108226868
Programming is autist-coded.
>>
>>108226878
I'm starting to realize that. You can't teach them jack.
>>
>>108226890
>teach them
wow you're so full of yourself
>>
>>108226895
Hard not to, considering this general.
>>
File: mycock.png (10 KB, 576x347)
10 KB
10 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
>>
NIGGA I'M GONNA LEARN SEE SHARP
>>
>>108227992
ok just learn rust then
>>
>>108228435
Eww no.
>>
File: gamewiki.png (659 KB, 1009x2426)
659 KB
659 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.
>>
>>108228491
>Mediawiki
They hate white people.
>>
>>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..
>>
>>108228774
I'm gonna use it with Monogame to make funny little 2D games.
>>
AH GOD HELP ME I LEARN PROGRAMMING FROM TIME TO TIME JUST BECAUSE I CAN I HAVE NO USE FOR IT AAA
>>
>>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_animation.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????
>>
>>108233309
Well, you use Claude, so you and/or your family are probably certified retards who put their personal information into everything.
>>
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
you have "you hates google.com" reversing to "google hates you.com"
>>
>>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
>>
>>108234907
In 95% of my interactions with LLMs I just end up calling them useless cucks ad infinitum.
Good thing I'm not on a plan.
>>
File: 1749384253074648.png (64 KB, 863x305)
64 KB
64 KB PNG
Grok CLI soon, maybe
>>
>>108233348
I thought you just reverse the order of letters, "you can" -> "nac uoy".
>>
>>108235225
Isn't that literally how Vietnamese works?
>>
>>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
>>
>>108235267
.oN
>>
>>108232352
Unfortunate, yes... BUT WHERE ARE YOUR CAPITAL LETTERS YOU GODDAMN DOOFUS
>>
>>108236204
nta but it looks to me like you stole them all
>>
>>108236249
You are that anon, spiritually.
>>
File: 1740935345190634.png (1.28 MB, 1462x1814)
1.28 MB
1.28 MB PNG
>>108233348
let res = inputString.components(separatedBy: CharacterSet(charactersIn: " .!?"))
.compactMap { $0 != "" ? $0 : nil }
.reversed()
.joined(separator: " ")
return [".", "!", "?"].contains(inputString.suffix(1)) ? res + inputString.suffix(1) : res
>>
>>108236260
i will take that as a compliment.
lowercaser gang represent
>>
>>108236268
>>108233628
oops

var 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
>>
>>108236448
Tranny
>>
File: 1770542417029208.png (15 KB, 90x90)
15 KB
15 KB PNG
>>108236455
what's trooncoded about swift?
>>
>>108233348
 print("${"you can cage a swallow can't you?".split(" ").reversed}");
>>
>>108236918
and this is why you niggers NEED child-proofed languages.
>>
>>108236918
you? can't swallow a cage can you
>>
>>108236939
not my problem thats bad input
>>
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.
>>
>>108236918
this is the type of person that complains about leetcode interviews btw
>>
>>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;
}
>>
>>108236997
yes
also switch to a column-oriented database
>>
>>108237090
That is in fact the program that I am writing
The row-oriented format comes from legacy software from the 80s. The vendor refuses to touch the Fortran core because it's so battle-tested.
>>
File: lain rat.jpg (715 KB, 2048x2048)
715 KB
715 KB JPG
fixed
    String 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;
}

>>
>>108231189
Did ya have to use little girls?
>>
>>108237478
Why wouldn't you?
>>
>>108237510
Uhhhhh... damn...
>>
>>108235029
thanks but all I need in the terminal is perl
>>
>>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 (345 KB, 1140x760)
345 KB
345 KB JPG
Can you close this thread?AI will do everything
>>
>>108237952
>all that you need in the terminal is OCaml.
are you sure about that?
$ echo -e "some\ttab\tseparated\twords" | perl -pe 's/\t/\\t/g'
some\ttab\tseparated\twords
>>
Seriously now,
while (something) {
something_else();
}

or
while (something)
{
something_else();
}
>>
>>108238058
loop
exit when Something;
end loop;
>>
>>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.
>>
>>108237478
yes theres literally no better thing to have as a pape
>>
>>108238058
depends on how easy/hard it is to read because of the clutter
>>
>>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.
>>
>>108238058
while (something) { something_else(); }

Simple as.
>>
>>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-fileapi-readfilescatter

They reduce the amount of mode switches, and they can be executed in parallel.
>>
>>108238885
>int io_submit(aio_context_t ctx_id, long nr, struct iocb **iocbpp);
>long nr
why not size_t ?
>>
>>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.
>>
>>108238764
Still wasting 80% of your real estate, I see.
>>
>>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);
}
}
>>
im adding a laughing man with rotating text as boot splash screen to my unikernel/OS for microcontrollers, then gotta turn it into some interface consumers can use to implement boot progress stuff
>>
>>108238824
while (something) something_else();

Even simpler.
>>108239857
>just
>>
>>108239857
good job. 1.86ms to Rust's 34.2ms on a 10k-word string.
nearly twice the RAM and +66% cache misses, but everything else is much better. Rust has 28.7 million cache references to C++'s 102k.
>>
TIMMY'S ON THE ROOFTOP
LEARNING HOW TO CODE
>>
Does using -march actually increase performance?
>>
>>108240013
Only in March.
>>
>>108240013
it depends
>>
File: agentic coding.jpg (228 KB, 581x811)
228 KB
228 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);
}
}
>>
>>108240036
good for that guy.
what have you done with it?
>>
>>108240036
So when is claude going to finish all the early access survival crafting indie games on steam?
>>
>>108240036
Because not everything is about the end goal you fucking midwit.
>>
>>108240036
because this shit works for weekend projects and one off scripts or shits, if it's something that has to be maintained it turns to shit since LLMs are just much faster jeets
>>
>>108240084
this is literally just python lol
>>
THERE ARE SNAKES IN HERE???
>>
File: pathetic.png (1.07 MB, 1920x1080)
1.07 MB
1.07 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 (211 KB, 889x1418)
211 KB
211 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
>>
>>108240036
who?
>>
>>108237007
>.t swallows leetshit everyday
>>
>>108240196
my wife wold never call me pathetic and i did >>108237231
>>
Any programmer that wants to have real employ-ability and also wants to be cracked, yet not a hipster, should focus on C++ as a main language, right?
>>
>>108240536
Cracked? Like buck-broken?
>>
>>108240223
take a honest look at your code and ask yourself how much of it actually does any real work and how much is just there to satisfy some insane attempt to fit in with PROFESSIONALS or something
>>
>>108240556
ie pretty good
>>
>>108240556
I forgot that cracked means something different to zoomers than it did to millenials.
>>
>>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
>>
>>108240582
>zoomies dont know what cracking means
holy shit
we are doomed, as a species, arent we?
>>
>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
>>
>>108240608
Bend over, buck.
>>
>>108240561
Believe me if i knew how to make the code simpler I would do it. Every single part serves a purpose except the Functor struct.
>>
>>108240536
you focus on programmnig, even if it using a scripting language such as Python
>>
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
>>
>>108240588
>paying
nigga watt? you have fucking free models that do it for you with local models, with free credits from free apis

I do almost all my coding with agents now. I dont pay a dime
>>
>>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?
>>
>>108240843
yep, sorry
>>
>>108239747
i'm trying, i really am. i struggle with my autistic brain
>>
>>108241053
We are all autistic here. It looks more pretty than the Qt version.
>>
>>108240536
Yeah, because C++ is totally not garbage and the end of Moore's Law isn't real.
>>
>>108241084
thx. i've spent the last three hours working on making the progress bar work in real time based off duration.
>>
>>108241084
>We are all autistic here.
Explains the lack of feedback.
>>
>>108233348
import 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;
}
>>
>>108241336
import 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.
>>
>>108241336
let 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.
>>
Is Haskell a meme language?
>>
>>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.
>>
>>108238885
ooo neat, I didn't know this existed
Thank you, I'll give it a shot
>>
>>108241577
the thing I hate the most about is how the category stuff are named
>>
File: tard.jpg (3 KB, 125x124)
3 KB
3 KB JPG
>>108241137
>>
>>108241665
Nice self-portrait.
>>
more like see peepee
>>
File: retard.jpg (46 KB, 698x500)
46 KB
46 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);
}
>>
>>108241137
So what's the alternative? Erlang?
>>
File: 1770448536475176.jpg (278 KB, 1152x2048)
278 KB
278 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.
>>
>>108242141
I'm angry now.
>>
>>108242195
>any language with convenient access to the C ABI can use them
Then why not use C directly?
>>
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?
>>
>>108242339
This is the top c++ developer, just image the quality of the rest of them.
>>
>>108242339
Looks like you want a scripting language instead.
>>
>>108242339
CSV files are no good because?
>>
unironically everyone should start with a modern baby language like c# / javascript / kotlin / swift / go and then only when they have 5 yoe they can graduate to cpp
>>
File: cpp_vs_c.png (292 KB, 1330x2422)
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
>>
>>108242161
>yet how many libraries or languages expose that capability?
they're all very well, but don't always fit the shape of what you're doing
>>
>>108242442
>gets asked a question
>within 10 seconds breaks eye contact not just with the text, but the machine itself
>stutters like a motherfucker
What did I just say about autistic patterns?
>>
>>108242214
>Then why not use C directly?
People for whom autism is a disability don't understand this, but optimizing every last aspect of a program isn't always a worthwhile win.
>>
>>108242486
What if you're doing is hardware-hostile?
>>
>>108242498
>language is optimization
dumb tard
>>
>>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 KB, 529x538)
140 KB
140 KB PNG
https://www.youtube.com/watch?v=B2gmKy3pHkw
>>
>>108242442
I like the terminology.
>Rust is garbage because it tempts developers to never reach n + 1.
>>
File: 1763024189850397.jpg (57 KB, 959x880)
57 KB
57 KB JPG
https://leetcode.com/problems/design-circular-queue/
>>
>>108244151
>>
>>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.
>>
>>108244623
most the time this is just favorable run on a non-noisy machine. idk why anyone takes these measurements as meaning anything.
>>
>>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 (217 KB, 367x549)
217 KB
217 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.61 MB, 1246x1010)
1.61 MB
1.61 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 KB, 1366x768)
163 KB
163 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.
>>
>>108243045
she did not subvert my expectations
>>
File: 1772109815920924.webm (2.01 MB, 1920x1080)
2.01 MB
2.01 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 is
import 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 (60 KB, 1478x950)
60 KB
60 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.
>>
How much of this thread is bots posting random shit?
>>
>>108246497
>What are you talking about? Either pointers on the stack are correctly updated or they aren't.
I was doing running updates like this
T *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 like
T *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
>>
>>108246949
Sjdhvnf?
>>
>>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..
>>
>>108247455
>you're better off maintaining a parallel stack where you would all pointers to GC objects that the function has.
That's what the second example does
>>
>>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.
>>
I almost never find myself using pointers. Everything just goes into hash tables. Then again I mostly do webshit so I guess they're used a lot in other places.
>>
>>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
>>
I just wasted my life optimising this obscure and completely useless algorithm

https://www.youtube.com/watch?v=JQYyAWVkhbc
>>
>>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 is
T *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
|_|_|-> ...
>>
wanted to test my booru clone and write a simple android app to upload images, but got gigafiltered by kotlin and android development
ama
>>
>>108242339
>My levels are created via XML files.
grim
>>
https://codeberg.org/elisiei/vir/src/commit/e1c6162e57884e7911d7f00db105452e601d729e/main.v
>bitch
>fucking
v stands for VULGAR
>>
>>108249295
>RegisteredDir
>all strings
>not using directory handles
I've seen enough.
>>
I'm learning Rust!
>>
>>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.
>>
>>108249440
... why don't you put the table with
>Spatio-Temporal Predition
>Low Latency
>Super-Resolution
horizontally next to
>Keyframe Interval
>Custom Mode
>Threads
? That would solve your 80% issue right there.
>>
>>108249500
i like vertical... my stupid brain. i like wrapping things in scrollbars and scrolling down. thats the honest truth.
>>
>>108249543
Human vision is horizontal, and so are our screens. We didn't switch from 4:3 to 16:9 for nothing.
>>
>>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.
>>
So far Rust doesn't look that bad.
>>
>>108250471
>>108243468
>>
>>108250516
Not sure if Rust really makes learning that harder, but it's an ok video.
>>
>>108250471
>I can't have linked lists but it doesn't look bad
>>
>>108251031
Usecase for linked lists?
>>
>>108251060
predictable reply, retarded reply
>>
>>108251065
Autistic reply.
>>
I'm legally changing my name to Rusty!
>>
>>108251358
cope
>>
>>108251435
>emotional misread
>>108251358
>>
>>108251532
more cope
>>
>>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)
>>
>>108251888
>Operating system concepts
Interfaces are much more important. If you understand interfaces you'll never fall for the retardation that are microkernels.
>>
>>108251888
Stop buying and start reading.
>>
>>108251858
take your meds
>>
what's a good algebra book? the ones on the /sci/ recommendation list are all like 300 years old, surely someone's written a decent modern one?
>>
>>108251975
Blitzer College Algebra
>>
>>108251975
Honestly, the way standards have gone to shit, you're probably better off reading a 300 year old textbook versus any modern one. At least something written prior to WW2.
>>
>>108251975
you don't need algebra to program
>>
>>108251888
Head First Java
Clean Code (Robert C. Martin)
Design Patterns: Elements of Reusable Object-Oriented Software ("Gang of Four")

since you're building a meme library, at least make it a little bit balanced
>>
File: 1744099934811029.gif (2.26 MB, 1920x1070)
2.26 MB
2.26 MB GIF
>>108252124
Found the imposter
>>
>>108252257
lol
>>
It's ugly how in Rust you return a value by ommiting the semicolon.
>>
>>108251939
No, autist.
>>
>>108251060
dynamic allocation...?
>>
>>108252659
you are a drooling braindead retard, probably a nocoder if you think linked lists have no use
>>
>>108253034
And you're retarded for responding to the wrong person. No conditional attached. You're just obviously low IQ.
>>
>>108253074
I don't give a shit, you are the retard replying to me.
>>
>>108253074
>You're just obviously low IQ.
So anyone using a linked list is low IQ? nigger.
>>
>>108253167
OK, retard. You sound like you belong in a cage as well.

>>108253182
God, the autism ITT.
>>
>>108253202
answer the question
>>
>>108253219
>autist doesn't understand you can call out autism separately of whether or not you agree with a given statement
>>
>>108253283
I accept your concession.
>>
>autist hallucinates concessions
I'm beginning to understand why people believe that LLMs will replace you autists. You manage less than 90% accuracy, too.
>>
:D !1 weekend project time
>>
I find funny when some anon is so stereotypical you can notice them through threads
I bet the one who's sperging about "autism" and "emotional misread" is the same redditor that cried in my OS thread
>>
>>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.
>>
>>108253473
said the idiot whose replying in support of no stance whatsoever
you like writing words that mean nothing, do you?
>>
>>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.
>>
>>108253526
>implying the opinions of autists matter
>>
>>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 (294 KB, 1366x768)
294 KB
294 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 (310 KB, 736x736)
310 KB
310 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
>>
>>108253948
>changes the default "Solution" class to a struct
holy&based
>>
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
>>
>>108254428
a long-delayed divine punishment for breaking Forth code when publishing an article about it.
>>
>>108254428
Do you have a few url examples that could be in the webarchive?
>MS fucking with their blogs
qrd?
>>
>>108253557
>redditor
>projection
>as expected of an autist
>>
Why did D never catch on?
>>
>>108254739
it sucks
>>
>>108254743
Why?
>>
>>108254751
many reasons, two of which are GC and string templates
>>
>>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.
>>
>>108254739
It's unfocused. It's basically 3 different languages cobbled together, neither being superior in their niche.
>>
>>108254944
it wasn't originally optional
>>
>>108233348
Python
str = "you can cage a swallow can't you?"
offset = int(f" {str}"[-1] in ["?", "!", "."])
print(" ".join(str[:-offset].split(" ")[::-1]) + str[len(str)-offset:])
>>
>>108233348
import 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?
>>
>>108255185
Holy jeetcode.
>>
>>108255235
>import Control.Arrow
>expect cool arrow shit
>it's just first
fuck you are life
>>
>>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;`");
}
>>
>>108255639
>naively treating arrays like stacks
>autodecoding
wdym by that?
>>
>>108255707
import 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 (->)?
>>
>>108254739
Trying to cater to C++fags and Javafags at the same time, meaning they catered to neither.
"Better C" or optional GC or whatever doesn't matter; their first impression was ruined, nobody cares.
>>
>>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.
>>
>>108255704
templates using string mixins
honestly string mixins themself aren't the worst esp. since shit like ASTs are ass for compatibility and super verbose and implementation tied
>>
>>108254739
Most languages fail. It's the default option.
But the initial focus on trying to sell the only language implementation didn't help early growth.
>>
>>108255837
use arrow notation
or https://hackage.haskell.org/package/needle if it still builds (probably not sadly)
>>
>>108242214
Because you need templates and constexpr to get optimum performance.
>>
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
>>
>>108256295
C++ does implicit copies all the time, but copying is explicit in Rust.
>>
File: 2026-02-27 23-14-48_s.mp4 (2.59 MB, 1892x1170)
2.59 MB
2.59 MB MP4
>>108256322
Nice
>>
>>108240536
If getting a job is your primary criteria you probably should just learn JS and/or Java.
>>
>>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.
>>
>>108256295
There is nothing you can do in C that you can't do in C++ or Rust. And there is a lot you can do in latter two that you can't do in C.
>>
GO TO THE HARMONY THREAD
YOU AREN'T GONNA SEE THIS IN A VERY LONG TIME ANON
GO NOW!
>>>/v/733936593
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>>
>>108256487
Eh, ironic gay stuff doesn't hit the same after the real gay shit. Thanks, I guess.
>>
>>108254739
They did better Java instead of better C.
>>
File: file.png (333 KB, 1308x1017)
333 KB
333 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
>>
>>108256474
Actually, type punning through unions is valid in C but UB in C++.
>>
>>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 KB, 690x690)
48 KB
48 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 (40 KB, 1280x882)
40 KB
40 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 KB, 673x694)
148 KB
148 KB JPG
>>108257884
>patterns of the golden ratio
ToT
>>
>>108249763
https://github.com/orlfman/FFmpeg-Converter-GTK
>>
>>108258826
>>
>>108258096

no school curl at front talking about lewd
>>
>>108257884
>with current technology
I cannot wait for your working proposal to build sub-atomic transistors, because that's about where we're currently at.
>>
File: 1754017863875791.png (32 KB, 455x290)
32 KB
32 KB PNG
hopefully there's less bit manipulation questions next month
>>
>>108258028
>http://web.archive.org/web/0/https://bytepointer.com/resources/old_new_thing/index.htm
good stuff anon, I hope most of the pages have been saved
>>
>>108258826
i hugely improved color correction. it now, can actually change RGB values.
>>
File: 1750460980140953.png (166 KB, 746x1094)
166 KB
166 KB PNG
>30% acceptance rate
makes me feel a little better about myself
>>
daily reminder that the downfall of programming started with the introduction of the for each syntax.
>>
>>108260278
class 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
>>
>>108260321
>12 minutes
impressive
I went straight to implementing a doubly linked list version thinking it would be faster, but nope it's just about the same speed and way more code.
>>
>>108260368
no idea. i saw your post and had grok do it. took him about 40 seconds of thinking.
i would ask claude opus 4.6 but i am at 100% usage and don't want to touch my balance for this.
>>
>>108256322
>it's harmony day
what's that?
>>
can we get a dpt for vibe coders, no one wants to see that shit
>>
>>108262032
we could but they stick around like stains on a mattress
>>
File: 1746609518099685.png (57 KB, 778x156)
57 KB
57 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
>>
>>108262480
how does that lead to a paradox?
>>
>>108262498
Because on "one line of type" you can type something like "the largest integer definable in one line of type plus one"
>>
>>108262480
There's literally nothing wrong with this
>>
File: 1745399638337206.jpg (68 KB, 699x485)
68 KB
68 KB JPG
>create a string
>write "the largest integer that can be stored in 128gb of memory plus 1"
>ram manufacturers go bankrupt
>>
>>108262572
Devilish!)

*to the side*
Get this FUCKING clown outta here...
>>
>>108262572
dumb /prog/foster
>>
>>108262572
that's actually a valid compression strategy with ai
>>
Why do people pretend Rust is hard?
>>
>>108262700
Rust has very steep learning curve. It aint C++ where you can just use simple subset and learn the rest over years.
>>
>>108262700
What? They just call it trans.
>>
>>108262700
It's unnecessarily restrictive.
>let's pretend all variables are shared between threads, mutex and atomics don't exist
>of course you can't have more than one mutable reference, duh
>>
>>108263682
Rust heavily uses mutexes and atomics and has the Send/Sync semantics for the sole purpose of expressing what you can do and how to share values across threads.
>>
I never saw a program that couldn't just be written in c
>>
>>108263769
Everything is in walking distance when you have enough time.
>>
>>108263777
if everyone exclusively learned and work in c, I reckon that trillions of manhours would be saved every year
>>
>>108263731
I'm talking about what the borrow checker can reason about
>>
>>108263880
Send/Sync is how the borrow checker can reason about sharing values across threads.
>>
>>108263921
and yet, multiple mutable references within a single thread are still forbidden
>>
new thread >>108264010
>>
File: 1409901609892.jpg (43 KB, 372x372)
43 KB
43 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
???
>>
>>108264019
dumb troon



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.