#💽Programming Chat v2
1 messages · Page 11 of 1
i understand
its the same reason we have Character/Wide_Character/Wide_Wide_Character/Unbounded_String/Bounded_String/String/Wide_String/Wide_Wide_String
in ada
Unbounded_String
yeah what of it
well just another thing to add onto the list there
theres probably wide/widewide variants of unbounded/bounded
but i haven't seen them
theres also the Interfaces.C strings...
yeah seems like ada has similar things then
off the top of my head
- &str is an immutable fixed-length slice of a string
- String is a heap-allocated, dynamically-sized, smart pointer that owns and can mutate the underlying data
- &[u8] is kinda what it says, fixed-length array slice of u8 (so chars as numbers)
- Vec<u8> is like the above but growable
- OsStr/OsString encode the strange semantics around strings owned by windows/unix
- CStr/CString handle the null termination among other things that differ from "normal" strings in Rust
Character / Wide_Character / Wide_Wide_Character - 8/16/32 bit characters for Unicode, ISO 8859-1, etc.
String / Wide_String / Wide_Wide_String - unconstrained array type of Character / Wide_Character / Wide_Wide_Character
Unbounded_String - growable String
Bounded_String - Unbounded_String with a known bound ("cap")
Interfaces.C - wchar_t/_ptr, refer to C for details
asm meanwhile
Your mom meanwhile
5
yeah char is the best
ok but like....
is your char *
- null-terminated
- owned by you
- heap or stack allocated
- mutable
- growable/shrinkable
sure it's simple but the consequence is you have to figure out the semantics of what you're working with
I don't think you haved to figure it out
You created it (most of the time) and every string is null terminated so
well lucky, is your char * null terminated? go ahead and check I'll wait 😈
Yes owo
Hold on I'm in the shower I gotta find out with termux 😭
a char * is supposed to be null terminated if it's representing a proper string but it doesn't have to be
so you could end up with one that isn't
Yeah but you could also get murdered
smh
the point is that there are things that you have to question with a char *
it can be useful sometimes because it gives you freedom in how to interpret it
but sometimes the ambiguity isn't helpful
Omg stop making good points your making my argument look bad omfg
whereas rust encodes the semantics directly into the type, so you end up with a lot more types, but you know exactly what you're holding

What if there was a string struct
And it had a single char at the front of it
With the pointer next to the char
And the single char had options in it
I mean then you've encoded some semantics into it
Oh shit
By definition it will be null terminated
because yknow a linked list will end with a null pointer
so you can kinda know something about it from just that
Car
Well I mean I can't remember the last time I saw a char * that wasnt null terminated
At least when used as a string
true because most people know to null terminate them, but the null termination isn't encoded into the type so it's possible to not null terminate them
""
too complex
i just want char *
sorry
Yeah it is complex
But char * makes you have to deal with the complexity yourself
me when I make a Schema with a number of characters greater than Positive'Last
Strings bound is Positive'Last...
me when I do it anyways.
I will call your function from C where there is no such bound
the humble PROGRAM_ERROR: bad data
alr @lyric mesa goof ball
so how the hell do i fix that code tower
i have no idea 😭
fired

found that goof baller
comma is ,
you piece of meat matter reactor
awww here it comessss🙏
btw @lyric mesa whats flake essentials id
id? like the internal id?
Wait wait
ohh
So only 48 bits in a memory address are even considered, the rest are just padding by spec...
What if you put the semantics in there?
you could ig
11560673664
yh its still goof admin system
even cmdr would be better solution
indeed
why did i change my name in passport 😭
nice notification contents
:3
the notification interface is something i spent so much time on
wait, what?
heck there’s even a different version for mobile devices
actually? is this a C spec or x86
nah im not buying iphone 69 pro ultra max+++ to preview it 😭 (i am)
the roblox studio emulator in question
scaling is 😍
good enough
flake was gonna have an overhaul before i cancelled the project, this being one of the ui concepts 😭
"we truly live in an age of wonders..."
*something censored*
it’s a spawn location 😭
the world is blurred behind the ui
i cant see what i type 😡
emulator moment
i wonder if i had same ping and fps in qserf 😭
but in fact i get 45fps (drops down to 8fps) and ping always atleast 700ms
btw why theres still unions in qserf dawg😭
they make my eyes blow up
oh so thats why my pc produces 120 dB of sound while in f9 area
am i skill issued 😭??
x86
oh no 48 bits was the gdt right
52 bits was the gdt
oh wait nvm you can have that in pages
its definitely not 64 bits though
The address bus is the set of wire traces that is used to identify which address in memory the CPU is accessing. The number of wire traces in the address bus limits the maximum amount of RAM which the CPU can address. CPU Address Bus Sizes CPU Address Bus Size 8086 20 bit 8088 20
we love binary
it sounds prettty cool
looks like its for supercomputers/servers but
I read that it has memory thats faster than ram
aside from that i dont know much about it
i dont :<
😭
oo
what's that
raycaster v4
ah i see
is bro doing his math homework in lua
looks like room for yall in hell
too much noise smh
holy shit
@spare quartz yoo
from the intel x86 programmers manual
addresses are supposed to only be 36 bits wide
lmao
so you could say amd is out of spec maybe??
oh but thats physical address size
also if it does not support IA-64 (which i assume now refers to x86_64)
im pretty sure thats for itanium
yeah its called ia-64
which looks like a cool arch but they never really got anywhere
because of compilers
crazy shit
imagine if we didnt get gpu's because our cpu's oculd so so much parallel math cuz of itanium
I still see software renderers that dont use sse (which came out in the late 90's!!)
funnily enough i saw a CPU rasterizer on twitter early today
ran at nearly 60fps with 2k tris of terrain geometry (untextured), but im pretty sure they didnt use any form of SIMD/vector extensions
damn
cpu > gpu
they should replace those vector extensions with how unused they are lol
idk... sometimes having 2000 crappy cores is better than 8 good ones
oh wow
but they arent doing matrix multiplication in one cycle I dont think
like what the cpu vector extensions say they do
well it does say Single Instruction Multiple Data
not Single Cycle/Microcode Multiple Data
waaah
if RDRAND taught me anything certain instructions are reallly crappy on speed
oh shit doesnt that take like 200 cycles
crazy that it isnt even for security and intel cant make a fast random number generator
a single RDRAND or RDSEED instruction takes 110 ns, or 463 clock cycles, regardless of the operand size (16/32/64 bits).
holy shit
yeah lets just throw intel and amd out the window with what they are coming up with
oh yeah did you hear about the x86 cortsortium they're making
On an AMD Ryzen CPU, each of the instructions takes around 1200 clock cycles for 16-bit or 32-bit operand, and around 2500 clock cycles for a 64-bit operand.
nope
god
would be absolutely crazy though
they better start from scratch with like x88 or something lol
woah linus is in it?
yeah
oh this is a business move to get x86 usage up by making the hr's of all these companies force x86 in every environment
cuz they normally just use risc-v or some ti arm for embedded
honestly i couldn't care what arch stuff uses since it's a moot thing today
but as long as they're doing stuff with it i guess its fine
I mean x86 is really kinda weird for embedded shit
you haved to make all these tables and shit using bad documentation
yeah it's quite large compared to something like risc v
what they really haved to do is make a ton of stuff optional and easier to use
efficiency wise iirc it's about the same; just costs differ
like wtf was with the gdt having address bits in different places on one entry
yea
raaah intel and amd need to fix x86 raaah
its so cool but its so needlessly complex and bloaty
lmao
complex instruction set computer consortium 1:
Lets make it so they cant do 128 bit math on the 128 bit registers!
me when i store strings on the 256 bit floating point registers 😎
fr thats exactly what i fucking though of when I first heard about it 😭
"holy shit I can store so much text"
fucking lost opportunity
I remember when I found out about them trying to figure out how to store a disc sector on them
WHAT THE FUCK IS THIS @spare quartz
wrnog picture
WHAT THE FUCK IS THIS @spare quartz
segmentation is disabled so no gdt??/
design i cant understand yet 👍
lol
man I should have probably made an effort earlier to read through the intel manual
im learning a fuck ton of stuff
like theres an entire register dedicated to debugging
why tf is there only descriptions of the gdt instructions but not the table in the intel x86 programmers manual
theres one with a link to "see gdt" and it goes to chapter 1
after 10 minutes ive only found 2 references to gdt, one just explains how it works in reference to everything else and the other explains that it has entries....
nothing on what the entries consist of
volume 3 chapter 3.2.1 and chapter 2.4 reference eachother as having the format for the table entires but they dont
osdev cites chapter 2.4 as a source
osdever cites chapter 3.2.1 as a source
wow
2.4 only says what the loader register thing is
FOUND IT
FIGURE 3-8
my god man
it doesnt have its own chapter for some reason its lumped in with the segment register (es, ds, cs...) chapter
its in 3.4.5 nvm
no fucking wonder it took so long for me to find this half the document wasnt even loaded
(you are unfunny)
meh
Cry
bruh
I was making pagetable for my bootloader
uint64_t pml5[512];
// make all memory rwx
void setuppageing() {
for (unsigned int loop=0;loop < 512;loop++) {
pml5[loop] = 0x1 || 0x2 || 0x8; // present, writable, writes go directly to memory
}
asm("mov cr3, %0" : : "r" (pml5));
}
``` this scares me
why does it work
and why does it freeze
oh its not working at all its just frozen
wait
how do you disable 5 level paging
if to disable 5 level paging you haved to change cr3
but to change cr3 you need to disable 5 level paging
whar???
notepad as an IDE is over
Nooooo
I mean notepad on Windows 11 is really shit anyways
honestly i think its perfectly fine for simple stuff like
and you can even uninstall this for the system notepad
but AI?? just give it a break will you??
For me Windows 11 notepad is really laggy and takes forever to do things
ah
Win10 notepad meanwhile I learned to code with that it was snappy asf
yeah thats system notepad
dunno when it was originally made, but its looks were from 7+
timeless
C:\WINDOWS\notepad.exe 🙏

its even still got the original icon
The original icon is such a sigma
if you have the MS store version installed tho it redirects to that
The one with the tabs?
yeah
Really I can uninstall that one hol up
Won't let me uninstall it
oh
My god man no wonder Windows is losing out everything is fuckin laggy
Still better than Linux
At least things run
Bro that's the one problem I havent had lol
Everything just runs after it's installed
degeneral..
#include <stdio.h>
void selection_sort(int *arr, int len)
{
for (int i = 0; i < len; i++)
{
unsigned int least_index = i;
for (int j = i; j < len; j++)
{
if (arr[least_index] > arr[j])
least_index = j;
}
int temp = arr[i];
arr[i] = arr[least_index];
arr[least_index] = temp;
}
}
int main(void)
{
int arr[] = { 5, 3, 4, 1, 2 };
selection_sort(arr, 5);
for (int i = 0; i < 5; i++)
{
printf("[%d] = %d\n", i, arr[i]);
}
return 0;
}
selection sort
selection sort
c my beloved
we dont need safety we need a more modern c that gives more control, raaah!
aye aye here's your toy language
// page map level 4
uint64_t pml4[512] __attribute__((aligned(4096)));
// page directory pointer table
uint64_t pdpt[512] __attribute__((aligned(4096)));
// page directory entry
uint64_t pde[512] __attribute__((aligned(4096)));
// page directory pointer table (program)
uint64_t pdptk[512] __attribute__((aligned(4096)));
// page directory entry (program)
uint64_t pdek[512] __attribute__((aligned(4096)));
#define rw 1U | 2U
// make all memory rwx and mapped to its physical addresses, so its easier to manipulate
void setuppageing() {
// map everything to physical memory
for (unsigned int loop = 0; loop < 512; loop++) {
pml4[loop] = ((uint64_t) pdpt) | 1U | 2U; // level 4 (512 gigabytes)
pdpt[loop] = ((uint64_t) pde) | 1U | 2U; // level 3 (gigabytes)
pde[loop] = loop<<21 | 1U | 2U | 1<<7; // level 2 (2 megabytes)
pdptk[loop] = 0;
pdek[loop] = 0;
}
struct limine_kernel_address_response kra = *kernelrequest.response;
// map this program so it doesnt freeze when loading
pml4[(kra.virtual_base & ((uint64_t)0x1ff << 39)) >> 39] = ((uint64_t) pdptk)| rw;
pdptk[(kra.virtual_base & ((uint64_t)0x1ff << 30)) >> 30] = ((uint64_t) pdek) | rw;
pdek[(kra.virtual_base & ((uint64_t)0x1ff << 21)) >> 21] = kra.physical_base | rw | 1<<7;
uint64_t physical_pml4 = kra.physical_base + ((uint64_t)pml4 - kra.virtual_base);
// load page table
asm volatile ("mov cr3, %0" : : "r" (physical_pml4));
}```
hell yeah
it works
except it page faults on nop for some reason
man this is making me want to use eufi instead 😭
figuring out how i wanna represent these types
if only 0x7F was included...
i could just make it a VCHAR .. 0xFF with a predicate but that feels bad
wait oops thats for field-vchar
there we go
WTF are you even implementing
HTTP
this is my full type sheet
i rummage around RFCs to get a list of types and implement from there
realistically field-line/value/content aren't possible to put in a type and OWS/message-body are already typed out
just need to put in a field array in the abstract message and start parsing
there
oops
Message_Body can't be a not null access cause String requires at least 1 element
plain access
what's this
super long typing
markup language for receipts
#1101168449855684678 message
stupid language
smh
h ow .
good news is that http thing is partially working
bad news is
i wrote the actual "server" code in 1 minute
so it don't work
i wonder how many libraries i'll break because i removed the optional whitespace after the header
or... field
they're called fields
all of them 
should've read the spec then!!
OWS -> Optional Whitespace
field-line = field-name ":" OWS field-value OWS
i care about my data microoptimizations..
guess the programming language ```ansi
[2;34mxLoop[0m: [2;31mfor [0m([2;31mconst [0mx [2;31mof [0mxs)
[2;34myLoop[0m: [2;31mfor [0m([2;31mconst [0my [2;31mof [0mys)
if (x == [2;34m3 [0m&& y == [2;34m5[0m)
[2;31mbreak [0mxLoop;

@timid quartz AAAA
SCREW YOU
I translated like 60 images of Japanese text and now google GLOBALLY thinks I’m Japanese
Now I see English comments and it asks “click to translate to Japanese”
lol
NOT AGIAN 😭
im trying to make a chat thing raah
except with peers instead of servers
(I have made no progress)
TCP is super easy to accidentally make into chat its so weird
thankfully that http server is now somewhat working
for some reason I wanted to make a replacement to tcp
that had built in encryption and shit
what were you planning to encrypt
data cuh
well, yeah, but TLS does that
if you want something else you've gotta have a reason
ooo whats that
oh tls is ontop of tcp
I meant like a complete replacement to tcp
TLS and SSL do not fit neatly into any single layer of the OSI model or the TCP/IP model.[4][5] TLS runs "on top of some reliable transport protocol (e.g., TCP)
wikipedia
I meant like replacing a transport potocol
so you want to encrypt the packet data
that'd be weird to impl
yeah
mm
the only packet level i'd see fit to "encrypt" is IP, but
that comes with a lot of problems
I cant imagine
like uh
say you wanna encrypt a source/dest ip and ports cause you're paranoid or something
how do you... transport that
you dont lmao
yeah
would haved to make a new ip protocol
unless you like,
send an initial handshake to negociate a connection, generate IDs for each side for each packet, and like
send data with that connection using the IDs as a src/dest... but that sounds like weird tcp
it would be a weird tcp tahts the entire point of it
it s just a different transport protocol thing
mmm
wait are ports even part of ip
i wonder if theres encrypted udp
tlsudp
uhhh i actually forgot...
the wikipedia page said tls has a similarly named cousin that works with udp
time to read the rfc raaah
yeah i guess the ports are decided on the type
and the addresses are exactly 32 bits
ipv6 wont be different
v6
doesnt ook different lol
lot less flags
ipv4 doesnt even use the flags
or maybe the depiction is just grouping them up
i should play around with the RAW socket option one day
yeah ik what raw is
apparently not even recieving a packet is common
hence why tcp exists lol
trying to look up references to it in this library (gnat sockets)
theres this one setting in specific...
there you are
no clue on how to use this enum but its there
ah
that sounds like a pain... then i remembered local networks exist
local messaging interface would be cool to make
well its for cables im guessing
like sending data directly over ethernet
without ip
or usb
idk
yeah i was thinking more along how datacenters/supercomputers do it
they all pass messages to each other with this weird protocol instead of IP
The Message Passing Interface (MPI) is a standardized and portable message-passing standard designed to function on parallel computing architectures. The MPI standard defines the syntax and semantics of library routines that are useful to a wide range of users writing portable message-passing programs in C, C++, and Fortran. There are several o...
ooo thats cool
lmao the articles 2 versions out of date
💀
oh yeah
on twitter again... someone compiled a minimal (assumed, they didn't show/cat the code they used) C main and apparently it called like
834* syscalls
despite doing literally nothing
the trustworthiness of the person isn't really too high though since they're blaming it on C instead of their compiler/stdlib
lol
well I mean you haved to get the arguements
thats a syscall
true, but it shouldn't need that many just to get argv
heres the pic they showed
oh they did cat the code they used huh
i wonder why their stdlib is so screwed
its probably calling mmap for every page
cuz theres also 100 mprotect calls
idk what mprotect is though
if i had to guess locking a page?
oh it sets if its user or not
oh
also getrandom being there is super weird
a buncho f bootloaderes randomize memory, I dont know if theres some security reason for that
oh yeah spectre
yeah but this is an empty main on a usermode env
higanbana:~/c $ echo "int main() {return 0;}" > main.c
higanbana:~/c $ cat main.c
int main() {return 0;}
higanbana:~/c $ gcc main.c -o main.o
higanbana:~/c $ strace -c main.o
strace: Can't stat 'main.o': No such file or directory
higanbana:~/c $ strace -c ./main.o
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
52.09 0.000137 17 8 mmap
20.53 0.000054 18 3 mprotect
13.31 0.000035 35 1 munmap
2.66 0.000007 3 2 close
2.66 0.000007 7 1 prlimit64
2.28 0.000006 6 1 arch_prctl
2.28 0.000006 6 1 set_tid_address
2.28 0.000006 6 1 rseq
1.90 0.000005 5 1 set_robust_list
0.00 0.000000 0 1 read
0.00 0.000000 0 1 brk
0.00 0.000000 0 2 pread64
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 2 openat
0.00 0.000000 0 2 newfstatat
------ ----------- ----------- --------- --------- ----------------
100.00 0.000263 9 29 1 total
blank program for me
wth is up with that guys stdlib lol
ohh
which is weird af considering their argument is to "use zig"
android is really fucking weird lol
lol
I tried zig
the documentation is everywhere but I kinda liked it
I wish the memory management was easier though
oh you just reminded me
apparently ada has no clear automatic memory management
objects will still be finalized, but never "freed from memory"
(barring Unchecked_Deallocation..)
I mean if its not being used as much as possible thats a red flag
as much as everything is clear in ada, how the memory is managed is... very arcane and not very well documented
lol
for example the Ada RM says a compiler can have a garbage collector
but for the last 40 years no compiler has ever added one
well I mean they are slwo
oh neat
im gonna be gaming on tuesday when I get to school lol
hope my teacher doesnt find it suspicious that my pc is running full games
and doesnt show up on the supervisor thing
wait now I wonder
if i made a old style game that booted from a cd or something
would be even funnier if it was 3D
GNU nano 4.8 /bin/buildAda
PROJECT=${2:-${PWD##*/}}
gnatpp -P$PROJECT.gpr -U; alr build --profiles=*=$1; sudo bin/$PROJECT
a command i made to automate building easier
just posting here in case i lose it
gnatpp - lints/formats ada code
alr build - builds code (incl. libraries) under a profile like validation
sudo bin - lets me run built applications that might require admin for testing (i.e. servers)
gnatpp needs to run before alr build cause "validation" will crash on all warnings* (including style)
ok
nice
It’s more explicit which is nice
While still protecting you from foot guns
What is any application level protocol but a chat
HTTP, SMTP, BitTorrent, you name it
just a really sophisticated conversation
must be how those woke radical groups communicate, we must filter all traffic manually
to destroy the woke movement
well you got me there
@spare quartz
with Ada.Text_IO; use Ada.Text_IO;
procedure Ada_Select is
type Array_Type is array (Natural range <>) of Integer;
Arr : Array_Type := (5, 3, 1, 4, 2);
begin
for I in Arr'Range loop
declare
Least_Index : Natural := I;
begin
for J in I .. Arr'Last loop
if Arr (Least_Index) > Arr (J) then
Least_Index := J;
end if;
end loop;
declare
Temp : Integer := Arr (I);
begin
Arr (I) := Arr (Least_Index);
Arr (Least_Index) := Temp;
end;
end;
end loop;
for I in Arr'Range loop
Put_Line (I'Image & ": " & Arr (I)'Image);
end loop;
end Ada_Select;
huh
selection sort
my friend is a TA for a data structures & algo course
so I speedran it in C
and then Rust
and then wanted to try Ada
fn main() {
let mut my_vec = vec![5, 2, 3, 4, 1];
selection_sort(&mut my_vec);
println!("{my_vec:?}");
}
fn selection_sort<T: PartialOrd>(arr: &mut Vec<T>) {
for i in 0..arr.len() {
let mut least_index: usize = i;
for j in i..arr.len() {
if arr[least_index] > arr[j] { least_index = j }
}
arr.swap(i, least_index);
}
}
rust
#include <stdio.h>
void selection_sort(int *arr, int len)
{
for (int i = 0; i < len; i++)
{
unsigned int least_index = i;
for (int j = i; j < len; j++)
{
if (arr[least_index] > arr[j])
least_index = j;
}
int temp = arr[i];
arr[i] = arr[least_index];
arr[least_index] = temp;
}
}
int main(void)
{
int arr[] = { 5, 3, 4, 1, 2 };
selection_sort(arr, 5);
for (int i = 0; i < 5; i++)
{
printf("[%d] = %d\n", i, arr[i]);
}
return 0;
}
c
@spare quartz
I think the rust one is quite nice
In mathematics, especially order theory, a partial order on a set is an arrangement such that, for certain pairs of elements, one precedes the other. The word partial is used to indicate that not every pair of elements needs to be comparable; that is, there may be pairs for which neither element precedes the other. Partial orders thus generalize...
basically a set of things that can be compared
Oh
i figured i just didn't know what it was at first
ada has operator overloading right
</> are defined by Scalar types in ada... iirc
yes
so you could make a record and operator overload for that record right
to compare the records
yes
ok
you can't overload rem/mod though :<
it's not a trait but it's better than nothing
can overload the remainder operator in rust too
i know limited gates assignment
wait so you can overload (abs) and (mod not (or rem xor))
what a weird boolean expression
the (or rem xor) isn't even valid
no lhs
and the not is in the wrong spot
im PRETTY SURE they just forgot a few commas
I think they meant (abs) and (not mod or rem xor)
so you can overload abs
and whatever not mod or rem xor evaluates to
evals to nothing since the righthand of xor is blank
"not mod" too... unless mod were like, a value
well, okay, technically
assuming the right hand of XOR being blank means 0
that means rem stays the same
anyways
struct A;
struct B;
struct AB;
impl std::ops::Rem<B> for A {
type Output = AB;
fn rem(self, _rhs: B) -> AB {
println!(":3");
AB
}
}
the humble function "rem"()
and then that lets you do
so many
let a = A;
let b = B;
let res = A % B;
oh yeah i forgot ada's exponentiation operator is **
i wonder what ^ is used for.. if anything
that's not remainder!!!
it is in rust!!!!
thats stupid!!!
that's gross
int arr[] = { 1, 2, 3, 4, 5 };
int elem = 2[arr];
bet you can't do THAT
EW
WHAT SI THAT
i mean technically thats a thing in ada (barring accesses)
it involves use of System.Address though
(You’ve (never (seen (lisp)))?
The PROGRAMMING LANGUAGE dummy
OHHH OVERGROWN MAKE
Though technically it’s a family of programming languages
There’s Common Lisp, Clojure, Emacs Lisp, and others
Is not
Lisp machines are general-purpose computers designed to efficiently run Lisp as their main software and programming language, usually via hardware support. They are an example of a high-level language computer architecture. In a sense, they were the first commercial single-user workstations. Despite being modest in number (perhaps 7,000 units to...
Is
Ada is overgrown make then 
how
nothing like make
more like overgrown pascal
neither is lisp
yes it is
nuh uh
that syntax is overgrown make
no it not
nuh uh
hopefully this doesnt crash the server
hmm
i think i can do this instead
uhjjggh
whar
'Access, 'Unchecked_Access, 'Unrestricted_Access
access types (pointers) are super heavily guarded in ada and basically i tried to circumvent a compiler check by throwing Unchecked at it
didn't work
lol
Shoulda just used Rust
Because… :3
rust
Idk there’s not this weird access stuff
RUST!!!
the reason im using an access-to-string instead of an Unbounded_String is cause i want to make sure the end user can't touch it
i COULD cop out but i dont wanna
Does mellow alert you every time someone says rust lmao
How would the end user be able to access it huh
i just check qsp often
the end user being the programmer using the HTTP library
But like how would they be able to access it
HTTP_11_Request_Message'Input (Stream).Target
Target is the access-to-string type (causing the problem)
Cant you just make target like not visible though
ic
i JUST realized
?
idk
In rust all I’d do is make the struct member not public and have a getter that returns an immutable reference
its cause im instantiating the Request_Message while String_Access can't be null
so it's creating the record and failing immediately
lemme fix that
yup
gotta be careful with not null access
struct Request {
target: String,
}
impl for Request {
pub fn get_target(&self) -> &String {
&self.target
}
}
It’s that easy
Just do the easy thing smh
access constant - RO access
access all - RW access
by setting it in the record instantiation
ic…
i could go the extra step and see if i can make Request limited but that seems too much
Or you could just have a &
que
Here
that's still using a getter which is not needed here though
not-nullable read-only access-to-string at instantiation is superior
Well rust doesn’t really support that
well make it support it
Unless you OnceCell it maybe
with an rfc or whatever you do
You could maybe OnceCell it
idk what that is
A cell which can nominally be written to only once.
This allows obtaining a shared &T reference to its inner value without copying or replacing it (unlike Cell), and without runtime borrow checks (unlike RefCell). However, only immutable references can be obtained unless one has a mutable reference to the cell itself. In the same vein, the cell can only be re-initialized with such a mutable reference.
For a thread-safe version of this struct, see std::sync::OnceLock.
though oncecell does allow for some interior mutability I think
mm
still a bit worried about this piece of code though
since the access would technically be invalid when it goes out of scope (but it shouldn't be gone)
yeah so it does allow for interior mutability if you own the value...
#[derive(Debug)]
struct MyThing {
target: std::cell::OnceCell<String>,
}
fn main() {
let mut thing = MyThing { target: std::cell::OnceCell::new() };
thing.target.set("hello".to_string()).unwrap();
let mut mut_ref = thing.target.get_mut().unwrap();
*mut_ref = String::from("goodbye");
println!("{thing:?}")
}
this outputs the changed string
MyThing { target: OnceCell("goodbye") }
but if let mut thing was just let thing then you couldn't .get_mut() on it
I think the better solution is just the getter
uh oh
If you really wanted to go the OnceCell route you could probably just have an immutable reference to the struct
But the non-public field with getter is probably more robust
This doesn’t look quite right
I’ll actually do the exe reader soon so I can challenge you to build something in Rust
finally something
ignore the weird key format thats just cause adas a bit confused on how to represent Token since it's an "array of characters"
there
fixed
new String'(x) apparently works
just need to parse the message body
who that
it gets you the read-only behavior you wanted?
Yeah
1.28 Mb of memory for a 50 threaded http server isnt bad right
so just type Target_Type is new String;
?
you said new string was enough
new String'(x) -> allocator
is new String -> type derivative of type String
Read_String_From_Stream is creating a new temporary string object which is then allocated and put onto an access by new String'(...)
what's there to be confused about
read string from stream makes temporary object I get that
and then it's allocated and put onto an access?
well i'm not gonna try and explain the inner workings but basically
an access type is created, assigned to Item.Target, which will keep track of the new string object instead of it being voided when out of scope
and what is String_Access 
access String?
ah ic
and new String'(x) coerces into an access constant String
gotcha
eys
hmmm... write-only access 🧌
im sure thats something you could do but it'd involve a lot more work
(and i don't know why you'd do it)
so like
to make a bad translation
new String'(x) outputs a char* (or a &String in Rust)
which coerces into a read-only pointer
yeah
oh yeah good news
this webserver is pretty OK at multiprocessing
i gave it 1,000,000 requests and it used 300% CPU at only 0.2% memory
(i have a 12 core cpu @ 64 gb of ram)
but now i need to add authentication and TLS,,,,
must use less cpu
no that's a good thing
i want it to use 1,200% cpu cause then that means it's using the threads to the best of its ability
Maybe it only used 300% because of the rate of threads dying to threads being made
the threads never die though
No no no but like
You make a new thread for every request right
Or a new Task rather
how do you even use 300%
By using 3 threads
300% across all cores
using 50 threads
Ok but
the load was balanced across all cores
You’re using 100% of 3 threads across all CPUs
i don't really understand still 😭
Like that’s what it amounts to
no
Like the work is spread across 50 threads but it only sums to 3 threads’s worth
pool of 50 threads, each time a connection is done it puts it back into the pool so its state can be set to the new connection (when available)
yes
So what I’m saying is
Maybe you weren’t spamming it enough
Because like the rate of requests incoming to requests being completed only resulted in 300% usage
So send more requests and send them faster
Like you eventually reached a steady state
Where you were at 300% usage
And the amount of new requests == the amount of requests being completed
So if you wanna get to 1200%, send more and send them faster
okay but theres gotta be limits to the benchmark software im using
That is also probably a factor
The one percentile was probably your first few requests
Cause you know, cold start
But once your threads were warm
ughhh cache is also probably playing a part toooo
would explain why initially it was 7,000 r/s while at the end of 1,000,000 requests it went up to 11,000/s
oops
i forgot to turn off the debug prints
holy crap
okay it got up to 500%
lol that would slow you down for sure
use this
!!
alright how do i use this
to make an http reuqest
uh curl
there's definitely a memory leak since i'm not doing deallocation whatsoever
but that's fine for now

throw this shit into valgrind
i know why its leaking memory (access types)
maybe this could be something to look into in the future
but I also thought ada didn't use the heap
not defined
but I also thought gnat didn't use the heap
see GNAT internals for how it's handled
eww gnat internals
Access-to-object types also have two kinds: access to dynamically allocated objects on the heap, and access to stack objects.
imagine ada not inserting calls to free() for you :3
i'd imagine the dynamically allocated Targets are the ones leaking the most
yeah because that's unsafe
either you never use access types or you use Unchecked_Deallocation
I smell foot guns!!!
of
rust does it :3
well you're encountering one right now with the memory leak
but what happens if you Unchecked_Deallocation and then try to use again
use after free :3
PROGRAM_ERROR, handled as usual
you can't segfault with ada pointers
there's 100% some way to exploit a memory vuln in ada
and this is expected
you can't
use after free isn't possible at all
not unless you use System.Address or Unrestricted_Access
both of which warn you out the gate
Unrestricted_Access ❤️
(p.s. Unrestricted_Access isn't defined in the Ada RM)
(only 'Unchecked_Access is, which you also can't segfault with)
but still just like
man
imagine your language not being smart enough to do memory management for you
because it's not possible
- we do not have your silly borrow checker
- ada has not had a GC in any compiler for 40 years
and AGAIN
this literally only applies to accesses
no I was saying that those things are smart enough to do memory management for you
(GNAT-specific accesses!)
whereas ada isnt ;3
i'd like to see you tell me a way to auto manage accesses safely then
borrow checker
not how accesses work
an access is basically just a fancy pointer
and a reference is also a fancy pointer
case closed
yes but the way they're defined makes a borrow checker impossible
can't
ada 2024 edition
what is a String_Holders.Holder
package String_Holders is new Ada.Containers.Indefinite_Holders (String);
ok but what does it do
english
it holds something


