#🪅-progaming
1 messages · Page 44 of 1
xdddd
i wonder if paper dev team have any plans on reworkign this
since they hard forked
are recursive structs considered a bad practice? not sure what would be the better approach for a file tree
(ignore the lifetimes, i have nfi what these are, just used 'a so rust-analyzer stfu
i mean how else do you want to do this
Nah they're fine, though in this instance a Vec<String> would do the job better
dunno
for parent or wdym?
i really want to rewrite my jvm parser from ground up
the naming is odd. what exactly is Entry.folder? the folder the Entry is in?
fuck it im doing it lol
yep. this is just a poc (actually it doews't even have any impl) yet
folder: Vec<String> has exactly the same set of values
is there anyone knowledged in avr libc? i know it has malloc/free fucntions, but do they work as i expect them to do? or do they behave differently?
The only issue with recursive structs is memory fragmentation and non sequential reads but that probably isn’t a problem here.
weird design
oh true. also i guess i can use [string] here insteaf of vec<string> for the sake of uh smaller struct?
inconsistent
[String] is unsized though so it's kinda inconvenient
why. i don't really get what's so wrong about it. or do you mean just the naming or
not sure what any of that means tbh lol
why is there both Folder::parent and Entry::folder
this makes no sense
why are you differentiating between folders and files like this instead of using the same struct
also you should name it Directory instead of Folder
i thought someone was going to tell me so 
i'm a proud windows user
ig i can just do it like uhhh so?
struct Entry<'a> {
name: String,
bytes: &'a [u8],
path: Vec<String>,
}
windows calls it directory too https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory
what is bytes in this case
either it should be path: String or path_elements: Vec<String>
storing a Vec as path is unintuitive
(you could also use a PathBuf)
oh it was supposed to be the raw file data in bytes but then i remembered that i should NOT make each file struct has megabytes of the data
i forgor
so now it's..?
why can't you just store the entries as names and paths and then load them as needed
i have no idea what's going on to be fair but that's what i would do 
i want the entry struct to have the begin address and size. i'm building a winrar-like app but for a proprietary file format used for storing game assets
It’s not applicable here as far as I can tell but when you have a struct that contains a list of structs (generally) each sub struct will be its own memory allocation and will fragment along with other allocations the memory allocated to the process artificially boosting the memory usage.
If you want to read all the data sequentially instead of storing just a list for each property you must do 2 pointer dereferences and due to not being linear the compiler cannot make any SIMD optimizations.
Here neither apply. Just logically it’s weird
"the begin address and size"?
i'm assuming you mean the beginning address and the filesize?
yeah. i can send the explanation from the prompt i asked chatgpt (i was so lost i had to ask chatgpt how to reverse engineer the file format)
I’m reverse engineering a proprietary
binary file format used for storing game assets. Well, there are actually three different files:
bigfile.bfn— used for storing file names and file tree. The structure is the following: first there are 4 bytes (u32) that represent the size of the folder’s name. Then there is the string - the folder’s name - that has that many amount characters as the u32 we just got. After that we have another 4 bytes (u32) that represent the amount of files in the folder, let’s call itfiles_len. After that there arefiles_lenamount of the following structure: 4 bytes (u32) that amount of bytes that represent a utf-8 file name. Then there’re another 4 bytes (u32) — the amount of subfolders in the folder we’re in. And the cycle repeatsbigfile.bfdata— the biggest size-wise file out of these, which as could be guessed contains the binary data for the files from the previous filebigfile.bfdb— the least researched file which, it seems, should link the file names with the binary data they contain. The issue is that I haven’t managed to reverse engineering it yet. I decided to pick one file frombigfile.bfnand found the address and size of the binary data it has inbigfile.bfdata. The way I could confirm that this file name exactly links to this data is by using binwalk. It shows which files are contained in the file’s binary by searching for signatures and magic bytes. That way I could find all the PNGs and I decided to take the last one, thinking that the order of files inbigfile.bfdataandbigfile.bfn. I was correct. That way I had the matching file name and the data it represents. Searching for the address of the file’s name frombigfile.bfndidn’t get any results inbigfile.bfdb. But searching for little-endian byte representation of the address of the file data was successful and just 8 bytes before it I found LE-bytes that represent the size of the file data.
this already exists in the stdlib, looks to achieve what you have here already? you can directly call readDir and then handle it that way: https://doc.rust-lang.org/beta/std/fs/struct.DirEntry.html
Entries returned by the ReadDir iterator.
chatgpt?????
yes 
i was like at the final step of finishing reversing this file format but i couldn't find the way to link file 1 and file 3
Things with big fancy trees like compilers often use fancier things than boxes, but for casual stuff it's fine
also i wonder what would be better:
- store the beginner address of the file data and the filesize in the entry struct
- store the beginner address of the file data and the final address in the entry struct
- don't store these in the entry struct, instead read it from file 2 when extracting the files from the 'archive'
so you're reading out of the file into your own structs and not from an file system
yes, these files/entries do not actually exist on the uh machine
i have an idea - what if i just look at the implementations of already existing archive managers made in rust
(async () => {
// Get the token using Vencord
const tokenData = Vencord.Webpack.findByProps("token");
const token = tokenData?.token;
if (!token) {
console.error("Token not found.");
return;
}
console.log("Using token:", token);
// Set headers
const headers = {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
};
// Make the GET request to the Discord API
const response = await fetch("https://discord.com/api/v9/users/@me/relationships", { headers });
// Handle the response
if (response.ok) {
const friends = await response.json();
// Filter real friends (type 1 = real friends)
const realFriends = friends.filter(f => f.type === 1);
console.log(`You' have ${realFriends.length} friends!`);
} else {
// Log full response for debugging
const responseText = await response.text();
console.error(`Failed to fetch friends: ${response.status} - ${responseText}`);
}
})();
i wrote this for #📜-js-snippets but i cant quite get it to send my friends i have
I have a valid token and i have a python equaivlent that fully works
i don’t have much experience with this but i don’t really think you’re supposed to manually write the headers, extract the token and send the request that way. i’m pretty sure there are helper methods inside either vencord or discord that do all that stuff for you
Hmm wdym ? do you know of these helper methods?
from reading a few snippets i assume it's this
ofc replace the body with the needed endpoint
that seems to work
Got it
(async () => {
// Use Vencord to fetch the relationships (friends list)
const response = await Vencord.Webpack.findByProps("getRelationships").getRelationships(); // Using Vencord's helper function
// Check if the response is an object and contains the friends list
if (response && typeof response === 'object') {
// Count the number of real friends (type 1)
const realFriendsCount = Object.values(response).filter(f => f === 1).length;
console.log(`You have ${realFriendsCount} friends!`);
}
})();
macro
Here's a valid reason to be scared

Horror
doing raw http requests should probably be a last resort
Y
Damn you cant nest pseudo-elements

hes just chatting sh*t tbh, this aint raw, its using fetch lmfao i dont think he knows code
Nope, he's right, thats a raw request. He should use discord clients api to get the relationships
erh depends if hes doing this for bot or user token
but yk better
Only users can have relationship
Wonder if you can do it with nested selectors
In bed
tfw rust’s from_ne_bytes is just transmute 
well I mean, what else are they supposed to do
yk
i’m pretty sure it can be done without unsafe code like so:
fn read_u32_be(bytes: &[u8]) -> u32 {
((bytes[0] as u32) << 24) |
((bytes[1] as u32) << 16) |
((bytes[2] as u32) << 08) |
((bytes[3] as u32) << 00)
}
how to handle ne to current endian
?
from ne bytes
if cfg!(target_endian = "big")
read_be_u32()
else
read_le_u32()
blehh too much of a hassle
safety ensured anyways because it's enforced by type system
i mean that cfg! part is literally what from_ne_bytes does ?
oh wait no
poo language
or yes
I love not having to copy paste all of my function signatures to header files for it to be able to be used elsewhere
I actually have no idea what the code for from_ne_bytes is
header file is the first thing you do bruh
then you implement it inside C file
its not that hard
also, you can just directly define it inside .h
ok but like, what if I don't need to do that
also idk what funcs I'm going to write exactly before I start writing it
I'm like
"oh yeah I should separate this out"
then I have to copy paste to headers
annoying
just use extern bro
mid
Wouldn't surprise me if part of the reason for using transmute rather than bit stuff is that it makes it easier to generate the impl for all types with one macro
to_bytes.rs: Line 94
fn from_ne_bytes(bytes: Self::Bytes) -> Self {
to_bytes.rs: Lines 94-100
fn from_ne_bytes(bytes: Self::Bytes) -> Self {
// Safety: transmuting between vectors is safe
unsafe {
#![allow(clippy::useless_transmute)]
core::mem::transmute(bytes)
}
}
yeah that's true as well
i have a crazy idea
what if i try to implement my parser in zig instead of rust 
zig seems surpassingly good for doing these kinds of things at first glance
Hi sorry what do you think? Would you like to try this, like we do with the filters for voices but to change the sound of the headset, for example, we would have a surround button, a bass boost button, a rock button... etc. all with a menu on the headset icon, so nothing to do with it and it would be a full plugin because it is not integrated as standard.
@woven mesa wondering how i should document modifiers on ddbkit docs in a way that isnt like a wall of text and unreadable
I tried tables but uhh..
yeah
you mean unlike the wall of text i wrote
idk
no the joke is i wrote a wall of text
I am thinking i might just hint at modifiers' existence via example codeblocks which i am already doing and i think it might work fine
im not sure if people will try to rely on xcode autocomplete or not because some might ignore that lol
I would heavily prefer to just not document them because of how self explanatory most of them are but i don't know..
I wish ddbkit server wasn't so dead so i could ask for input
zig experience:
create a variable
code won't compile because oferror: local variable is never mutated
make the variable a const
code won't compile because oferror: unable to evaluate comptime expression
like ??????
oh i think i get why that happens
why is zig so damn hard
like it builds fine
i run it
and i basically get "it failed, idfk why"
(it's a thing in zig too)
Oh, you want to use _ = functionWithUselessReturn();
You must use local variables.
it's p bad as i know nothing about zig, i just read the features page and sample page, but i was expecting the compiler to help me
const std = @import("std");
pub fn main() !void {
const file = try std.fs.cwd().openFile("C:\\Program Files (x86)\\Steam\\steamapps\\common\\KarmaZoo\\resources\\cookedData\\bigfile.bfn", .{ .mode = .read_only });
const reader = file.reader();
try read(reader);
}
pub fn read(reader: std.fs.File.Reader) !void {
const folder_len = try reader.readInt(u32, .little);
var list = try std.ArrayList(u8).initCapacity(std.heap.page_allocator, folder_len);
defer list.deinit();
try reader.readAllArrayList(&list, folder_len);
try std.io.getStdOut().writer().print("{s}\n", .{list.items});
}
ig it's something with the list
Do you have IntelliJ?
i'm using zed but like i do have other jetbrains' ides
Or RustRover better if on Windows
Yeah.
Get that, and the ZigBrains plugin
(I am biased as my bestest friend ever made it)
This, plus zls
zls needs to be version matched with zig
I usually just use latest upstream for both
done
i think i'm using tagged version of zig as i didn't figure out how to use nightly
You'll prolly need to for zls to work, I think the plugin can help with that
I can get on computer in a bit, can u vc or nah?
i can just listen if it's fine with you 
Perfectly valid
i can't guarantee that i'll actually start using zig, but if you don't mind it, i'm down to learn something new
let me quickly connect my headphones
i looked in quickCSS for something to hide the nitro emojis on reactions, but i couldn't find anything besides just making the nitro bits less flashy. the problem is that anything below what's hidden doesn't want to render properly, does someone have any ideas?
or do i go to theme development for this kinda stuff sorry idk
Cssing lazy-rendered lists usually doesn't work well
would i need to do javascript then?
https://github.com/Kyuuhachi/VencordPlugins/tree/main/Anammox does that, among other things
thank youuu
<script>
const volume = persisted('volume', 0)
$: exponentialVolume = $volume ** 3
</script>
<video bind:volume={exponentialVolume} />
did i ever mention how much i fucking love svelte
just for shit like this
wtf is that syntax
would anyone know or be able to help me make it so i can get notofications on my phone from discord dms while still being online and ac tive on my pc? like no idle delay etc
svelte!
its peak
compiler level reactivity is peak
TLDR updating volume in any way, automagically updates the exponential volume
so i can do $volume = 0.05
and it becomes 0.000125
in the video
and persisted just syncs it with storage, so localStorage or idb
so i can have peristent variables
let volume = use_state(|| 0.0);
let exponential_volume = (*volume).powi(3);
let onloadedmetadata = Callback::from(move |e: Event| {
if let Some(video) = e.target_dyn_into::<HtmlMediaElement>() {
video.set_volume(exponential_volume);
}
});
html! {
<video onloadedmetadata={onloadedmetadata} />
}
``` xd
jesus
case in point:
15% of a 5800x3d
on a single poor animation
this is why you should ONLY ever transition and animate transform and opacity
horror
wakatime has a vdp???
tryna run my multi-purpose discord bot 
ok
hop on the dev portal and enable all intents
you mean navigation button?
the shit on the side of ur mouse?
Browsers have a back button.
so navigation
i'm about to loose my shit
declare global {
interface MediaSession {
setActionHandler: (action: MediaSessionAction | 'enterpictureinpicture', handler: MediaSessionActionHandler | null) => void
}
}
BRUH
like why isnt this possible in typescript
you cant override already defined types
D:
declare global {
interface MediaSession {
setActionHandler: any;
}
}
what about & {}
yeah waht about it
1:1 same issue, you cant override
you can define new, but not override
lib.dom.d.ts takes priority over anything you'll ever do
// @ts-ignore
dogshit language
agree
easily: you don't
if you want to force types which are incorrect then youre in a wrong language
if you define interface X and interface X already exists you can define more types on X or redefine existing ones
you cant redefine existing ones
make a patch with bun
you can only append types to an existing interface
oh fun
make a patch with bun
had to do a forced asertion
setActionHandler: async (...args) => navigator.mediaSession.setActionHandler(...args as [action: MediaSessionAction, handler: MediaSessionActionHandler | null]),
but i dont like it
idk how one can look at this and go "yeah this is fine" https://github.com/ThaUnknown/jassub/blob/main/Makefile
its the type of code that you write once and then never touch it because it can break the whole build process
yeah
i wanted to add pthreads to that build config
gave up after like 3 days of work
justfile looks interesting though
@dense sand did ya see the animation perf i posted above btw?
yes
does that sound like a good idea to you

yes it does, because the default navigator types are often missing shit
esp if you're working with new chrome only apis
it would break type safety
i mean yeah
you clearly dont understand what i want to do
but that's fine
navigator.mediaSession.setActionHandler('enterpictureinpicture', console.log)
is valid code, but the default ts types are invalid
and erorr on it
in terms of language design i don't think they should add the ability to modify interfaces which are not yours
you can just use ts-ignore
and i'd argue using browser specific apis is bad
sure, for C or Rust it makes sense
but for a language where u can do Function.prototype = null
its not good design
typescript is meant to make things safer...
i have 0 idea how a screenshot of typescript marketing keypoints, relates to the fact that the default types for the language it provides are invalid an cant be fixed in any way
without forking the types and maintaining them yourself i guess
What is TypeScript? A pile of leaves that makes a shitpile invisible and even easier to step in
i assure you this image of david tennant has a profound relation to this topic
has anyone here worked with java xml validation and custom schemas?
im getting this weird error
may i ask why you are using xml instead of json
cause xml fits this better
Xml validation is the third circle of purgatory
would you use json for designing uis?
maybe
I would use whatever the ui library I use does
it fucking declared there, whats your problem 😭
java class name in attribute makes me worry about thiis api design
no i mean the class="org.jaibf.plugin.TestInventory"
oh thats ok
means it's using reflection....
and i fear what other things it's doing
i love refelction
it just brings back memories of eclipse plugin dev
horror
what's the point of duplication
Futile
I have never in my whole career seen a xml namespace do anything that could be remotely described as "work"
if i were to do this, i'd use a library that can just pass the ast of the xml and do everything else myself

wtf did i just found
Explore the causes behind the "Cannot Find The Declaration Of Element" error in XML validation and learn how to effectively troubleshoot this common issue.
Disclaimer/Disclosure: Some of the content was synthetically produced using various Generative AI (artificial intelligence) tools; so, there may be inaccuracies or misleading information ...
this is chatgpt answer rewritten into wall of text, rendered as a video published to youtuhbe
ai slop
@hoary sluice this is what i think kotlin feels like
what are you doing....
Horror java mvc
with reflection is crazy
How do you expect me to do DI
gu
?
lmao wtf
what the fuck is this
does anyone know any good local dns server
i dont want to use pihole to just redirect a few queries
@deep mulch zootie
i think theres one in Go thats really good
ive heard of unbound but the config for that looks scary
but i might go witht hat because it has nix support
i will give you shock therapy so you will hate nix
NEVER
you will never get me to hate nix
guhh
sorry to interrupt your.. whatever this is

i am stuck trying to think of a good system for persistent state in discord commands
database
use a discord message as the state
just update the message whenever the state changes
use discord search feature to find the message
i am trying to have buttons which remember some context about the command
i have no hands
i don't want to put the data in the buttons themselves
i have a custom TTLMap implementation
the data only needs to last a short time and not between restarts so db is pointless i think
db is being used for other things 
i just wasn't sure about a good way to structure things
wasn't sure whether i should do
run(context) {
context.set_state({ current_page: 0 });
context.respond({ components: [/* ... */] });
},
component_event(context, id) {
const state = context.get_state();
}
or
run(context) {
context.respond({ components: [/* ... */], data: { current_page: 0 } });
},
component_event(context, id, data) {
}
context is basically something which implement stuff relating to the context as well as a respond function
currently there is a SlashContext and a PrefixContext but i guess i'd need a ComponentContext as component responses work differently...
so it wouldn't actually be the same object
so maybe the former is a little weird
wait
better idea
just design the api naturally and hopefully the implementation will not be insane
run(context) {
context.respond({
content: "Press the button",
components: [{
text: "Click me",
callback: click_context => {
click_context.ack();
context.respond("You pressed me");
}
}]
})
}
(do you even need to acknowledge the interaction if you are editing the message anyway)
(also i forgot async+await lol)
i had an unsane idea for generating button customIDs
use URLs

moderation/ban?callback-id=0
Store everything in button id
You can use Base1114111
ehh no

that's cursed and sounds like a bad idea because you might forgot that you're storing the data in a button and accidentally leak something
guh why did it suddenly stop working
What do you rate my solution (in Java)
https://onlinegdb.com/G97XgM_Tq
Since #🗳-plugin-requests are closed, can I PR a new plugin?
PRing is always fine (but be prepared to be ignored for months)
thats okay
Plugin requests is fir begging without contributing
Well usually you first request, then triage then PR
according to the contrib guidelines my plugin should be fine, basically discord selects the last sent msg and if you sent a msg for which the server has not sent a response that it was posted yet, discord selects the last sent msg when you use the arrow key, extremly annoying. I want it to select the last sent msg, regardless of the server having replied yet. If it has not at the time of sending the PATCH, it should queue the patch, wait for the server to reply and then send the edit
seems like the extension's 0.2.2 broke it with the symlinks
working on fix
oh wait you're the one that made the issue
yeah lol
i think this might be related to https://github.com/zed-industries/zed/issues/20559
or maybe not
idk but there's a bunch of issues with LSP
i've only faced with this issue
it's so annoying
and for some reason the zed team doesn't really seem to work on a fix despite it being a really major issue
they're not working on windows
sad
there've been like 3 or 5 PRs attempting to fix that issue but all of them got closed because "it's not a proper fix"
like i'd rather have some fix than most extensions being broken
yeah
and the worst thing is that i'm not really sure like what to blame
like is it wasmtime's issue or wasi's issue or zed's issue
well it makes sense they don't want bad code in their codebase but it's still better than nothing and you can just add comment in the issue
i'm not so sure how exactly extensions work in zed, but it seems like it basically tries to execute the commands with wasm paths (prefixed with /) outside wasm runtime or whatever
because wasmtime can open /* paths just fine
https://github.com/lilnasy/zed-windows-builds here you can obtain builds that contains https://github.com/zed-industries/zed/pull/22600 patch
💀 amazing idea, let's modify std behaviour
that silly bug is stopping me from starting to use wakatime :(
yeah i can, it's just that i want to have a comfy way of managing it - currently by using scoop
i don't really want to like manually add it to path, to apps list, etc.
well yea understand
that's way easier on linux
like i have my own packages repository for pkgs that are not on void repos
so everything is managed by xbps
its not that hard
the hardest thing is to do it
i fully switched to linux like 2 years ago
i tried to move to linux (or at least get used to it) a year ago
i installed mint and it seemed good for the first two weeks
but then i just kinda lost any point in using it
so i was just booting in windows
they'd rather focus on an ai that people with fake jobs use
then ai to do the prompts
that's true lol
mint has the wrong phisosophy
they try to make it easier to migrate from windows by making it look similas to windows and super bloated
u need to install arch manually, without install scripts, get a tiling window manager and either delete windows or promise urself not to use it at all for a month or two
what the hell
my code worked
scary...
i literally only made one mistake and first time it worked
(just forgot to register event handler)
average day using rust
it's interesting how code made by copying and pasting other code works best usually
I wrote a Discord bot and when it was in production there were virtually no bugs and i was terrified

did u write it in rust
yes
crazy how i was able to guess that just from the fact that everything worked right away
in this case earlier i was using typescript
oh then ur lying
i was using rust for one thing but not another thing
how does v8 "know" not to garbage collect i 
does it just keep all variables loaded
or do that when there is an eval call
(as i believe that's the only function which can see local variables without needing to pass them)
using direct eval forces it to make a bunch of assumptions
ah
makes sense
thanks
now i can stop being paranoid about a few bytes extra memory usage
@valid jetty why is stdlib qsort only barely faster than random geeksforgeeks merge sort impl
with 1 million random numbers between 0 and 1 million
bc its supposed to be standard
works on all data
unspecialized
yea ^^^^
does it not optimize for ints if it sees ints
specialized ones probably have better pivots for the qsort
it will always be an int bestie
so unspecialized as in it doesnt specialize for specific ranges of ints?
also your input set is not integers lol
wdym
u cant read i think
i love mobile and outside
lmao
why tho
can u not define a sorting function for structs
you can???
that’s the point of the cmp thing in qsort it takes a comparator function
but that function still compares ints lol
but like theres radix sort which only works on large ints, i thought thats the kind of specialization u were talking abt
but like theres radix sort which only works on large ints, i thought thats the kind of specialization u were talking abt
i love having bad internet and sending msgs twice
yes
it takes in a void*
it cannot know it's an int that it's comparing
the only thing it does is call the cmp function on 2 elements every turn
^^^^
i made my own in elle xd
fn Array::sort<T>(T[] self) {
if self.is_empty() || self.len() <= 1 {
return;
}
__internal_qsort(self.elements, 0, self.len() - 1);
}
local fn __internal_qsort<T>(T *array, i32 low, i32 high) {
if low >= high {
return;
}
T pivot = array[high];
i32 i = low;
for i32 j = low; j < high; j += 1 {
if array[j] < pivot {
T temp = array[i];
array[i] = array[j];
array[j] = temp;
i += 1;
}
}
T temp = array[i];
array[i] = array[high];
array[high] = temp;
__internal_qsort(array, low, i - 1);
__internal_qsort(array, i + 1, high);
}
looks so good i need to learn elle....
@valid jetty is claude 3.7 neferious
i decided to try claude today but i didn't know it's literally fucking 10 free msgs a day or something
and unlike on chatgpt there isn't like free model that you can use without any limits
and the subscription is even more expensive than chatgpt plus
$30 a month
i guess i'll just keep using 4o(-mini)
im using chatgpt plus from a girl on snap rn
might buy claude again
yea cause they dont have 10 trillion dollars to burn from vc money
also what kinda annoys me a bit is the lack of any markdown in claude
i'm so used to it in chatgpt
it's kinda hard to read text in claude
@woven mesa you use uikit for ipod right?
I was wondering if you use a uikit navigation controller as well
trying to use any sort of collection view causes my swiftui navigationview to act strange
holy shit nevermind
.ignoresSafeArea(.all)
why does that work even
okay
why the fuck does a scrollview act so weird in swiftui holy shit
i finally added allocator switching to elle xd
yea
sowwy my mom had my phone
she was playing pokemon go
its okay
you will make a claude wrapper that adds markdown support
it's easy to do
just need to tell the ai in the prompt that it can use markdown and then well render it
sadly this won't fix me being broke as hell
does it not have a free tier
either i did something wrong or the free tier is only like 10 messages a day or every 6 hours
ohhh
you could try duckduckgo's frontend https://duck.ai
DuckDuckGo. Privacy, Simplified.
amazing 


use it inside zed
In zed you have 10$/month for free
i mostly use chatgpt for some coding stuff at school from my phone
i'm just often very bored there so i just read some code and ask chatgpt to explain some stuff for me
wtf does that mean
it means that the function is defined here
(you probably have an error or warn on a different line and it's misinterpreting extra info about it as something it should display)
is there a limit or something
that looks so ugly, but i hope it's fine
why is type not narrowing here...
emoji.name should become keyof icons, no?
(trying to make type checking stricter because i keep missing bugs
)
@spark tiger hiii
hiii hru
me too
that would be implicit conversion
there's no guarantee that emoji.name is a key of icons as far as typescript is concerned
which is meant to happen
i guess it only narrows the value on the right side
not the left
whar why doesn't that work
that's confusing
does it not check at runtime ??
if typescript was to narrow the type, the type of s would be keyof typeof a, when there are actually more keys which are just not required by the type
:3
what does the last part of your sentence mean
"there are actually more keys which are just not required by the type"
@placid cape you can finally switch allocators lol
(its logged after #free because i wanted to show that its just a stub for the gc and arena as you dont free like that)
you can also do --nogc to use arenas instead of a gc as the default allocator
i dont either really but i had just a little bit of time so i did it
took several attempts lol
Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <FLEXTableView: 0x115d26a00; baseClass = UITableView; frame = (0 0; 390 844); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x302513960>; backgroundColor = <UIDynamicSystemColor: 0x3030ae280; name = tableBackgroundColor>; layer = <CALayer: 0x302b64a00>; contentOffset: {0, 0}; contentSize: {390, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <FLEXHierarchyTableViewController: 0x11ec4b700>>
ok thanks bro
huh, then next i shall ask why const c: typeof a = b is even valid given that b is clearly not typeof a unless it somehow does some restriction thing such that you can only access the keys that a has
also audio explanation fire
nvm reheard and you did say this
because if you have a type like { a: string } it does allow other keys
but why
why is access like that even allowed
surely you should be forced to have typeof b to access b's keys
(i am coming from rust's typesystem for context)
it does not
indeed
no easy implicit casts unlike *script
you can do const thing: { a: string } = { a: "a", aijfkwajfjkwf: "aweiawejkewa" }
.unwrap() ❤️
only if you do { a: string } & Record<PropertyKey, any>
if let Some(x) = y
if you do this it lets you
the fact that typescript even has any is husk
it should be marked uhh
unsafe

and you still get autocomplete so its better than just Record<PropertyKey, any>
do you love that elle has any
hate
but that's specific to object literals
any
const a = {a:"eawewa", yormum:"afwjkwafkwajf"}
const b: { a: string } = a;
works
(i think)
var body: some View
(99.99% sure)
yeah i guess
what does this mean
my core point was
because if you have a type like { a: string } it does allow other keys
i forgot this doesn't work if you use the object notation
@austere anchor do you love
use std/prelude;
use std/allocators/arena;
use std/allocators/heap;
fn do_stuff<T>(T *allocator) {
#set_allocator(allocator);
$dbg(#env.allocator.kind);
ptr := #alloc(i32, 5);
#free(ptr);
$dbg(ptr);
}
fn main() {
$println("By default:");
$dbg(#env.allocator.kind);
$println("-".repeat(40));
do_stuff(HeapAllocator::new());
$println("-".repeat(40));
do_stuff(ArenaAllocator::new());
$println("-".repeat(40));
$println("Default allocator:");
do_stuff(#env.default_allocator);
}
but if you implement an interface in a class for e.g. yo ucan also add loads of _properties to keep internal state like i do
you can finally have temporary buffers and stuff

means apple is mad about you not recording this explicitly in NSPrivacyTrackingDomain
recording what tho
allocator pretty nice
before it was just GC lol
uhh whatever <private> is after u've managed to unhide it
fr
if you wanted to change it before you had to change the allocator at the time of compiling the compiler
@valid jetty does elle support no_std for embedded
yes
ellec foo.le --noalloc --nosm --nofmt --nostd
disables all
actually you dont need --nogc
if --noalloc is there it wont make gc anyway
although the issue is that it compiles to qbe lol
so youre not gonna be running it on embedded anyway
does qbe need an os or sumn?
is arm64 not for embedded?
eh most hobbiest stuff is just like arm64 or armv7 anyways
qbe doesnt have armv7 either lol
that should probably be added
probably hard
so many
lmao yeah
maybe in the distant future
it shouldnt be that hard tbh
just time consuming
consuming time i dont have
@austere anchor tiny spikes yippee
troller
i wonder if i can make more zero cost abstractions like this
why doesn't java abstract System.out.println to just println
lmao
meanwhile i decided io::println was too long and made aliases so you can do $println
among others
https://stackoverflow.com/a/29337429 oh this is so cursed
java went the other way and decided nothing is global
im about to chat spam
so apologies
but is this a good explanation
is there anything else i should have
♡ Allocators
Elle has a moderately complicated allocator system. Here's how it works:
- By default:
- garbage collection
- Using the
--nogcflag at compilation:- arena-based allocation
Changing the allocator:
#set_allocator(MyAllocator::new());
Resetting to the default allocator:
#set_allocator(#env.default_allocator);
Make sure you don't forget to free any memory leftover when switching allocator!
#set_allocatordoes not call thefree_selfmethod on the previous allocator when switching allocator, to allow for programs designed like this:
fn main() {
arena := ArenaAllocator::new();
#set_allocator(arena);
x := [1, 2, 3]; // x is allocated through the ArenaAllocator
#set_allocator(#env.default_allocator);
$println(x); // allocates via default allocator
#set_allocator(arena);
#env.allocator.free_self(); // frees the arenas
#set_allocator(#env.default_allocator); // go back to default allocator
}
What should an allocator have defined on it?
- Allocators should have the following methods defined on them:
MyAllocator::new()(preferrably allocating the allocator structure itself viamem::malloc)MyAllocator::alloc(MyAllocator *self, i32 size) -> void *(size in bytes to allocate, should returnvoid *)MyAllocator::realloc(MyAllocator *self, void *ptr, i32 new_size) -> void *(new_size in bytes. should returnvoid *)MyAllocator::free(MyAllocator *self, void *ptr)(may be omitted if permitted by the allocation model, will becomenoop)MyAllocator::free_self(MyAllocator *self)(destructor for the allocator itself, NOT objects created by it)
Disabling allocation altogether:
- You can pass the
--noallocflag during compilation. Keep in mind that, while this will remove allocators, you won't be able to use any of the standard library, as all of it depends on these allocators. This goes well with the--nostdflag.
its all a trick which is funny imo
the arbitrary allocator is a struct that has fields for the underlying allocator and function pointers to its methods
#set_allocator gets the type of that expression passed in, ensures its a struct or struct *, then sets the fields of the arbitrary allocator to the function pointers of the allocator you specify, or if it cant find a method it sets it to a noop method that returns nil
silly
probably better ways to do this
#set_allocator(MyAllocator::new()); should return the previous allocator so that you can nest them hierarchically
that
is a bit cursed but i like it
the issue is that you lose access to the information about the allocator at compile time when you do #set_allocator
as it works with pure void *
so if it returned prev it would need to return a bunch of void * together or something idk
#env.allocator.kind is set to a string literal but that makes it runtime based
the point is that im making my own language lol
LLVM front end?
nope qbe
Wharg
What backends does qbe even have
Where SPIR-V
so you can do
fn main() {
x := 39;
$scoped(ArenaAllocator::new(), fn(i32 *x) {
arr := [*x, *x * 2, *x * 3];
$println(arr);
}, &x);
}
``` and this time it *will* call `ArbitraryAllocator.free_self` before setting to the previous allocator
Also kinda strange that free_self doesn't free associated allocations
sure why not
Your spec said otherwise
that thing above was meant to more like, free_self shouldnt be used like free in c stdlib
as in, if you alloc something, dont use free_self to free it because that frees the entire structure
What's wrong with a model doing that?
It's easier in some contexts
Create allocator, do a bunch of dumb stuff, free the whole allocator
nothing is wrong i just said that free_self specifically frees the whole allocator including all of its allocations instead of just an object created by the allocator
its important to make that disctinction
because you might use it thinking it frees an object
idk
yea i know
this
fn main() {
arena := ArenaAllocator::new();
#set_allocator(arena);
x := [1, 2, 3]; // x is allocated through the ArenaAllocator
#set_allocator(#env.default_allocator);
$println(x); // allocates via default allocator
#set_allocator(arena);
#env.allocator.free_self(); // frees the arenas
#set_allocator(#env.default_allocator); // go back to default allocator
}
maybe i should be more specific
better?
* `MyAllocator::free(MyAllocator *self, void *ptr)` (frees a specific object passed by pointer, may be omitted if permitted by the allocation model, will become `noop`)
* `MyAllocator::free_self(MyAllocator *self)` (destructor for the allocator itself including all of its allocations, **NOT** objects created by it)
elle already has defer
Epic
use std/io;
fn main() {
let size = 10;
i64 *numbers = mem::malloc(size * #size(i64));
defer mem::free(numbers);
for let i = 0; i < size - 1; i += 1 {
numbers[i] = i * 2;
let res = numbers[i];
io::printf("numbers[{}] = {}", i, res);
}
if numbers[2] + 1 * 5 == 10 {
// Calls `free` here
return 1;
}
// Calls `free` here
}
It's very useful for memory management
or in the case of custom allocators actually 1 sec
Also errdefer
use std/prelude;
use std/allocators/heap;
fn main() {
#set_allocator(HeapAllocator::new());
size := 10;
numbers := #alloc(i64, size);
defer #free(numbers);
for i in 0..size - 1 {
numbers[i] = i * 2;
res := numbers[i];
io::printf("numbers[{}] = {}", i, res);
}
if numbers[2] + 1 * 5 == 10 {
// Calls `free` here
return 1;
}
// Calls `free` here
}
``` """*modern*""" elle
threading is not exactly something im working on at the moment lol
i have no idea xd
Trolley
Global state moment
Guess async corotuines would also be out of the question then
making the current allocator be a mutex sounds kinda painful
probably because theres no inline asm yet so coroutines cant really be done anyway unless you like link with custom asm objects when compiling (which tbf could be part of the runtime, at one point i was doing something like that with asm for finding the top of the stack for the GC i made)
then i found a better solution (or well simpler and more portable) so platform specific asm wasnt needed
unfortunately thats not possible for coroutines because you need to save registers which is very platform specific
javascript sexism???
@woven mesa how do u do your uikit list with swiftui
r u having issues
I just wanna use a uicollectionview instead of a lazyvgrid and a scroll view
but i find uiviewrepresentable odd
appswitcher example
app switcher?
icon *
I will need to experiment this is good code to reference from ty
question does this update like if a @State changed
im just eepy
uhh its not configured for it
but it wouldnt be difficult to implement
actually @native spruce it would work i think bc it calls reloaddata on the table
oki
it'd be so nice if you could just get typescript to return unknown instead of any when indexing on unknown key
currently it seems you have to use as keyof whatever to get it to work but if circumstances change this could stop being safe
i cant find it but there is a package that turns a lot of stdlib types to return unknown instead of any
how would that work with lsp though
wdym
its just a package that edits a bunch of types to return unknown instead of any
it would just work as if it was returning unknown to begin with
ah i do not believe you said stdlib types before editing it
the issue here is indexing objects
this is any instead of unknown
I tried turning on noExplicitAny again but it is such a pain
even if you put unknown it has an error
@woven mesa this took forever
but is it beautiful
I use a uicollectionview because of speeds
list and lazyvgrid sadly don't meet up to my standards :c
swiftui is pissing me off I think
ngl I may just choose uikit for this view because holy shit lol
combining swiftui and uikit stuff has never been so difficult
I think SwiftUI is a good option sometimes and then I use it and then I regret it immediately because one really valuable modifier is missing or something
swiftui is good for simple views with not much complexity
but when you want something that’s performant (like using a uitableview or collectionview) there will be problems
For example pushing a swiftui view from a uiviewrepresentable is horrible
I wanted to use this api but iOS 16 only
there goes my hopes and dreams
swiftui just keeps sounding like compose but if a quarter of its apis were deprecated
is there a uikit version of compose
closest would be the view system
but this is not related to deprecated apis
but it uses layout xml files
if you hate yourself you can do it all programmatically
well uikit is like that but it also has an option to not use xml layouts
I do it programmatically

(imo the proper way of doing it)
its just extremely verbose in android land
most devs will just do the basic layout in xml and make it functional in code
programmatic uikit https://github.com/khcrysalis/Feather/blob/main/iOS/Views/Sources/SourcesViewController.swift
lovely isnt it
telegram devs were a little insane though and only did it programmatically
(it is technically faster since no xml parsing is needed)
telegram devs so good
its only really beneficial for very low end devices
typically very old ones
as telegram supports some ancient android versions
nvm its min sdk 23
my apps actually support older versions
beautiful
disagree
what do you do then
uihostingcontroller?
navigationDestination?
UIHostingConfiguration works perfectly
I said pushing a swiftui view not UIHostingConfiguration
like onto the navigationstack
is navigation link breaking
how would I use a navigationlink inside of a uicollectionview (representable) without a uihostingconfiguration
introspect and manually push a new view to the stack
wrap your new swiftui view with uihostingconfiguration and push that
wouldn't that just use a uihostingcontroller
reminder I said without a uihostingconfiguration
mbmb
this is how it looks in the code
i spent several days trying to get method access to work properly like an idiot
then realized pratt parsing just makes it work out with no effort anyway
why are curly brackets unary operations
i thought it made sense
if you have one item in brackets, it fills up the only slot
if you have 2, you use a comma which is a binary op
for more, you chain commas
tho i'll probably have to restructıre them into a list
and if you have 0 items, lexer inserts a control token
do you want it to be compiled?
interesting
i didnt bother looking up popular parsing methods and using them lol i made my own from scratch
which means that the field access thing is unpredictable (its the wrong way around)
yep
i was gonna do that but a friend told me to look into pratt parsing a bit
so i did, and i'm glad that i did
💀
although i dont do namespace accessing like that lol
1 sec
lo
i honestly dont know what else to do now
lmao
maybe its finally time to make some enums
or like refactor the 4.5k line compiler into multiple files
yeah that's kinda weird imo too
basically for me they work like regular math operators
so left to right and respecting priority
if an op has a later order, it swallows the earlier order ones before it in the tree
that's basically how pratt parsing works
thats how i wish i did it tbh but oh well
i do that for ranges tho lol
.. is an arithmetic operator that takes in lhs and rhs and calls a function that creates a range out of them
half of me wants to use llvm but i gotta be more reasonable
so probably qbe
yeah qbe is nice for start
idk how usable tilde is
i need to finish my parser refactor
i dont personally like sea of nodes IR
also theres like no documentation on it yet
qbe doesnt have lots but it as at least a litt;e biot
what are you talking about?
interesting
this is smart
if youre planning to make your compiler more complicated or eventually represent a higher level language i dont recommend qbe
its too simple for that
i started it off with it and now i regret it because the compiler is too complicated to represent some programs in qbe and i need to do a lot of heavy lifting in the front end
any examples?
generics, deferring, custom allocators are all compilation gimmicks, qbe has no way to do any of that stuff
dynamic dispatch too
i want to have dynamic dispatch because its very useful but qbe just makes it very hard as its so simple
not that llvm has that stuff either but its type system is a lot stricter which makes it easier in the end
understand
a simple program like this
use std/prelude;
use std/allocators/heap;
fn main() {
#set_allocator(HeapAllocator::new());
x := #alloc(i32);
#set_allocator(#env.default_allocator);
}
compiles to all of this
oh
lol
the assembly is even worse
and keep in mind this is with a runtime so most functions that are used dont even have their bodies
im thinking
would it be a good idea to get rid of the /std prefix?
so you can do use prelude; and use allocators/heap; directly
nah
i can do that really easily
keep it
hmm ok
it's look like rust but something tell me this is not rust
this is not that bad
i was thinking because some modules can be quite lengthy to type out like use std/collections/hashmap;
or use std/runtime/allocators/arbitrary;
nop its a thing im making
i would keep it as it is
maybe thats for the better tbh
what is the language ?
elle
fun @native printf(format: string, ...) -> i32;
fun @infix lol(left: i32, right: i32) -> i32 {
return left + right;
}
fun @infix lol(left: string, right: i32) -> i32 {
return 99 + right;
}
fun @infix lol(left: i32, right: string) -> i32 {
return left + 99;
}
fun @public main() {
printf("%d\n", 5 lol 3 lol 9 lol "a");
return 0;
}
broom
infix
you can put the annotations anywhere
so you can also do @public fun main() now
that sounds really hard to make i would struggle with that
not the annotations
but overloaded infix functions
you mean infix
yeah its horrible
parsing infix functions is the biggest mistake i ever done
i need to figure out how to do it properly
i literally got rid of the incrementing operator (aka postfix and prefix) from elle because it caused so much parsing and compiling slop lol
i want to keep the syntax as simple as possible
maybe one day ill do the go thing and make it a statement and ONLY let you do x++
yeah thats what im doing mostly
so i really dont want things like ?. etc like in js
i have a small set of things and im extending existing ones
ill also rework the field access to be just a math operator, like @icy needle
im adding a lot of things to this
maybe ill add a #reset_allocator(); which does #set_allocator(#env.default_allocator) for you
compile time functions 👍
ya
imo better than stuff in C where it looks just like a regular function
the # thing is inspired from rust with the ! for macros
i just have @ like in zig
but ill probably change it bcs now i have problems to figure out what is an annotation and what's a compile time function
since each statement can potentially have annotations
lol so easy
fn parse_reset_allocator(&mut self) -> AstNode {
let location = self.current_token().location.clone();
self.advance();
self.expect_tokens(vec![TokenKind::LeftParenthesis]);
self.advance();
self.expect_tokens(vec![TokenKind::RightParenthesis]);
self.advance();
AstNode::SetAllocator {
value: Box::new(AstNode::FieldAccess {
left: Box::new(AstNode::Environment {
value: None,
location: location.clone(),
}),
right: Box::new(AstNode::Literal {
kind: TokenKind::Identifier,
value: ValueKind::String("default_allocator".into()),
location: location.clone(),
}),
value: None,
location: location.clone(),
}),
location,
}
}
yeah that's what i figured
or i could do the vlang meme and transpile to c
true
gm
gm
so easy to add new features
https://github.com/acquitelol/elle/commit/44d39423d4d82b623fe23cde86889a09a769e0d1
literally 32 additions for a whole new builtin
the hardest thing is to start and make a proper structure
@valid jetty support for aligned allocs?
allocs on stack are aligned to 8 bytes
alocs on heap are aligned to ptr width which is usually also 8 bytes
but no way to set custom alignment yet
qbe supports it, there is alloc4, alloc8, alloc16 for stack
and i could just allow for custom alignments in the allocators thats not particularly hard


