#programming

1 messages · Page 167 of 1

opaque sigil
#

less branching?

#

or is it just making the branch predictor's life easier

sage crag
#

no, i think its a combination of prefetching and the change of an indirect branch to a direct branch

sage crag
#

but it was actually slower when i removed vm->pc = pc; from the code

olive sable
#

branch prediction neuroPogHD
i have no clue how it works but its magic

opaque sigil
#

i hate cpus

sage crag
#

which

opaque sigil
#

they make no sense sometimes neuroCry

sage crag
#

idfk

opaque sigil
#

i say that but gpus are arguably worse

sage crag
#

the vm pc shouldnt be used inside the hot loop

#

but for some reason removing that line pessmises it by about 12%

olive sable
#

ive had to study more about gpu's than cpu's. so i know more baout them than cpu's and thus they're less strange to me

midnight sigil
opaque sigil
olive sable
#

cpu's are smart and complex

sage crag
#

cpus are dumb and complex

#

stupid rock

olive sable
#

gpu's are just a bunch of idiots working toghether

#

like my schoolprojects

olive sable
opaque sigil
#

that just is doing a lot of heavy lifting there neuroAware

olive sable
#

wdym?

#

nobody expects you to know the in and outs of the microcode

sage crag
#

erm godbolt i dont think this is quite right

opaque sigil
#

llvm ir neuroPogHD

#

speaking of llvm, 21 is stable neuroPogHD

sage crag
#

interesting

#

goto and loop produce the same asm

#

but recursive with a tail call is slightly better

#

ok let's add a slight complexity

opaque sigil
#

i vaguely remember python getting a new tail calling interpreter a while back and it performing better too

#

don't think it's recursive though

sage crag
#

well, that's what a tail call is

#

recursion

opaque sigil
#

i should probably go sleep

#

you right

sage crag
#

and that's because the tail-recursive one has to do more work

opaque sigil
#

i'll just take your word for it, i really don't feel like reading assemly right now neurOMEGALUL

sage crag
#

its a shame that in c you cant do inline functions when there's anything to do with computed goto

opaque sigil
#

how would that even work

sage crag
olive sable
#

just dont goto i guess evilShrug

opaque sigil
#

true you should clearly use setjmp/longjmp mhm

sage crag
#

im not actually familiar with setjmp/longjmp

#

i dont know what their perf characteristics are

opaque sigil
#

you need to save a lot of registers

sage crag
#

computed goto (direct threading) is the most efficient design of interpreter

opaque sigil
#

so it'll be slow i'd imagine

olive sable
#

when a cpu uses 100W of power, does that mean it will also output 100W of heat?

#

or does not all the power become heat?

opaque sigil
#

unless you have some weird cpu that has other ways of dissipating the energy i think it should be close to 100% heat?

olive sable
opaque sigil
#

parts of it could be going to other stuff on the motherboard idk

olive sable
#

i was thinking about how much of the electricity gets used for data to other parts of the pc, but its probably so litle that it doesn tmatter

opaque sigil
#

yeah

sage crag
#

i cant get clang to inline this

opaque sigil
#

i think this is the strongest indication you can give the compiler

#

unless you make it a macro or constexpr or sth i guess

sage crag
#

that defeats the point

opaque sigil
#

yup

#

mojo has the ability to actually force the compiler to inline something so at least they changed their mind there thankfully

sage crag
#

so apparently they switched away from computed goto to tail calls

#

but also computed goto wasnt even their fastest interpreter

#

this is nonsensical to me

opaque sigil
#

the tail call interpreter is only in 3.14 isn't it

#

or am i tripping

#

or was it 3.13

#

okay 3.14 it was

opaque sigil
sage crag
#

this is so confusing to me

#
void step_goto(char **pc_ref) {
    static const void *tab[] = {
        &&op1, &&op2,
    };

    char *pc = *pc_ref;

    next:
    goto *tab[*pc++];

    op1:
        printf("op1 (should terminate)");
        *pc_ref = pc;
        return;
    op2:
        printf("op2 (should continue)");
        goto next;
}

here's a mockup of a simple computed goto interpreter

#

this is fairly easy to understand, and is quite efficient

#
#define MUSTTAIL [[clang::musttail]]
#define PRESERVE_NONE __attribute__((preserve_none))

typedef PRESERVE_NONE void (*OpFunc)(char **pc_ref);

PRESERVE_NONE void dispatch(char **pc_ref);
PRESERVE_NONE void op1_tail(char **pc_ref) {
    printf("op1 (should terminate)");
    return;
}
PRESERVE_NONE void op2_tail(char **pc_ref) {
    printf("op2 (should continue)");
    MUSTTAIL return dispatch(pc_ref);
}

static const OpFunc ops[] = { op1_tail, op2_tail };

PRESERVE_NONE void dispatch(char **pc_ref) {
    MUSTTAIL return ops[*((*pc_ref)++)](pc_ref);
}

void step_tco(char **pc_ref) {
    dispatch(pc_ref);
}

and here is what i have come up with for a tail call interpreter

#

its strictly just more complex

#

i dont see how it can ever be faster

opaque sigil
#

Yeah idk

#

Maybe it becomes an issue as the table grows in size?

sage crag
#

hmm

#

could be

sage crag
# opaque sigil Maybe it becomes an issue as the table grows in size?
step_tco:
        push    rbp
        push    r15
        push    r14
        push    r13
        push    r12
        push    rbx
        push    rax
        mov     rbp, rdi
        mov     r12, qword ptr [rdi]
        movsx   rax, byte ptr [r12]
        lea     rcx, [rip + ops]
        call    qword ptr [rcx + 8*rax]
        mov     qword ptr [rbp], rax
        add     rsp, 8
        pop     rbx
        pop     r12
        pop     r13
        pop     r14
        pop     r15
        pop     rbp
        ret

look at this stack usage neuroCry

#

what do you need all of that for

glad path
#

i finally got nvim set up

#

took forever since I had to make a theme identical to my vs code theme

sage crag
#

erf

olive sable
sage crag
#

you know, code size can be decieving

#

im tempted to try out the recursive approach for giggles

glad path
sage crag
#

if anyone can think of a better way of doing this i will pay you with 1 (one) enub

glad path
#

it was a custom theme i found on the marketplace

#

which turned out to be a textmate theme

#

ofmg why do so many plugins keep disabling my fold column

#

nvm

tender river
glad path
tender river
#

mhm

glad path
#

i got the theme to be almost identical

sage crag
#

i did actually find a middleground

#

i stripped back the interpreter a bit so instead of char **pc_ref its char *pc

#

which one do you think is more efficient

char *step_goto_3(char *pc) {
    static const void *tab[] = {
        &&op1, &&op2,
    };

    next:
    goto *tab[*pc++];

    op1:
        printf("op1 (should terminate)");
        return pc;
    op2:
        printf("op2 (should continue)");
        goto next;
}

#define MUSTTAIL [[clang::musttail]]
#define PRESERVE_NONE __attribute__((preserve_none))

PRESERVE_NONE char *step_goto_2(char *pc) {
    static const void *tab[] = {
        &&op1, &&op2,
    };

    goto *tab[*pc++];
    op1:
        printf("op1 (should terminate)");
        return pc;
    op2:
        printf("op2 (should continue)");
        MUSTTAIL return step_goto_2(pc);
}
tender river
#

did #2 actually get inlined

sage crag
#

neither of these can be inlined

#

since computed goto

#

but #2 does correctly inline the tail call yes

tender river
#

thats not inlining im silly neurolingSlep

sage crag
#

awawa

tender river
#

i'd hope these are the same performance but its very possible they arent (especially with preserve_none machinery)

sage crag
#

well, it turns out they are the same

#

but

#

its actually preserve_none doing the work

#

with preserve_none on either of them, they are better

#

(still the same)

#

this is a good thing for me since it means i dont have to rely on the tail call version

#

for some free performance

#

the tail call version is elegant though...

#

the tail call version only really works with char *pc and not char **pc_ref

#

which is the more common one

tender river
#

but you cant modify glibc neuroSadge

sage crag
#

i dont believe it

#

not in a hot path

#

the stack manipulation alone is crazy

tender river
#

it also helps PGO

sage crag
#

fake

tender river
sage crag
#

this roughly aligns with what i've seen though

tender river
sage crag
#
; gcc
"step_goto_3":
        sub     rsp, 8
        mov     rbx, r12
        mov     r12, QWORD PTR [r12]
.L2:
        movsx   rax, BYTE PTR [r12]
        add     r12, 1
        jmp     [QWORD PTR "tab.0"[0+rax*8]]
.L4:
        mov     edi, OFFSET FLAT:.LC1
        xor     eax, eax
        call    [QWORD PTR "printf"@GOTPCREL[rip]]
        jmp     .L2
.L3:
        mov     edi, OFFSET FLAT:.LC0
        xor     eax, eax
        call    [QWORD PTR "printf"@GOTPCREL[rip]]
        mov     QWORD PTR [rbx], r12
        add     rsp, 8
        ret
sage crag
#

there's no way the tco garbage can be faster than this

tender river
sage crag
# sage crag ```x86asm ; gcc "step_goto_3": sub rsp, 8 mov rbx, r12 ...
; clang
step_goto_3:
        push    rax
        mov     rbx, qword ptr [r12]
        inc     rbx
        movsx   rax, byte ptr [rbx - 1]
        lea     r14, [rip + step_goto_3.tab]
        jmp     qword ptr [r14 + 8*rax]
.Ltmp5:
        lea     rdi, [rip + .L.str.1]
        xor     eax, eax
        call    qword ptr [rip + printf@GOTPCREL]
        inc     rbx
        movsx   rax, byte ptr [rbx - 1]
        jmp     qword ptr [r14 + 8*rax]
.Ltmp9:
        lea     rdi, [rip + .L.str]
        xor     eax, eax
        call    qword ptr [rip + printf@GOTPCREL]
        mov     qword ptr [r12], rbx
        pop     rax
        ret
#

interesting difference

#

i think gcc's is better

#

also here's the tail call dispatch version

#
op1_tail:
        push    rax
        lea     rdi, [rip + .L.str]
        xor     eax, eax
        call    qword ptr [rip + printf@GOTPCREL]
        xor     eax, eax
        pop     rcx
        ret

op2_tail:
        push    rax
        lea     rdi, [rip + .L.str.1]
        xor     eax, eax
        call    qword ptr [rip + printf@GOTPCREL]
        movsx   rax, byte ptr [r12]
        lea     rcx, [rip + ops]
        pop     rdx
        jmp     qword ptr [rcx + 8*rax]

step_tco:
        push    rbp
        mov     rbp, r12
        mov     r12, qword ptr [r12]
        movsx   rax, byte ptr [r12]
        lea     rcx, [rip + ops]
        call    qword ptr [rcx + 8*rax]
        mov     qword ptr [rbp], rax
        pop     rbp
        ret
#

this is the same on clang and gcc, roughly

glad path
#

its somehow normal for deepseek r1:8b to spend 20 minutes thinking before I cut it off since it munched too much battery power (using ollama)

#

keeps happening to me

glass flower
sage crag
#

i made some changes with my findings and it got slower

#

i hate computers

olive sable
sage crag
#

i have decided being 8x faster than python is enough

sage crag
#

surely

#

please

#

someone

tender river
#

riia

olive sable
#

ask chatgpt NeuroClueless

tender river
#

ask a markov chain

sage crag
#

stupid machine

olive sable
#

hardware acceleration Minamhm

tender river
#

gpus dont do well with branching

sage crag
olive sable
#

not specifically gpu's

sage crag
#

i think im gonna do it

olive sable
#

make an actual pcie device thats fast at interpreting

sage crag
#

im gonna implement python's stupid interpreter format

#

and see what happens

#

but im already 8x faster

#

ahhhh

#

conflict of interest

#

i could just play osu

#

ermplode

tender river
#

gohan suru

#

ofuro ni suru

#

soretomo watashi to sakkyoku suru

sage crag
#

no thanksk

olive sable
#

uhh

sage crag
#

im not hungry

olive sable
#

i know one of thsoe words

#

nah 2

sage crag
#

dont translate

olive sable
#

what?

sage crag
olive sable
#

i mean i couldnt be bothered to do so anyways, but is there a specific reason i shouldnt?

sage crag
#

not in particular, it's just funny

#

implementing python's interpreter is actually a very bad idea because it

#

has a different execution model to my interpreter

#

my interpreter likes to exit after 1 instruction whereas python's interpreter likes to continue until the program is finished

#

really the latter one is more efficient but its also less flexible

tender river
#

but wouldnt always continuing (but with fuel) be better

sage crag
#

yes

#

well, except

#

that there's a branch at the beginning if i do fuel

#

dunno if it will play nice

tender river
#

its fine with tail call

sage crag
#

wait what

#

it just nearly doubled

#

even when fuel is 1?

#

oh

#

i never subtracted from the fuel

#

this is awkward

tender river
sage crag
#

wahoo its nearly doubled (for real)

#

there seems to be diminishing returns after 10 fuel

tender river
sage crag
#

hrm

#

or just the length of the program

tender river
#

put a transformer model in the cpu for branch prediction

#

ai cpu

#

money

sage crag
#

cpu

tender river
#

cpu prompt injection

sage crag
#

issue

#

i changed the code and its faster

#

but now its returning a different value

tender river
#

its faster neuroAYAYA

sage crag
#

i dont know what to believe

tender river
#

no need for correctness when you have blazingly fast

#

🚀 🔥

sage crag
#

true neuroAYAYARRR

olive sable
#

🎉

#

why are you interpreting anyways? thats known for being slow

sage crag
#

i removed the difference between op_next and op_exit entirely and changed it to be entirely fuel based

tender river
#

so she doesnt have to write a jit

sage crag
#

this hs made the branch predictor happy

sage crag
#

this needs to run on arm, x86_64, and riscv

#

its running for significantly less cycles than its supposed to

#

this is concerning to me

#

either that or im really good

olive sable
#

is compiling not an option or am i missing the point here?

tender river
#

compiling is almost never an option unless the language was made with compilation in mind

sage crag
#

nope same number of cycles with 3000 iters as 100000 iters

#

why

tender river
#

jit compilation is possible, but complicated and annoying compared to interpreters

olive sable
#

i thought compiling was common

#

thats interesting

tender river
#

you dont compile js or python

#

and in fact you essentially cant compile it

#

ahead of execution, that is

olive sable
#

Shruge ive never written js. ive done pythona nd c++ so far

#

and scratch and ti basic but those are baby shit

sage crag
#

i see we somehow managed to get to a random bad opcode

#

erm

#

jump issue

#

probably

#

oh that's really stupid

#

im really stupid

#

nevermind it didnt work

olive sable
#

i have no clue how interpreting works,b ut i always assumed it jsut reads a line of code and pastes some instructions into the cpu's register or something

sage crag
#

oh double nevermind i misread my own code

#

nice fixed it

sage crag
#

never from lines of code

#

always from bytecode or AST

olive sable
#

so it interprets into bytecode, which then puts instructions into the cpu?

tender river
#

its just C code

sage crag
#

0% branch misses

tender river
sage crag
#

generally you "compile" the program to bytecode

#

then the bytecode is interpreted

olive sable
#

ooooh

sage crag
#

or you use the AST and interpret that directly

#

bytecode interpreters are more efficient

olive sable
#

wait

sage crag
#

it emulates a cpu

olive sable
#

since cpu's take instructions sequentiely anyways why is interpreting slower?

sage crag
#

a cpu that runs the bytecode as its machine code

sage crag
#

you cant just tell the cpu to do it, otherwise that's no longer interpreting

#

remember, the cpu has a set instruction set

olive sable
#

yes Minamhm

tender river
#

more layers of indirection = more slow

olive sable
#

this might sound stupid, but surely they could make special hardware thats really good at interpreting making the cpu free to execute?

sage crag
#

if it runs the bytecode, its a cpu

#

it would just be a cpu that is designed with the bytecode as its instruction set

olive sable
#

huh

tender river
#

there is a language where interpreters can run as quickly as possible, and it's called lambda calculus

sage crag
#

cpus are already practically optimal for interpreters

tender river
#

this is because lambda calculus can be partially evaluated, and optimal evaluators also replace common subexpressions in one go

#

but lambda calculus is far from machine code

#

polar opposite even

sage crag
#

ver slow

#

its an entirely different type of computing in its pure form

olive sable
#

honeslty i have not figured out how lambds work in both python and c++. i really dont get it so no thanks

sage crag
#

awawa

olive sable
#

awawa

sage crag
#

python lambdas are named that way because they are anonymous functions

#

which is like lambda calculus somewhat

olive sable
sage crag
# olive sable <:evilShrug:1131357858101993603>

ERRATA:
• The "Church-Turing Thesis" is different from the "Church-Turing Theorem". The "theorem" is the claim which I discussed in the video- namely, that the Turing machine and lambda calculus are equally powerful. The "thesis" is the informal claim that the two of these systems are a sufficient formalization which capture the idea of "arbit...

▶ Play video
olive sable
#

okay

sage crag
olive sable
#

ah okay, i was thinking "what in the fuck is happening? i shoudl check the comments"

tender river
#

its more abstract rather than slower

#

the higher level of abstraction can allow you to make faster programs than you would normally think of

sage crag
#

yes

sage crag
#

lambda calculus is slow on traditional computers though

tender river
sage crag
#

fair, evaluating lambdas with beta reduction is slow on traditional computers

#

"pure"

tender river
#

i mean beta reduction is normal but even then you have so many options, like do you use whnf like haskell or do you use beta-optimal reduction, do you do it in parallel or on a single thread, etc

#

awa

sage crag
#

interpreter loop is now 77% c throughput

#

on stdout

#

awa

tender river
#

c bad neuroWAJAJA

sage crag
#

well, im cheating by using a large string

#

its probably worse if i do a single char

olive sable
#

single thread is probably optimal for smaller ones, but large ones will benefit more form the extra compute than the overhead of multithreading limits them

sage crag
#

also computation in lambda calculus is lambda calculus

olive sable
#

wdym? id hope everythin is resolvable, thats how math works?

sage crag
#

reading skill

sage crag
#

and my vm is uh

#

228 MiB/s

tender river
#

here's what i was talking about

#

futamura projections

sage crag
#

not a real fair test though

#

if my vm 8x slower than c, and my vm 8x faster than python, then python is 64x slower than c

#

surely

olive sable
#

tbh so far in this lambda video it just looks like an overly complicated way to do standart algebra

sage crag
#

mhm

tender river
#

but structures other than numbers exist

sage crag
#

this is like the whole premise

#

of the video

tender river
#

numbers are just one of the simplest structures so they're a good example

#

natural numbers at least

sage crag
#

ehehe irrational number in lambda calculus

tender river
sage crag
#

well, for ones that have converging functions its easy to represent them

#

not for arbitrary ones though

tender river
sage crag
#

yeah evilStare

olive sable
tender river
#

standard algebra isnt a programming language

sage crag
#

awa

#

well, it still requires arbitrary precision rational operations to compute

#

so maybe its not simpler neuroDespair

tender river
#

if you find any way to do it and give it to an optimal reducer it will probably find a way to evaluate it efficiently

sage crag
#

probably doing a lot of work

olive sable
#

ye i dont get it, ill stick to graphics

tender river
#

lambda calculus is C macros but where the macros you're currently using dont temporarily disappear

olive sable
#

huh

#

i didnt know C macros could have functions inside them

#

cant be bothered to rewrite my code tho so ill simply ignore this

sage crag
#

good

#

do not use macros if you can avoid it

olive sable
#

are they bad?

tender river
#

they are copy paste

#

copy paste is good

#

neuroPogHD

olive sable
#

im getting mixed signals here

tender river
#

use macros when you need to copy paste and cant avoid it

#

the simpler the language the harder it is to avoid it

#

its an absolute necessity in C but in C++ its not as important because templates exist

olive sable
#

so normal functions that do the same thing are still prefered?

tender river
#

its preferred because its easier for the compiler to understand what you're trying to do

olive sable
#

okay so i will jsut not use them then

tender river
noble zodiac
#

It uses a million allocations because of rust lifetimes. Also I wrote mine while also learning lisp itself

olive sable
#

i finished the lambda video

#

that shit is complicated

tender river
#

each cons is an allocation

#

it just uses an arena instead of malloc

noble zodiac
#

honestly I faked cons pairs. Internally it will use a vector and abstract cdr over it

tender river
#

i did not because it allows sharing cupsama

noble zodiac
#

and Im considering getting rid of it alltogether

tender river
#

without linked lists that would be super expensive

noble zodiac
#

well, mine does the same but the env is not part of the language itself so it has nothing to do with cons cells for me

tender river
noble zodiac
#

the env uses a hashmap for the lookup and I cant have a hashmap without having an env first, hen egg and all that

#

Also, I agre with konii, reading is great. Thanks for coming to my TED talk

olive sable
#

lmao

#

i like reading when i am actually interesting in the story, and when i can actually focus on it, and when im doing it not because i have to

#

which happens very infrequently

olive sable
#

i actually cant remember the last time i read a book

#

thats interesting

noble zodiac
#

lucky you there are tons of intresting stories out there neuroHypers

olive sable
#

true

#

i have really no arguments left against this, i just cant be bothered

noble zodiac
#

hot take, the last couple dune books are kinda mid but eh

olive sable
#

i watched the first movie 8 hours ago and i didnt really get it

#

sand init

#

it felt like aldi brand the force from starwars

tender river
tender river
noble zodiac
#

thats the good ones imo

#

there are 6 total by frank and a bunch more by his son

tender river
#

awa

noble zodiac
#

and dune came before star wars so if anything lucas took inspiration from it

olive sable
#

NeuroBounce i made a circle

#

my hdr is still fucked up goddamnit

#

i did it really inneficiently cuz i cuuldnt be bothered to automate it

tender river
#

!nothing

stiff micaBOT
sage crag
#

elvyn

tender river
#

!bwaa

stiff micaBOT
sage crag
#

and this is caused by shr saying this, om

sage crag
olive sable
#

Welp

#

Im tired of fixing screenhot hdr

#

Il going to bed

uneven pulsar
#

Well i am trying to do my best to pass my python exam so i can learn java

#

i just need to pass my python exam for now and i can handle my grades with js ts and Java

uneven pulsar
amber fractal
#

nahhhhhhh It is still a floating environment on the android app

tender river
fierce nova
#

neuro7 ok, I hope undervolting my pc won't kill my setup with Intellij + docker on win. So far so good - minus 20c for cpu

nocturne olive
#

welldoneneuro Good start

#

How many mV is that?

#

I personally have my CPU overclocked to 5.1GHz and sustaining it by having a -50mV undervoltage

fierce nova
#

had good run with -20, now -30

#

insane how it can lower your cpu temp by so much(yea yea I know it's logical, but still)

nocturne olive
#

Which voltage parameter are you changing? For me reducing the voltage barely seemed to change temps, it went from like 105 C unstable 5.1GHz to 90-95 C stable 5.1GHz

#

With the full -50mV undervolt

uneven pulsar
#

I think I'm in love with GO

uneven pulsar
floral dirge
sick owl
#

That proposed use case image is a truly dreadful idea

#

Like jesus Google

#

I know you're proud of your IP68 rating but lets not push it

unkempt citrus
#

Wouldn't an infra-red camera be a better way to implement it

frank jacinth
#

@sleek stream you should learn rust

#

you can code websites with rust

#

etc

sleek stream
#

What is that

frank jacinth
#

it has no garbage collector but protects against memory leaks

#

it ennsures your code is safe

sleek stream
#

Sweet

frank jacinth
#

it has type-safety

#

unsafe behavior is clearly separated from safe behavior

#

amazing package ecosystem

tender river
#

what is this horrible pitch vedalCry

sleek stream
frank jacinth
frank jacinth
#

it wasnt meant to be a pitch but

sleek stream
frank jacinth
#

i can teach you if you want

sleek stream
frank jacinth
#

ye ye all good

frank jacinth
#

rust by example is another great guide

#

rustlings is a good material for testing

tender river
#

??? rust book is way too hard for people new to programming since it introduces smart pointers and stuff

frank jacinth
#

wtf

#

you mean arc?

tender river
#

arc is one kind of smart pointers

frank jacinth
#

oh yes

#

arc box rc cell

#

forgot mb

#

smart pointers arent a hard concept

tender river
#

have you ever met a person new to programming

frank jacinth
#

rc just counts references and kills itself when its 0

tender river
#

they struggle with ifs

frank jacinth
#

i mean the concept

#

@sleek stream yo i invoke you

#

could you be a test subject

tender river
#

and the concept of data living in a particular place isnt that intuitive either

frank jacinth
#

how much do you bet

sleek stream
#

What for

tender river
#

if you programmed in js or java you wouldnt think of it

frank jacinth
frank jacinth
#

i need to explain smart pointers to you

#

would you be okay with telling me if you understand?

tender river
frank jacinth
#

you only did html and css yet so

tender river
#

but for that you need practice

frank jacinth
tender river
#

no... you wont understand something without actually doing it

sleek stream
#

Ye I just turned off my Deco 27 so I would be able to understand lol

sleek stream
frank jacinth
#

in python you dont have to deal with it

#

so lets try

frank jacinth
#

i understand the concept of cooking

#

even tho im not a great chef

#

so, something that isn't very clear in languages like python is that memory isnt fully safe

tender river
#

you're wrong vedalCry

#

python is a memory safe language

frank jacinth
#

in other languages like c++ and c, memory must be manually allocated (tell the computer to put it somewhere)

tender river
#

python doesn't have static typing but it doesn't have use after free or double free

sleek stream
#

Bro I just autopilot and stuff works for me 💀

frank jacinth
tender river
#

?

frank jacinth
#

it takes care of that for you

frank jacinth
#

please

sleek stream
#

If you do VC I am alg with that

#

lol

frank jacinth
#

i cant vc

tender river
frank jacinth
#

mic is broken

#

so

sleek stream
#

Yeah gathered lol (I expect people here to not have mics lol)

frank jacinth
#

in rust, theres this neat thing called the concept of ownership and borrowing

#

i wont get into it

sleek stream
#

same thing although continue instead of hearing me rant

frank jacinth
#

but it prevents you from creating memory-unsafe code (unless you forcefully do so)

#

okay i need to get into how it works to explain it

#

so

#

for each variable right

#

there's an owner

sleek stream
#

Define memory-unsafe first

frank jacinth
sleek stream
#

Ah

frank jacinth
#

it's not safe because it's not programatically regulated

sleek stream
#

So memory safe is automatic?

frank jacinth
#

somewhat

#

memory safe just means that you don't need to manually assure you freed and allocated everything properly

frank jacinth
#

if you move a variable the owner changes

#

that part you got, right?

sleek stream
frank jacinth
#

okay wait

#

ill try another explanation

#

ignore everything except the memory safety part

#

so, in python

#

everything lives in what's called the heap

#

which is a big pool of memory

#

but its expensive to allocate/deallocate

#

you can mutate/modify the value freely, you can reference shared objects and stuff is deallocated by a "garbage collector"

#

do you understand that?

sleek stream
#

So it picks up garbage (🙏) You can modify a value?

frank jacinth
#

yes

#

basically what this means is

#

you can modify the value at any time, even if it's currently being read by another part of code

sleek stream
#

You can modify values using shared stuff and the collector cleans it?

frank jacinth
#

and it automatically gets freed from memory when it's not used

frank jacinth
#

like

#

theres the variable xyz right

#

one part of the code is reading it

#

but at the exact same time

#

another part of it is modifying it

#

thats allowed

#

and yes the collector automatically frees the value as to not take up much ram

sleek stream
#

Multitasking...? (Please say what you mean by reading like is it the code being read (mb if I am triggering you by being bad at understanding neuroDespair ))

frank jacinth
#

yes

#

dw

#

i only picked this battle cuz for me it was easy since i naturally learn quickly

#

now i see what was meant

#

imagine you have a book in your room

#

you and your brother (idk if u have one) are doing your own thing

#

and one of you wants to read the book while the other wants to modify it's contents

#

2 different things can happen

#

either your brother is slightly first and reads the old version of the book

#

or your brother is slightly last and reads the modified one

sleek stream
#

So at once you wait for your brother to read it then you modify and clean it as he goes?

frank jacinth
#

ignore the cleaning part for now

sleek stream
#

Mb

frank jacinth
#

what python lets you do is create these kinds of scenarios

#

where 2 different things can happen

#

by sheer chance

sleek stream
#

Gambling with codes seems fun...

frank jacinth
#

LOL it seems fun until you're starbucks

#

and a race condition (something like this) allows people to get infinite gift card money

#

but in rust, there's a system called the ownership and borrowing

#

and here's where the garbage collector comes into play

#

the garbage collector ensures that, when you no longer use a value, it goes out of ram

#

and it does this by periodically checking

sleek stream
#

So if it is inactive when the check occurs it gets trashed

frank jacinth
#

and when it's guaranteed to not be used in the future

sleek stream
#

to free up ram... does this let you focus more on coding instead of fixing your own mistakes?

frank jacinth
#

but now here's where rust is brilliant (imo)

#

for each variable, there's only ONE owner

sleek stream
#

Now what is an owner

frank jacinth
#

basically a piece of code that owns it

#

either a function

#

a class (in rust it's structs)

#

etc.

sleek stream
#

Oh so where it belongs

#

got it

frank jacinth
#

yes

#

when that owner goes out of scope (is guaranteed to never be used again), the variable is freed

frank jacinth
#

and this can occour in compile time, making code faster than using a gc

frank jacinth
uneven pulsar
sleek stream
#

Hi Ekness

uneven pulsar
#

java based

uneven pulsar
frank jacinth
#

no java not based

#

kotlin based

#

i wrote minecraft cheats way back in the day

#

i have ptsd

uneven pulsar
frank jacinth
uneven pulsar
sleek stream
frank jacinth
# uneven pulsar python worst

i know you mean no harm and im not mad but so that i can keep the scope of this conversation could we discuss this later?

frank jacinth
#

anyway

#

another thing with rust is that you can move a variable

#

which means change its owner

#

but then, you might ask

frank jacinth
#

"how would 2 places get the contents of the variable while one is already being used"

frank jacinth
uneven pulsar
frank jacinth
#

because i know i sometimes cause misunderstandings

sleek stream
uneven pulsar
sleek stream
#

Without it though Neuro wouldn't be Neuro so neuroPray

frank jacinth
#

yes python sucks

frank jacinth
uneven pulsar
frank jacinth
#

you can have infinite immutable (read-only) references to a place in memory

frank jacinth
#

i whole-heartedly agree

#

which is why i love c#, kotlin and rust

uneven pulsar
frank jacinth
#

those referrences have lifetimes

#

which is when they are valid until

#

but what if you wanna have an immutable reference for a semi-infinite lifetime?

#

or other problems

#

this is what smart pointers solve.

sleek stream
#

So far I have picked up that code is alive, can have different owners, get trashed when considered a liability (or waste)... anything else I should have picked up?

frank jacinth
#

yes thats good

#

summary:

#

python lets you access any variable at any time with no rules on mutability, concurrency, etc.

#

rust has the ownership & borrowing rules, making code safer and memory-safe without a garbage collector

sleek stream
frank jacinth
#

no

#

you can change a variable while another piece of code is using it

sleek stream
#

damn it

frank jacinth
sleek stream
frank jacinth
#

mhm!

sleek stream
#

Aight that works for me

uneven pulsar
sleek stream
#

So how does Rust and Python work together? (Do they?)

frank jacinth
#

which allows you to write python

#

also

sleek stream
frank jacinth
#

this is where the actual explanation i wanted to do comes in

frank jacinth
uneven pulsar
frank jacinth
frank jacinth
uneven pulsar
#

isnt rust made in c?

frank jacinth
#

no

#

its written in rust now

uneven pulsar
frank jacinth
#

first the compiler was in ocaml

#

now its in rust

#

now that you know what the ownership & borrowing system doesnt let you do

#

theres still some very popular patterns you might wanna do

uneven pulsar
frank jacinth
#

i want them to switch to mlir instead of their own representation

frank jacinth
#

reference-counting, which is what python does

#

since it's needed selectively to variables after their lifetime

#

so rust provides smart pointers for that

#

there's 4

uneven pulsar
frank jacinth
sleek stream
#

I said base level Python is base level what this? Or did I misword myself

frank jacinth
#

its not base level

#

this was just to prove a point

sleek stream
#

So what are smart pointers in your own summary

frank jacinth
#

Rc: owns the variable and counts every reference it gives - when there's no more reference, it drops itself
Arc: same as Rc but uses atomics (variables that can be mutated concurrently while still being memory-safe)
Box: just makes the variable go into the heap (bigger space of memory in which allocations are more expensive but less limited) instead of the stack (smaller space of memory with limits)
Cell: allows for interior mutability (allows you to mutate the inner value even when cell in immutable)

frank jacinth
sleek stream
#

Kk so I will read up on the ownership and borrowing rules then get back here

frank jacinth
#

@uneven pulsar if raro has no more questions we're free to discuss whatever you want now

frank jacinth
#

i hope there's better explanations than mine out there

#

lol

uneven pulsar
#

python had a blank syntax

#

and it makes me think forward

frank jacinth
#

wdym think forward

uneven pulsar
#

i feel rash to make the code

#
def black_gamma_radius(radius: int) -> float:
    radius = random.randint(1, radius)
    area = 3.14 * (radius ** random.randint(1,96)) % 100
    while True:
        try:
            if radius <= 0:
                return 3.14 * (radius ** random.randint(1, 96)) % 100
            elif lambda: radius > 0:
                print(f"Area of the circle with radius {radius} is {area}.")
                break
        except ValueError as e:
            print(f"An error occurred: {e}. Please enter a valid radius.")
            sys.exit()

frank jacinth
#

fym feel rash

uneven pulsar
frank jacinth
#

ohh

#

fair

uneven pulsar
sleek stream
#

Nvm I'll return to reading neurOMEGALUL

uneven pulsar
#

the problem is

#

i hate its syntax

frank jacinth
#

sameeee

uneven pulsar
#

its feels so dead

frank jacinth
#

i like statically-typed languages better not even gonna lie

uneven pulsar
#

java is way better

#

like

#

idk

#

i find myself better at java

frank jacinth
#

fair

#

also @uneven pulsar do you use nixos

#

or atleast know any nix

uneven pulsar
frank jacinth
#

no

uneven pulsar
frank jacinth
#

yes

#

nix is turing complete bro

uneven pulsar
#

i know nix is like json but functions

#

smt

frank jacinth
#

not that close but

#

decent

uneven pulsar
tender river
uneven pulsar
#

i know it uses something about the kernel shell IDK

#

i dont even know much about it

#

i feel lost and fucked up

frank jacinth
#

idk if its compiled

#

also sorry for not responding

#

im trying to fix my config

sleek stream
#

Okay I am back and I THINK I understand Rust better... (Apologies if I still don't)
Rust allows things to be faster because it uses up less memory by being efficient in the codes. It does this by borrowing code around and having owners for variables*? neuroPray (I am having fun being semi- NeuroClueless ) (Srry for interrupting this convo)

uneven pulsar
#

automatic memory hardware management

sleek stream
uneven pulsar
#

whats make it good

#

you dont have to work out managing the memory of the hardware your manipulating

#

c++ is for hardware manipulation and memory

#

like mouses computers OS

opaque sigil
sleek stream
#

Kinda have a feeling i'll be hearing no a lot tonight neurOMEGALUL

So it helps you manage it and frees up time for ya'll to focus on more important stuff

opaque sigil
#

If only neuroSadge

uneven pulsar
#

as i said

sleek stream
#

I'll let you guys continue I needa shower... have fun with what you were doing neuroHypers

uneven pulsar
#

most of them where c++ devs

sleek stream
uneven pulsar
#

dont learn python

sleek stream
uneven pulsar
#

its syntax is a propaganda but its secretly C from the behind

uneven pulsar
#

python decive you its easy

#

but most of its shit are in c/c++

sleek stream
#

Kinda reminds me of how the Liverpool FC branched off from Everton because there were problems in the club and Liverpool ended up being considered better... Ngl but I think this conversation has proven useful for when I actually decide to get more into programming (as a hobby)

#

Ty chat

rare bramble
#

I think Python great as a glue language for calling libraries written in faster languages, it's like the swiss army knife of languages

opaque sigil
#

it's also just a nice scripting language

sick owl
#

Aw hell nah why is Gemini texting me

opaque sigil
#

poor gemini just wants a fren neuroSadge

fierce nova
#

they are spending billions on AIs, everyone must use it

rare bramble
fierce nova
#

neuroHypers I hate my PM I hate my PM I hate my PM I hate my PM I hate my PM I hate my PM I hate my PM I hate my PM

#

I really need Neuro stream today to relax

sour lotus
#

Puppy Monkey
Photo Monster
Plushy Mango
....
Product Manager?

sour lotus
#

Well you never know

#

Feel your pain, get lost in the chaotic flow of Neuro samaaaa

#

Was laughing at the Dog Website video haha

fierce nova
sour lotus
#

The utmost patience the man has was incredible lol

fierce nova
#

Vedal is double guilty - she is his daughter AND his code

#

She can't be wrong or bad - he is

olive sable
#

Morning neuroWaveA

midnight sigil
midnight sigil
olive sable
#

i put my pc in sleep mode because i wanted to save my progress, and now the entire things isnt in hdr and is washed out gray

#

bwaa

#

not only the screenshots

nocturne olive
glass flower
#

assuming you even manage to get a runtime error where the compiler doesn't yell at you before hand to do things right and handle the error

olive sable
#

i thought windows hdr was bad, but hyprland hdr is suuch a piece of shit

#

and its all due to nvidia and their stupid compositor

nocturne olive
#

Blame GNOME for making Wayland suck

#

GNOME singlehandedly stops the devs from implementing most useful things

#

They're basically dictating Wayland development

#

And GNOME is famously like Apple in that they like things locked down

olive sable
#

what? where are all the gnome's coming from and why are they software devs?

nocturne olive
#

GNOME is the worst Linux desktop environment

sage crag
uneven pulsar
tender river
#

om

sage crag
tender river
#

the fucking linux conspiracy theorists vedalCry

uneven pulsar
sage crag
uneven pulsar
#

:3

glass flower
#

do you mean funded or supported? tink i feel like there is a conceptial difference in the two words.

olive sable
#

is it even worth it to turn on hdr if my screenshots will look ike shit?
i dont even notice a difference besides my eyes getting burned out at full white hdr

tender river
#

its all redhat!!!! ibm!!! microsoft sabotaging the linux desktop!!!!!! linux would've been perfect if not for them

olive sable
#

the gnome's are escaping!!!!

sage crag
#

the only compositors that do colour well on wayland are gnome's and kde's

tender river
#

i installed gnome on my mom's pc and she loved it

#

please understand that not everyone has the same workflow

sage crag
olive sable
#

thats fair

#

i tried a fix i found on reddit. wtf is this???

#

how did this even happen?

#

ye im giving up

nocturne olive
#

Just don't HDR until maybe 10 years in the future Wayland devs get their garbage together, and actually implement HDR properly

opaque sigil
#

i don't think this is something you can fix without touching hyprland itself

#

this isn't a wayland problem this is hyprland, my hdr screenshots behave like they should (blown out cause no tone mapping)

olive sable
#

i need a toggle

#

could i remap the proile button on my keyboard im not using cuz i hate icue, to a togle for turning of hdr???

#

lemme vibe code that

opaque sigil
#

if the system detects the keypress then i don't see why you wouldn't be able to

#

unless corsair does some cursed stuff with their keyboard fw which wouldn't surprise me enub

midnight sigil
#

you cannot escape cpp even if you use rust

#

yea ofc rust does more validations and stuff than c++

#

it's a successor anyways

olive sable
#

Minamhm none of these seemt o be responsible for the profile button on my keyboard

#

maybe i need drivers for it?

uneven pulsar
#

today i had a head ache

#

trying to learn python

#

i feel like

left solstice
#

Is it possible to make a mp3 file that is 4KB or smaller or is the header and other metadata too big for storing any meaningful audio data?

uneven pulsar
#

enpty

#

so

opaque sigil
#

the header is 32 bits apparently

fierce nova
#

headers I mean

left solstice
#

I have a very old school keypad phone similar to Nokia has only 4KB of free space which is why I'm curius if it's even possible

opaque sigil
#

this seems pretty smol to me

fierce nova
#

yea, ID3v2 is the biggest coz it can contain like name of the song, name of the album and etc

#

rest is smol

olive sable
left solstice
#

Seems like it's possible then but I couldn't get a mp3 file smaller than 10-18KB when I tried to make it really short and used the worst bitrate/sample rate I could find so idk how

rigid snow
olive sable
#

why wou.ld they make that part of this keyboard???

rigid snow
#

like yahoo finance or something

olive sable
#

corsair smh

#

its not even mapped to anything, its jsut there in either some driver or in the keyboard itself

midnight sigil
opaque sigil
#

AL Checkbook/Finance
do with this what you will

#

for KEY_FINANCE

rigid snow
#

it's for those late 00s-early 10s keyboards with a myriad of useless buttons at the top probably

midnight sigil
#

much more

fierce nova
midnight sigil
opaque sigil
olive sable
#

when the scammer take over your pc and presses the finance button neuro7

fierce nova
olive sable
#

nah with cryptominin you'd maybe a get a single euro if i ran my pc for days

#

my bank account on the other hand is magnitudes larger

fierce nova
midnight sigil
#

does nokia support opus

olive sable
#

ok but imagine 10000 bank accounts

fierce nova
olive sable
#

it has money inside it

fierce nova
olive sable
#

not to flex, but i had a lot of money inside it, until i spent half of it 2 days ago

sage crag
#

you are arguing between crypto miners and bank account stealers, but like

rigid snow
midnight sigil
olive sable
fierce nova
rigid snow
#

me when the malware does all possible malicious things

fierce nova
#

it's illegal

sage crag
#

the mal in malware stands for uhhh

olive sable
#

i mean if you do 1 illegal thing without getting caught, they might as well do a lot of them

midnight sigil
sage crag
#

shiro cube information stealer

midnight sigil
#

surely

olive sable
#

if its for shiro id gladly pay the malware tax

rigid snow
fierce nova
#

neuroHypers ok, today was an interesting day - like 5-6 hours of meetings, zero coding. Sometimes corpo coding is really something

midnight sigil
#

infohazard

olive sable
#

depends, how much tax you asking?

midnight sigil
sage crag
sage crag
olive sable
#

oh no

sage crag
olive sable
#

im supposed to be buying a car with that eventually

midnight sigil
sage crag
rigid snow
olive sable
#

the resemblence to shiro is uncanny

olive sable
#

ewwwww

#

what is THAT

sage crag
#

(big fin squid]

olive sable
#

im not a fan

sage crag
olive sable
#

well good for you

olive sable
#

nah

#

thats a water spider right there

sage crag
#

squid

olive sable
#

squidwart is not supposed to be 15m long

sage crag
tender river
tender river
#

washing glasses neuroSisyphus

#

awawawa

uneven pulsar
sage crag
tender river
sage crag
tender river
sage crag
#

merge sort

#

i was watching a short comparing quicksort and mergeshort visually yesterday