#🪅-progaming

1 messages · Page 111 of 1

supple whale
#

its rust black magic

winged mantle
#

use c preprocessor on java to have one codebase for multiple minecraft versions in mod

supple whale
#

i dont think my compilation flags are wrong either

jade stone
#

i think all major minifiers just remove blocks of code that are statically unreachable

royal nymph
#

ages ago I tried using a worker for discord webpack search, but creating and preparing the worker took like 2 seconds cause I had to serialise and copy over all the webpack modules so it ended up being way less efficient

jade stone
#

i love sending every discord module over websocket blobcatcozy

supple whale
#

its not a worker btw

#

its just raw WASM

royal nymph
#

yeah i know

winged mantle
supple whale
winged mantle
supple whale
#

since u cant just randomly pass other memory as a reference

#

u need to set the memory

royal nymph
#

can't you use shared array buffer

#

I never used wasm

supple whale
#

nope

#

it wont help

#

you still need to PUT the data into the stack

#

imagine some1 has a file on his own computer, and goes to hash it on a 2nd computer

#

u cant just go "yeah use the other's PC RAM"

#

you need to copy it onto the first PC's ram

#

pretty much the way i'd explain it

#

thats how wasm : js works

#

the original data was in JS, it needs to be "added" to "appended" to WASM's memory

#

since the program has its own memory in its own sandbox

#

WASM is initialized with a specific memory buffer, and that's it's sandbox, just like how its done on a normal PC with native code

#

when u go to use a pointer it needs to be a a pointer to the memory you're using

#

it cant all of a sudden be diff memory

#

but yeah, wasm seems weirdly slow on newer versions of chrome

#

idk if JS got better or if i fucked smth up

tired vigil
#

Is this also how asm.js worked or was that used on the same thread with the same memory? (I just found out about this like yesterday)

supple whale
#

asm.js just compiled assembly instructions into JS code

#

so... effectively it implemented a CPU in JS

#

you can imagine how horrific that was for performance

tired vigil
#

I think firefox actually optimised asm.js code somehow

supple whale
#

but strictly speaking, no, you could hack it, but it would be a hellish undertaking of an ungodly level

tired vigil
#

When "use asm" was used, indicating that it should be optimised
But idk

supple whale
#

yeah wtf

#

why did my WASM get like... x5 slower

#

wtf changed

#

it used to max out at 2M IOPS for 8b, now it maxes out at 400k

#

wtf

#

js got slower too?

ivory heath
# supple whale nope

You can. It’s purely implementation limitations. Idk what your rant about the stack is about

supple whale
#

this is going to be fun to re-test....

supple whale
#

and u want to hash it in WASM

#

then you need to copy the data into WASM memory

#

there's no way around that in browser

ivory heath
#

You can just share a heap ptr.

supple whale
#

sir....

#

the heap

#

is in the wasm's memory too

#

and the data

#

is outside of wasms memory

ivory heath
#

Allow js to write to WASM? where is the data coming from?

supple whale
#

english

#

?

#

i think u forgot a comma

#

or like 3 of them

#

its coming from JS

ivory heath
#

Fixed I had a stroke

supple whale
#

since shocker, wasm in browser cant interact with anything else than itself, and some atomics

#

so if you want to say hash a file, you need to load it via JS

#

and then copy into WASM

#

since WASM cant access any W3C apis directly for reading shit like files etc

ivory heath
#

Yeah they neutered it’s theoretical capabilities.

supple whale
#

nope

#

they didnt

#

its all 100% inline with WASM's design principles

#

WASM was always meant to be a safe, sandboxed way of executing native code

#

not "free performance for destroying JS"

ivory heath
#

WASM isn’t native it’s just a “jvm in the browser”

supple whale
#

which is why it always makes me laugh when people are delusional thinking that they can "fix the perf problems they have" with WASM

supple whale
#

for the most part

#

it's not far off

ivory heath
#

WASM is neutered in every aspect

#

It’s slower than naive

supple whale
#

well yeah its bytecode

ivory heath
#

Massive overhead communicating with JS

supple whale
#

ofc its slower than native

ivory heath
#

wtf was the point

supple whale
#

that was the point

#

WASM has NEVER been about perf

#

sandboxing it was always the #1 thing

ivory heath
#

It’s not native

supple whale
#

by "native code"

#

i mean shit like C/C++/Rust/Go

ivory heath
#

And what is the advantage of a second sandbox?

supple whale
#

native languages

#

or languages that are meant to compile to native code

supple whale
ivory heath
#

Porting libs that are gonna run like shit in the browser

#

Smart

supple whale
#

that said WASM had its share of sandbox excapes

supple whale
#

100%

#

thats EXACTLY the point of WASM

ivory heath
#

HORRIBLE

supple whale
#

nope

#

you just dont understand

#

because compiling a lib which will run at 95% of the perf of JS to WASM will take u a day

#

porting it to JS will take u 2 months

#

if you're a good developer, in most cases way longer than that

#

that's been the goal of WASM

#

and people HEAVILY missunderstand that

#

when they see the "asm" in "wasm"

ivory heath
#

But what are you even porting?
Too slow for image and video codecs.

Your proprietary api for your database I guess ?

supple whale
#

are you the authority of all web?

#

what matters is allowing developers to do that

#

they are plenty of highly proprietary native libraries

#

that are the only ones in the world that do one giga specific thing

#

shit, i can even think of encryption algos like that

#

for the longest time there was no ed25519 implementation in JS

#

wasm was a good lazy solution for that

#

because would u risk fucking up ed25519 by writing in manually in JS? or simply compile a lib to wasm in 15 minutes

ivory heath
#

WASM could have been more

supple whale
#

sure, but it wasnt meant to be more

#

it perfectly accomplishes what it was designed to do

#

without a single flaw

ivory heath
#

It could have done more easily

supple whale
#

becuase what it was DESIGNED to do, is different from what people think it is

supple whale
#

no?

#

legit all of squoosh uses WASM

#

and I use wasm myself for muxxing in browser

#

because shocker! you dont need to convert the codecs, browsers already support that

#

u just need to change the containrs

#

and re-wrap them using native code

#

like MSE

ivory heath
supple whale
#

but noooo people need to import all of fucking ffmpeg for some reason

#

lol?

supple whale
#

x1.1 speed of real time vs x10 speed of real time?

#

fuck cares, its real-time?

#

"oh no i cant watch my video at x10 speed when using WASM, what will i do"

ivory heath
supple whale
#

because you're likely re-encoding all of it

ivory heath
#

Speed is apart of access

supple whale
#

instead of letting browsers do the heavy lifting

ivory heath
supple whale
#

anyways, WASM does what it was designed to do perfectly

#

and there's legit 0 problems with its implementations

#

it solved what it was set out to do, for the most part without hickups

#

its just for some reason, people keep wanting flying cars, which is stupid, because cars are meant to drive on roads, not fly, and a flying car will never be as good as a car and an airplane separately

#

that's trully the state of WASM

#

its why i'm writing this entire paper

jade stone
#

i love typescript i love typescript

supple whale
#

becuase people are unhinged as shit

supple whale
#

CLASSIC

supple whale
jade stone
#

yeah

#

unhusk

ivory heath
supple whale
#

see

#

if everything is moving to them

#

that means they dont suck

#

because otherwise every1 wouldnt be using them

ivory heath
#

Or people just cope with shitty software

supple whale
#

its trully that simple

#

there's not some shadow goverment who's manipulating companies into using browsers

#

its simple, developing for browsers is HORRENDOUSLY simple and fast

#

and what motivates companies more than anything?

#

costs!

#

and developing for browsers, simply has the lowest costs

#

because of all the development advantages it has for companies

ivory heath
supple whale
#

what end users get is another story

ivory heath
#

LOL

supple whale
#

because end users are not who decides what software is written

#

its companies

#

and companies only care about money

#

its trully that simple

#

and yep, end users get fucked in the process, because who would have thought, making a magic all in one wand that solves all problems isnt easy

ivory heath
#

But X software can run a literal order of magnitude faster natively. Or rely on out of date libs the browser has.

Or depending on the browser some features don’t work even between forks of chromium

supple whale
#

and that matters for some X company because?

ivory heath
#

If you target win32 and supply x86 and arm congrats your software works universally

#

You only have to support windows (x86/arm).

#

Wine.

#

Fucking wine

#

Wine is that good

#

At the cost of the end user

tired vigil
#

0.25s is a pretty big delay for a click event tbh

#

discord on WSA also reloads the whole app when you move the window to another monitor 😭

#

no other app does that

#

also WSA is goated and I hate microsoft for discontinuing it

ivory heath
#

I think people do notice.

#

This is the downfall of software

#

Enshitification

tired vigil
#

windows subsystem for android
(exact opposite of what it sounds like)

supple whale
#

oh

#

didnt google do their own thing for that now?

tired vigil
#

well what do users even care about
I'm sure it's not ai slop apps

supple whale
#

via WSL

#

or am i missremembering?

#

ah its not WSL

#

gg

ivory heath
#

I’m saying your mentality is. And yeah i remember when native apps were a thing

tired vigil
#

I couldn't figure out how to launch external apps tho

ivory heath
#

It’s already a problem

#

And the free lunch of hardware improvements is over

#

You have smaller transistors to look forward to and back side power delivery

tired vigil
#

nope, local actually

#

the performance is similar to wsa

#

yeah

#

😭 all the options are either chinese adware slop or android studio 500ms latency emulator that crashes after opening two apps

#

oh you edited the message

#

cya

tired vigil
jade stone
#

since when was there a native popover api

supple whale
#

not long

jade stone
#

i will mirgate to it soon and use my own popovers

supple whale
jade stone
#

shrimply dont

#

firefox is mid anyway

supple whale
#

as long as Firefox exists we can't have nice things in the world

ivory heath
#

sodalove Firefox

tired vigil
#

Firefox view transitions when

royal nymph
jade stone
tired vigil
#

It's more inter than inter

royal nymph
#

FUCK NO YOU HAVENT

jade stone
royal nymph
#

also what the hell were they thinking with this banner

.page-layout__banner {
    display: none;
}
jade stone
#

@solid gazelle

jade stone
solid gazelle
#

good banner

jade stone
#

@royal nymph MDN INSANE

supple whale
#

ya'll use MDN

#

and not shit like devdocs?

royal nymph
#

idk why

jade stone
#

yeah

royal nymph
#

it's the same font but it looks so different and is painful to read

valid jetty
#

@deep mulch do you know radix sort

use std/prelude;

fn bucket_sort<T>(T[] arr, u8 digit) {
    buckets := (0..10).map(fn() [T;]).collect();

    for x in arr {
        digit := (x / math::pow(10, digit)) % 10;
        buckets[digit].push(x);
    }

    return buckets.concat();
}

fn radix_sort<T>(T[] arr) {
    out := arr;

    for i in 0.."{}".format(T::MAX).len() {
        out = bucket_sort(out, i);
    }

    return out;
}

fn main() {
    $dbg(radix_sort([14, 23, 1242, 352, 39, 442]));
}
#

such a simple sorting algorithm

deep mulch
#

i look and then promptly forget a week later

#

idk how you remember any of this

jade stone
#

before

#

(wayback machine)

#

after

valid jetty
#

its the one where you have like

first bucket sort is:

numbers 1 3 1 8 9 2

and you put them into buckets of 1-10

so in the bucket of 1s, there is 1 and 1
in the bucket of 2s there is a single 2
etc

then you concatenate all the buckets (a bucket is just a dynamic array)

for numbers with multiple digits you just apply bucket sort on each digit and thats radix sort

#

it is surprisingly simple

jade stone
#

@royal nymph THEYRE USING JETBRAINS MONO NOW

valid jetty
#

its the first sorting algorithm ive ever made working first try

winged mantle
#

eugh

valid jetty
#

its a very simple algorithm

deep mulch
#

oh rosie my rosie

jade stone
#

Fix MDN with this one simple trick

#
@-moz-document url-prefix("https://developer.mozilla.org/") {
:root {
    --font-family-code: monospace;
}
}
deep mulch
#

@jade stone SALAD

deep mulch
#

(fn() [T;])

#

Evil.

supple whale
jade stone
#

@deep mulch love?

deep mulch
#

im gonna explode rosie with my mind

supple whale
#

here u go

deep mulch
#

NO idea what type it returns

jade stone
#

also i prefer the UI of mdn, even after the change

deep mulch
#

wjaht does this even return fn bucket_sort<T>(T[] arr, u8 digit) {

jade stone
#

to devdocks

valid jetty
royal nymph
#

the new one looks thicker, no?

deep mulch
#

i literally cant read this

#

rosie will use pseudocode

valid jetty
#

buckets is T[][], calling buckets.concat() will join together all the arrays to form T[]

deep mulch
#

guh

valid jetty
#

ok hold on

jade stone
deep mulch
valid jetty
#
bucket_sort(arr, digit) -> sorted_arr {
    buckets = [] for i in 0..10
    
    for x in arr {
        digit = (x / digit ** 10) % 10
        buckets[digit].push(x)
    }

    return joined(buckets)
}

radix_sort(arr) {
    out = arr

    for i in max digits of int {
        out = bucket_sort(out, i)
    }

    return out
}
``` @deep mulch
deep mulch
#

love

#

i can read

#

is buckets a list of lists

valid jetty
#

yes

#

specifically a list of 10 lists

#

because there are 10 digits

deep mulch
#

oh rosie my rosie

royal nymph
#
@import url('https://fonts.cdnfonts.com/css/menlo');

.page-layout__banner {
    display: none;
}

:root {
    --font-family-code: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
}

code {
    font-size: 0.833rem
}
#

it still looks wrong but better

deep mulch
#

.

#

make elle mascot love @valid jetty

royal nymph
#

@jade stone userscript that automatically redirects mdn links to pre-redesign archive link

deep mulch
#

do not ???

royal nymph
#

actually can you selfhost the old version

valid jetty
#

i love elle's mascot i will NEVER make it love

royal nymph
#

i despise the new In this article

valid jetty
#

potential proof it was written by ai

deep mulch
#

what is max digits of int {

valid jetty
#

format the max size of your integer type into a string and take its length

royal nymph
#

so much better

valid jetty
#

youre doing a bucket sort for each digit

valid jetty
#

well you can

#

seems to be 10

deep mulch
#

rosie moment

valid jetty
#

but essentially you wanna do a bucket sort for each digit of the numbers

#

you could also probably loop through the numbers once to find the biggest one, so you can take that number's amount of digits

deep mulch
#

what is the return type of radixSort

valid jetty
#

that way youre potentially not sorting pointlessly

valid jetty
deep mulch
#

how

valid jetty
#

bucket_sort returns T[], radix sort will return that too

deep mulch
#

something isnt right

valid jetty
#

because its returning out which is the return value of bucket_sort

deep mulch
#

bucketSort returns an array

#

it would build a 2d array

#

h

#

oh

#

wait

#

i see

valid jetty
#

youre not concatting the values

#

youre recomputing each time

deep mulch
#

SH

#

i see now

royal nymph
#

mdn fioxed

deep mulch
#

shhhushh roise

#

roie

valid jetty
#

each iteration of bucket_sort sorts by 1 digit

#

lole ok

deep mulch
#

okayu ti works

valid jetty
#

i think you read out = bucket_sort(...) as out += bucket_sort(...) right

deep mulch
#

yes

valid jetty
#

silly operator overloading

deep mulch
#

fix elle syntax @valid jetty

valid jetty
#

elle syntax is perfectly understable if you try to read it for more than 1 second

deep mulch
#

nop

#

rust more readable

valid jetty
#

whats not readable about this

use std/prelude;

fn bucket_sort<T>(T[] arr, u8 digit) {
    buckets := (0..10).map(fn() [T;]).collect();

    for x in arr {
        digit := (x / math::pow(10, digit)) % 10;
        buckets[digit].push(x);
    }

    return buckets.concat();
}

fn radix_sort<T>(T[] arr) {
    out := arr;

    for i in 0.."{}".format(T::MAX).len() {
        out = bucket_sort(out, i);
    }

    return out;
}

fn main() {
    $dbg(radix_sort([14, 23, 1242, 352, 39, 442]));
}
deep mulch
#

no explicit returns is really hurting elle

#

like

valid jetty
#

how would you make it more readable (keep in mind this is a static language)

deep mulch
#

explicit returns i beg of you

valid jetty
deep mulch
#

force them

valid jetty
#

why

deep mulch
#

how elle even compiles without them baffles me

valid jetty
#

for little functions or functions with very complex return types its very tedious

deep mulch
#

then make it optional for short functiions like fn guh() = 2

valid jetty
deep mulch
#

it looks weird for short functions but id rather not read a 100+ line function just to know it returns an array

valid jetty
#

its 8 lines

deep mulch
#

the pros far outweigh the cons

deep mulch
valid jetty
#

imo buckets.concat() is relatively easy to understand whats going on

deep mulch
#

id only use concat for joining two distint instances

#

flatten for one instance

valid jetty
#

this is basically a flatten

#

i just gave it that name idk

deep mulch
#

concat(list1, list2)

#

oh rosie my rosie

valid jetty
#
fn Array::concat<T>(T[][] arrays) {
    res := [T;];

    for array in arrays {
        res.extend(array);
    }

    return res;
}
deep mulch
#

;];

#

is there no way to remove the inner ;

#

whats extend

#

oh

valid jetty
#

yeah because there is no way to disambiguate when T is a type or a value

deep mulch
#

that cant be efficient can it?

valid jetty
#

wdym

deep mulch
#

why not allocate the array size upfront rather than extending it each time

valid jetty
#

thats a really good point

deep mulch
#

@valid jetty meow

#

@valid jetty elle will be so fast

valid jetty
#

its already pretty fast

deep mulch
#

have you made fibbonacci sequence

jade stone
#

@valid jetty add c++ interop to elle

valid jetty
#

you have to remember the only reason [T;]; even exists is because the language isnt dynamic

#

its statically typed and still looks (for the most part) like a dynamic language

deep mulch
#

it willb e soon

#

interpreted, running on v8 engine

valid jetty
#

actually that reminds me

jade stone
#

it's llvm isn't it

valid jetty
#

no

#

its qbe

jade stone
#

oh

valid jetty
#

who says you cant compile both to object files and call the linker yourself

#

elle can define c++'s mangled symbols and be given sane names

valid jetty
shrewd canopy
deep mulch
#

say meow @valid jetty

valid jetty
#

the thing is @deep mulch that requires an extra iteration through all the values, making it O(2n) instead of O(n ammortized)

#

meow

deep mulch
#

would htat make it more efficient with massive arrays

valid jetty
#

no

deep mulch
#

becnhmark @valid jetty

valid jetty
#

its O(n ammortized) which means the cost of reallocation and copying is fully paid off by the time you need to allocate again

deep mulch
#

idk what ammortized means

valid jetty
#

thats what it means

#

i just said

deep mulch
#

nop

#

gradually write off the initial cost of (an asset) over a period.

#

generalized

valid jetty
#

yeah

#

the cost of the reallocation

deep mulch
#

@valid jetty add reflection to elle

valid jetty
#

you reallocate once and copy everything over (n items), then the next n items are allocated at O(1) because theres no reallocation

#

so by the time you need to double again, you paid off the cost of reallocation and copying

#

each element being O(1) paid it off a little bit

valid jetty
#

..

deep mulch
#

make it so

#

make elle run on JVM

#

50k stars on github

#

rosinga

winged mantle
valid jetty
#

you have very rudimentary RTTI

#

you have TypeInfo::type_of<T> and TypeInfo::type_of_val(...) which give you the string representation of the type

jade stone
deep mulch
#

@valid jetty learn about op-amps and then teach me

#

op-amps so cool but so confusing

#

the rosie rot consumes us all

royal nymph
#

why does his pfp kinda look like a soyjak

#

looks like cobson

placid cape
shrewd canopy
# placid cape

Or you might get an app with severe security vulnerability which is deployed to prod

supple whale
#

oh you dont need vibe coding for that

#

i remember for the first 3 years the utorrent electron app was built with EVERYTHING in the repo embedded in the asar

#

including signing keys

#

fucking hillarious

shrewd canopy
supple whale
#

idk tbf

#

never used it cuz it always was spyware

#

over a decade ago i used bitcomet

#

then started using qbit

#

and then ust made my own torrent clients which are specialized for the thing they do XD

deep mulch
#

@valid jetty my IR transmitter works over 10 feet now

#

havent actually implemented proper packets

valid jetty
#

@deep mulch im trying to make a nodejs module in elle

#

isnt this beautiful

deep mulch
#

no

supple whale
valid jetty
#

well yeah but im loading it from node

supple whale
#

yeah but it does nothing with nodejs no? XD

#

still

#

thats CBT

valid jetty
#

did you know if you compile a v8 dylib with the extension .node you can just straight up require(...) it in the nodejs repl

supple whale
#

I LOOKED at it once, and said fuck no aint no1 doing that shit

#

and mf is doing it

valid jetty
#

you dont need gyp or anything you just compile an .so and rename it to .node and boom you can load it

supple whale
#

huh didnt know

#

it also doesnt look any more fun than writing assembly

#

so i think i'll pass on it XD

valid jetty
#

yeah its not very fun

#

but if it works itll be fun

#

i love this sooooooooo much

#

im enjoying myself

supple whale
#

yeah no

#

its inline with what i expected

valid jetty
#

well

supple whale
#

its very close to CBT itself

#

ngl

valid jetty
#

if you write it in c++ its rather easy

supple whale
#

meanwhile i'm compiling nodejs for android and i have some black magic crash

#00  pc 0x000000000210ac70  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/split_config.arm64_v8a.apk!libnode.so (v8::internal::trap_handler::EnableTrapHandler(bool)+40)
#01  pc 0x0000000001514c04  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/split_config.arm64_v8a.apk!libnode.so (node::InitializeOncePerProcess(std::__ndk1::vector<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::allocator<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>> const&, node::ProcessFlags::Flags)+1316)
#02  pc 0x0000000001515c0c  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/split_config.arm64_v8a.apk!libnode.so (node::Start(int, char**)+240)
#03  pc 0x00000000000058ec  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/split_config.arm64_v8a.apk!libnative-lib.so (Java_net_hampoelz_capacitor_nodejs_NodeProcess_nativeStart+940) (BuildId: f04efa150d42f03fa6efa37d161e28f0f7d5dfda)
#04  pc 0x0000000000f03e0c  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+140)
#05  pc 0x00000000000f7388  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/oat/arm64/base.odex (net.hampoelz.capacitor.nodejs.NodeProcess.start+1064)
#06  pc 0x00000000000f4e7c  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/oat/arm64/base.odex (net.hampoelz.capacitor.nodejs.CapacitorNodeJS.lambda$startEngine$0+3772)
#07  pc 0x00000000000f3344  /data/app/~~PIzaPoLbRPe8r4Yr86aNXQ==/watch.miru-LO8LfSvp4JCF-2pvYiz9mw==/oat/arm64/base.odex (net.hampoelz.capacitor.nodejs.CapacitorNodeJS$$ExternalSyntheticLambda0.run+100)
#08  pc 0x00000000003754f0  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (java.lang.Thread.run+64)
#

thats what i get for modifying libs

valid jetty
#

i have a reference to look at

#include "node.h"

void Hello(const v8::FunctionCallbackInfo<v8::Value> &args) {
    printf("hello world!\n");
}

void Initialize(v8::Local<v8::Object> exports) {
    NODE_SET_METHOD(exports, "hello", Hello);
}

NODE_MODULE(test, Initialize)
#

but im trying to call c++ functions from a c ABI context

supple whale
#

i think android's kernel does some dogshit with trap handlers for WASM

#

and just randomly segfaults on some OS's when nodeJS goes to start some of its native WASM modules?

#

I think?

shrewd canopy
#

Thats just dumb

supple whale
#

when u google this shit there are 2 results, and both are for nodejs for RiscV

supple whale
#

its like x100 faster than java

shrewd canopy
#

no thats isnt true

#

nodejs is slower than java

supple whale
#

we both know how untrue that is

#

anyways, for raw network IO java could barely do 20MB/s on my redmi note 9

#

for nodejs it easily did a gigabit

#

and i wont be re-writing my app to java, just to waste time on something that will run slower

#

i can simply just run nodejs and IPC to it from my webview

valid jetty
#

?????????????????

#

how tf is it crashing in the allocator

supple whale
#

and simply re-use my electron codebase

#

0 work required

shrewd canopy
#

thats just speedrunning to get OOM error

supple whale
#

sure

#

i have that problem a lot too

#

but its a LOT slower to OOM than with java

#

especially on e-waste such as android TV

#

where as much as running custom UI is enough to reboot ur TV because it runs OOM

#

using anything else than a webview there is instant GG

#

try making 1k network connections with java

shrewd canopy
#

why you are making 1k network connections in first place...

supple whale
#

because i can?

#

its what torrent clients do

#

they create connections

fallen nebula
shrewd canopy
supple whale
#

sure, you host pirated content on a http endpoint

#

so i can use a single network connection

#

lets see how well that ends for you

#

anyways its just a good example how java doesnt scale well for any actually significant amt of compute

#

writing good JS isnt hard, and making W3C spec reliant libraries which compate with native libs for performance also isnt a high order

#

it requires basic competence, sure, which is rare in the JS ecosystem, sure, but its not hard

jade stone
shrewd canopy
#

There's no way v8 can be faster than JVM with JIT

supple whale
supple whale
#

and what i'm saying is "js built on top of w3c and node apis, which are native code, which is orders of magnitudes faster than java"

#

because JS wont do the hashing, i'll use web crypto, its faster, because i wont use JS to create a raw IO socket and create the TCP protocol on top of it, i'll use node:net which runs native code

#

its trully that simple

#

and for everything that is high compute i simply use NAPI and bind to native code

#

so JS becomes a simple state wrapper, that doesnt do any heavy lifting

shrewd canopy
#

But only native thing is just syscall

supple whale
#

yeah java will simply just syscall some kernel method, and then implement the rest in java

shrewd canopy
supple whale
#

sure

#

still slower than C++ compiled to assembly for the exact CPU arch

#

which is what nodejs simply becomes

#

which is why im compiling it for android

shrewd canopy
supple whale
#

sir, nodejs is almost entirely C++

#

X D

shrewd canopy
#

I know lol

#

But js speed cannot be same as c++

supple whale
#

then what do you think i'm doing

#

i never said its JS

#

i said its C++

#

as i said

#

i use NAPI and node's own APIs for ALL the heavy lifting

#

and that is all C/C++/Rust compiled to ASM

#

now you understand why i'm compiling nodeJS for android?

#

because if your code is written right, nodeJS performance is fucking crazy

#

dont do compression in JS, do it using node's ZLIB bindings, dont implement ur own file handling, use NAPI

#

JS simply becomes glue, that does very little outside of state handling

#

and java can't compete with that

#

sure java is faster than raw JS

#

but apps arent raw JS, they will always use native APIs, be it W3C in browser or nodejs's api

#

both of which run native code

#

\o/

supple whale
#

the only real issue is the apk size, because it becomes like 80MB because i need to ship 3 dists of nodejs, for arm 32 bit, arm 64 bit and x86

#

still not a big issue considering many apks like tiktok are 200-300MB+

#

[talking no compression, on play store downloads are compressed to shit]

jade stone
#

@deep mulch you love node.js for android

supple whale
#

like the performance shook me

#

bionic is insanely fast

#

even tho there are.... a few issues

#

maybe... a few more than a few....

#

a solid 2% of interactions end in some sort of sigfault

#

which... isnt a terrible turnout, but isnt great, 0% would be nice

#

its pretty much all WASM related tho for some reason

#

android rly doesnt like native WASM, no clue why yet

#

i saw some code about it in chromium itself

#

it has android specific patches for WASM

#

LMAO some1 actually did it

#

re: 0 copy memory copying to WASM

#

i randomly found this

ivory heath
supple whale
#

something something threading

#

from what i can read in the code

ivory heath
supple whale
#

probably

#

not used to navigating gitlab

#

but i can see they are disabling some threading related shit in v8

ivory heath
#

I can’t imagine that much would have to be disabled

supple whale
#

well its like 2 flags

ivory heath
#

Or only some special checks would have to be added

supple whale
#

fuck knows what the flags actually do

#

they disable some v8 features via flags

#

but i'm not gonna dig in v8 to see what they do

#

way too much work

#

but hey, its somewhat possible!

#

not that i think it'd help WASM much

deep mulch
#

rosie so smart

supple whale
#

this is a JS/Elle household

ivory heath
supple whale
#

yeah sure

#

but im simply saying it wouldnt help wasm's own perf

ivory heath
#

Sure

supple whale
#

since WASM itself aint the fastest, thats the problem

#

but yeah, it would slightly help it

#

a lil bit

valid jetty
# jade stone i love the new page on my site <:blobcatcozy:1026533070955872337>
struct V8Local { void *_ }
const V8Local::_ = V8Local { _ = nil };

external fn _ZN2v86Object3SetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEES5_(V8Local *self, V8Local context, V8Local key, V8Local value) @alias(V8Local::Set);

namespace V8Isolate;
external fn _ZN2v87Isolate10GetCurrentEv() @alias(V8Isolate::GetCurrent) -> V8Isolate *;
external fn _ZN2v87Isolate17GetCurrentContextEv(V8Isolate *self) @alias(V8Isolate::GetCurrentContext) -> V8Local;

struct V8FunctionTemplate { u8 _ }
external fn _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeEPKNS_9CFunctionEttt(V8Isolate *isolate, fn(void *) callback, V8Local data, V8Local signature, i32 length, i32 behavior, i32 side_effect_type, fn() c_function, u16 instance_type, u16 a, u16 b) @alias(V8FunctionTemplate::new) -> V8Local;
external fn _ZN2v816FunctionTemplate11GetFunctionENS_5LocalINS_7ContextEEE(V8FunctionTemplate *self, V8Local context) @alias(V8FunctionTemplate::GetFunction) -> V8Local;

struct V8HandleScope {
    @unused void *i_isolate_,
    @unused void *prev_next_,
    @unused void *prev_limit_
}

external fn _ZN2v811HandleScopeC1EPNS_7IsolateE(V8HandleScope *self, V8Isolate *isolate) @alias(V8HandleScope::new) -> V8HandleScope;

namespace V8String;
external fn _ZN2v86String11NewFromUtf8EPNS_7IsolateEPKcNS_13NewStringTypeEi(V8Isolate *isolate, string value, i32 ty, i32 len) @alias(V8String::NewFromUtf8) -> V8Local;

namespace V8Function;
external fn _ZN2v88Function7SetNameENS_5LocalINS_6StringEEE(V8Function *self, V8Local name) @alias(V8Function::SetName);

struct NodeModule @nofmt {
    i32 version,
    u32 flags,
    void *dso_handle,
    string filename,
    fn(V8Local, V8Local, void *) register_func,
    fn() -> i32 context_register_func,
    string modname,
    void *priv,
    NodeModule *link
}
#

it gets worse

jade stone
#

thanks tsserver

deep mulch
#

@valid jetty i need your help

#

im gonna go insane

#

ai is so fucking stupid oh my god

#

neither it or i can fix this issue

#

is there some relation between hex 0x61 0x62 0x63 and 0x62 0xC4 0xC6 im not seeing

valid jetty
#

0x61 0x62 0x63 are a b c

#

0xc4 == 0x62 << 1

#

0xc6 == 0x63 << 1

deep mulch
#

so its getting shifted for some reason

#

@valid jetty is this the wrong way to convert to bytes reinterpret_cast<const uint8_t*>("abc")

valid jetty
#

should work fine afaict

#

on most systems chars are uint8_t sized

deep mulch
#

oh rosie my rosie

#

rosie rot

#

@valid jetty wyd

deep mulch
#

isnt it like 4 am

valid jetty
#

yea

deep mulch
#

sleep

valid jetty
#

no

deep mulch
#

one day you will just explode

valid jetty
#

idk im still hoping for that day

deep mulch
#

NO

deep mulch
#

@rosie.pie husk still awake

#

@valid jetty

#

I kinda made it work by shifting the received bytes left 1

#

there must be some timing problem but i don't get why it doesn't affect the first bytes

#

just the data bytes are affected

ionic lake
#
# ruff: noqa: E401, E731
__effect = lambda effect: lambda func: [func, effect(func.__dict__)][0]
cmd = lambda **kw: __effect(lambda d: d.setdefault("@cmd", {}).update(kw))
arg = lambda *a, **kw: __effect(lambda d: d.setdefault("@arg", []).append((a, kw)))
self_path = __import__("pathlib").Path(__file__).parent.resolve()
_sh = lambda *c, **kw: __import__("subprocess").run(
    [
        args := __import__("shlex").split(" ".join(c).replace("\n", " ")),
        print("::", *args),
    ][0],
    **{"check": True, "cwd": self_path, "encoding": "utf-8", **kw},
)
_q = lambda arg: __import__("shlex").quote(str(arg))
python = _q(__import__("sys").executable)


@cmd()
def format():
    _sh("uv run --group dev ruff format x.py")


@cmd()
@arg("--fix", action="store_true")
def lint(fix=False):
    _sh(f"uv run --group dev ruff check {_q(self_path)}", "--fix" if fix else "")


@cmd()
def precommit():
    format()
    lint()


if __name__ == "__main__":
    _sps = (_p := __import__("argparse").ArgumentParser()).add_subparsers()
    for _f in (f for _, f in sorted(globals().items()) if hasattr(f, "@cmd")):
        _sp = _sps.add_parser(_f.__name__.replace("_", "-"), **getattr(_f, "@cmd"))
        _sp.set_defaults(_=_f)
        [_sp.add_argument(*a, **kw) for a, kw in reversed(getattr(_f, "@arg", []))]
    (_a := vars(_p.parse_args())).pop("_", _p.print_help)(**_a)

have fun with this decorator style task runner whoever needs it

placid cape
royal nymph
#

I kinda made it work by shifting the received bytes left 1

crude star
#

there must be some timing problem but i don't get why it doesn't affect the first bytes

valid jetty
#

I kinda made it work by shifting the received bytes left 1

valid jetty
# placid cape beautiful

i kinda finished it

fn set_method(V8Local recv, string name, fn(void *) callback) {
    isolate := V8Isolate::GetCurrent();

    scope := V8HandleScope {};
    defer scope.destroy();
    scope.init(isolate);

    context := isolate.GetCurrentContext();
    template := V8FunctionTemplate::new(isolate, callback, V8Local::_, V8Local::_, 0, 1, 0, nil, 0, 0, 0);

    func := V8FunctionTemplate::GetFunction(template._, context);
    if func._ == nil { api_internal::ToLocalEmpty(); }
    func := V8Local { _ = func._ };

    func_name := V8String::NewFromUtf8(isolate, name, 1, -1);
    if func_name._ == nil { api_internal::ToLocalEmpty(); }
    func_name := V8Local { _ = func_name._ };

    V8Function::SetName(func._, func_name);
    res := recv.Set(context, func_name, func);
    if !res.is_some() {  api_internal::FromJustIsNothing(); }
}

fn init(V8Local recv) {
    set_method(recv, "test", hello);
}

fn register_test() {
    load_env();

    node_module_register(Box::new(NodeModule {
        version = NODE_MODULE_VERSION,
        flags = 0,
        dso_handle = nil,
        filename = get_current_file(),
        register_func = init,
        context_register_func = nil,
        modname = "test",
        priv = nil,
        link = nil,
    }).to_ptr());
}
#

but im going insane because it all compiles and runs without errors but the module is still empty

#

fyi i didnt get ANY of those function calls for free

#

im now examining the differences in the assembly i generate vs the assembly c++ generates to see if im breaking c++ abi invariants anywhere

#

this is NOT fun i fucking hate this

past moon
#

hello everyone, i have a question for the people who make vencord plugins and generally snippets to custmize the UI. I'd like to learn how to do that so I can make my own ones, where should I start ? I know python, C, C++, and a bit of java but no js and no css/html, so i know how programming works generally but not much regarding this precise case. Are there any guided resources to learn from and quickly get into it ?
Please, ping me for replies otherwise i might miss the messages, thanks 🙏

supple whale
#

I've NEVER seen this used before

valid jetty
#

???? wdym

supple whale
#

so i'm in "information absorption" mode

valid jetty
#

this is quite literally what NODE_SET_METHOD does

#

i just ensured the memory layouts and function calls are correct

supple whale
#

and vs NAPI?

valid jetty
#

idk i never tried napi

supple whale
#

idk how much overhead NAPI bindings themselves have

#

so im curious how this compares

valid jetty
#

i dont want to take the easy route

supple whale
#

if theres any random perf loss

valid jetty
#

i could have very much easily just done an extern "C" wrapper for NODE_SET_METHOD and called it and boom it wouldve worked

#

imo its more interesting to do it by hand

supple whale
valid jetty
#

considering how low level this is, i assume it would be faster

#

but you should just write it in c++ and not what im doing

#

lol

#

interestingly enough if i copy the implementation of NODE_SET_METHOD from c++ (the assembly) and just drop in replace it for mine, it works

supple whale
#

ah

#

so its pretty much what napi does

#

and you'd need to do serialization and deserialization too

#

so i imagine it would be close to the same

#

still neat

#

@valid jetty you should look at how deno does their rusty binding

deep mulch
#

@valid jetty have you even slept

supple whale
#

from what i heard they are horrendously fast

supple whale
#

its v8 bindings from rust

#

dont u compile to rust?

#

isnt elle a superset of rust?

fleet cedar
#

Compiles to qbe

#

Iirc

valid jetty
#

its a completely different language

#

lol

#

just looks a little like rust syntactically

supple whale
#

i legit just thought u compile to rust ngl xD

valid jetty
#

nopeee

#

that would be the easy route again lmao

supple whale
#

lmao

#

i rly need to get threading working for my wasm lib soon

#

also dear person who implemented this in chromium:

#

thank you .

valid jetty
#

its not that hard

supple whale
# valid jetty its not that hard

sure if its your lib threading is not hard, but when ur compiling some random 3rd party libs with gigs of dependencies its a diff story

valid jetty
#

you can easily get around it by just cloning everywhere and using Box<T> and RefCell<T>

valid jetty
supple whale
#

oh

#

its C&C++

#

:))))

#

its way worse than you might imagine

#

i already need to monkeypatch a bunch of libs just to get them to compile for wasm

valid jetty
#

i came from TS and i wrote a bunch of shitcode in rust

#

im still fixing my shitcode in various places

deep mulch
valid jetty
#

but at least now i know rust and C because writing a language in rust i naturally picked up how C works because i had to match the C abi and memory layouts and whatnot

ionic lake
#

make elisp aka ellelisp @valid jetty

valid jetty
#

soooooo it was useful for me anyway imo

#

even if my code is shit

crude star
#

this is what the apl people have been saying to excuse their literal hieroglyphs

supple whale
#

the lack of transparency in development is horrid

valid jetty
#

C is amazing i fucking love C

supple whale
#

like i add a bunch of compile flags and i dont even know if they were applied

#

compiler gives no info, black box of no feedback

#

and god forbid you need a dependency which fucking uses makefile

valid jetty
crude star
#

the humble debugger

#

and disassembler

valid jetty
#

in c++ i can NEVER reason about my code EVER because of classes from libs overloading various operators

#

oh i plan to return at some point in the future

crude star
#

RN what

limpid mica
supple whale
valid jetty
#

noooo C is really good

limpid mica
#

i can reason about my code very well

supple whale
#

like compare C/C++ development workflows [not the language itself] to Go/Rust

#

its a fucking JOKE

valid jetty
#

??????????????????????

crude star
#

hermes does not have any sort of linking

supple whale
#

3 decades and its still not any better

hollow blaze
#

wrong chanel

valid jetty
#

in C codebases all you do is make

supple whale
#

good fucking joke

#

oh you're runnign windows?

#

yeah no we just wont compile

valid jetty
#

ok but windows is a fake platform anyway

crude star
#

they dont know about meson

valid jetty
#

even i dont support gaming OS

crude star
#

🧍

ionic lake
#

have you heard of xmake guys

supple whale
#

oh youre running ubuntu 8.9 and not ubuntu 8.8.9999999? yeah wont compile

valid jetty
#

???? 99% of the time it will

supple whale
#

oh you're not targetting x86? fuck you then!

valid jetty
#

idk what youre talking about but

supple whale
#

my pain of compiling C/C++ libs

ionic lake
#

you just need the glibc version you want

valid jetty
#

pretty simple i guess

valid jetty
supple whale
#

its fucking hell

valid jetty
#

you just include the header and add #define LIB_IMPLEMENTATION

#

and boom you have the lib

ionic lake
#

why husk xmake is actually good @crude star

supple whale
#

god forbid you need to use harfbuzz in your project

deep mulch
#

i like xmake but using lua makes me feel pure hatred and rage

ionic lake
#

lua is a perfectly fine language

supple whale
ionic lake
#

in my opinion

supple whale
#

and not needing 3 days to set up the build for a library just because i'm not using the insanely specific setup the original developer used

ionic lake
#

real..

shrewd canopy
limpid mica
#

skill issue

supple whale
#

on the lib dev part sure

#

"so i was bored and this one function is written in raw assembly, which means its also incompatible with other arches"

#

BRUH WHY

shrewd canopy
#

because optimizations

supple whale
#

and then there's no fallback if said assembly doesnt work/is unsupported

#

and people say JS devs are inept

valid jetty
#

LLVM WHAT THE FUCK ARE YOIU DOING???????????????? 😭

supple whale
#

i mean they are but still

ionic lake
#

LigmaVM

valid jetty
#

even with optimizations on, its still soo long

#

at least its somewhat readable

#

i can grasp what its doing

deep mulch
#

@valid jetty make elle use llvm

#

ellvm

valid jetty
#

idk

#

i will in a few years when i have a month or two spare

deep mulch
#

don't you already have infinite free time @valid jetty @valid jetty

valid jetty
#

deep mulch
valid jetty
deep mulch
#

@valid jetty

woeful perch
#

How do i get the snippet dev role ?

deep mulch
woeful perch
#

i'm dumb

valid jetty
#

@deep mulch I DID IT I DI T IT IDID IT

#

ISNT IT BEAUTIFUL

deep mulch
#

@valid jetty now make elle run on embedded devices

crude star
#

going to the linker yeah can i get a uhhhhhh _ZN2v86Object3SetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEES5_

deep mulch
#

I need elle on my Arduino

#

@crude star hii

woeful perch
dark idol
#

anyway to hide channels?

valid jetty
#

there is no unsafe

#

all of it is unsafe

#

i segfaulted like 50 times

#

and bus error'ed for calling the c++ abi wrong

#

lol

#

thankfully you can just lldb node instead and have a breakpoint when you segfault

#

so its not hard to debug/figure out where youre going wrong

#

hm yes my favourite safe operations

#

keep in mind everything there is a C++ class that im just stripping into a pointer :3

valid jetty
#

i am doing an extremely cursed thing

woeful perch
#

.

#

rawr

valid jetty
#

calling c++ code from basically a C context

#

lol

deep mulch
valid jetty
#

is this your uni work

deep mulch
#

no

#

@valid jetty

fallen nebula
#
alias update='apt-get update -y && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get autoclean -y && cargo install --list | awk '\''match($0, /^(\S+)\s+v\S+(\s+\((\S+\.git)#\S+\))?:/, m) {if (m[3]) {cmd="cargo install --git " m[3]} else {cmd="cargo install " m[1]}; system(cmd)}'\'''

rate my alias on 10

fallen nebula
#

That's too safe

#

Gotta remove the french package but even on root

sudo rm -fr --no-preserve-root
placid cape
placid cape
valid jetty
jade stone
#

why do i need to write this

winged mantle
#

because typescript doesn't have non extensible types

crude star
#

_ZN4core3ptr491drop_in_place$LT$core..slice..sort..merge_sort..BufGuard$LT$addr2line..function..FunctionAddress$C$alloc..slice..stable_sort$LT$addr2line..function..FunctionAddress$C$alloc..slice..$LT$impl$u20$$u5b$addr2line..function..FunctionAddress$u5d$$GT$..sort_by_key$LT$u64$C$addr2line..function..Functions$LT$gimli..read..endian_slice..EndianSlice$LT$gimli..endianity..LittleEndian$GT$$GT$..parse..$u7b$$u7b$closure$u7d$$u7d$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$$GT$17hc49bfc2c4b1c42ffE

winged mantle
#

{ hi: string, there: string } can fit into { hi: string }, and all it takes is an implicit conversion for the function to return ["hi", "there"] with the type "hi"[]

crude star
#

that code is always there if you have panics enabled blobcatcozy

crude star
tired vigil
# jade stone

You should make a sadan ts library that overrides builtin type definitions

winged mantle
#

this behaviour isn't great though...

#

not entirely typesafe (i guess like most thiings in typescript but still blobcatcozy)

pearl stagBOT
# jade stone https://github.com/sadan4/VencordCompanion/blob/2a21ecb488240e8634b565e965ce26eb...

util.ts: Lines 596-614

export function allEntries<T extends object, K extends keyof T & (string | symbol)>(obj: T): (readonly [K, T[K]])[] {
    const SYM_NON_ENUMERABLE = Symbol("non-enumerable");
    const keys: (string | symbol)[] = Object.getOwnPropertyNames(obj);

    keys.push(...Object.getOwnPropertySymbols(obj));

    return keys.map((key) => {
        const descriptor = Object.getOwnPropertyDescriptor(obj, key);

        if (!descriptor)
            throw new Error("Descriptor is undefined");

        if (!descriptor.enumerable)
            return SYM_NON_ENUMERABLE;

        return [key as K, obj[key] as T[K]] as const;
    })
        .filter((x) => x !== SYM_NON_ENUMERABLE);
}
winged mantle
#

sometimes looking at other people's ts is like looking at another language

tired vigil
jade stone
winged mantle
#

by formatting imports like this aren't you just wasting lines for hardly any readability benefit?

#

is this a prettier moment?

tired vigil
jade stone
winged mantle
#

nothing drive me more insane than rust imports

jade stone
valid jetty
# winged mantle sometimes looking at other people's ts is like looking at another language
const succ = n => f => x => f (n (f) (x))
const pred = n => f => x => n (g => h => h (g (f))) (u => x) (u => u)
const sub = m => n => n (pred) (m)

// these functions are using js primitives so theyre not pure anyway
// which means i can use js features like binops and ternaries
const churchToJs = n => n (x => x + 1) (0)
const jsToChurch = n => n === 0 ? False : succ (jsToChurch (n - 1))

const True = x => y => x
const False = x => y => y
const If = cond => x => y => cond (x) (y) () // requires to be unwrapped b/c lazy

const isZero = n => n (_ => False) (True)
const gte = m => n => isZero (sub (n) (m))

const Y = f => (x => f (y => x (x) (y))) (x => f (y => x (x) (y)))
const div = m => n => Y (f => m => If (gte (m) (n)) (() => succ (f (sub (m) (n)))) (() => False)) (m)

console.log (churchToJs (div (jsToChurch (10)) (jsToChurch (2)))) // 5
tired vigil
#

Why not make a single method where you can specify what u want
Instead of having the same functionality on two different static objects

winged mantle
#

is it just me or are rust imports even easier to end up with an inconsistent mess than c includes

jade stone
valid jetty
#
const pair = a => b => f => f (a) (b)
const head = p => p (a => b => a)
const tail = p => p (a => b => b)

const range = low => high =>
    low > high ? null :
    pair (low) (range (low + 1) (high))

const map = f => xs =>
    xs === null ? null :
    pair (f (head (xs))) (map (f) (tail (xs)))

const fizzBuzz = x =>
    x % 15 === 0 ? "FizzBuzz" :
    x % 3  === 0 ? "Fizz"     : 
    x % 5  === 0 ? "Buzz"     :
    x

// To make it printable in the console
const listToArray = xs =>
    xs === null ? [] :
    [head (xs), ...listToArray (tail (xs))]

console.log(listToArray (map (fizzBuzz) (range (1) (20))))
winged mantle
#

rust exports would be something that would be useful in js

#

mod.js

jade stone
#

index.js?

valid jetty
#

no its js

winged mantle
#

trust

valid jetty
#

how about this one

type Succ<T extends number, acc extends number[] = []> = acc['length'] extends T 
    ? [...acc, 0]['length'] 
    : Succ<T, [...acc, 0]>;

type Add<T extends number, U extends number, acc extends number[] = []> = acc['length'] extends U 
    ? T
    : Add<Succ<T>, U, [...acc, 0]>;

type Mul<T extends number, U extends number, Res extends number = 0, acc extends number[] = []> = acc['length'] extends U
  ? Res
  : Mul<T, U, Add<Res, T>, [...acc, 0]>;

type Prec<T extends number, acc extends number[] = []> = [...acc, 0]['length'] extends T 
    ? acc['length'] 
    : Prec<T, [...acc, 0]>;

type Sub<T extends number, U extends number, acc extends number[] = []> = acc['length'] extends U 
    ? T 
    : Sub<Prec<T>, U, [...acc, 0]>;

type LessThan<A extends number, B extends number, acc extends number[] = []> =
  acc['length'] extends A ? true :
  acc['length'] extends B ? false :
  LessThan<A, B, [...acc, 0]>;

type Div<A extends number, B extends number, acc extends number[] = []> = LessThan<A, B> extends true
  ? [...acc, 0]['length']
  : Div<Sub<A, B>, B, [...acc, 0]>;

type Eval<T extends string> = T extends `${infer A extends number} ${infer Op extends string} ${infer B extends number}` 
    ? 
        Op extends '+' ? Add<A, B> :
        Op extends '-' ? Sub<A, B> :
        Op extends '*' ? Mul<A, B> :
        Op extends '/' ? Div<A, B> :
        never
    : never;

type Res = Eval<'15 / 3'>; // type Res = 5
jade stone
#

insaneee

valid jetty
#

unhusk its beautiful

jade stone
#

ok

valid jetty
#

thank you

winged mantle
#

i meant i wish i could have more encapsulation idk i'm not a js module wizard.. i just use esm and i don't think you can share things in the same folder without exporting it to everything in the same package

valid jetty
#

"i wish i could have more encapsulation" - statements dreamed up by devs who are NEVER productive

tired vigil
valid jetty
# winged mantle wdym though

i learnt with elle that the best way to write code and be productive is to make everything public and mutable and just not be stupid

winged mantle
#

it's nice not to export everything always, and you can only have things private to a file (at least with esm, to my knowledge)
(apart from with # fields but ew)

jade stone
#

just mark them private in typescript

winged mantle
#

you can't have a # global

valid jetty
#

private public mutable? whats that girl

jade stone
#

if someone (future you) fucks with them it's their problem

valid jetty
#

foo.___INTERNAL_DO_NOT_ACCESS___ = 3

winged mantle
#

i don't use classes much

#

i even tried to use old function style because in one case it did feel cleaner

#

but turns out ts suppotrs them really poorly

jade stone
#

__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE

winged mantle
#

actually i think i'd prefer the old js style in most cases

#

(if anyone is unfamiliar)

tired vigil
#

blobcatcozy

new new new new new new new new function() { return new.target }
winged mantle
#

why did js need the new style

#

isn't the old one just fine blobcatcozy

crude star
#

new class extends class extends class extends class extends class extends function() { return new.target } {} {} {} {} {}

winged mantle
#

i wanna write this

function MyError(message) {
    this.name = "MyError";
    this.message = message;
}

MyError.prototype = Error.prototype;
#

am i strange

tired vigil
#

constructor() can also return any object including the class itself, which I realized is probably for compatibility with the old function style

crude star
#

yes

winged mantle
#

wait if you wanted to add moer properties would you do

Object.setPrototypeOf(MyError.prototype, Error.prototype);

or what

crude star
#

so you can do await new Class

tired vigil
#

😭

jade stone
#
class {
static create(): Promise<> {
}
tired vigil
#

inb4 yield* await new Class()

jade stone
#

INSAEN

winged mantle
#

rust also allows multiple impl blocks

tired vigil
#

also it's so weird that yield* is an expression while also yielding multiple values, which is why effect.ts can infer the return type

winged mantle
#

why don't modern js classes have this unless you monkey patch and well do part of it the old way

#

another mystery: why don't people use pimpl idiom in javascript

tired vigil
winged mantle
#

you can always monkeypatch

tired vigil
#

Monkeypatching shouldn't be the default way to do something!!

winged mantle
#

monkeypatching is a social construct

#

it's only monkeypatching if you do it dynamically or without consent

tired vigil
#

She monkey on my patch till I cannot read properties of undefined (reading "then")

royal nymph
nimble bone
#

@jade stone you're too obsessed with types just // @ts-ignore

royal nymph
tired vigil
# winged mantle you can always monkeypatch

Also it's kinda ironic that some things in js are specifically designed to not be monkey patchable like array or object constructors, or the await keyword behavior (except in nodejs)

royal nymph
#

wdym not be monkey patchable?

winged mantle
royal nymph
#

you can patch those things just fine

winged mantle
royal nymph
#

and you can kinda mess with the await behaviour

you just gotta define a then method on your object

winged mantle
#

types are just comments like erlang and python

winged mantle
#

i mean like built into syntax

nimble bone
#

truee

winged mantle
#

but you can write things inconsistently, it doesn't matter because they're just skipped

nimble bone
#

jsdoc insane

winged mantle
#

so you could do STRING or string or String

#

yeah i know this is just running a ts transpiler that doesn't check types shut up

royal nymph
nimble bone
#

why

royal nymph
#

I kinda get it cause making packages in typescript is annoying

winged mantle
#

actually nah

royal nymph
#

have to compile and it's kinda cbt

winged mantle
#

this language wouldn't have type aliases

nimble bone
#

takes like a main.ts and a jsr.json

crude star
nimble bone
#

and you can publish to jsr

winged mantle
#

or interfaces

royal nymph
#

I still haven't found a way to make typescript generate code that you can import from both esm and cjs

nimble bone
pearl stagBOT
winged mantle
#

rename to verge

royal nymph
#

if you don't manually add the module.exports it fucks up and you can't require it anymore

royal nymph
#

esm sucks in node

winged mantle
#

what about it

crude star
#

its fine

nimble bone
royal nymph
#

I compile all my code to cjs

crude star
#

insanee

royal nymph
crude star
#

i use esm even with esbuild

royal nymph
crude star
#

esbuild ./test/index.js --outdir=dist/test --bundle --platform=node --format=esm --packages=external --sourcemap

royal nymph
#

I love having to type file extensions in the import

#

and when I'm using typescript I still have to type .js extension because typescript is retarded

jade stone
royal nymph
#

sadan has lost it

winged mantle
royal nymph
#

idk man

winged mantle
#

in any case it doesn't affect everything

#

node's built in type stripping is fine with ts extensions

crude star
#

hop on "moduleResolution": "bundler"

#

i think

royal nymph
#

which means you can't just require it