#programming
1 messages · Page 43 of 1
My x86-64 is kinda rusty, what is rbx used for here
will y'all be sad if i explode
rbx is usually a general purpose register for indirect memory access
the main thing here is the amount of popping from the stack that is happening
i do not trust it
I mean
this is the program
Doesn't the calling convention say things should be put on the stack
Past a couple arguments
yes, but the a[b] = x should compile down to (a.ptr + b).* = x
which it isnt
Turing completeness of transformers
compiler optimisations are nonexistent 
As the wise beard said, try other profiler then. Maybe intel v-tune would help?
Idk I haven't slept yet my brain is kinda mush rn 
i barely have enough symbols to objdump 
speaking of objdump, here is the objdump of the binary
i have the polling rate set to 50000
not my fault the program is too fast
...i guess i should increase the loop length
100 
i forget im not in a vm anymore
i changed it to 100 million
m data
3.3kb binary is ok for this
still smaller than zig hello world
is it possible that it measures the next instruction?
i mean i guess you'd think they tested it properly and stuff
Now this looks a lot more reasonable already
i would hope perf works correctly
if not its mildly concerning
no idea how polling works in perf 
this is true
its only going to give a rough heat distribution
i set the polling rate to 50000 when the default is like 1000
so theoretically its accurate
interestingly there is a lot of time spent in Arena.realloc too somehow 🤔
i guess that makes sense if im copying a hundred million elements

Constant resizing would do that yeah
Preallocate 
either way its not really a big deal to worry about this while the compiler is doing nothing
i have a function for this in fact 
very smart
without preallocation

with preallocation
I wonder, how does one even figure out which instruction to attribute a sample to
lots of guessing 
i like looking at it even though its not perfectly accurate
I guess there's nothing stopping you from inserting some information
And treating each instruction as a block
382 mb vec 
Are the other 4 functions from libc
nope, libc is not being linked
i do not know what they are
probably some syscall or page fault handler
Yeah I guess
maybe they are in the objdump
i only worked with stuff like that on windows
Only one way to find out
or more likely its just absolute jumps being inserted in the compiler i guess
but i could literally inspect every register in the API
you can do that with perf stat but its not as useful as perf record
so just record the eip
Hmmm
m
im not interested in making the vec faster for now i think
inserting 100 million elements in 220ms is surely enough for anyone
also notably goes up to 280ms if you dont preallocate
What's next 

unicode 
its ok i have most of the useful codepoint handling stuff written already in ableos
for font loading lol
Ah nice
i wrote some cursed code that converted stdin and stdout to be nonblocking to play with epoll but ran into some compiler panics with inlining
why is there async in the most sync language 
guys, how good are you at coding you would say?
No
no
async is secretly just state machines
can you say hack into X headquarters?
yeh totally 
i cannot confirm nor deny having already done that
stateless async when
SeemsGood
need a smarter compiler 
stateless code too
stateless binary
eax? we dont do that here
e�x and r�x are my favourite registers
guys, do you know lean4?
i only know lean the proof checker
yep
i know of it
oh it looks like lean4 is its implementation
want to learn how to contribute to the mathlib in lean
to get started https://adam.math.hhu.de/#/
Idk if I should be relieved or disappointed that this wasn't a deez nuts joke
I wouldn't dare xD
Missed opportunity smh
Do you know DN? 👀
something relevant to hblang https://github.com/leanprover-community/mathlib4/blob/master/Counterexamples/Girard.lean
(not actually relevant because hblang doesnt make any guarantees that are broken by type: type)
What is this?
a proof that type being the type of itself allows you to construct a contradiction, thus proving anything
ill look in a minute
its hard to prove
you dont have to 
Aren't there big foundational problems with set theory already with universes?
why are we talking about type theory again
i wouldnt say there are foundational problems, set theory still works fine for many applications, it's more that you have to be careful of how you use it
does this both execute the indented code?
Yes
Does type theory solve all the issues present in set theory?
it's basically labels and the switch statement is goto
that's how i understand it
Yeah
Each case isn't its separate scope, that's why when once case executes, if it's not followed by break, the next also executes
helps that this is often how it ends up being implemented too
hmmmm.
ok
treat it as jumping to the corresponding value and executing from there on
Also the reason why in multiple languages even though you declare a variable in a case branch, it still complains about duplicate variable name declaration
match statements in c++ when
switch(something) {
case "a":
int num = 4;
break;
case "b":
int num = 3; //ERROR: Already declared above
break;
}
Fun 
whats the diffrence between match and switch?
match is what you expect switch to be, each case is a separate scope
(in c++)
which lang
C++

you can make it work but for the sake of everyone's sanity let's say you cannot
macros? 
#define match switch

nah
oh hell nah
im having issues cuz the tutorial did everything in 32 bit but i need it in 64 bit 
need to update my sdl stuff
there are ways of solving set theory's problems while staying within the framework of set theory, but in a sense yes, some type theories were designed in a way that allows you to avoid paradoxes, imo you should prefer one over the other based on their other properties (like that type theories are easy to use for automated theorem proving, while set theories are convenient for encoding arbitrary relations or predicates)
in the first place, it depends on what you want to reason about
ts-pattern calls 
this wont even work unless you're in C# because chances are something's address doesn't match "a"'s address
Most of the languages use Equality check for switch no?
I'm 100% sure Java and Kotlin works
well it wouldnt work in C
uh
rip
what issues?
uhm....
rip previous conversation
what got deleted?
that was a little too aggressive
some aggressive cello pounding got deleted
idk wht that means but sure
rip
i think i'm clear to resend this? https://blog.pragmaticengineer.com/builder-ai-did-not-fake-ai/
The claim that the AI startup “faked AI” with hundreds of engineers went viral – and I also fell for it, initially. The reality is much more sobering: Builder.ai built a code generator on top of Claude and other LLMs; it did not build a so-called “Mechanical Turk.”
is that automated or did a mod do that anually?
it wasn'tm e
lisp sounds like the programminglanguage of snakes
nah thats lisssssssssP
speaking of programming languages, Google released their incident report about how they took down half the internet yesterday
https://status.cloud.google.com/incidents/ow5i3PPK96RduMcb1SsW
it was (probably) Go's fault, they didn't handle an error and dereferenced a null pointer
wouldn't have happened with Rust 
-# there's also a few other factors at play there but let's ignore those and just blame Go
no language will save you if you just dont handle errors
but they can try to save you from accidentally not handling errors
the reports i read did mention that natasha was a real tool but that it was not well liked or something
could be good based on the description though
works a lot like how i want my kubernetes agent thing to work lol
i hate golang error handling with a passion, how do people think it’s somehow better than exceptions
what do you mean you manually have to check for each error
This policy data contained unintended blank fields. Service Control, then regionally exercised quota checks on policies in each regional datastore. This pulled in blank fields for this respective policy change and exercised the code path that hit the null pointer causing the binaries to go into a crash loop.
wish i were a fly on the wall in the room this button was pressed
its a opengl
idk why it went to 1.0 tho, it should be 2.0
classic pink default
For some customers, the monitoring infrastructure they had running on Google Cloud was also failing, leaving them without a signal of the incident or an understanding of the impact to their business and/or infrastructure.
double OOF
also if you think using gcp is a good idea you have to know google does not dogfood off gcp at all
what they use internally is very different
that’s why no google products had an outage
maybe gemini
i would imagine that's largely because most of it existed before gcp
if i was a gcp customer i would imagine they offered their existing developments on gcp
they definitely have it integrated at least partially
that's a feature not a bug
but the backend for gmail for example wouldve been in place for years
not much reason to onboard it to the "platform" as a whole
probably just fr that reason too lol
backup
i know for a while amazon's services were separate from aws as well
they have been trying to do otherwise with new stuff
i think theyre mostly all aws now though
will issue not skill issue
The problem is that you're declaring num twice. What you probably want is to declare int num; before the switch statement and then assign either 4 or 3 to it with just num = 4 etc.
BTW you can't switch on strings like this in C++ since you'd just compare the string pointers not the content. This might seem to work in trivial code if you for instance assign a string literal "a" to something since the compiler will figure out that it can use the same memory region for both "a" literals, but it'll fail if you for instance read user input into a buffer and try to compare.
The easiest way to deal with this in C++ is most likely to do an if-else with std::string comparison.
That is the point I wanted to make, that it does not create a sco0e, hut it is a goto underneath.
In higher level languages it does work, causeost of the use equality function check instead of address checking
switches in C++ support fallthrough so you can end up in multiple different cases
they should just add pattern matching in c++29 
but you can just create a scope yourself if you really want to so its wahtever
Yes, cause it is a goto, not a scoped if thingie
okay but that's boring
In C# I just do the cursed scoping:
switch (something) {
case "a": {
var num = 4;
} break;
case "b": {
var num = 3;
} break;
}

comfy 
then again its C# i'm expecting too much
when i made some unity mods i did start with C# but it very quickly pushed me out to F#
often times thats exactly what it is
explaining lambdas to imperative programmers
okay imagine a code block with lazy evaluation
bold of you to assume that people know about lazy evaluation
its ok not all of us understand that the principle "you can use this value as many times as you want" can naturally be extended to "you can pretend this value never existed if you want"
hello
ut8 string

just to be clear i am actually parsing it and not just pretending 
i wonder
would it be possible to detect the base of the numbers you're trying to print
probably not right
well, at least not with help from the compiler
who like the web developer and use javascript ?
i use JavaScript, but i dont write it so 
i wrote javascript once and i dont want to write it again
undefined is so wrong
why is it not a NameError
technically
i guess so
but it would mean wrapping them
so, not happily
log.print is mean to take format arguments but i havent done it yet
lossy conversion
actually Iam trying to learn it
le triangle
i forgot how much shit you need to do with the vao's and vbo's.
pyOpenGl had those but i switched to zengl for web support and zengl doesnt have those. i need to relearn them
my condolences
if you have questions about the language whenever feel free to just ask, there's plenty of people here who know more about it than they probably should/would want to
how do you learn , do you use websites or youtube?
you can, but imo you learn the most from trying to use it and problem solving
it is handy to watch a video on it first to get an idea of the syntax and how stuff works
i'm a big fan of jumping down the deep end and forcing myself to learn that way but that doesn't work for everyone
which is why everyone should start with hblang

c++ they learn it to us at college
tbh when lookign at hbland i couldnt figure out how it worked
one downside of trying/using all kinds of languages is i keep getting the syntax wrong 
im not in college tho, and we'll be doing C# when i am next year
why is this the same size as the hashmap code
main := fn(): uint {
arena := lily.alloc.Arena.new()
defer arena.deinit()
// emoji := "😊asd"
emoji := u8.['h', 'e', 0xC3, 0x28][..]
string := lily.collections.Utf8String(
lily.alloc.Arena,
).from_utf8_bytes_lossy(&arena, emoji)
return 0
}
wdym
This is the evolved version of my soft salamander robot: an air-powered, squishy little creature inspired by its real-life counterpart.With a fully flexible spine, coordinated leg motion, and a redesigned control system, it walks, turns, and wiggles with surprising character.
The robot is powered by custom vacuum actuators and controlled by an e...
Silly
also i assume utf8 being under collections is only temporary
binary size
it should still be smaller
no
well, a little bit
c# good language it's take fourth place globally
utf8 codepoints maybe
for utf8 strings, they require an allocator, so they go in collections at least for now
i guess fair enough
not interested in fragmenting it much more than it already is
can put it with a proper string type into its own module later though
right now im just aliasing them
forget OwnedString it doesnt exist any more
ah yes. this may or may not be what the python code looke like on the right
in hblang you have []u8 
probably more
and Utf8String if you count lily

i will probably make OwnedUtf8String a separate thing again when i can be bothered
if i see one more example of inheritance via animals or shapes i'm going to lose it 
kinda accurate 
because having the allocator in the type makes it a bit restrictive
ah the classic Factory thing, which only enteprise level java devs follow
there's String/str, CString/CStr, and OsString/OsStr at least
str is just the beginning since you can give it different indirection
Box, Arc, Cow, &
found the image
(it's incomplete)
yeah, but you can do that with all types, so I'm not counting those 
you can probably nest Arcs too
I don't think that should count as infinite string types 
Arc<Arc<T>> is semantically equivalent to Arc<T>
Arc<[u8]> should count at least tbf
not even a string, that's just bytes 
Arc<str> is fair
but idk if that even works
at least in rust, its not a string
your code doesnt work? go learn assembly 
str and String are guaranteed to be valid utf8, and OsStr and OsString use the encoding of your os
CStr is also (valid?) utf8, but its null terminated
Path and PathBuf are OsStr and OsString wrappers
but byte arrays have no compile time guarantees which rust loves so much 
actually it isnt utf8
it's not UTF-8 but is usually converted to a normal UTF-8 string to be useful
i dont wanna think about small string optimisations
In this article, I'll describe how I implemented German string and the challenges of doing so in Rust. Specifically, I'll examine how to enable shared ownership for such data structure. Providing unique ownership is relatively trivial, and there is already a nicely written tutorial from the Rustonomicon teaching you how to [implement a Vec], w...
it's about as disgusting as you'd imagine it be
random nerd sniping xkcd
sso is fun and easy 
its not fun and easy when the standard string doesnt use sso and you have to find and replace a billion type signatures though
could you just replace the Rust std String implementation with this?
do NOT confuse it with single sign on though
single sign on is NOT fun and NOT easy
i dont think that theres anything in the standard library that mandates String to be a fat pointer with capacity
yeah, I think so too
could be interesting to try this out and see how it impacts performance for large builds with many dependencies that don't use this optimization
another item added to the "maybe do this someday" list
its possible to create an extension to the language that allows borrows that are independent of the owning object's moves 🤔
then sso would break that
like a handle that points to an object rather than a specific location, and you have to guarantee that the object lives for that lifetime rather than stays in place for that lifetime
no branchless programming 
branchless programming my beloved
who needs branch predicition? just dont have branches 
so true
I read SSO immediately goes to Single-Sign On lol
this is what big cpu doesn't want you to know
if statements are the work of satan and should be banished
SSO is easy. Choose a vendor and be done 
I don't think this would matter?
AFAIK all that crates like strumbra or smol_str do is store the string as part of the struct itself, not inside of a Box which would put it on the heap
that struct can still be moved around as long as the reference to it remains valid, no? 
Because I don't want to touch the technology underlying SSO with a 9ft pole
which true is the one true true?
truetruetrue
ive said the word to the point that its lost its meaning
TRUE... True... true...
-# true...

there should be a language where booleans are actually probabilities
probably exists already
guys i think im gonna do it.
i think im gonna make this project have seperate files
not one monolith
clang will thank you
may the clang be with you
But how many translation units? 
idk what that means so 0
Woah, unheard of invention
I expect to see you writing header files any time soon
idk
in my experience replacing branches with branchless computation is often a really bad idea 
Basically everything that the compiler sees on a single invocation is a translation unit.
So having a ton of headers and a single cpp you would still have a single translation unit.
Smells heavenly
The white part is coconut milk, don't worry
if you can do it in a well layed out method you probably should. but dont get too "creative" with solutions cuz thats gonna create more overhead than you're saving
nah, you shouldnt even if its well laid out
the compiler can do it better
i can't wait for sam to ditch emscripten 
and the code will be easier to read
Sometime the compiler could be smarter than you sam
don't try to be smarter than the compiler unless you can prove it, just don't make its life unnecessarily hard
for glsl in my experience it does give some benefit to at least think about reducing branches
additionally branches are incredibly cheap on modern cpus
gpus HATE branches
im not talking cpu lol
Like what konii do

Oh, fair
to be fair then, gpus are about 2 decades behind on compiler opts 
WHAT?
glsl shaders 
hyperbole
but its typically a lot harder to optimise a shader than a cpu program
the things we give up for parallelism
I'm no graphics programmer so I don't know the state of GPU programming lol
mainly due to parallelism, yes
you can just think of it as
cpu = few smart cores
gpu = many stupid cores
i'm talking about a hypothetical language extension
Also depends on what you branch, branching on constants or shader input behaves very differently
All I know about gpu world is just from the funny internet man lol
don't remind me of the nonsense I had to do for branchless code in cuda C
if you could borrow a string's data while still allowing the caller to move the string itself without destroying or mutating it

gpu cores are like tadpoles. there are many but they have no clue what is happening and most of them will die if left alone
do not do what i do when i start trying to make things faster, it's bad for you 
we even used X macros 
Luckily I do not need extreme performance most of the time
me neither im just a numbers junky
i need more power!!!!!!!
4k fps is for chumps
yeah, I got that
but I don't see how a small string optimization would be hindered by this more than any other struct would be
where the struct is actually stored does not matter, there is no explicit reference to the stack anywhere
if it's just about performance, then you can already kill the optimization by just putting it in a Box
unicode garbage is my favourite kind of garbage
not CJK? 
or are those characters just not rendered properly 
because when you borrow the string as a slice, it returns a pointer to heap if its stored on the heap or stack if its a smol string
do you build any projects with c# ?
"�A��&0�"�b���"
F# is cool C# god forbid (at least its not java i guess)
I only use C# when I'm forced to
this is the unicode replacement character U+FFFD which i insert in place of an invalid byte when converting bytes lossily to utf8
I know the basic of c# it's more simple than c++
its not hard to be simpler than C++
true...
except it doesn't really return a pointer, it returns a reference, which for string slices is AFAIK implemented as a fat pointer
with your hypothetical extension, this reference would have to instead be a handle of some kind that remains the same even if the data it points to moves
with my extension, the reference could still be a reference as long as parent object's moves dont invalidate it
in fact, a String's moves don't invalidate the &str
i suppose similarly moving Vec<T> doesnt invalidate the &[T] provided T allows it
CSM coming along nicely, now I just need to combine them 
-# Camera frustrum is shown in yellow, and sun frustrum shown in grey


I just pass the depth to the fragment shader along with a uniform buffer that holds the thresholds to combine them
For optimization each depth is on a singl colourchannel in an rgba image
That way you dont need to bind 4 image buffers
wait, since when can clippy emit something as an error?
yup, it can
I have also seen many modern games just use a giant image and reserving different areas for different maps, same difference though
since when? never seen that before
True.
Im doing webgl tho so im limited to 4096x4096 to keep phone compatibility
Otherwise i could do 32K x 32K 
I have the leisure to not target anything other than the hardware I own 
I'm 95% certain that clippy is wrong, but I'm also 50% certain that I'm often times not right when I say 95%
its fine just allow it
let me actually verify it before crying foul
no no why would a code analysis tool know better
as expected, clippy is right
the amount of includes is already getting out of hand

i have turned the gl context into a seperate file now 
idk what the diffrence is between c, cpp, h and hpp but it seems to work
they are for c and c++
so what about c vs h?
just conventions (that are kind of enforced by the compilers)
c source code vs header
the idea is that the header files sort of act as an api spec
whether that's internal or public for others to use your library
H files only have the definition
depends on the library but yea, it can be like that
Normal for complex project
Which is why u also put the IFNDEF or something I don't remember
other way around 
definitions have the fn body, declarations do not always have the fn body
what you can do is create a prelude.h, put commonly used header in there and then only include that in your actual source files
But ye u typically never wanna import the .cpp file
codegen 
the file looks like this. so its just the definition yes
Nope
That includes the fn body
?
Definition is just the function name, return type, and parameters/arguments
*declaration
stop mixing up the words
bold of you to assume that sdl_createwindow won't give you a null pointer
it works so 
not like you can do anything without a window
in the .h file instead of defining the function body with {} u just do ;
Then in the cpp file u import the .h
I'm sorry okay, my mind is already full of stuff I better not know about lol
And write the same function again but with body
reject separate headers and source files, embrace single header libraries 
why woudl i write it twice?
the joys of the C programming language
Circular imports
what the point of having it in a seperatew file if i have to put it in the main anyways?
If u have for example
ah C and forward declarations, my beloved
aslo, why are yall neuroClueless'ing me? it works so whats the problem?
it won't when sdl decides not to give you a window
but as i said it's not like that matters in this specific case
wdym, its error checking, you do that in case something doesnt work
you'd have to panic either way realistically
pretty sure that it will stop working once you have more than 1 file that uses this header
there are a million reasons why sdl might fail
mylib.h Which imports mylib2.h
And mylib3.h imports mylib.h and mylib2.h
And then have main.c which imports mylib3.h
U are importing mylib2.h twice
Did he not use #pragma once or include guard?
And a function can't be defined + declared twice
no 
if it doesnt work then just let it crash and burn. no reason to keep a game-engine running that wont dispaly anything
NICE
Pragma once my beloved
the point is that you are suppose to notice and tell the user: hey, this went wrong. In fact, you tell it to yourself since some random dude will tell you UHHH it just crashed and you have no idea why
erm clearly you have to be forward looking and handle that gracefully so you don’t have problems when you decide to add a multiplayer server feature in the future

...he will do multiplayer? In C++ and webgl?
?
are you not supposed to import something that in imported file already imported?
it’s not like i’m being serious but why not
I thought you were serious lol
it wouldn't even necessarily be because of the missing include guard
even if the header is included only once per compilation unit, the symbols from the header are still present in multiple objects when linking
im sure that by then i will fix this single file resposible for creating the context
maybe
i want to create neuro monopoly eventually
True
I forgot about that part
am i missing something here, what’s the problem
there's nothing stopping you from just having a singular header with all definitions either and just including that
or not have a header at all but that doesn't work if anyone else is supposed to use your code from outside
It's just hard to do I guess
Oh right, I forgot about websocket. Man it's been a long time since I did anything with that
im not sure how i would do a server tho. ideally a player gets to host so i dont have to maintain a server myself but that invites hacking
probably actually better for a game
damn you apple why cant i forever loop my audio files!!
Thats where WebRTC comes into play
So you just need a server for signalling
Or become a relay in case of NAT
STUN and TURN respectively
fuck p2p based multiplayer that’s not what i meant
Why?
Anyone know a good tutorial channel for getting into learning JavaScript
because when a player’s potato computer becomes a server and i happen to join it i don’t enjoy the 10 game ticks per second
another one 
why are they all learning javascript?
JacaScript is used by RPG Maker MV I’m sorry
Because its ez
super widely used ig
everything is easy once you know how its done?
besides like physical effort
Yeah but the step required for JS is literally notepad and browser
I just wanna make a fun retro inspired JRPG and I already own the software
Do a test to determine which one to be the host lmao
But yeh, I can see why its annoying
cout << "host error: potato pc, automatically rerouting host connections";
I think the best place is just reading up documentation but thats just me because I already know programming concept
Yes. And insult them while you're at it lol

ideally a core or 4 for the game itself an a core for hosting no?
so just choose the one with enough cores that also has the highest clock
Ideally it is a separate process ngl. So you can have a dedicated server too
you could still call the seperate procces from the main game tho i think?
altho that probably wont work in webgl ye
Yes
Maybe a web worker. But I don't know how feasible that is
ill see
Good to know then. I don't read much the API availability that I don't really use
Because JS lol
they're not? damn
i guess you'l need to go through js then for a worker thread
Yea that's why I said the best shot is probably web worker. A separate script run independently
it's a bit more complicated than that because you also have to consider things like latency to other peers and reliability of the connection
also you have to implement host migrations because the host might close the game at any time, but that's just an issue with P2P games in general
true
can't draw to the screen, but can probably render to an offscreen canvas (or do compute with compute shaders, if WebGL has those)
or you just don’t handle host migration which is exactly what 99% of games do
“The host has disconnected from the session. Return to main menu?”
for now i wont be doing p2p yet. the game engine is not even built yet, i have a single polygon on screen
great user experience, just randomly get kicked from the game 
exactly
my main takeaway from this is, i just wont be defining shit that gets defined in my imports
I have knowledge of the basics of c++ we took oop and data structure but to be honest data structure was not that easy , so now I want to start c# I want to ask if anyone use it too
What if each peer is also a host so the system is basically byzantine general problem 
actual nightmare
Shhh, let Sam encounter it
p2p is not yet planned
isn’t this how GTAO operates btw
Interesting. I know some CRDT can be used to implement those. But I don't know how much of a task it will be
what if 2 imported files use the same import? wouldnt the import happen twice then too?
i have no idea how they do it on a technical level but have you ever heard of what hackers can do there
HE ENCOUNTERED IT GUYS
yes
that's literally what an include guard prevents 
Just use #pragma once
see? the joys of C++ 
No, I do not play GTA after SA
they cant seriously expect me to #ifndef every single import no??????
They, in fact, could and will
yes they can, and they do
Just use #pragma man

the list of those things include but aren’t limited to: spawn whatever you want, spawn cages around every player, teleport all players to a specific location, explode every player, spawn a giant fucking LOD mirror copy of the map above it, give any weapons to any players, fly in any vehicle, fly without one, etc.
should give you an idea
yuove said this multiple times but that doenst help me not knowing what that is
Ahhh, chaos. I love it
pragmas are compiler hints
In this case once for telling it to only include the file once
putting #pragma once at the start of a header makes the compiler only read that file once
if it's already been read it gets ignored
so it does the same as an include guard except without the #ifndef stuff
Treat everything that starts with # not as a code, but instruction for the compiler
#pragma once, if the compiler read it on a file, will only process said file once
start of the main header, or every header?
every header 
Every
Unless the header already have ifndef
Which probably true for the sdl and other library
ye but i need to add it to my own ones
Yep
except the game is a mmorpg and the majority of players are trying to grind and hackers are kids who enjoy preventing them from doing so
technically #pragma once is a non-standard feature
I love gcc extensions
Aren't every pragma is?
nah the sdl doesnt have pragma
There's your include guard
This bites me in the ass because apparently most math function isn't constexpr in the standard, but it is in gcc
But it does have ifndef followed by define
tru
Thats include guard
I have consulted the C99 standard
#pragma itself is standardized but any parameters are not 
yea, once was considered but rejected
it does not like pragma in the main.cpp
any semblance of good ux? in MY c??
oh, except #pragma STDC apparently
never heard of it 
.cpp or .c doesn't need it
3 standardised, rest extensions
Its very technical
you don't include .c or .cpp files
because you don't import it
Yeah, thats the simple answer lol
I'm bad at explaining shit
Without going on a tangent
also with C++20 you could use modules instead. Not that I would recommend it
imagine using c++20
idk what the diffrence is bu sounds complicated
They have a chance to make it good. Nope, they butchered it
why do they have a system that does the same thing as the include system?
Because includes suck
because they're stupid?
They're just copy paste
they wanted to modernize it
Tl;dr, we just treat module as if it doesn't ever exists
did you not know about the C preprocessor? 
I've said it before, #include is just basically saying "copy whatever is in the file here"
why would i?
You can include c files too
you are programming a C(++) application
There's nothing stopping you
It will not
Fuck
Could have used Rust where all that bs is not necessary :D
No, the style is horrendous!
yeah, or any other remotely modern language really 
no see, they prefer the bracket to be on the same line in the rust world, literally unusable
Let's be realistic, rust would be even more painful
not with imports no
At least here he can use opengl 1:1
they also have a formatter that allows you to configure the bracket to be on a new line if you hate yourself and don't like conformity
but that would require creating a .toml file with a few lines of text, absolutely impossible 
surely there's a crate that abstracts differences between OpenGL and WebGL
you can use WGPU in rust
that would mean no support for most browsers so nah
there is
https://crates.io/crates/glow
its not that easy
But not widely supported
But also, sam writes his own GLSL so maybe using the same language family is better
(this doesn't need WebGPU or wgpu btw, it's just bindings to OpenGL and WebGL and can use SDL2, same as the current stack on C++)
webgl does not have geometry shaders, no tesselation, no CSM without seperate passes.
lower max buffer sizes, lower version of glsl supported, ....
and those are things that cant be just translated
you need to change the entire shader function
but besides that it should be fine
ok, hear me out
just generate one big <table> with colored cells that are exactly one pixel for every frame


you mean pass that to the vulkan renderer?
just raw dog that into html
-# this wouldn't actually help because rendering and presentation are different operations btw 
ok sure, but that would effectivly be wastin 75% of all the gpu's work since it always does 2x2
same reason you shouldnt have a lot of small trianlges
absolutly not
it would be hilarious tho
getting the gpu output and then passing it back to the cpu is a really bad idea
and im 99.999% sure that wont help with wgpu comaptebilit
i did this with my project, 
I colored a 1600 x 900 texture pixel by pixel and I rendered that onto 2 triangles that cover the whole screen
you're doing WHAT
btw this was a joke. The dom parser will get an aneurysma
ceace this behaviour emediatly
I'm just sitting here, laughing my ass off
I didn't know how to do it better so it will stay that way 
that seems fine
I think you could write directly to the framebuffer instead of using a texture but I'm pretty sure fullscreen quads are not that uncommon
See, this is why webdev is fun
The world is your oyster
its about 900 x 1600 times better than tsurai's quad per pixel, but not ideal
preferably just blit it
you cannot put a value on art
if you want to see the monstrocity
https://github.com/juhotuho10/rust_GPU_raytracing
in my experience copying all the data to another framebuffer when not needed uses 15+% of the total rendertime
you really shouldnt
refresh running project
try new display for md
it crashed
how could i have anticipated this
looks nice tho, good job 
also, this time clippy really is wrong, frfr
would be a small improvement if the texture is in VRAM, though as long as there's no shader it'll be slow regardless 
It says there dangerous
i like to live dagnerously
true 
Same
dagne rously 
When unsafe {} is not enough
they made it too tempting to use
calling it that
well i gotta try dangerously setting it
clippy is wrong, this is not a complex type 
You're only using standard rust generics, can't be that bad
Not even any trait boundaries
What about when danger is not enough?
Are we entering cursed territory then?
good morning programming
rm -rf $HOME
I can't find the issue here, it seems fine
the texture gets written directly from a compute shader, which then gets read from the render shader that displays the fullscreen quad
could probably just merge the shaders into the render shader, but if you want some form of asynchronous rendering then using a compute shader should work great
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf $HOME || echo Click
Play roulette instead
lmao
put the shader maker thingy also in a seperate file cuz it felt right.
im doing this purely based on vibes.
it is annoying how half these functions are underlined with red cuz they only work in web
in ms word you can atleast press ignore
mine are underlined in red from all the import errors and total failures of awareness on my part
you code in WHAT?
i dont
fixing the errors: ❌
permanently ignoring the errors: ✅ 
office 97
Ahh yes, I forgot that MS Word can refers to two distinct product
they're not really errors in the first place. it jsut doesnt work locally
People mostly assume MS OFFICE Word
nope
You know, ideally it should not show error because the compiler should know you are compiling to some target
it compiles with emcc src/main.cpp -o main.html -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 -s MAX_WEBGL_VERSION=2, but besides that it doesnt
if you want to target native then I'd consider that an error 
if not then fix your VS Code settings 
i always fuck up my config somehow and end up with anything installed in the venv undetected by vscode
even tho i have it as the env for the editor too
Coding on vibes is based
Nuke your user and system config dir and start over 
Still waiting for #embed to finally be supported by all major compilers 
Look at bear on GitHub
i did that and it was good for a while and then it started happening again so i said f it
And point your ide towards that
I think the error squiggle could be removed with proper cmake
i do want native to work but im not big brain enough yet to know how to do
if sys.platform == "win32":
import gl3.h
...
else:
import emscripten.h
...
this shit in C++
It's called compile flag

Basically you do this
#if PLATFORM_NAME == "Win32"
...
#else
...
#endif
Pog it worked in my setup at school yesterday btw, I got the vision, coefficients, and serial all working together
And when you compile, you set the flag by doing
g++ -o main ./main.cpp -DPLATFORM_NAME=Web
thanks for censoring the photos of me you keep on your walls at all times
what about when compiling to wasm?
Lolll
Then use the emcc compiler with the flag set accordingly
ok
i think im gonna have to make a seperate context.hpp file for local, since the current one has emscripten fuctions
i just have a makefile
full command for wasm would be emcc src/main.cpp -o main.html -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 -s MAX_WEBGL_VERSION=2 -DPLATFORM_NAME=Web
for native it would be something like clang++ src/main.cpp -o main.exe <big list of include directories and objects from libraries here> -DPLATFORM_NAME=Win32
Yeah, that works but tedious and brittle. Especially if you need to add more and more library or your source file grows in number
im not expecting it to grow much more
just need something to read gltf and i should b good
Yeah, for small project I think its still bearable to use makefile
Or just set up your project to be a natural unity build. Then a small batch/bash file will probably suffice
i forgot this menu existed in win+v
(☆▽☆)
this is a no unity household
surely you aren't referring to Unity the game engine
Not the game engine 
https://en.wikipedia.org/wiki/Unity_build
In software engineering, a unity build (also known as unified build, jumbo build or blob build) is a method used in C and C++ software development to speed up the compilation of projects by combining multiple translation units into a single one, usually achieved by using include directives to bundle multiple source files into one larger file.
bad
horrible
please nobody ever do that
Even I, a chaos lover thinks that is not okay
havinmg the word unity in my pipeline would rruin my image as a homemade game-engine
never saw it in any actual project either
If linker is an issue, use https://github.com/rui314/mold instead
must be ancient, from times when single-core processors were a common thing
Yeah, that makes sense
you should try using Bazel
it's an anagram of Blaze, which is a very cool word

Fuck bazel build system
i hate how some programs have comments like //set atttributes right above a function named setAttribute(args)
like brother we can read we know
Depends mainly on linker speed yeah, since linking is single threaded and can be a bottleneck.
I am using it right now, but my project is currently only 4.5k loc so not that big. It is kind of reassuring to me to just hit a button and be certain the build system didn't fuck up but that might be just my msbuild PTSD.
Yeah, make actually useful comments if you're gonna make some, otherwise just rely on self-commenting code

bazel 
might as well use maven for building c++
Gradle
Use mold my dude
Some tensors share memory, this will lead to duplicate memory on disk and potential differences when loading them again: [{'language_model.lm_head.weight', 'language_model.model.embed_tokens.weight'}].
A potential way to correctly save your model is to use `save_model`.
More information at https://huggingface.co/docs/safetensors/torch_shared_tensors```"Good job spending one hour quantizing that model. Oh, you want to store the result? Well, I guess sucks to be you then."
Also the proposed "save_model" function does not exist and the linked web page tells me nothing.
ML is cursed ngl
at least it's using safetensors
pickles were even more cursed imo
The fact that the ML eco system is built on Python is cursed
it doesnt seem to like it
it should've been Julia 
Sorry, I was wrong and have since corrected the code lol
ah
#if not #ifdef
Storing the model in non-safetensor "works" but then loading fails :D
Thats certainly is something alright lol
Why? I don't currently have a seperate link step 
Oh, right. The unity build...
on a multicore processor (all of them) it should usually be faster to compile multiple files individually and then link with mold than to compile all of them in a single process but skipping the linker
If it becomes unmaintainable and I feel the need to restructure I'll think about it. But I kinda want to test the waters and see how far I can go. It also looks like mold currently doesn't run on windows so that is also not working for me rn.
LLVM lld is also pretty fast and should work on Windows
couldnt get it to work, i have this now instead
Depends on how many files and how big, I guess. There is less parallelism but you don't have any io overhead. Let me check if I can find some sources that have some numbers comparing unity-builds with conventional c/c++ project structure.
I wanted to suggest something, but #elifdef isn't a thing until C++23 
#if PLATFORM=="Win32"
#include "glcontext.hpp"
#elif PLATFORM=="Web"
#else
#endif
Platform is not reserved right?
nah, for this one i dont have to specify a variable in the build function
idk
Fair
if you want it to be slightly cleaner you could create a platform.h where you check for _WIN32 and __EMSCRIPTEN__ and define your own macros accordingly
then you can include platform.h everywhere and use those instead
i could ye, but do you mean with the include or jsut a file with 3 if statements?
Or you could also do
#ifndef TARGET_PLATFORM
#ifdef _WIN322
#define TARGET_PLATFORM "Win32"
#elif defined(__EMSCRIPTEN__)
#define TARGET_PLATFORM "Web"
#else
#define TARGET_PLATFORM "Fallback"
#endif
#endif
this is getting complicated
no indentation so i cant tell wtf you're even doing
mhm no platforms other than win32 and web exist

im hoping it works on linux too, so fallback for that
i hope it crashes on imacs tho, out of principle
also indentation here is so cursed
Hey, sam wanted it, not me. I wrote it without indentation lol
are yo not supposed to use indentation there?
i like readablility
For hblang I think that shit would be cleaner
No, usually anything that starts with # does not get indented. Its a code style thingie like the bracket. But there are no hard rules
Now that's silly
im beginning to think yall hate making your files readable, and then complain that C++ isnt readable and go to rust
C++ convention is bad tho
-# I approve
And luckily there is no one complaining like rustfmt
yeah, that's what I mean
if you do this you can have your own TARGET_PLATFORM macro
or alternatively define separate macros like TARGET_PLATFORM_WIN32 and check if those are defined everywhere else
i dont see why i would need to do that tho
you don't need to
it's useful to have for when you need it
Its just when someone need to do cross compilation, usually its done that way
what even is cross compilation?
I should not have said that
you are currently cross-compiling from Windows to wasm
Compiling on one platform for another
I think
but wouldnt just using #ifdef _WIN32 again work?
or is that bad for some reason?
If someone want to compile from linux, it won't work
see, hblang is very good for this:
// in lily
$match target.current {
.hbvm_ableos => {},
.x86_64_linux => {},
_ => {},
}
// in the language itself
$if @target("hbvm-ableos") {}
and these get checked at compile time
But then if you use the flag, the compilation can be configured by setting the flag manually
g++ <long ass command> -DTARGET_PLATFORM="Win32"
hmmm
so you mean that the variable gets checked at compilation and not on the target system?
macros? at comptime?? boring, add runtime macros
Indeed
oh
there are no macros here 
hmmm
Anything with # is compile time only
ok i see your point
Lovely
Anything starting with # is for the preprocessor
if you call them something else they don't stop being macros
It happens even before the compiler actually
no, there are literally no macros
Meanwhile CodeParade adding generic template to C#
is the point that it compiles down to the correct @use directive
from this
the it being lib
very close. modules are types in hblang, so you can return an @use() as a type.
but it does in fact only compile the correct @use(), yes
the point is that compile time code is a bit special because it can create types and use dynamic values (@Any()), but there are no type objects at runtime. @use returns a type because types are modules
like this i guess?
so it is compile time code
Yeah
(except the _WIN322 typo)
blah blah
it cant replace macros in the general case but it can replace a whole bunch of conditional compilation; the most complicated part is that parameter and return types are allowed to depend on function arguments (same as zig i think) but i wouldnt call it dependent types since its known at compile time
Now here is the fun part. You see the NOT green one? That is your current active compilation target. With proper VSCode config, you can change it by setting the correct compile_commands.json. That means anything that's only valid on the web won't be underlined as error when you are not targeting it
no code generation, just conditional compilation and inlining 
also since the functions arent bijective there arent the analogs of infer in typescript
you use @Any() or you dont
you probably could create an arbitrary binary using just the typesystem though
WHAT?
hard to call it a type system when its just running arbitrary code javascript style 
to add to this, it also means that you usually won't see compile errors for the Web target in VS Code because it's set to Win32 (or the other way around, no errors for Win32 when set to Web)
but such is life when using C or C++
also, the type system involves a highly sophisticated termination analysis algorithm - running the compile time code for a while and seeing if it terminates
this is true
old compiler handled this better
but new one never recieved anything of the sort because we never write incorrect code right 
The Halting Problem (easy mode) solution
bet the computer is gonna feel really dumb when i unplug it
in my experience unplugging computers doesn't make them disappear
what does the compiler need this information for?
to decide if it should log an error and skip that compile-time expression?
are you sure you're doing it correctly
its not really information, its just basically error handling
so basically
if i want to implement arithmetic in pure types
i can only go up to the 8th fibonacci number before the compiler starts complaining

but before then, it works

this is not a joke

so it is just to stop people from putting an infinite loop in the compile-time code
I did not perceive it as such
yesh perhaps
i had to request an increase on compiler stack size from 1mb to 8mb in order to compile this https://git.ablecorp.eu/chayleaf/hblsp/src/branch/trunk/json.hb
here is the src code 
$N := Suc(Suc(Suc(Suc(Suc(Suc(Suc(Suc(Zero))))))))

there's a certain beauty in whatever tf this is
at the same time
its uh
not useful
not useful in hblang
I thought it was S U C
Oh wait, it is
compiler abuse 
Successor
json parser is compiler abuse indeed
kinda rude to make a json compiler tbh
Suc(cessor)
but representing numbers as linked lists is very useful if you want something like actual dependent types

