#🪅-progaming
1 messages · Page 62 of 1
WHY
i just modified the thing that kodetoad sent earlier lol
it's a byproduct of how typescript treats array values
no i meant to meo w
no need for object.hasown
but it's weird, and should be possible
daaas what i mean
i gave up after like 5 mins
anyways its not that important
its just some cache, where i replicate a gql mutation server offline
vee should do audit on my codebase
because... why not
find all typescript horrors
it;s fun how i used snake case in database
so i'll have to delete the database
or do complex migrations

average TS server moment
this is actually p good
i guess compiling types for development helped a lot
i needed to increase the max memory previously
cuz the default 4 gigs wasnt enough lol
afaik typescript does something like this
lhs is typeof Entry["mediaListEntry"]["status" | "score" | "repeat" | "progress"] which becomes Entry["mediaListEntry"]["status"] & score...repeat & Entry["mediaListEntry"]["progress"]
because the only common type bewteen them is null, you are trying to assign something non-null to something null which errors
by the time my bot is finished poffor will be ready 🙏
i'll release the codebase for this project this month
shit will hit the fan
maybe type hhints arent the best idea
uhhh idk exactly what youre looking for but i would do it like this
function _fillOutKeys<T extends {
id: number;
isFavourite: boolean;
mediaListEntry: {
id: number | null;
status: "CURRENT" | "PLANNING" | "COMPLETED" | "DROPPED" | "PAUSED" | "REPEATING" | null;
progress: number | null;
repeat: number | null;
score: number | null;
customLists: unknown;
} | null;
}>(entry: T, variables: Omit<NonNullable<T['mediaListEntry']>, 'customLists'> & { lists: (string | null)[] | null | undefined }) {
const keys = ['status', 'score', 'repeat', 'progress'] as const
for (const key of keys) {
(entry.mediaListEntry![key] as any) = variables[key];
}
}
cant modify the original types
they are inferred
ah
they are inferred from the gql api schema which is dynamically generated
ok i was gonna say lmao that did seem a little weird that you were manually defining the types
but even then why cant you just do (entry.mediaListEntry![key] as any) = variables[key];
husk
as unknown 
does nothing
yeah it does
no error
my setup is GIGA strict
with the original setup
do you need type safety for something like this if youre hardcoding the keys anyway lmao
its just keys which i sync from/to the offline storage
yeah but if youre hardcoding them why do you need type safety, you know those keys will be in the objects
@supple whale i might have shown you this before but rate this cursed type
import { createStore, set, get } from 'idb-keyval'
import { writable } from 'simple-store-svelte'
export default new class LocalSync {
store = createStore('watchlist', 'local')
entries = writable<Record<number, StoredMedia>>({})
constructor () {
get('entries', this.store).then(s => {
this.entries.value = s ?? {}
})
this.entries.subscribe(entries => {
set('entries', entries, this.store)
})
}
}
because the API schema might change one day
and i want it to error when my code tries to compile
hmmmmmm
and when the api schema changes, my code will automagically detect it
ive done worse
and go "WOAH THERE, FIX ME"
oh, this was 10x worse
i managed to get it down to this
since i re-build the DB schema every time i open the code editor
idk how to help you with this lmao its an inherent TS issue with for..of loops i think
look at these beautiful unbound types
INSANE
use something like readonly string[] iirc
if the local offline sync breaks it wont be the end of the world, its only a fallback for a fallback for a mutation
lol yeah obviously
but its funnier when i make a parser at the type level
btw you get autocomplete with this
@valid jetty make typescript parser with typescript types
just like enums
yeah because first is 0
its the same with real enums
not a fault with my impl
technically the type level thing does this
with some type magic (its just a functional language)
lol yeah but uhhh
beautiful strings
couldn't you use a mapped type to avoid that
look closely how the autocomplete is generated
my fav TS code
type EnumToObject<Keys extends string[], Acc extends string[] = []> =
Keys extends [infer First extends string, ...infer Rest extends string[]]
? { [K in First]: Acc["length"] } & EnumToObject<Rest, [...Acc, First]>
: {};
type Split<T extends string, D extends string, Acc extends string[] = []> =
Trim<T> extends `${infer First}${D}${infer Rest}`
? Split<Trim<Rest>, D, [...Acc, Trim<First>]>
: [...Acc, Trim<T>]
type Whitespace = " " | "\n" | "\t";
type Trim<T extends string> =
T extends `${Whitespace}${infer R}`
? Trim<R>
: T extends `${infer R}${Whitespace}` ? Trim<R> : T;
function enu_m<T extends string>(x: T) {
return x.split('\n').filter(Boolean).reduce(
(acc, cur, i) => ({ ...acc, [cur.trim()]: i }),
{} as EnumToObject<Split<T, '\n'>>
);
}
const x = enu_m(`
First
Second
Third
Fourth
Fifth
`)
@supple whale love?
what
mine simply doesnt scale to so many hundreds of types i have
what are you even making lol
man
if you come VC i can explain
in text it will take too long to explain
too complex XD
i cant really atm lol
voice message time
true
do you not have vencord installed
✨ Spice up your Discord experience - Get Vencord Today!
🌶️ https://vencord.dev/ 🌶️
i think Trim<T> might be one of my favourite TS types ever
type Whitespace = " " | "\n" | "\t";
type Trim<T extends string> =
T extends `${Whitespace}${infer R}`
? Trim<R>
: T extends `${infer R}${Whitespace}` ? Trim<R> : T;
its such an elegant way to do a trim
✨ Spice up your Discord crashes - Get Vencord Today!
just upload as regular attachment
that's about as simple as i can explain it
ofc on top of that data i built an entire app
thats cool but what website could POSSIBLY need all of that
netflix that can go offline at any moment in time
and still work seamlessly
as if you never went offline
\o/
i mean true
who uses Netflix
123movies
its a desktop app, which instead of using servers to host media, uses torrents from public bittorrent trackers and streams them real time
nice website
this isnt a streaming website
its a torrent streaming app
average firefox user
so basically vlc
shouldnt have spoofed ur resolution
wait why is it so laggy lmao
not even close
i don't use torrents anyways
probs no scrolling acceleration on ur end
I'm not spoofing anything
only magnet for games
no i have scrollling acceleration on
I'm on normal vanilla firefox
@leaden crater you
@deep mulch ja was
seems like the entire website just became oneko somehow
oh god this statement is so brainless it hurts me to read
idk then, its just the app i'm working on
i'm re-making it from scratch with cooler tech simply
i mean its just a website to download the app
pls pls make the logo 見る not みる 🙏
what
you're being so arrogant
it's being rebranded, but i do need a new logo
not characters tho
i need a proper actual logo
can unironically pay u if u make one
please hop off messing with scrolling it's atrocious
why override the scroll animations 
i hate js smooth scrolling
because i know i can be, as there are very few people out there than know more about the bittorrent protocol than me
yeah it works nice on chrome, that's about it
i just wanted to fuck with it
i'll nuke it in the future
it's just that I despise when websites mess with my scrolling
cope
lol ok
next time I'll enable hide blocked users
idk i can see the text microjiggling (idk if this is the technical term)
i simply thought of it as an idea, and decided "hm, i can write some giga efficient code for this"
(you know when things snap to pixels in the middle of animations)
and just left it in as a toy
normal website: you can scroll up quickly and get to the top instantly
js smooth scroll website: you have to scroll for 3 seconds straight to go back to the top
ah yeah, i learned the hard way my code sucks at <60hz
export default function (t, { speed = 120, smooth = 10 } = {}) {
if (!settings.value.smoothScroll) return
let moving = false
let pos = 0
let scrollTop = 0
let lastTime = null
t.addEventListener('wheel', e => {
e.preventDefault()
// is trackpad
const spd = (e.deltaY !== (e.deltaY | 0) || e.wheelDelta % 10 !== 0) ? speed / 10 : speed
pos = Math.max(0, Math.min(pos - Math.max(-1, Math.min(1, e.deltaY * -1)) * spd, (t.scrollHeight - t.clientHeight) + (smooth * 2)))
if (!moving) {
lastTime = null
update()
}
}, { capture: true, passive: false })
function getDeltaTime () {
const now = performance.now()
if (!lastTime) {
lastTime = now
return 1
}
const deltaTime = now - lastTime
lastTime = now
return deltaTime / 14
}
t.addEventListener('pointerup', () => { pos = scrollTop = t.scrollTop })
function update () {
const delta = pos - scrollTop === smooth * 2 ? 0 : ((pos - scrollTop) / smooth) * getDeltaTime()
scrollTop += delta
t.scrollTo(0, scrollTop < 1.3 ? 0 : scrollTop)
moving = Math.abs(delta) > 0.1 && !!requestAnimationFrame(update)
}
}
but the code for it was cool
XD
but we put 4 billion dollars into these fancy scroll transitions
nah it was like 15 mins
this code has ruined my appetite /lh
that entire project is just "hm i have a cool idea on the shitter, lets see how i can make it"
one of you is going to betray me
idk, imho its giga smart
scrolling using h shifter when
code is cool, end result not so much xd
@deep mulch https://acquitelol.github.io/simplex
most of my ideas are so giga random tho: https://github.com/thaunknown/video-deband i love this lib, like a lot
zoot doesnt even know how to solve an inequality problem with the simplex tableau smh
thought "why not"
I don't know what that is
and it fucking worked
I betrayed you. I installed a double door concreted 40x300x25 blast proof up to 40mJ
i forgot about the table i have so much to do recently
why would you name a function parameter a single letter in js so it's hard to know what type it is
maaaan

naming parameters one char is only valid if it's obvious
i mean i guess it's obviously an element but what element
like e for event
i don't do e for event and error
because people use it for both

so it's ambigious
i just do event and error
e for event, error and element, why not 
err is valid
2.718281828459045
I usually do ev, err, el
you can still rename stuff when destructuring though 
my variable names are like the opposite of yours
Rosie does this
function pip (enable = !$pictureInPictureElement) {
return enable ? burnIn(video, subtitles, deband) : document.exitPictureInPicture()
}
single letter variable names

burnIn
rosie hates keyboards
does it cause monitor burnin
@leaden crater
yeah, i made a lib for burning in images onto video elements
@deep mulch
which lets you render images on top of videos when using mediastreams for webrtc, or when using video.requestPictureInPicture
wondering if you could make an extension to stop sites from changing scroll anim
description: screw you miru

def
i don't really like when websites mess with scrolling at all
unless you overwrote the event and made preventDefault do nothing
im trying
can't you use css instead of js
let_me_now_the_variable = 0xFFFFFF
if let_me_now_the_variable != 0xFFFFFF
wipefs
yea i wanna break this
scroll spying is really
creepy
deletes ur pointer
laughs in C
sillly
wrong name XD
what a gooner
am i insane or would it just be better to use a React.memo
https://www.youtube.com/shorts/CAEuTN4qYqI
Simple performance optimization in React #react #reactjs #reactjsdeveloper #programming #progammer #frontend #devtok #coding #code #codetok #cs
INSANE
biome has the opposite of this (no explicit) and its fucking annoying
why would you ever want that
when i explicitly type any, i do it for a reason
nvim does it nicely (they put all the hints at the end in sequence
would you rather use records or mapped types
wait, doesnt that make typing some things just impossible
i actually like and hate how rust forces specifying the return type
since implicit returns exist you'll not end up with oopsies and also just prevents mishaps if types change downstream
you can disable the rule
but its annoying
you would have to be insane to enable it
the issue is that if i were to make explicit return types it would break just about every elle function ever written
the refactoring would be uhhhhhhhh
not fun

import json
class Test:
def __init__(self, data):
self.data = data
self.open = open
def __del__(self):
with self.open("data.json", "w") as file:
file.write(json.dumps(self.data))
a = Test({"a": "banned noises"})
while True:
pass
why self.open
because for some reason regular open is not present in __del__
insane
Yeah python and rust don't do implicit self.foo like c++ and java do
no i meant why even have the open field on self
(and they said open global func doesnt exist in __del__)
Just create a God Object :)
That is every type
Mostly mocking people who create massive objects that essentially do everything. A god object is a sort of joke about that.
In object-oriented programming, a god object (sometimes also called an omniscient or all-knowing object) is an object that references a large number of distinct types, has too many unrelated or uncategorized methods, or some combination of both. The god object is an example of an anti-pattern and a code smell.

It is a Bad Thing that OOP encourages/allows devs to do when they don’t know how to structure their code well
literally NOT what i want to do
This is a positive thing
window
Lol
useful for when i make a mistake and the code just locks up forever
This is why we DON'T use window
(string parsing)
Unless it's actually necessary
Recursive regex my beloved
it uses regex
read_word reads up until \s
but if you call read_word() twice it will always return an empty string or throw an exception (end of string)
because it reads up to the space and if you call it again there's nothing to read

so this could potentially freeze
while (reader.can_read())
read.read_word();
As of my last project I'm a big fan of separate lexer phase
i wrote json parser without lexer before
i literally just wrote it without researching patterns of how to design a parser
same with every time i've written a custom command parser
i just learned from my spaghetti mess and rewrote it better
(over the last few days)
simply by splitting up responsibility
the result seems to be similar to mojang's command parsing
https://github.com/Mojang/brigadier/blob/master/src/main/java/com/mojang/brigadier/StringReader.java
well apart from i did not have the responsibility of any string parsing in the stringreader
i split it into three modules: command parsing, primitive parsing, and a basic string wrapper which uses the concept of a cursor
Resident Evil 2
I don't know about command parsing, but for real languages token trees are really nice
gotta do this to match from the cursor
i wish i had made the cursor represent the next char instead of the current one
the latter is super confusing
npm install re2
Makes error recovery a breeze

i mean that would probably be good for user input regex
why not just use lewi's rust regex wrapper
Yea, it's what Cloudflare moved to iirc after the...
Accident
Catastrophic anti-XSS Regex
when you give me typescript
this is what i create
(i might be slightly defensive in my programming)
i need an eslint rule to require i always type return types

Also I'd Object.freeze(array) before returning get_result(). The properties of this._result are read only but the arrays are still mutable
Unless that's intentional
it's not
well i don't think it worried me that much this class is just here to try and stop the wrong types getting in the wrong places
but this code could be wrong i guess
would it be better for this to be a unit test's responsibility
idrk
this literally reparses everything marked as a user, channel etc to make sure it's a valid snowflake
Also
throw new Error(`typeof value === 'string' && is_snowflake('${typeof value}') is false; expected true`);
Are you actually meaning typeof value a second time?
object.freezze does not prevent array from being changed
unless you mean freeze each array
that's a TS config
oh?
no implicit return
ywyw
you do
would be useful for awaits though
i have not set up eslint
it's another tool to learn for me
hence why i have put it off
(this project has been massive learning with node and typescript, tools which i both used a bit before but not much until this project)
oh god i should check out my probaably really insecure node projects from 2020
Also
one of my node.js projects has a netbeans directory
😭 😭
lmao
/^\/(Africa|America|Antarctica|Asia|Atlantic|Australia|Europe|Indian|Pacific)\/.*$/.test(path.pathname)
i think this is a php project i ported
I'd use Object.entries() instead of for (const key in schema) and if (!Object.hasOwn(schema, key))
Fair enough
It doesn't, and it IS a lot more readable
😭
i think both are pretty similar in that regard
for (const key in schema) {
if (!Object.hasOwn(schema, key))
continue;
const option = this._schema[key];
if (option === undefined)
continue;
const value = (option.array ?? false) ? [] : null;
this._result_define(key, value);
if (option.required ?? false)
this._missing.add(key);
}
vs.
for (const [key, option] of Object.entries(schema)) {
if (option === undefined)
continue;
const value = (option.array ?? false) ? [] : null;
this._result_define(key, value);
if (option.required ?? false)
this._missing.add(key);
}
the former feels more explicit
maybe I could make a helper which uses iterator instead of array
then i would feel less paranoid

I would prefer to avoid Object.entries everywhere in case the performance does matter somewhere than mix and match
It's very very negligible performance impact, you're only gonna feel it on millions of iterations
You forget how good modern hardware is
And hold on
Optimizing things that don't matter is a waste of time
why
.
if you call read_word() twice the second time it will not advance the cursor
idk if that's bad design
Usually this variable would be called fuel
but it would seem weird for reading a word to also skip whitespace
function* objectEntries<T extends object>(obj: T): IterableIterator<[keyof T, T[keyof T]]> {
for (const key in obj) {
if (Object.hasOwn(obj, key)) {
yield [key, obj[key]];
}
}
}
Teehee
Like this?
not ... really?
it doesn't waste any time really in this case
i prefer to just use the faster thing where it makes hardly any difference to readability
js and py arent the sharpest tool in the shed for speed
Never have been
js is pretty good for an interpreted language thanks to v8 and bun though
@valid jetty i have succumbed to my intrusive thoughts
help me name my language
havent decided on the syntax yet
probably zig-esque
i don't really like using things which allocate a bunch of stuff for no reason lol
I still use for of loops because c style loop is less readable
Best of luck
catscript
.cs
not to be confused with C# (.cs)
wait idea
If arhsm is making a scripting language it would surprise me
try to optimise the parts which matter the least by rewriting in rust
its gonna be compiled, blazing fast, memory safe!
Rustaceans don't work like that
just for the meme
so people can see i tried really hard to optimise unimportant stuff
(tbf i did do js benchmarking for ages)
(on stuff that didn't matter that much)
you would've though on a discord bot command parsing would be a lukewarm path

Name it Axon (after neurons) or Skeld (Old Norse for shield)
hmmm
Welcome back brainfuck
arhsmlang
sounds funny but i was genuinely THIS close to calling it rosielang
call it "ts"Script 🥀
this shit script
imagine the best language
a combination of assembly, php, and actionscript
ok but on a real note
high level but still impossible to use
inchresting
had to lower it from 10k to 100 to not take 200 years since i had to add console.log to make it not be jitted to oblivion
i would call the language after a flower
but thats just me
if not, aim for something short and snappy
dont wanna call it mycutelangscript
thats actually a good idea since my favorite unicode character is also ✿
you could call it Calla with .cl or Hana with .ha or Hazel with .hzl or Ivy with .ivy or Peony with .pny or Zinnia with .zn
or rosie with .pie
Yea for...in works best when it's all numerical string keys
i cant be arsed to write a random non numeric key generator now
i like hana 
thanks 
Looool it's even worse with that
Yeah they were in fact correct to use for...in for performance
AmigaOS, MorphOS, WarpOS, AROS, Windows, macOS, Linux, Android, and iOS.
what are these horrors
Lole
Yeah that's never getting used
Honestly I'm also not allergic to my code file formats being more than two letters
.hna wouldn't offend me
that setup code
is so cusrsed
how the fuck does that even work
jesus
that's abuse as fuck
didnt even know u can abuse builtins like that
lol
Lmao yea
in what case does for ... in even contain non own keys?
no clue
there's only this but no one writes code like that
i just copied this
i think they meant hasOwnProperty
Object.hasOwn is hasOwnProperty
inherited property other than those from Object itself
so it could be if for some reason you're passing a class idk

nope
class methods and the likes are all non enumerable
so it makes no difference
no but
class Agh extends Base {
a = "a";
b = "b";
}
class Base {
beeMovieScript = "According to all known laws of aviation...";
}
if you create new Agh it will also have beeMovieScript
which would be iterated with in
though will Agh still fit into Record<string, "a" | "b"> idk
probaly not
that wouldn't make sense
i guess it's only an issue if you set the prototype directly because there might be extra values which don't conform to the record
pro gamers
pretty sure class property assignments are just sugar for
constructor() {
this.a = "a";
}
so they aren't inherited, they are direct properties
yes but no
it interacts differently with super()
huh
but isn't beeMovieScript inhereted
ohh wait
so when you do agh it's not like the super class is initialised separately and becomes the proto
and this refers to that other instance in the super constructor
that would be weird lol
oh yeah i think the proto would have the functions and be equivilent to ClassName.prototype?
Duality of a man
both
lmao
typst
Holy shit i might actually write my thesis in this
It looks soooo much cleaner and easier than latex
i did this thing
// これには「context」が要る
#let 日本語() = text.lang == "jp"
#let i18n(..args) = context args.at(int(not(日本語())))
#let demo(..args) = context if 日本語() {
args.at(0)
} else [
#args.at(0)
Translated:
#args.at(1)
#text(0.8em, luma(120))[
The above is for demonstrational purposes only.
]
]
#let 設定 = yaml("config.yaml")
#let 名前 = yaml(if "名前" in 設定 { 設定.名前 } else { "name.public.yaml" })
#let code(..args) = if "両方" in 設定 and 設定.両方 {
demo(..args)
} else {
context args.at(int(not(日本語())))
}
#set text(
lang: if "日本語" in 設定 and 設定.日本語 or false { "jp" } else { "en" },
font: if "日本語" in 設定 and 設定.日本語 or false { "Hiragino Mincho Pro" } else { () },
)
// 例
#code(
いちご
関数 メイン()『
プリント(「こんにちは、世界!」)。
』
rs
fn main() {
print("Hello, world!");
}
)
and you can define custom syntaxes for custom languages too
its soooo cool
i don't have a preference between latex and typst but I'm really used to latex
basically depending on a key in config.yaml you can toggle between these like super easily (literally just a bool away)
its so much better than latex because compilation is instant
can your latex do this?????
i use chrome + tinymist for auto previews, you can probably adopt this slop as a zed extension
https://codeberg.org/arhsm/.dolfies/src/commit/3109cfc21a2147d74d6930ff7e772eb047f59e79/programs/nvim/config/scripts/typst-preview.nu#L1-L26
https://codeberg.org/arhsm/.dolfies/src/commit/3109cfc21a2147d74d6930ff7e772eb047f59e79/programs/nvim/config/lua/configs/typstpreview.lua#L40-L49
typst-preview.nu: Lines 1-26
#!/usr/bin/env nu
def main [
--url: string
--port: int
--websocat: string
--user-data-dir: string
] {
try {
let endpoint = (http get $"http://127.0.0.1:($port)/json" | get 0.webSocketDebuggerUrl)
let query = $'Page.navigate { "url": "($url)" }'
echo "Session exists, navigating..."
echo ($query) | ^($websocat) -n1 --jsonrpc --jsonrpc-omit-jsonrpc ($endpoint)
} catch {
(
google-chrome-stable
--disable-first-run-ui
--no-first-run
--remote-debugging-port=($port)
--user-data-dir=($user_data_dir)
--app=($url)
)
}
}
typstpreview.lua: Lines 40-49
return ('%s --url "%%s" --port %s --websocat "%s" --user-data-dir "%s"'):format(script, port, websocat, user_data_dir)
end
local open_cmd = make_open_command()
return {
open_cmd = open_cmd,
dependencies_bin = {
["tinymist"] = "tinymist",
},
tinymist handles the auto update (so you dont have to constantly reload) and my script makes document switching easier
.dolfies??? @wheat kernel mention??????
yes
i only use latex for formulae
math in typst is actually sane
latex is cbt
latex is insane but I'm too
arent we all
is that mizuena
yes
@valid jetty tolling
tole tole [happy]
mizuena is the best thing to exist
if only sega confirmed mizuki’s gender so people would stop saying it’s “unconfirmed” and use that as their excuse for transphobia 💔
regex makes everything so much better
but Sega confirmed no?
nop
Sega kil
-a lazy developer 2025
they never explicitly confirmed she was trans in mizu5 it’s just HEAVILYYYYYY implied (like “that’s the whole point/plot of the story” kind of implied) but it’s never explicitly stated she’s trans
i didn't read mizu5 but i saw a lot on tt and yt
mizu5 was SUPPOSED to end the gender war that existed but instead it turned it into trans allies vs transphobes
i am finally realising that readonly is important in typescript

because if you make one array readonly it can't be passed into a non-readonly array pameter
so i should probably be adding it everywhere it's not mutated

wait ugh but object can also be readonly
who does readonly interfaces for function parameters i never see that
no one
tree
jdk
is there any reason to do Array.isArray instead of instanceof Array when you're using node.js
in js?
no not in js
please add defer to C
the type becomes implicitly any[] if you use isArray
if you use instanceof it infers them correctly
oh readonly array
does anyone use readonly arrays they seem kind of afdjkhs
Mutability annotations are useless in all languages except rust
Nope
@winged mantle
any issues are more related to memory safety rather than issues with const
Const in c++ is not transitive, and nothing stops the data from being mutated behind your back through a different pointer
but you would need to cast away the const... which is comparable to an unsafe in rust i would say
For example the const in const unique_ptr<T> doesn't mean shit
that's because you're not making T const
you're making the pointer const

i dunno if you can make the pointer const but probably
That's ub if the pointer points to something that is const, but if it's been casted to const you can cast it away just fine
Yes, const is shallow aka worthless
i wrote this recently
#define __DEFER_INTERNAL__(f, v) \
auto void f(char*); \
char v __attribute__((__cleanup__(f))); \
auto void f(char*)
#define __DEFER_WITH_COUNTER__(x) \
__DEFER_INTERNAL__(__f##x##__, __v##x##__)
#define __DEFER__(N) __DEFER_WITH_COUNTER__(N)
#define defer __DEFER__(__COUNTER__)
int main() {
int *x = malloc(6 * sizeof(int));
defer { free(x); };
return 0;
}
``` but it relies on the cleanup func extension in GCC
just do const unique_ptr<const T>
it's the equivilent to const T* const i believe
or wahtever it is
wow very cool, but i need multiplatform support unfortunately 😭
i love this ❤️
just make the preprocessor more powerful 😭
why not use zig
or something
or write custom c transpiler

would be a fun and educational project but also lots of time wasted
i think its just an easy regex find & replace tbh
transpile to RUST
how to parse c with regex
you dont have to parse anything tbh
or i mean it depends how complex do you want it to have
don't you need to find the exit of the function
well nvm you would need normal parser
that seems hard to do
just find the return
what if it's implicit return
what if return exists in a string
what if macros do some stuff
true
ill make a language like rust but it will be worse in every single way and it will just transpile to rust

just use antlr4
Yep, if you don't store it it's just dropped immediately
must_use in question:
Sure
It's a reasonable way to say "I am deliberately not using or storing this value"
so im brainstorming the syntax
i am too much of a rust user
its all rust
There already exists a worse-than-rust -> rust transpiler, it's called tac
do you wanna see very initial designs of elle for inspiration lmfao
or not inspiration but to laugh at it
show show
keep in mind this was before i really learnt rust
// Import statements follow a lib:file@{method1, method2...} format;
use elle:io@{print};
use elle:int@{random};
const languageName = "Elle";
// Use `pub` to make functions public so they can be imported by other files
// You *must* expose the main function for it to be runnable
pub op main() {
let resWithThree: Int = randomWithMultiplier(3); // Returns a random number between 0 and 10 multiplied by 3 using positional arguments
let resWithSixteen: Int = randomWithMultiplier(multiplier: 16); // Returns a random number between 0 and 10 multiplied by 16 using keyword arguments
printMessage(
"First result is %d and second is %d",
resWithThree,
resWithSixteen
);
let maybeRes: Int? = randomWithPossibleError();
if (maybeRes) {
// In this scope, maybeRes is just Int32 not Int32?
printMessage("Result is %d", maybeRes);
} else {
// This is a character because it's a single quote.
printMessage('a');
printMessage("Oh no! We failed.");
}
}
op randomWithMultiplier(Int multiplier) -> Int {
// If a function uses keyword arguments they must *all* be keyword arguments
// Use the ret keyword to return from the operation
ret random(between: 0, and: 10, included: true) * multiplier;
}
// Operations can either return a value or void.
// `nil` is the undefined/null value in Elle.
// Use the '?' operator at the end of the return type to denote that the function can return nil.
op randomWithPossibleError() -> Int? {
let result: Int = random(0, 5, true);
// Match keyword works very similar to other languages
ret match result {
3 -> nil,
val -> val,
}
}
// No return argument needed if function returns void
// Note that this is *only* if the function returns void
op printMessage(String message) {
printf(`[%s] %s`, languageName, message);
}
idk what i was doing with op and ret lmao
I FOUND AN OLDER ONE
// Import statements follow a lib:file@{method1, method2...} format;
require elle:io;
require elle:int@{random};
// Use `expose` to export functions so they can be imported by other files
// You *must* expose the main function for it to be runnable
expose op main() {
Int32 resWithThree = randomWithMultiplier(3); // Returns a random number between 0 and 10 multiplied by 3 using positional arguments
Int32 resWithSixteen = randomWithMultiplier(multiplier: 16); // Returns a random number between 0 and 10 multiplied by 16 using keyword arguments
printMessage(`First result is %{resWithThree} and second is %{resWithSixteen}`);
Int32? maybeRes = randomWithPossibleError();
if (maybeRes) {
// In this scope, maybeRes is just Int32 not Int32?
printMessage(`Result is %{maybeRes}`);
} else {
// This is a character because it's a single quote.
printMessage('a');
printMessage("Oh no! We failed.");
}
}
op randomWithMultiplier(Int32 multiplier) -> Int32 {
// If a function uses keyword arguments they must *all* be keyword arguments
// Use the ret keyword to return from the operation
ret random(between: 0, and: 10, included: true) * multiplier;
}
// Operations can either return a value or void.
// `nil` is the undefined/null value in Elle.
// Use the '?' operator at the end of the return type to denote that the function can return nil.
op randomWithPossibleError() -> Int32? {
Int32 result = random(0, 5, true);
// Match keyword works very similar to other languages
ret match result {
3 -> nil,
val -> val,
}
}
// No return argument needed if function returns void
// Note that this is *only* if the function returns void
op printMessage(string message) {
io::print(message);
}
this looks interesting
I'll definitely take inspiration
modern elle can do all which that can do except match statements, keyword arguments, and string interpolation :3
still more features than java /s
java is such a slop
when documenting code, and the 2nd function is essentially the same but with a different parameter, would you copy paste the docs or just leave it empty like this?
anyway "modern" elle
use std/prelude;
use std/option;
const LANGUAGE_NAME = "Elle";
fn random_with_multiplier(i32 multiplier) -> i32 {
return rand::random(0, 10) * multiplier;
}
fn random_with_possible_error() -> Option<i32> {
result := rand::random(0, 5);
if result == 3 {
return Option::None();
} else {
return Option::Some(result);
}
}
fn print_message<T>(T message) {
$printf("[{}] {}", LANGUAGE_NAME, message);
}
fn main() {
rand::seed(time(nil));
resWithThree := random_with_multiplier(3);
resWithSixteen := random_with_multiplier(16);
print_message("First result is {} and second is {}".format(resWithThree, resWithSixteen));
maybeRes := random_with_possible_error();
if maybeRes.is_some() && res := maybeRes.unwrap() {
print_message("Result is {}".format(res));
} else {
print_message('a');
print_message("Oh no! We failed.");
}
}
copy paste the docs
make it explicit
wym maybeRes
typeof maybeRes === Option<i32>
you could have a res you could not have a res
so you maybe have a res
hence maybeRes
the infamous enum 💔
what does that do
if you ever need 3 states you can literally just
enum Foo {
A,
B,
C
}
fn foo(x: Foo) {
match x {
Foo::A => ...,
Foo::B => ...,
Foo::C => ...
}
}
``` (this is rust not elle)
i was thinking about a 3 valued bool the other day and i told a friend about it and he absolutely despised the idea
0 for no
1 for yes
2 for idk maybe
thats not a rust thing lol
a lot of langauges have enums
heck even TS and C have enums
yes but i hate c
yea you should :3
i was doing some c yesterday for school and the problem took almost one hour, when it would take 1 minute in cpp
what was the problem
it looks very intimidating
it was to find a certain ascii character in a string and find how many occurrences there are and replace each occurrence with the total number of occurrences
example: apple
we say p
a22le
nop that's just my head
yeah thats justified
are there any restrictions on the code???
because thats pretty easy lol
not really, just using the ascii value
maybe but it's pain in c
would it be simple in rust, should i give up c and learn rust
#include <stdio.h>
#include <string.h>
char *replace_with_count(char *str, char target) {
char *copy = strdup(str);
int count = 0;
// count occurences
for (char *p = str; *p; p++) {
if (*p == target) count++;
}
if (count == 0) return copy;
// replace occurences with count
for (char *p = copy; *p; p++) {
if (*p == target) *p = '0' + count; // ('0' + x) is an easy way to convert a number into its char representation
}
return copy;
}
int main() {
char *word = replace_with_count("apple", 'p');
printf("%s\n", word); // a22le
return 0;
}
``` easy enough
@lavish frigate is rust learnable in 3 months
i did it differently a bit
idk i dont think that should take an hour lol
well okay maybe i was exaggerating a bit but they take a lot of time for me
i really don't get c strings
why do i have 2 autocompletes 😭
idk depends on how fast you learn i guess i still have a lot of stuff to learn myself
i’ve been learning rust while making elle for at least a year
where to learn (don't say the manual)
because i have commits from a year ago
make stuff
find stuff you need and try to write it in rust
well if you dont want the book then just make stuff
ask questions as you go
can i ask here or would it be too bothersome
sure you can ask here
yeah
I'll utilize my free time to learn rust because anyways the school year is almost over
but i don't really know where to start, like,
i don't know how to write in rust
theres a book

id just pick a project and learn while working on it
the book is so good that it rust comes with it preinstalled
if i could (kinda) do it, you can too
well if i read pacman manual entries i think this is doable
well its less a book and just a written tutorial
explaining a bunch of concepts
I'll start today (if i finish schoolwork) or tomorrow
i still have to write 6 more c stupid problems for Monday
i recommend you read the first page rn so your brain will think of it as unfinished work and you forget less easy it can also add a lot of intrigue and curiosity to drive you after your schoolwork
👍
installing rust with curl is the last thing I'd think about
crazy
you install rustup with curl which is basically an official version manager
and then you install cargo and rustc using rustup
yes but pacman -S rustup
sure
i already have rust installed because of that prime problem a while ago
depends on what you mean by learn
you can learn to read it in 15 minutes
you can learn everything you need to write a compiler in a day
you can learn to use it well in way less than 3 months
you can learn to use it well in a week fueled by pure dedication
i really want to learn rust but like
i took a day to learn it then wrote an interpreter but my code ended up being super ugly so now im rewriting it on and off
a compiler
What do you usually make
or do aoc
i learned to install and manage arch problems that i have (besides nvidia) in 2-3 days because of dedication
thats the problem
i dont make anything anymore, i dont got ideas
now do nixos
fuck nixos
have u ever used it
What did you use to make
hyfetch --DISTRO nixos
hyfetch 
no but i heard all the yapping about it in this server and I'm not eager to think about nixos anymore
well, mostly websites and discord bots 😭
Try to make websites and discord bots in rust!
but god do i want to do more
yeah but what do i makee
nix is genuinely so awesome and you dont even need to install the distro you can just use the package manager
at least dont say fuck nixos then
a compiler
i am going to shoot you
why
a compiler is scary
no its not
make a website about you
its fun
A fullstack crossplatform app framework for Rust. Supports Web, Desktop, SSR, Liveview, and Mobile.
@hazy pine you can recode doom in rust
euaewhe
you guys are too good at coding
suree buddy
sureeee
it took me 30 minutes to do something in c
something as easy as possible
i cant do ANYTHING in c
should i use vim, nano, nvim, or visual for rust
tsoding reference
nano
💀
it segfaulted 15 times within a microsecond, crashed my computer, it rebooted, it bluescreened, tried to start, c installed linux, linux started, i tried to get out, it deleted all my data, i shut my pc down, c turned it back on again, it deleted linux again, installed windows, it bluescreened, started again, hacked into the NSA, got my data back, fixed my code, recompiled and then it worked
u should use nvim for everything besides kotlin and qt
use whatever you are most comfy with
if someone is most comfy with nano that doesnt mean he should use nano
i literally used nano for my last rust file (it was very mundanely basic)
it severely hinders productivity
what if i want all my cool fancy vscode features
u can get all of them and more in nvim
someone in a familiar environment is infinitely more productive than forcing them to use nvim
because you are comfy with it doesnt mean others are
more productive for the first 5 minutes after which their productivity degrades severely because in those 5 minutes theo couldve learned enough vim to be at least twice as fast than in nano
I'm only familiar with the worst app known to mankind, codeblocks
i tried nvim, used it for a week, got all those fancy plugins and whatever people recommended and even learnt how to use lua to config it
i still below half my productivity level as with vscode just because its so unfamiliar and just does not work for me
i had to use nano a bit ago cause nixos comes with only nano preinstalled and it was the most horrible experience of my life and i dont understand how anyone could ever use nano to actually write software, i can understand vscode or jetbrains ides but nat nano
are u using vim motions in vscode
no
how are u navigating then
keybinds or mouse
I still use this in neovim 
unbind them and force urself to use proper keys
idfk the default vscode keybinds
i did that
Did u learn?
u should learn to use vim motions inside vscode
honestly im using nvim cause vscode is too heavy
yess
i tried vim motions and it sucked for me
vim motions dont require nvim
still absolutely suck at vim motions
again i did try nvim, i still use vim on the server
i tried vim motions on jetbrains and vscode
it just does not work for me
and telling others to force your ways again is just stupid
I need a new vim setup 
yea it sucks for the first week or month cause ur not used to it yet, like literally everything in life, it doesnt mean u should give up, i was garbage at vim for a long time but now im so glad that i learned it cause when i see other people writing code without vim its just painfully slow
im not forcing anyone idc how efficient you are
it makes no difference in my life if you use vim or not
im just telling you its worth it
why are you trying so hard then 😭
The 0.2 seconds it takes to my hand to get to the arrow keys isnt that bad
im bored and burnt out
yea from using nvim
lmao
hop back on vscode to avoid burnout
vscode will fix all your problems
use vscode immediately
it will 1000x your productivity
@hoary sluice just type :qa!
use nano
need to do a bit more vimming to cool down
its not even abt the time save at that point its abt the comfort
i feel like people hate nano with no ground whatsoever, it's actually pretty good
the linux poisoned mind will never understand this
no its garbage i used it last friday and hated every second of it i will never use nano again im gonna install vim via curl if thans what it takes
cuz people are stuck up and must repeat everything they heard online ignoring what other people find productive or comfy
Winget duh
name a single comfy thing about nano
i will not hear this opinion
I'll use whatever i want
its jusn a barebones editor made for people getting started with editing in the terminal
its very quick, especially with the keybinds and its easy to learn and master
if someone prefers that experience over the alternatives who are you to tell them off
i dislike vim
especially when you are so hyper focused on a different editor
nobodo actually learns nano because its a good editor, they use it because its all they know
ok
do you use nano as your main editor
nobodo actually learns nvim because its a good editor, they use it because other people force them into learning it
if i want something quick and don't want to boot up visual studio before my idea vanishes yes
it's very simple to use and gets the job done
why are you making fun of me typing fast on my keyboard and not bothering to fix mistakes that everyone can look past anyways
im not making fun of you
im copying what you are doing so you realize that what you are saying is insane
except people actually use nvim as their main editor?
except people actually use nano as their main editor?
ok, I'll use sticky notes as my editor, how's that then
you just said vscode is ur main editor
is nvim really that bad
it's not
no
no its not
i use codeblocks, visual, nano
but someone here is arguing about preference
visual as in vi?
like i said idc what you use i just dont understand how someone could ever use nano as their main editor and ive never seen someone who, when making an actual project (not just patching up config files in the terminal) actually uses nano
if you know someone feel free to show me
¯_(ツ)_/¯
cause if u do then we agree
pls say vscode not visual
visual is the name of vi, the predecessor to vim
its confusing
been experimenting with fuzzy find in vscode
i like it a lot
been experimenting with fuzzy find in nvim :blobcatcozy: i like it a lot

why did it not send
teach me your ways
sadly fzf in nvim sucks 😔
how
its just not like in vscode
ah ok that explanation makes sense and i now understand why nvim fzf is worse
lol the biggest bottleneck of my parsing code is Object.defineProperty
its just so much slower
oh yeah
i remember why i was doing this
if i make my parser a library who knows what insane things people will try

what do we think
https://store.steampowered.com/app/3401490/Replicube/
Replicube is an open-ended programming puzzle game/toy about writing code to replicate 3D voxel-based objects.
SOLVE PUZZLES
The main content of the game involves trying to match a reference object by working out code that will replicate it. There is no "right answer", if your code produces the same object, it's correct!
…
Apr 24, 2025
single process for 1m discord servers
hello its literally completely intantaneous
you sure?
yes im sure
maybe its something with your computer being slow in general idk for me nvim fzf is just extremely slow while everything else is fast
they literally use the same tool idk what youre on about
the only way its not instant is if i start vim in the root directory and search for something
which is almost 200GB of files
and even there it takes less than a second and updates live so you see more and more files show up as it searches
both vscode and nvim use ripgrep in fzf so they have the exact same speed because they use the same tool
still the fzf search results fill instantly so there is nothing slow about it
unless you were working in a gigantic project (hundreds of GB of non excluded files) and were using normal grep in nvim and ripgrep in vscode
is it fzf that is slow or your terminal emulator
its me ragebaiting
true
if you are an ass to me when i try to change the convo to something better i will just start ragebaiting
and the easiest way to do that on nvim users is to lie about speed
yes thanks im havign anxiety from C
what search engine is that...
looks like bing
like bruh i literally compiled with it and it correctly crashes when running in gdb environment, but it wont trigger on any leaks...
forget “what’s the best linux distro” this guy’s asking the real questions
literally just a vscode reskin
i use real vibe coding tools like
@valid jetty typst looks very complex, like spaghetti compared to latex (project from a friend)
too much paranthesis
this looks like spaghetti cuz what the fuck is that use of whitespace
i find latex more readable
almost all of these parens are unnecessary

