#🪅-progaming
1 messages · Page 92 of 1
like
if i'm using printf from stdio
should i just copy that and put it in a separate file because maybe i'm not using anything else from stdio
The benefit with using code by others is not having to write it yourself
For complicated things like printf, that's a pretty big benefit
Also yes, the resulting executable becomes smaller because the implementation is in a shared dll
Does statically linking then put the whole binary in or just used functions?
uhhh
i was more asking
can i just steal printf from stdio.c
and keep a copy
so my statically linked exec doesn't become massive
Sounds like a terrible idea but go ahead
cause i've seen
like
there was someone
doing a hobby project
making the smallest linux or something
its on youtube
i think they did something like that
and i was wondering how practical it is
Copypasting functions makes your exe bigger, not smaller
why does this fucking shit show my full name there 
To be creepier than necessary
wouldn't statically linking do that too ?
Hi, King Charles The Third, how can i help you?
@woven mesa I may get back to working on clipboard app after I get my location simulator thing working
because after that I inherently have nothing to do lol
apart from experiment with new things
and I feel a lot more experienced now than ever

same!!
omg
Eh, doesn't matter
not when my laptop hard crashes
It'll still only be executed once
no its not
Unless it fails
i had in one instance 1k instances of bash
execve kills the current process and starts a new
wha
swiftui was just slowing the app down ☹️ so I got demotivated on it
look heres what happen
i do pkill blood (my prog name)
and then it started making bash shells
so
jus don't put execvp in while(1)
i just cpu bombed myself i guess
poor laptop from 2016
also, is there a way to hide specific guild tags?
oh and wait
right
right
you're correct
i just found out my mistake
but lemme show you nontheless
lets use that one coredata wrapper i figured out how to use it
while (1) {
pid_t pid = fork();
if (pid == -1) {
perror("error");
return;
}
execvp(comb_str, NULL);
}
cancer code
Well yeah forking is a different matter
don't be mad at me im stoopid
which
Why is whitespace a token
you use coredata??????
why not
since when
Because whitespace is not significant in most languages
The point of a lexer is to split into meaningful units
hmm
right
now that you mention it it is kinda smart to leave whitespace out
I also may ditch the bottom panel entirely
holy crap
in favor of a floating one like windows
+1 iq gained
lc.i windows clipboard manager
maybe something similar actually that's kinda ugly
eh whatever I take back what I said about removing the panel
@fleet cedar ty actually i removed the whitespace token now my parser code is at least 10x more readable (yes i did just ignore whitespace tokens inside the parser)
the
if matches!(stream.peek(), Token::Whitespace) {
stream.next();
}
i dont but the wrapper is nice
i think its called grdb
well, are you trying to do that too?
nope
making a shell
more discouraged after forkbombing myself
😭
👍
i wanted that too but i wanted it to appear on the text caret
then why does ur binary need to be statically linked and why does it need to be small
i want to ask that too
my brain
eh
dunno
i statically link my binaries only on linux
why
why would i want end users to install swift toolchain
unpatched nix support 
Why are you writing a shell in c of all things
i literally don't know
i wanted to pick something up
and i don't know
learn something
write a compiler
for ?
new language
so do what pyro is doing ?
whos pyro
Or old language
meh
Resurrect cobol
oh chloe
financial systems?
im not writing a compiler i am writing a new shell i told u before 😭 but its gonna have a language "inspired" by rust
not already, still
you're making a "sh" clone
no
well yeah
mmm
you just have basic shell funcs then
if i could figure out why execvp kills my original process
i feel like
i could make stuff way easier
for myself
Because that's its whole thing
It replaces the current process with a different one
its yt time to see how people are running threads with C
its gonna be a mostly expression driven language, im thinking of a syntax similar to rust but like:
let something = (echo "test");
if something == "test" {
git commit -m "a";
}
i think thats pretty cool
@solemn ravine https://github.com/groue/GRDB.swift its actually quite nice
made an alias
oh no another rust video
part 27: Ownership is cool in rust
im
should i already just switch to rust? @fleet cedar
like am i torturing myself?
we are all using rust here
Yes
Up to you
😭
well hey
don't do that
absentee father what are you
just give me an answer
not me
I'm an internet stranger
you too
swift has a massive list of dynamically linked libs
swift is basically just apple flavoured rust
rust first-time compile takes 20 minutes to even wake up
swift is readable rust
they have extremely similar syntax 😭
sure but you should probably read up on how memory works first
at least a little
rust will throw you off otherwise
i dont mind rust but some of the syntax makes me explode
and also some of the naming conventions
i am following rustfully's explanation
so
like?
i don't know i just feel like i'm weak not knowing how to make stuff work in C
who gaf about c in 2025
Its not cute on windows
nothing is cute on windows
horror
swift is a pretty good lang i think it should also be used for apps on windows & linux maybe then native apps wouldnt be so painful
that happened kinda
replace swift with rust
I hope Microsoft tries to make another api for native apps and fails that would be really funny I think
Suggest normal alternative to Windows where 80% of games work fine
Lol
i hope microsoft files for bankruptcy
linux
Lmao!
and its way more than 80%
Linux isn’t even close to 80% what are you on 😭
yea true
yea its more like 99
i cant think of a single game ive ran on linux
There has been a huge push cuz of the steamdeck but it’s maybe 50%
Yeah 98% isn't very close to 80%
everything that doesnt have kernel ac works
Bro is glazing linux too much
[0m[32m[1m 'c.
,xNMM.
.OMMMMo
OMMM0,
.;loddo:' loolloddol;.
cKMMMMMMMMMMNWMMMMMMMMMM0:
[0m[33m[1m .KMMMMMMMMMMMMMMMMMMMMMMMWd.
XMMMMMMMMMMMMMMMMMMMMMMMX.
[0m[31m[1m;MMMMMMMMMMMMMMMMMMMMMMMM:
:MMMMMMMMMMMMMMMMMMMMMMMM:
[0m[31m[1m.MMMMMMMMMMMMMMMMMMMMMMMMX.
kMMMMMMMMMMMMMMMMMMMMMMMMWd.
[0m[35m[1m.XMMMMMMMMMMMMMMMMMMMMMMMMMMk
.XMMMMMMMMMMMMMMMMMMMMMMMMK.
[0m[34m[1mkMMMMMMMMMMMMMMMMMMMMMMd
;KMMMMMMMWXXWMMMMMMMk.
.cooc,. .,coo:.[0m
[0m[1m[32m[1mlakhanlothiyi[0m@[32m[1mLakhans-Mac-mini.local[0m
[0m------------------------------------[0m
[0m[33m[1mOS[0m[0m:[0m macOS 14.6.1 23G93 x86_64[0m
[0m[33m[1mHost[0m[0m:[0m Macmini8,1[0m
[0m[33m[1mKernel[0m[0m:[0m 23.6.0[0m
[0m[33m[1mUptime[0m[0m:[0m 151 days, 20 hours, 47 mins[0m
[0m[33m[1mPackages[0m[0m:[0m 132 (brew)[0m
[0m[33m[1mShell[0m[0m:[0m zsh 5.9[0m
[0m[33m[1mResolution[0m[0m:[0m 1680x1050[0m
[0m[33m[1mDE[0m[0m:[0m Aqua[0m
[0m[33m[1mWM[0m[0m:[0m Quartz Compositor[0m
[0m[33m[1mWM Theme[0m[0m:[0m Blue (Dark)[0m
[0m[33m[1mTerminal[0m[0m:[0m WarpTerminal[0m
[0m[33m[1mCPU[0m[0m:[0m Intel i5-8500B (6) @ 3.00GHz[0m
[0m[33m[1mGPU[0m[0m:[0m Intel UHD Graphics 630[0m
[0m[33m[1mMemory[0m[0m:[0m 6262MiB / 8192MiB[0m
[30m[40m [31m[41m [32m[42m [33m[43m [34m[44m [35m[45m [36m[46m [37m[47m
[38;5;8m[48;5;8m [38;5;9m[48;5;9m [38;5;10m[48;5;10m [38;5;11m[48;5;11m [38;5;12m[48;5;12m [38;5;13m[48;5;13m [38;5;14m[48;5;14m [38;5;15m[48;5;15m
tf is using that much ram
not hard to do when the alternatives are windows (garbage) and macos (good but its proprietary)
iutl if you have issues with linux gaming just play good games
Loolloddol you say?
?
rexim does
if you have issues running valorant on linux, ask yourself why youre trying to run valorant
idk what the hype is around valorant
why do everyone play it
all my frens play it
the only good shooter game is cs and guess what it works on linux
ask @solid gazelle he spends hours a day on val
i hate bad mac software
cant play fortnite on linux 😭 😭
me when i leave bad software running on my server mac
mac server is crazy
fn is the only game i’d miss slightly but even then i havent played it in months bc i only ever play it with one friend of mine
i only started in s3 or s4
Another win for linux
yop
how long until epic releases mac releases of fortnite again
how did epic do anticheats on macos
according to protondb numbers there's somewhere between 15-25k games that do work on linux and only ~400 that are confirmed to not work so that 99% of games working is pretty accurate
@pseudo sierra
and before you ask yes over half of the games that don't work are cuz of ac
games with kernel anticheat arent games
they’re rootkits
so they dont count
what are the other half
spyware
its very hard to make a game not work on linux
unless you add a flag that crashes if ran on linux
in every file
just wait until i compile for ia64
does windows work on ia64
Or just the main function
random bs or ancient games that use really obscure calls that behave weird in wine/proton
its intel itanium
well you can always patch it out
how do people manage to use “obscure” calls
guhh
if half the game relies on access to the windows kernel then its gonna be hard to just patch it out
fr
At that time things were often done with raw asm
if ur game is written in ia-32 asm its not gonna work sorry
who
has coded in ia-32 asm
in their life
well actually nvm
beside some people
who has written a game in ia-32 asm
// code below is from an llm + me. don't trust it
if (pid < 0) {
perror("fork failed");
exit(EXIT_FAILURE);
} else if (pid == 0) {
char *args = {};
execvp(bin_name, NULL);
perror("execvp failed");
exit(EXIT_FAILURE);
} else {
int status;
waitpid(pid, &status, 0);
printf("Child process finished with status %d\n", status);
}
return;
i've stooped low
i'm sorry
scrolling through the top 1000 games on protondb it's basically all ac problems and the only one I've seen so far that wasn't was some funny problems with 32bit prefixes or smth but the last report was 3 years ago so it's probably been fixed 
crazy thing to say for someone who cant use pdn without vm/dualbooting
paint.net my beloved
y not use krita tho
feel like its good enough
@fleet cedar
how do i allocate memory for a substring if i don't know the length of it?
do i malloc and then realloc or ?
i wanna know what you'd do
because krita and paint.net are 2 entirely different pieces of software with different goals and different target audiences
they can both edit images
that's good enough for me
😭
and krita is made to be good for drawing and paint.net is made to be simple
nothing compares to the speed at which i can edit stuff in paint.net
it opens in less than a second, i have my image edit with simple tools and a simple ui and then i close the app
doesnt work thats why i said "without vm/dualbooting"
there are some people trying to make something comparable for linux but of course it is still early
wait y
do you know y?
you can find that out yourself i do not use linux desktop
i am on glorious windows
i didnt see the ancient games part of that message until just now
but yeah nvm
yeah what about it
ltsc iot enterprise
no thanks
why would i use ltsc iot enterprise
gives me access to some more stuff too
i do not have the usual bloat
why would i want to use pdn
well yeah you can reduce weight quite easily
who cares
exactly what a non pdn user would say
you cant value it until you try it
and as a linux user you cant try it so you are missing out
@lavish frigate
i literally never draw anything
pdn isnt for drawing
you think i havent used it?
then what
image editing
you have no clue about it so yes
i never edit images either
ive used it for drawing
& opening it once doesnt count
y not use photopea*?
@hoary sluice fix
LMAO
because photopea is photoshop lite and not paintdotnet
again
entirely different goals and target audiences
maybe i don't know what pdn is offering
its so great because its native so its fast and its simple
it offers paint on the net
absolute perfection
either way gimp is better
where's your shape tool dumbass
@lavish frigate
oh my god GIMP is so infuriating sometimes
Imagine rectangles
Imagine Rectangles >>>> Imagine Dragons
average windows user response when cant think of response
you just cannot ragebait me lil bro
try not to immediately prove my point challenge
im a lil bro : 3
this is a 2018 nvidia issue
right
tbh nvidia on windows is fucky wucky too
i have 2 monitors
i play 2 videos
one monitor instantly crashes
great drivers
update yo damn drivers
then something else is going on
ARGHH
&str 
windows issue!!!
Use a language that has strings
my strings are on the heap
Or build them yourself
i am attempting
not a fan of char[]?
void bs_trim(char *str) {
bs_trim_start(str);
bs_trim_end(str);
}
void trim_start(char *str) {
size_t start = 0;
while (str[start] && isspace((unsigned char)str[start])) {
start++;
}
if (start > 0) {
size_t len = strlen(str);
for (size_t i = 0; i <= len - start; i++) {
str[i] = str[i + start];
}
}
}
void trim_end(char *str) {
size_t len = strlen(str);
while (len > 0 && isspace((unsigned char)str[len - 1])) {
str[len - 1] = '\0';
len--;
}
}
void char_tokenize(char *str) {
printf("{");
for (size_t i = 0; i < strlen(str); i++) {
printf("[%c]", str[i]);
}
printf("}\n");
}
look i have nothing against the language
i have shit against myself
i am the stoopid
okay?
language is perfect
(im coping)
no its not
HOLY YES
ARGH
@fleet cedar i have made
substrings... kind of
look at my beauty
char *bs_splitargs(char *str) {
char *substring = (char *)malloc(1024);
size_t iter = 0;
size_t len = strlen(str);
while (iter < len) {
if isspace(str[iter]) {
break;
}
else {
iter++;
}
}
for (int i = 0; iter < len; i++) {
substring[i] = str[iter];
iter++;
}
return substring;
}
no llm involved here HAHA
@lavish frigate barely 24fps at lowest settings
Genuine question : Why breaking the while loop instead of doing something like
while ( iter < len || !isspace(str[iter]) )
{
iter++;
}
?
uhhhh
dunno
me stoopid :3
ty for telling me
i've had bad experiences with multi-rule loops in C#
so
yeah bad habits
No problem ! I didn't know multi-rule loops were problematic in C#, what problem do they have ?
uhh
apparently sometimes
if one of the rules is true**
it doesn't check the next rule
or backwards
didn't matter if you used AND/OR
just was like that
me and a classmate were stuck on it for a while
eventually we just did nested loops
What the - ?
oh my god it happened again
literally
okay so
i have this right?
while (iter < len) {
if isspace(str[iter]) {
break;
}
else {
iter++;
}
}
i put this and now it doesn't work
That's my fault !
with || it continue even if you are out of bound because when iter >= len then !isspace(str[iter]) will be evaluated
yeah OR be like that
question
aside from
C
what was the hotkey to
uh
make text like this
It's inline code : `Your text`
I don't know if there is one actually
why is vencord gay again
🌍 🧑🚀 🔫
it has always been
To get talkative people talking - and it works
man i wish i wasn't one
I don't think you're allowed to use discord if you're under 14
i am 16 sir
June 19 2009
how so
was it june or july
i forgor
You said you are one, which os below 14
you know sometimes my iq drops below one
because i had to think like 30 seconds straight to realize you were saying
how do you forget your birthday
i don't
i have to convert calenders
sure i can say
from what calendar
28th Tir, 1388 HS
I always confuse which is which of june and july too
Hijri Shamsi
its gay month now
so
june now
and
uhh
like
17th Khordad
so
20 more days
probably june yeah
19th of June 2009
i was born
how am i just now finding out theres a solar hijri
we have
Hijri Ghamari (Moon)
Hijri Shamsi (Sun)
Saudi uses Moon
we use Sun
whats the point of using a solar calendar that isnt gregorian
youre just making conversion confusing for no reason
whats the advantage of using solar hijri over lunar hijri
i have no idea
just tradition ig
we've been using dis shi since islam came
so
well no that would be lunar
unless persia started using solar immediately?
naw
uhh
it was
Abu Bakr
that ordered invasion of persia
and then
he ded
Omar came
and then he took over persia
yeaj
@fleet cedar https://i.imgur.com/wWrS0Y4.png
i love strings
you know that
look atp you know more than me about our calanders
lol
i don't care i just need to conv this shi like daily
why not just keep track of both dates
uh
my phone only does gregoryian
and i don't have patience to make waybar count for me
so do u use gregorian in daily life
no i generally don't have use for calender
i forget days daily
only to know that i have physics exam tmrw
lol
YES
ohhhh
satisfaction
(i don't want to think about how i did this)
are you proud of me :3 ?
@fleet cedar
now put ur code in an llm and ask it to scream at you
Did you check for memleaks with valgrind?
with what?
oh my god it will
gm chat
Valgrind
Sleep is not real
let me see
because their body is defined at the point when you call them
because they need to be specialized
what if i
do that for every function
not just generic ones
qbe allows hoisting
and it would not only allow hoisting in elle but it would also act as dead code elimination directly
functions that arent called are never generated
Which definition of hoisting? Js style?
no, just
calling a function before its definition
fn main() {
foo();
}
fn foo() {
}
this currently doesnt work
requires forward declaring
Oh, you mean thing that hadn't been a problem in any language developed the last 40 years
well
its not a problem in elle either if i make explicit return types
but i dont like that for prototyping
and this kinda solves it indirectly so
can you not call non generic functions before theyre defined?
yes iirc
because theyre not immediately computed theyre kept somewhere to be specialized when you call them
actually idk but at the very least generic functions can call other generic functions before theyre defined
i present to you: a language developed in the last 40 years where this is a problem
well no i could just push all expression statements to the end of the ast
benefits
- dead code elimination
- hoisting is good
- compilation times will be faster
cons:
- mutually recursive functions will probably stack overflow (though i can catch that i think)
- this doesnt play nice with the lsp because its essentially lazily evaluating the bodies of functions, a function's body will only have lsp support when that function is called in reachable code, which obviously isnt ideal
idk how to approach the lsp problem, this is already a visible problem with generic functions
what if its not a problem
i can just do the rust thing of no lsp support unless that function is exposed in a crate
evil
Where does rust do that
but rather than it being exposed in a crate its whether its called in visible code
you get nothing, not even autocomplete or hover support, nevertheless errors
its as if youre typing into a text file with syntax highlighting
Ah yes, no diagnostics in files not part of the project
@valid jetty i was trying to make readln and came to the conclusion that making io without monads or any types at all is stupid so now im watching typed lambda calculus videos
Not sure what that has to do with declaration order
function definitons will be forced at the call site, and if there is no call site then the definition will never be forced
well if you do this
fn main() {
}
fn foo() {
}
``` the main fn will be compiled because its the entry point but as the foo fn is never called from any reachable code, its never compiled
^^^
Sounds horrible
Elle will bundle Grok to complete your code
if a function wasnt forced through reachable code
its just compiled after
with the same method of reachable calls
fuck this might need multiple passes
- compile
main- the entrypoint, force functions as needed - functions which werent forced are compiled seperately after, forcing any calls inside as needed
- repeat until no functions are left (???)
i dont quite know that much of the implementation details i would have to try it
it is june !!
is the lsp separate from the compiler
well technically yes but its very intertwined
#[cfg(lsp)] or something for compiling unused functions?
even if it was completely seperate, unused functions being compiled out-of-order would cause the exact same error lol
i can do that for lsp only tho
why would they be compiled at all
for lsp support
since when does the lsp compile
the lsp goes through the whole codegen to find errors and hover stuff, just doesnt go as far as to generate any files
oh
are steps 2 and 3 only done when its the lsp
with more information about the impl details, yes
maybe if i watch enough videos on lambda calc i will eventually know formal math notation
do you not
husk
i just know the ones that i had to use or had to know the definition of somewhere
"if the sky is blue, then the sky is blue" https://en.wikipedia.org/wiki/Modus_ponens
In propositional logic, modus ponens (; MP), also known as modus ponendo ponens (from Latin 'mode that by affirming affirms'), implication elimination, or affirming the antecedent, is a deductive argument form and rule of inference. It can be summarized as "P implies Q. P is true. Therefore, Q must also be true."
Modus ponens is a mixed hypothet...

why do you need that stuff just make it a builtin to rust
horror to maintain
i wanna read from files
how do i read a file line by line
readLn filename line = -- builtin``` ???
this probably means i open the file a lot
or make it ugly and hacky
if its a monad i can do
file = fopen "filename"
readLn file
readLn file
readLn file
readLn file
readLn file
readLn file
readLn file
readLn file
fn main() -> Result<()> {
let path = Path::new("foo.txt");
let file = File::open(&path)?;
let reader = BufReader::new(file);
for line in reader.lines() {
println!("{}", line?);
}
Ok(())
}
can values in icypeas not hold arbitrary values from rust?
then why cant a variable hold a BufReader and then you just call readLn on it
thats literally just a monad but i stole it from rust instead of implementing it properly
well yeah i guess
what if the user wants to make their own monad
they cant just edit the compiler
ok fair enough
and this whole thing breaks down if i wanna compile
are you planinng to go further into it and add applicatives and functors and stuff
im planning to make a type system and have everything else come for free
uhhh i dont think thats exactly how it works but sure
a functor is a morphism from a category to another right
ok it is
dont functors come for free
its literally just a function T -> U
A functor is just a covariant generic type
for free as in doesnt require changes to the interpreter
(Technically doesn't have to be covariant but the abstraction is more useful with that constraint)
i was about to say
well it has to be a function
is a functor not a function of a category that returns another category
this statement has been living in my head rent free ever since you said it
idk why
it just has
"Functors are structure-preserving maps between categories. They can be thought of as morphisms in the category of all (small) categories."
how is Vec a functor
You can turn any Fn(A) -> B into a Fn(Vec<A>) -> Vec<B>
then T -> Vec<T> is a functor, not Vec
Vec itself is an object
And guess how that (type-level) function is spelled in for example haskell
oh theres a difference between Vec and Vec<T>
is this idiomatic??
gen.tree.iter()
.filter_map(|stmt| match stmt {
Primitive::Function(FunctionSource { name, .. }) => Some((name, stmt)),
_ => None
})
.collect::<HashMap<_, _>>();
Vec<T> is just a convenient way to refer to Vec applied to an unspecified type
yes ok i get it
its spelled []
at least i don't know how both work
Vec is of type T -> U and Vec<T> is U if i understand it correctly
but in that case, its the vec constructor that is a functor, which is a function
Haskell spells those kinds (that's what type-of-type is called) * -> * and *
Vec::new is completely unrelated though
Functors are fmap, not pure
have you guys ever used a multimap
any function T -> Vec<T> is a Vec constructor
yes in aoc
Yep and any such function is irrelevant for the topic of functors
which includes Vec::new if T is specified
why, Vec::new is a vec constructor from an empty set of T to a Vec<T>
Functor means any function A -> B can be mapped to a function f A -> f B
A -> f A is irrelevant
i think i confused oop constructors and type constructors
i get it now
a functor needs a T -> f T and a f T -> f U
well in a program you need a way to create f T
Having A -> f A is called a pointed functor, but haskell just folds it into Applicative
Sure but not as part of Functor
Haskell
are hashset difference operations fast??
my intuition tells me its O(n) where n is the length of hashset A
but im not sure
In theory they can skip all the hashing stuff, but since rust hashmaps have different hashers per instance it's just essentially {x for x in a if x in b}
Still O(n) though, yes
i see
@valid jetty ```hs
println "outside comment"
{- inside comment -}
-- inside comment
{-
inside comment
-}
{-
{- inside nested comment -}
-}
{-
{-
inside nested comment
-}
-}
println "outside comment"
try not to rip off haskell challenge
i can actually just use the haskell lsp
kill yourself what
who writes comments like that
Being able to comment out a block is very useful
the neferious /* */
Ever wanted to comment out part of your css?
Insane language written purely in C without a separate backend??https://nature-lang.org/
A modern programming language designed for elegant, efficient, and reliable software development
I really like its match
what’s special about it
it’s just like any other match lol
@hoary sluice
(not my screenshot)
Is this a Mandelbrot in sqlite
you can do it in rust but its ugly
it looks bettes than an else if chain in languages that support it
like kotlin
in rust its
match () {
_ if ...
}
toxic 😦
haskell does
i want to eventually allow arbitrary operators, and // is way more likely to be used as an operator (probably will be built in floor division) than -- or {- -}, same goes for #, i want to use it in syntax and not waste it on being a comment
uea
and in comes with the added benefit of Haskell compatibility
so i can procrastinate writing a tree sitter parser for longer because the Haskell one will work
i dont have {} blocks
but probably will in the future
so thats another benefit
the only way -- is reasonably conflicting with an operator is decrement, but i refuse to add that either way
mainly because there are no mutable variables but also because -= 1 is better
css not having // is a annoying af tho
if foo-- is equivalent to foo - 1 then just write out foo - 1
using /* */ for multiline and not // for signle line would be confusing
gn
it is not equivalent
lol
ik it mutates foo
but if you want -- in an immutable language then itd be equivalent to - 1
and then another distinction
this is postop, it mutates afterwards
foo-- will yield foo lol
not foo - 1
yes rosie i know how -- works
if you cant mutate foo then foo-- is either foo - 1 or noop
noop wouldnt make sense
foo - 1 also makes no sense lol
neither would - 1 but we need some kind of argument for not using -- for comments

unless foo is a monad and -- calls map(-1)
gm
in what code are yall using match statments so much the way its done matters
matches alone are ugly and add a lot of indentation
real question is why are you not using more match statements, they are more powerful than if statements while looking cleaner, can simply code and most of the time only add a single level of identation
why do you have lots of branching logic
branching logic is bad for performance and the human mind is bad at holding a lot of conditional logic
the only real use case i can think of for a match statment is when dealing with enums
enums themselves however can usually be a value that means something
or, well why do you have that many enums
you can do things like matching against 2 enums
match (x, y) {
(X::Foo(a), X::Bar(y)) => x * 2 > y
}
among others
for single-case matching, it’s useless
but for stuff like this it’s really clean
if you need single case matching use if let X::Foo(a) = x {}
well for one the performance cost is negatable due to compiler optimisations (unless you use a shitty language? but well why use that then)
match statements are powerful exactly because they help you deal with conditional logic. grouping together possible branches (since the compiler should tell you when a branch isnt covered) with most of the time the only viable alternative being switch statements (which are ugly and often handled in awful ways like implicit fall-through) or if-else ladders which come with their own problems. lots of conditional logic is also sometimes unavoidable depending on what you are trying to accomplish. like the people here are making their own languages ffs
i.e.
this:
let status = match status_code {
200 => "OK",
404 => "Not Found",
...
_ => "Unknown",
}
is much better than:
if status_code == 200 {
println!("OK");
} else if status_code == 404 {
println!("Not Found");
} else {
println!("Unknown");
}
good languages that force you to cover all branches also make exhaustiveness checking easier (something which if/else doesnt do so you can easily run into an uncovered branch). if you use enums and in the future add to the enum the compiler will instantly spring up telling you to cover it which makes refactoring easier. really useful if you need to convert between values & especially guards
if you use rust as an example match statements can also be used on structs & tuples which can be incredibly helpful:
let point = Point { x: 0, y: 100 };
match point {
Point { x: 0, y } => println!("X is zero! Y is {y}"),
...
}
well for one the performance cost is negatable due to compiler optimisations (unless you use a shitty language? but well why use that then)
compilers cannot optimize branching conditions without using PGO or bolt passes. I have no idea what world you live in. even then if the hot path isnt hit, the cpu has to walk back the entire pipeline
forcing you to implement all conditions of an enum is nice. ill give rust that. however how many times are you using or forced to use an enum or match statment that how its written matters.
and pattern matching isn’t even hard to do, you’re just traversing 2 asts simultaneously and once you meet a catch-all pattern you just allow it to be equatable to the whole subtree of the expression you’re matching
“for this interview you will be tasked with traversing a tree” * 2
im still flabbergasted at "well for one the performance cost is negatable due to compiler optimisations"
until recent years, compilers would not optimize if statements into direct branches like they did for switch/match cases
i remember looking at a video on this in c++ a while ago
In this video, I will show why in C++, switch is as fast as if. Or at least not way faster as people say.
Join my Discord:
https://discord.gg/eehehsPAka
Check out my Steam Game Midnight Arrow:
https://store.steampowered.com/app/2310670/Midnight_Arrow/
Join this channel if you want to support me 😻:
https://www.youtube.com/channel/UChkC4u4Kd...
compilers have done it for almost two decades.
also compilers dont usually use jump tables, instead a binary search on a dictionary
because if we have large gaps in our data... lets say 3 to 500, then we have a lot of zeros filing the jump table
and an unexpected value will segfault or cause a stack overflow
im comparing the performance cost of match to if-statements specifically of course branching still costs performance
match statements allow the code to be laid out for better optimisation from the compiler
they get converted to basically the same thing in LLVM IR or get mathed out in POLLY
no compiler thinks in C/Rust
oh because hes using gcc as an example lol. altho im suprised gcc IR didnt already do it....
the example where the comiler optimizes the whole loop out is this BTW
https://llvm.org/docs/Passes.html#indvars-canonicalize-induction-variables
oh my god
interesting, if there's no semicolon it sees it as an assignment
good feature?
man i really have no idea where to start with codegen
LLVM Ir giving me flashbacks
Anyway, bring benchmarks and your IR/bitcode output to the backup claims that "X IS FASTER" or "Y IS SO MUCH BETTER"
At the very least go throw it at godbolt
Amen
What about let x = false && (let y = 2) == 2;?
What is the value of y afterwards
Even though the y = 2 is not executed?
you can make it not short circuit declarations
fuck that's a good point
x = ((false) && ((2) == 2))
x is a boolean then with value false since the boolean and isnt satisfied
yea but then what's y
do you want to do scoping?
y is defined inline but won't be set if the rhs isn't reached
so y will be potentially uninitialized
i think rust will throw an error about that
personally id rather not let inline declarations be a thing
Yeah inline declarations seems just weird
it's useful when you don't wanna make sugar for declaring multiple variables at once
x:= y := z := 0;
walrus,,
I think everyone know branchless is faster
It’s also kinda hard to show it’s faster in just IR
Branchless is faster up until you have a CPU which expects branches and you're thrashing the branch prediction with your funky logic
Faster is PGO
done by hand.
Write code YOU can read
Measure the impact
Focus on making shit maintainable so you can fix it when it's INEVITABLY slow
And with the IR/bitcode etc you can see if it's actually turning your switches into luts
Hmm i can’t get away with this by evaluating it right to left can i
What about let x = (let y = 2) == 2 && false;
that breaks any invariants a developer may have about logical operators
it’s supposed to be lazy
if the lhs isn’t true the rhs isn’t even computed
Yeah short circuiting
so doing it rtl essentially breaks that principle
or well
flips it
gives unexpected behavior
x would be false from true && false. For the other case if I go by short circuiting then y won’t be assigned
Yes and then what would be the value of y
Why would it be 2? It hasn't been assigned
((let y = 2) == 2) && false would still evaluate the lhs first
I haven’t actually thought this through
but false && (let y = 2)
would see the false and immediately exit
@valid jetty does #cast return option
no
if it cant cast its a compile time error
actually
interesting
this makes sense with how the codegen is set out
inline variable declarations are compiled before the variable itself, so y := 2 is essentially inserted at the top before any condition occurs
not sure if thats intended behavior in this case
but at least the value isnt uninitialized
actually no
we had this the wrong way round lol
or
hmm
😭
Yeah, can’t guarantee y is declared
im so fucking confused
y is set to 2
but
the rhs branch is never hit
because nothing is printed
so how tf is y being set
is it garbage data/? idk
which case is this
codegen for
use std/libc/io;
fn main() {
x := false && (y := 2) == 2;
io::cprintf("%d, %d\n", x, y);
}
What do you mean by this
What if you swap lhs and rhs of &&
should be the same right?
im just confused because logically in this case, y should be uninitialized garbage but it isnt
let me examine the assembly
holy shit qbe optimized it away
.text
.balign 4
.globl _main
_main:
hint #34
stp x29, x30, [sp, -16]!
mov x29, sp
mov x0, #16
sub sp, sp, x0
mov x0, #8
add x1, sp, x0
mov w0, #2
str w0, [x1]
mov x0, #0
add x1, sp, x0
mov w0, #0
str w0, [x1]
adrp x0, _.21@page
add x0, x0, _.21@pageoff
bl _printf
mov x0, #16
add sp, sp, x0
mov w0, #0
ldp x29, x30, [sp], 16
ret
/* end function main */
qbe detected that its doing 0 == 0 and just removed the branching
wtf
the compiler did not preserve short circuiting?
elle itself did, qbe didnt (apparently?)
im still looking into this assembly
this is weird
Yeah that’s what I meant. There’s 2 str instructions
that assembly is the exact output of this code without the print on L14
strange
after like an hour of reading docs i got a function that adds 2!
yay
definitely largest sense of accomplishment so far
I found this in the discord code
this always returns true, right?
Might be some sort of browser compatibility check
thats a =, not a ==
Yes
isn't length a read only property
It assigns to an unwritable field and thus should throw a typeerror
oh alr
Should I even have unsigned integers? It's pretty annoying since cranelift does not have unsigned integers
Yeah I'm removing unsigned types, they add a lot of complexity for me
Dont remove unsigned types...
If you want to be a language feasible for practical use, you will have unsigned integers
if you want to be a good language
is there any k8s devops mage?
trynna use the @kubernetes/client-node, but im getting unable to verify the first certificate
the config code is literally
import { KubeConfig, CoreV1Api } from "@kubernetes/client-node";
const kc = new KubeConfig();
kc.loadFromDefault();
export const k8sApi = kc.makeApiClient(CoreV1Api);
export default k8sApi;
no IR has unsigned types because they typically have the same memory representation
they usually instead have unsigned operations like comparison and equality which you must do differently if it’s unsigned
^^^
unsigned types are just front-end sugar, along with using an unsigned version of operations
Addition, subtraction, and multiplication turn out to be the same for signed and unsigned, so there aren't different operations for them
the only thing that types themselves tell you is the size, alignment, etc at an IR level
yep
Division and comparison have separate signed versions though
yeah i always use @kubernetes/client-node in prod
its goated
works rly well
Nope I always do (float) ((int) f1 / (int) f2)
well i mean yeah
typically you promote integers to floats when there is a float in the operation
seems too ass
not the other way round
like bruh
it was a joke
you're confusing k8s being ass, with the client being ass
its good
these letter number letter acronyms are annoying
just say kubernetes
like in rendering for a vector2 but you have a position on a grid which is an integer

does (float) 17 return something close to 17
do you not love a11y, i18n, &c?
a11y secretly stands for ally because of pride month but dont tell coorps that
/run ```rs
println!("{}", f32::from_bits(17))
Here is your rs(1.68.2) output @fleet cedar
0.000000000000000000000000000000000000000000024
im an o1p
that’s a pun cast 😭😭 ofc that’s not gonna work
o6t
yea i mean, the issue is in minikube probably, cause i cant even access the api from browser
o1p
e2e
t2s i0s s0o a1s
thats how i do it
i was searching for e yesterday and it literally just wasnt there
i thought i went insane but i have a fucking screenshot
ah yeah, node might be binding to the wrong network interface
and it just doesnt see minikube
what does kubernetes even do
average minikube shit
i had a full dev cluster in my job so i didnt have this prblem
should i just wrap it to docker container or something
no clue tbf, i never deployed a k8s box in my life
i was just a junior YAML engineer
isn’t it more work to count the number of letters in between kubernetes than to just type it out
😭 ok
its not a choice
please use the appropriate abbreviation "e6e" for everyone instead of every1
p4e u1e t1e a9e a10n “3” f1r e6e i5d o0f e41
who says internationalization instead of i18n
me