#🪅-progaming

1 messages · Page 104 of 1

winged mantle
#

i have a pretty vague idea of what linking is

crude star
#

dynamic linking is when you statically link at runtime

#

self-modifying code and all

spark tiger
#

i got demoted.

winged mantle
#

oh yea there's stuff like static where linking actually is relevant to the programmer

#

just add a uuid to the end of the name

jade stone
#

Oh, neat!

crude star
median root
#

whats the actual difference between JIT and interpreted? Every damn "explaination video" I see tells me "Its the computer reading the code" or the "computer directly executing instructions" but last I checked computers didnt just "read code". My other thought was that it could be translating source code into another language to be executed as the program runs, however is this not transpiling?

frosty obsidian
#

interpreted languages don't get compiled

#

jit compiles as its executed rather than beforehand

fleet cedar
#

But there's certainly some gray zones

frosty obsidian
#

jit is a mix of interpreted and aot

deep mulch
#

wing detected

fleet cedar
#

Modern cpus have builtin jits

median root
fleet cedar
#

The processor itself iterates over each instruction as it runs and generates micro-ops that it then runs

crude star
#

the compiler interprets the code and outputs new code

#

fact

frosty obsidian
median root
fleet cedar
#

It is very educational, yes

median root
#

or how this is done?

frosty obsidian
#

you can look into existing interpreters

median root
crude star
#

cpython is hell

shrewd canopy
limpid mica
#

i love interpreters

crude star
#

ruby the language where random amounts of periods is valid syntax ```
irb(main):001> ..
irb(main):002> ...
irb(main):003* ....
(irb):2: warning: ... at EOL, should be parenthesized?
internal:kernel:168:in 'Kernel#loop': (irb):3: syntax errors found (SyntaxError)
1 | ..
2 | ...

3 | ....
| ^ unexpected '.'; expected an expression after the operator
| ^ unexpected end-of-input; expecting a message to send to the receiver

from /usr/lib/ruby/gems/3.4.0/gems/irb-1.14.3/exe/irb:9:in '<top (required)>'
from /usr/bin/irb:25:in 'Kernel#load'
from /usr/bin/irb:25:in '<main>'

irb(main):004> .....
irb(main):005> ......
irb(main):006* .......
(irb):5: warning: ... at EOL, should be parenthesized?
internal:kernel:168:in 'Kernel#loop': (irb):6: syntax errors found (SyntaxError)
4 | .....
5 | ......

6 | .......
| ^ unexpected '.'; expected an expression after the operator
| ^ unexpected end-of-input; expecting a message to send to the receiver

from /usr/lib/ruby/gems/3.4.0/gems/irb-1.14.3/exe/irb:9:in '<top (required)>'
from /usr/bin/irb:25:in 'Kernel#load'
from /usr/bin/irb:25:in '<main>'

irb(main):007>

limpid mica
#

unexpected .

deep mulch
#

.

frosty obsidian
#

zeet loves kotlin partially being interpreted

limpid mica
#

range my ranges

deep mulch
#

@frosty obsidian

crude star
#

oh my god

#
irb(main):005> ..............0
=> ..............0
limpid mica
#

yeah

#

tho i must wonder what version of ruby you're on

crude star
#

3.4.4

#

python is better than ruby because they have the bigger 3.x version

#

go is the worst because they're still on 1.x

#

and said there wont be a 2.x

limpid mica
#

sorry i went

deep mulch
supple whale
#

greaaaaaaaat

#

chrome introduced a regression in ffmpeg in v136

#

which is still in all active stable chromium versions

#

and it fucks seeking and loading

#

does this effectively

#

and its been like this for MONTHS

#

and they only fixed it in 140.0.7299.0

#

which is a dev build released a week ago

#

mmmmmm thank you

#

over half a year of this shit being fucked

ornate quiver
# median root whats the actual difference between JIT and interpreted? Every damn "explainatio...

compiled -> a compiled compiler translates source into machine code that is able to be directly run
interpreted -> a compiled runtime reads source code, parses it into it's own bytecode, and virtually runs it (hence, a "virtual machine")
JIT -> an addition to a an interpreter in a runtime, that transforms the parsed bytecode into real machine code, which provides a marginal performance boost as it can be directly run by the cpu, instead of being virtually run by the interpreter
AOT -> a loose combination of compiled and JIT, where portions of the bytecode is transformed into machine code ahead of time, just like compiled, but run from the context of a runtime (like in GraalVM, or .NET with AOT on)

#

the point is that either the cpu directly can run instructions it supports, or it can run the instructions of an interpreter, which will virtually "run" custom bytecode (aka. a VM), and accomplish the same thing

fleet cedar
#

I wouldn't call several orders of magnitude marginal

ornate quiver
#

well I guess it really depends on the situation but yeah JIT can be really good

runic sundial
#

Yeah what

ornate quiver
#

I worded that as dumbed down as I could and it ended up being husk

runic sundial
#

JIT is the difference between a cool and good or warm and bad interpreted lang

#

Try running Minecraft world gen with JIT disabled and come back saying "marginal"

#

Prolly the best example

ornate quiver
#

it really matters for performance critical areas but not so much for other stuff
which is why android does profiling before JITing methods to not waste resources on compiling methods that won't yield a significant performance increase

runic sundial
#

Not doing JIT means you're getting the worst-case

#

Which makes a lot of sense for Android UIs, where the code paths need to be fast IMMEDIATELY

#

And the compiled caches prolly won't last as soon as the user switches to another app

ornate quiver
#

i believe it's persisted

runic sundial
#

TL;DR it matters anywhere where you're gonna be doing the same thing a lot, over and over for some period of time

fleet cedar
runic sundial
#

The real power of JIT is that you have all the context in the world at runtime

#

You know with certainty what code path is hot or cold

crude star
#

they grow downwards

fleet cedar
#

You're the other half then

#

May I offer an unhelpful compromise? I think stacks don't grow

crude star
#

who needs stacks

#

just have infinite registers

runic sundial
#

Don't care what direction the stack goes

#

In memory or otherwise

#

It's a stack.

#

When I stack things the stack grows taller.

fleet cedar
#

Fact

#

Direction is useful for metaphor and visualization though

runic sundial
#

They should have called it the mineshaft

#

If it needed to go down

#

Anyway who the hell visualizes the stack as going down lmao

runic sundial
#

You love memory

#

How do you feel knowing that Java is more memory safe than Rust?

#

It's true.

valid jetty
#

the stack and heap are sort of touching

#

and the stack grows downwards towards one end of the rope while the heap grows upwards towards the other end

winged mantle
#

OK tbh i was lying in bed thinking of ideas for Unicorn so maybe I should work on that instead
(Unicorn was the name I thought of for a scripting language but i didn't think of many actual features blobcatcozy )

valid jetty
#

this is probably a wrong way to think about it

#

but it works for me

#

(and that pivoting point in the middle changes as the stack requires more memory)

winged mantle
#

interpreter

valid jetty
#

😭

winged mantle
#

i've wanted to work on an interpreter for a long time

#

seems fun

fleet cedar
#

Most importantly, heap is not necessarily consecutive

valid jetty
#

well yeah because of fragmentation

fleet cedar
#

And I think stack is usually closer to the end of the address space, with heap below it

#

But I'm not sure about that

valid jetty
#

but i was thinking more about how one grows to one end and the other grows to the other

fleet cedar
#

Especially since with threading or whatever there can be multiple stacks

valid jetty
#

with virtual memory you can't really reason about any of this in real code but yeah

fleet cedar
#

Yeah

valid jetty
#

in an ideal world my model would work i think

fleet cedar
#

In the grand scheme of things, the stack itself is just another heap allocation

valid jetty
#

fair

#

actually that's so real

#

the stack is just a bump allocator wires

fleet cedar
#

Kinda yeah

ionic lake
#

go back into ur stack

#

get to work

fleet cedar
#

Compiler has a bit more control over it than a typical bump, but conceptually yeah

valid jetty
winged mantle
#

so good

entrypoint {
    println("hello world")

    entry := ScoreboardEntry.make({ name: "joe", score: 10000 })
    println(entry.toString())
}

type ScoreboardEntry {
    name
    score

    meth toString() {
        return f"Name: {{name}}; Score: {{score.toString()}}"
    }
}
#

why don't any languages use the meth keyword to declare methods

hoary sluice
valid jetty
#

entrypoint yet meth

#

lmfao

#

i love consistency

crude star
#

entrpt {}

valid jetty
#

main {}

limpid mica
#

start {}

valid jetty
#

why is there a meth keyword anyway

#

you can use the left parenthesis to differentiate properties and methods

crude star
#

because func doesn't work there

#

its a method not a function

fleet cedar
valid jetty
#

use the fact that there is a left paren after the identifier to tell you that it’s a method rather than a property

supple whale
#

why is this unironically good......

elder yarrowBOT
#

I've sent you a DM with more info!

austere idol
winged mantle
#

if i make an editor i will make it so that multiple spaces always render as one to force you to use tabs

supple whale
lavish frigate
#

reactive frameworks hate this one simple trick! see how this hacky developer avoided installing 50gb of dependencies for reactivity using web components!

ionic lake
#

okay

winged mantle
#

i have reached the point of insanity in language design

valid jetty
#

??? what do you mean name of the type

#

is that not the thing next to the type keyword

winged mantle
#

yeah

#

and the types of type is the Type type which contains name

deep mulch
#

crazy

winged mantle
#

it's genius

valid jetty
#

wait

#

why is Type a type

#

oh dynamic typing

winged mantle
#

i mean go and java have the ability to inspect types too

deep mulch
#

add reflection to elle @valid jetty

winged mantle
#

the icing on the case is this is a word document that i am typing code into

valid jetty
deep mulch
#

@valid jetty make elle library for generating elle code

valid jetty
#

you can do this

#

you cant do much more

valid jetty
deep mulch
#

nop

#

generating code during runtime

#

i mean like a elle builder

winged mantle
deep mulch
#

.add_const("guh", 500)

winged mantle
#

is it viable to support method chaining with automatic semicolon insertion

valid jetty
#

if you take in a generic value to ElleMeta you can not only get the type's name but also its expression as a string

#

thats how $dbg works

#

thats also how type_of works btw :3

valid jetty
#

ElleJIT

deep mulch
#

@valid jetty make Elle run on JVM

#

we need

winged mantle
#

asi seems generally kinda bad

#

but it does look clean

#

i thought kotlin might do it well but apparently this breaks

deep mulch
#
"""
line 1
line 2
line 3
""".trimIndent()

?

valid jetty
#

elle

"line 1
line 2
line 3"
#

or ```rs
"line1\nline2\nline3"

shrewd canopy
valid jetty
#

no im saying thats what it currently is

deep mulch
#

@valid jetty rosinga

lavish cloud
#

every time I see people working on langs I want to try making my own only to end up remaking kotlin

winged mantle
#

i have managed to design a language that doesn't resemble anything i've used that much

#

but it is kinda cursed

#

also i need to impl it

#

and i haven't really designed that much

#

it doesn't even have switch statements... first things first though

#

oh yeah it's a scripting language

#

my instincts kicked in and i added a rune type

#

maybe that's a bit weird?

ornate quiver
#

lolll

lavish cloud
#

so true

#

honestly the two improvements I'd want to see:

  • static extension methods
  • C++ interop in KNative (somehow)
    • If we can't have that, at least the ability to use any given toolchain so I can develop switch mods with it
frosty obsidian
#

technically you can extend the companion object but that would only work if the target actually has one

shrewd canopy
#

and its different between multiple compilers (although clang tries to be same as gcc)

lavish cloud
frosty obsidian
#

theres a proposal for it

deep mulch
#

@frosty obsidian will make it get merged faster

frosty obsidian
deep mulch
#

guhhh

#

they never heard of a linter before

frosty obsidian
#

i also don't like that

#

i don't see it seriously solving a problem

#

would just be a new thing libraries force on you

deep mulch
#

@frosty obsidian hi

royal nymph
#

idk how anyone could think this is a good idea

#

Apple moment

deep mulch
#

yop

royal nymph
#

I love when libraries decide how I'm supposed to write my code

ornate quiver
shrewd canopy
#

Why do you need static extension methods

ornate quiver
#

i was doing some fancy syntax stuff a while back
related to dsl for patching and I needed static extension methods but there was literally no way to accomplish what i was trying to do

#

actually so bad

shrewd canopy
#

How

lavish cloud
ornate quiver
#

funniest thing is you can't even translate a java api into kotlin without breaking backwards compatibility
because you can only make statics on singletons for some fucking reason

jade stone
lavish cloud
ornate quiver
#

not the same thing but still interesting

runic sundial
#

Phantom refs can get u destructors

jade stone
lavish cloud
#

Well for JVM you can just write JNI/JNA

lavish cloud
#

Cleaner manages a set of object references and corresponding cleaning actions.
Cleaning actions are registered to run after the cleaner is notified that the object has become phantom reachable. The cleaner uses PhantomReference and ReferenceQueue to be notified when the reachability changes.

ornate quiver
#

oh this is cool wait

#

this perfectly solves an issue I was having

#

love

lavish cloud
#

Oh wait that's a neat idea

#

Writing a GC impl for C++

deep mulch
#

I might could use this for ffmpegkt

lavish cloud
deep mulch
#

they're horrid

#

since it's just 1:1

lavish cloud
#

Well yeah

#

Writing a proper wrapper would be a nightmare

deep mulch
#

that's what I'm doing

#

works good

#

recently I added hardware accel encoding

#

how have I never heard of cleaner before guhh

winged mantle
#

in javascript it would be really annoying to make it optional as you literally implement it by accepting an object

#

why have a lexer when you can have a grokker

royal nymph
#

you have to explicitly close them but still

runic sundial
#

I prefer AutoCloseable over cleaners

#

like

#

In C++, a destructor is called when that thing goes out of scope

#

aka; you know WHEN it will happen for that exact resource

#

For cleaners, the GC will run whenever it wants.

royal nymph
#

in Java/Kotlin you have to explicitly close via a statement akin to C# using

runic sundial
#

Lombok @Cleanup

#

or try with resources

royal nymph
#
try (var thing = new CloseableThing()) {
    thing.explode();
}
CloseableThing().use {
     it.explode()
}
#

the try syntax is so cursed lmao

runic sundial
#

ya

#

with Lombok it ends up being:

{
    @Cleanup var thing = new CloseableThing();
    thing.explode();
}
#

And it will do the whole try(){...} for you

#

Very useful when you have more than one closeable

fleet cedar
#

Well, you can try-with-resources with multiple things

#

But not if you want to do other things between

royal nymph
#

lmaooo

#
try (var closeables = new CloseableManager()) {
    var foo = closeables.add(new Foo());
    var bar = closeables.add(new Bar());
}
winged mantle
#

the try syntax is so cursed... followed by more cursed syntax

#

epsecially if you name the var

CloseableThing().use { thing ->
    thing.explode()
}
#

ig that's the unfamiliar lambda syntax

lavish cloud
deep mulch
#

your video cant be seeked

#

fix

lavish cloud
#

works fine for me

#

it's literally the most basic conversion of ```bash
owo_video () {
FILE=$(ls -Art1 "/home/mart/Videos" | tail -n 1) # most recent file
TMP=$(mktemp --suffix .mp4) # file to write to
ffmpeg -y -i "/home/mart/Videos/$FILE" $TMP >/dev/null # convert to mp4 with ffmpeg
owo -u $TMP # upload to owo
}

deep mulch
#

probably cause image host

hoary sluice
deep mulch
#

yes

spark tiger
#

it doesnt work at all for me

#

oh now it does

royal nymph
shrewd canopy
#

Browser moment

#

Just always use VLC or default Windows media player smh

winged mantle
#

somebody i was talking to thought vlc was spyware

tired vigil
#

real gaymers use potplayer

shrewd canopy
supple whale
#

unfortunately the only actually functional video players in the world are mpv and kodi

#

everything else falls short

#

potplayer lacks support for a bunch of formats, vlc doesnt do color mapping correctly

#

and most other players dont do hdr or dv correctly

#

chromium patched with extra codecs like ac3 and dts is third when it comes to accuracy and featureset

#

but it lacks subittle format support since it only has VTT

deep mulch
#

I love mpv

royal nymph
#

i hate mpv @deep mulch

supple whale
#

mpv sucks for users

#

gotta write 200 lines of config before its usable

#

and import like 14 luas

#

from a usability standpoint its fucking rancid

deep mulch
supple whale
#

because mpv fucks hdr and dv out of the box

deep mulch
#

I just use jellyfin for content with HDR

supple whale
#

which

#

it has like 5 apps

crude star
supple whale
#

i unironically use my own build of chromium for playing videos

#

because it lets me make my own video player with the shit i want

#

with the least cancer and fuckery with color spaces, formats, codecs and weird features

supple whale
deep mulch
#

love

winged mantle
#

is this insane

#

my lexer is overengineered but i like how it has methods named peek and seek

#

peek 'n' seek

#

peekin' and seekin'

valid jetty
#

are you cheating and using a library for your lexer..

winged mantle
#

no

valid jetty
#

you dont really need a trie for a lexer, whats the point?

winged mantle
#

to make it cleaner

valid jetty
#

what..

winged mantle
#

avoid giant switch case

valid jetty
#

ok but you do know you made a giant switch case with different syntax right

winged mantle
#

yes

#

but i prefer it for some reason

valid jetty
#

😭

#

you dont even need this if you really want your lexer to be "clean"

winged mantle
#

my trie impl is cursed

valid jetty
#

for my ichigo lexer i have this

fn Lexer::next_token(Lexer *self) -> Option<Token> {
    if self.is_eof() {
        return None();
    }

    self.skip_whitespace();

    c := self.current_char();

    if _, op := c.to_operator() {
        self.advance();

        return Some(Token::new(
            TokenKind::Operator,
            TokenValue::Operator(op)
        ));
    }

    if c.is_letter() {
        return Some(Token::new(
            TokenKind::Identifier,
            TokenValue::String(self.consume_identifier())
        ));
    }

    if c.encode() == "「" {
        return Some(Token::new(
            TokenKind::String,
            TokenValue::String(self.consume_string_literal())
        ));
    }

    if c.encode() == "※" {
        return Some(Token::new(
            TokenKind::Comment,
            TokenValue::String(self.consume_comment())
        ));
    }

    if c.is_number() {
        return Some(Token::new(
            TokenKind::Number,
            TokenValue::Number(self.consume_number_literal())
        ));
    }

    if c.is_punctuation() {
        punct := self.current_char();
        self.advance();

        return Some(Token::new(
            TokenKind::Punctuation,
            TokenValue::String(punct.encode())
        ));
    }

    return None();
}
winged mantle
valid jetty
#

oh spam

#

whatever

#

but my point is, collect all punctuation into a generic "punct" token

#

then compare on particular strings

#

instead of having a seperate token for each punctuation type

winged mantle
#

i even did this sorta thing for matching binary

valid jetty
#

with a trie??

winged mantle
#

no

#

i just made it declarative

deep mulch
#

Koda toda crazy

valid jetty
#

idk but what youre doing seems a little overkill to me

deep mulch
#

@valid jetty

valid jetty
#

i would just have a few basic token kinds and then match on their value

pearl stagBOT
# winged mantle https://github.com/TheKodeToad/fish8/blob/main/system/opcodes.go#L17-L52

opcodes.go: Lines 17-52

var opcodes = [...]opcode{
    {"00E0", clearScreen},
    {"00EE", returnFromCall},
    {"1---", jump},
    {"2---", call},
    {"3---", skipIfVarEqualsByte},
    {"4---", skipIfVarNotEqualsByte},
    {"5--0", skipIfVar1EqualsVar2},
    {"6---", setVarToByte},
    {"7---", incVarByByte},
    {"8--0", setVar1ToVar2},
    {"8--1", setVar1ToORVar2},
    {"8--2", setVar1ToANDVar2},
    {"8--3", setVar1ToXORVar2},
    {"8--4", incVar1ByVar2},
    {"8--5", decVar1ByVar2},
    {"8--6", shiftVarRight},
    {"8--7", setVar1ToVar2MinusVar1},
    {"8--E", shiftVarLeft},
    {"9--0", skipIfVar1NotEqualsVar2},
    {"A---", setIndexToByte},
    {"B---", jumpWithOffset},
    {"C---", setVarToRandom},
    {"D---", drawToScreen},
    {"E-9E", skipIfKeyHeld},
    {"E-A1", skipIfKeyNotHeld},
    {"F-0A", awaitKey},
    {"F-07", setVarToDelayTimer},
    {"F-15", setDelayTimerToVar},
    {"F-18", setSoundTimerToVar},
    {"F-1E", incIndexByVar},
    {"F-29", setIndexToFontFromVar},
    {"F-33", splitVarDigits},
    {"F-55", copyFromVarsUntil},
    {"F-65", copyToVarsUntil},
}
winged mantle
#

this was simpler

#

but i like declarative pattern matching

valid jetty
#

i mean if you say so

winged mantle
#

kinda ugly to need to group things by prefix

valid jetty
#

youre not grouping by prefix

#

youre grouping by class

#

oh you meant the opcode thing

#

im dumb

deep mulch
deep mulch
#

@valid jetty @valid jetty @valid jetty

#

you are world smartest person

valid jetty
#

@deep mulch minklang progress when

#

im gonna get nin0chat working in elle before you get your first hello world running

deep mulch
valid jetty
#

good

deep mulch
#

@valid jetty hiiii

valid jetty
#

hiiiii

#

look at this beautifully formatted code

fn Token::precedence(Token self) {
    $assert(self.kind == TokenKind::Operator);
    op := self.value.as_op;

    if op == Operator::Mul
        || op == Operator::Div
        || op == Operator::Rem { return 2; }

    if op == Operator::Add
        || op == Operator::Sub { return 1; }
}
winged mantle
#

i wasn't a fan of needing to group unrelated opreators

deep mulch
#

what if you could do
if op == (Operator::Mul | Operator::Div | Operator::Rem)

winged mantle
#

bitwise or

deep mulch
#

yes

valid jetty
deep mulch
#

rosie could mke some insane syntax like |||

winged mantle
valid jetty
#

look at specifically the last if statement

winged mantle
#

oh wait

deep mulch
#

oh rosie my rosie

winged mantle
#

each char is an individual token

#

well that's also not that useful

#

but i want == to be a different token type to =

#

this is too much for my small brain...

valid jetty
#

i'm pretty sure there is a way to collect tokens into a single token kind while their string value represents their actual semantic meaning

#

(including multi char ones)

#

hold on lemme consult stb c lever

deep mulch
#

who

#

what

#

rosie knows something sinister

valid jetty
winged mantle
valid jetty
#

well yeah

winged mantle
#

so you're back to square one

#

even if you do totally insane things it should still process @!|||===:=!!= as @ ! || | == = := ! !=

#

you need a greedy match... but not too greedy

valid jetty
#

hmmm i'll sit on this overnight i think

#

i'm pretty sure there's a better way

#

elle does the approach you didn't wanna do lmao

valid jetty
#

maybe you can have a function similar to match_keyword kinda, but instead of matching a particular keyword you match any punctuation tokens

#

so the function internally would match against "==", then "=" , etc, and if none match then it's not a punct token

deep mulch
#

rosinga

valid jetty
#

i'll model this in the morning

valid jetty
#

yes

#

tagged enums dont exist

crude star
#

horrible

valid jetty
#

None needs to be the same size as Some so that it can be represented the same in memory

#

hence it needs to be generic

#

hence it needs to be a function

#

@winged mantle ```rs
use std/prelude;

enum TokenKind {
Punctuation // we only support punctuation in our lexer :)
}

struct Token {
TokenKind kind,
string value
}

fn Token::match_punct(Token self, string punct) {
return self.kind == TokenKind::Punctuation && self.value == punct;
}

struct Lexer {
string input,
u64 position
}

fn Lexer::consume_string(Lexer *self, string value) -> Option<string> {
for i, c in value.iter().enumerate() {
if self.input[self.position + i] != c {
return None();
}
}

self.position += value.len();
return Some(value);

}

fn Lexer::consume_punct(Lexer *self) -> Option<string> {
if _, v := self.consume_string("@") { return Some(v); }
if _, v := self.consume_string("||") { return Some(v); }
if _, v := self.consume_string("|") { return Some(v); }
if _, v := self.consume_string("!=") { return Some(v); }
if _, v := self.consume_string("!") { return Some(v); }
if _, v := self.consume_string("==") { return Some(v); }
if _, v := self.consume_string(":=") { return Some(v); }
if _, v := self.consume_string("=") { return Some(v); }
return None();
}

fn Lexer::next_token(Lexer *self) -> Option<Token> {
if _, punct := self.consume_punct() {
return Some(Token { kind = TokenKind::Punctuation, value = punct });
}

return None();

}

fn Lexer::iter(Lexer self) -> Iterator<Token, SingleEnded> {
return Iterator {
env = Box::new(self).to_ptr(),
next = Lexer::next_token,
next_back = nil
};
}

fn main() {
lexer := Lexer {
input = "@!|||===:=!!=",
position = 0
};

res := lexer.iter().collect();
$dbg(res);

// now we can do things like:
token := res.remove(0).unwrap();

if token.match_punct("==") {
    // do things here
}

}

#

just, as long as || is before | itll be matched first

#

and you dont need seperate tokens for each punctuation

#

and you dont need to make each punctuation a single character

#

win-win

#

this is the token stream from the $dbg call

#

which is correct

#

or well, i think you actually wanted != to be a seperate punct

#

but i didnt add it to the list

#

but you can see hopefully how that would work

#

you just add != before normal = and it gets matched first

#

there

#

technically all of these consume functions should be called try_consume because they can potentially not return a valid punct

#

but again you get the idea lmao

#

ok good night

#

ok i cleaned it up a bit

solemn ravine
#

@woven mesa I gotta redo the cells in the clipboard manager to look like this T_T

#

im so lazyy

woven mesa
#

o

winged mantle
#

😭 stayed up until 1:00 i'm sorry....

winged mantle
#

try not to make code look like cannibalism challenge

winged mantle
#

a go developers idea of clean code

fleet cedar
#

Won't second case always be true

winged mantle
#

how...

#

it's just [A-Za-z]

#

this could just be a regex

#

[0-9A-Za-z_$]

fleet cedar
#

Either second case is always true, or third case is always false, or the syntax is doing something very fishy

winged mantle
#

, is effectively the same as ||

fleet cedar
#

Then second case is always true

winged mantle
#

|| would be better but this is a go developers idea of clean code blobcatcozy

winged mantle
#

walk me through it

fleet cedar
#

All chars are either >= A, <= Z, or both

winged mantle
#

all chars are A-Z?

#

😨

#

oh wait

#

i wanted &&

fleet cedar
#

No all chars are U+0 through U+10FFFF

winged mantle
#

that's the operator

#

idk how i missed that

fleet cedar
#

10FFFF is >= A

winged mantle
#

i also have average go developer iq

#

the code was correct before

#

i will just use normal operators

#

less confusing

valid jetty
#

hold on i came up with a better solution while i was pondering

winged mantle
#

this feels like it would be the most pleasant to add to

#

you can't get any simpler

fleet cedar
# winged mantle

The correct implementation to this function is unicode_ident::is_xid_start/continue

winged mantle
#

ehh

fleet cedar
winged mantle
#

i mean... is anyone going to use my toy language

fleet cedar
#

No

winged mantle
#

it's an excercise in futility

#

parsing performance can matter sometimes

#

i'm just trying to learn

valid jetty
#

@winged mantle look at this

fn Lexer::try_consume_punct(Lexer *self) -> Option<string> {
    original_position := self.position;
    puncts := ["==", "!=", ":=", "||", "|", "@", "!", "="];
    best_match := None<string>();
    i := 0;

    while self.position + i < self.input.len() {
        current := self.input.slice(self.position, self.position + (i += 1));

        for p in puncts {
            if p.len() == current.len() && p == current
                && best_match.is_none_or_with(
                    fn(value, p) p.len() > value.len(), p
                )
            {
                best_match = Some(p);
            }
        }
    }

    if best_match.is_some() {
        self.position += best_match.unwrap().len();
    } else {
        self.position = original_position;
    }

    return best_match;
}
``` pattern matching on the puncts :]
#

this might be a little overkill

winged mantle
#

that's was the idea i started with but i felt a trie was a better structure

valid jetty
#

hm

winged mantle
#

let me write uncle bob clean enterprise grade code

valid jetty
#

but you cant have a string value if you do it like that aaaa

#

needing a token kind for every single punct feels so..

#

idk

winged mantle
#

i'm sorry...

#

isn't that what you do in elle though

#

you have a separate token for Comma and Equal

#

maybe i should copy you and use consume instead of eat too

#

eatDigits

valid jetty
#

i didnt use good practices i just wrote whatever i first thought of

winged mantle
#

why not make a punk token type

valid jetty
#

punk

winged mantle
#

what the hell is a punct meant to be

#

punk is cooler

#

feels like when you see a bsod at an airport

#

the go compiler falling apart because my code is just too good and vomiting out its internals

#

but hey it compiles really quickly

#

the compiler crashes within less than half a second

#

ok in all seriousness how 😭

#

i should just riir 🚀

#

rust would unironically be more suited for this but i wanted to write in a gc language first

#

write in java like the interpreter guide i was reading did

#

or just work out what the hell is going on

#

is this a common go issue

#

or did i just trigger an edgecase

#

ah i'm using go dnf package

#

i will try official distribution

valid jetty
#

@winged mantle what do you expect this to print

use std/prelude;

fn main() {
    xs := [1, 2, 3];
    it := xs.iter().map(fn(x) x * 10);
    xs.push(4);

    $dbg(it.collect());
}
winged mantle
#

10, 20, 30, 40

valid jetty
#

yes :3

#

its so silly

fleet cedar
#

I'd say error, but if not, yeah that

winged mantle
#

no idea what happens in rust

valid jetty
#

why would it error

valid jetty
#

because borrowing

winged mantle
#

ah

#

/run

import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        // java 8 based just in case
        List<Integer> myInts = new ArrayList<>(Arrays.asList(1, 2, 3));
        Stream<Integer> stream = myInts.stream().map(x -> x * 10);
        myInts.add(4);
        System.out.println(stream.collect(Collectors.toList()));
    }
}
rugged berryBOT
#

Here is your java(15.0.2) output @winged mantle

[10, 20, 30, 40]
winged mantle
#

it does the same in java @valid jetty

valid jetty
#

yeah i know this is expected behavior

winged mantle
#

yeah it'd be weird if it didn't work like this

#

but theoretically you could make it throw

#

store crc with list

#

i should learn c# and do linq everywhere

#

i don't even know how it works

#

probably like

List<String> myStrings = new List<String>();
List<String> aaa = SELECT item FROM myStrings WHERE position("aa", item) < 3;
#

wait it's literally pretty similar 😭

valid jetty
#

that is not how you do it in c#

winged mantle
#

can you get brew for linux

#

i just wanna do brew install go

valid jetty
#
var xs = new List<int> { 1, 2, 3 };
var it = xs.Select(x => x * 10);
xs.Add(4);
Console.WriteLine(string.Join(" ", it.ToArray()));
#

this is how i would do it

#

Select is like .map in any sane language

winged mantle
valid jetty
#

well yeah it is but thats not the "sane" way to write it

#

i fear nobody actually writes sql-style queries

winged mantle
#

you would've thought this would exist for a reason...

#

this code compiles

#

this code crashes the compiler

#

how??

#

fixed 14 hours ago

#

probably

#

i can also remove the equals

winged mantle
#

lol

placid cape
lucid trail
valid jetty
#

because you’re not doing as many comparisons

#

you instantly rule out some puncts based on their first characters

lucid trail
#

the pattern matching?

valid jetty
#

yes

lucid trail
#

yeah

#

my way of checking is really horrible, actually

spark tiger
#

but yeah it looks really cool to do sql queries that way

valid jetty
#

i mean the way elle does it is also technically like that but not as nice

#

it checks for the = character then advances and checks if the next is also an =, if it is then the punct is == otherwise it’s =

#

so basically manual pattern matching

tired vigil
#

Why is discord's i18n key hash function so bad
It uses 36 bits (6 characters) from a 64 bit hash, but their base64 implementation is wrong so the last 4 bits are duplicate, effectively lowering the entropy to 32 bits
So like with their intl maps already having over 20k items, there's almost a 5% chance of a collision between all the keys

#

I tried bruteforcing it but there are just so many valid hashes, even with 37 characters (uppercase + numbers + underscore, I didn't even try lowercase letters)

dense sand
#

how does one fix this vulnerability?

#

i tried to override it but it doesnt work

deep mulch
#

impossible

nimble bone
#

@deep mulch is this a @cinder egret reference

deep mulch
#

yes

valid jetty
#

nin0 do you unironically listen to taylor swift

nimble bone
valid jetty
#

what the fuck

nimble bone
#

why am i in programming i thought this was regulars

ionic lake
dense sand
nimble bone
ionic lake
dense sand
#

okay thaks

ionic lake
#

you're welcome champ

dense sand
nimble bone
#

true

crude star
#

(I have no idea)

tired vigil
#

I might do a pr cuz it's kinda irking me that the code is clearly wrong
Hopefully it doesn't break any vencord patches

jade stone
#

@nimble bone i'm working on vencord compnaion again

deep mulch
#

@crude star hii

crude star
#

zt

deep mulch
#

rini

jade stone
#

@deep mulch my code was so bad, adding basic caching (which hits 99% of the time) makes it read 60x less data from disk every time it reloads

winged mantle
jade stone
#

All we would need to do is change the one hash function.

winged mantle
#

technically it would look like an apocalypse with vencord reporter though and the scare would be funny

jade stone
#

horrid types

export type AssertedType<
    T extends Function,
    E = any,
> = T extends (a: any) => a is infer R ? R extends E ? R : never : never;

export type CBAssertion<U = undefined, N = never> = <
    F extends (n: Node) => n is Node,
    R extends Node = AssertedType<F, Node>,
>(
    node: Node | N,
    func: F extends (n: Node) => n is R ? F : never
) => R | U;
chilly viper
#

hi

#

please send me code for minecraft 2

tired vigil
#

TIL type assertions can be inferred

winged mantle
#

complains about rich type system

jade stone
#

just saying they're a bit cursed

jade stone
winged mantle
#

discrimination

jade stone
#

sadly it's still missing autocompletion

jade stone
# winged mantle discrimination

In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type, or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types. Only one of the types can be in use at any one time, and a tag field explicitly indicates which type...

#

i love discriminated unions

#

i wish more languages had support for them

#

@deep mulch add discriminated unions to kotlin

tired vigil
jade stone
#

otherwise user error

deep mulch
limpid mica
deep mulch
#

@limpid mica hiii

limpid mica
#

hi zt

#

nice to poke you as always

tired vigil
# jade stone

This is just Extract<U, { [D]: K }> why do you need a whole new type utility for this husk

royal nymph
#

to discriminate

jade stone
tired vigil
#

😭

nimble bone
#

saladinanity

jade stone
#

javascript should get if let

winged mantle
#

HORROR

jade stone
#
declare function foo(): string | undefined;
if (let bar = foo()) {
  console.log(bar);
}
supple whale
#

declaring in ifs

#

perish

winged mantle
#

i thought you meant like rust patter natmching

#
if (let string(str) = input) {

}
jade stone
#

that would be insane

winged mantle
#

just to check type

jade stone
#

i want it because i would rather not type out this longish type

#

wait

#

i'm stupid

winged mantle
#

yea

jade stone
#

but i still think if let would be cool

winged mantle
#

do if walrus

jade stone
winged mantle
#

like go

jade stone
#

(i also hate go)

winged mantle
#

if myThing, err := doThing(); err != nil {

}

jade stone
#

insaneeee

winged mantle
#

:= is the best feature of go

#

I will not call it by the official name

crude star
supple whale
supple whale
#

i considered refacoring all my code to use it

winged mantle
#

there's a library to implement the (CENSORED) operator in js

#

😭

crude star
#

makes even less sense it being !== undefined

#

C++ has that syntax though blobcatcozy

#

(also go)

jade stone
winged mantle
#

ever met the type of person to use thing !== null && thing !== undefined

crude star
#

no

#

!= null is exactly that

jade stone
#

@winged mantle let's comprimise with != void 0

winged mantle
#

isn't there a node util

#

void 0 is horror

crude star
#

i always write void 0

supple whale
# winged mantle := is the best feature of go
async function err <T>(Promise<T>: v): T {
   try {
      return [null, await v]
    } catch (e) {
      return [e, null]
    }
}

const [err, res] = await err(fetch(url))

or you could patch promise directly

crude star
#

bundler brainrot

winged mantle
#

do void new function(){}

jade stone
#

res, err

supple whale
crude star
#

return ((function() {})(), undefined)

winged mantle
#

huh

#

go always uses the last parameter for error

jade stone
#

yeah

#

same with node iirc

supple whale
#
Promise.prototype[Symbol.iterator] = async function () {
     try {
      return [null, await this]
    } catch (e) {
      return [e, null]
    }
}

but idk how to do typedefs for this

and then simply

const [err, res] = await fetch(url)
winged mantle
#

i think node had it as first so you didn't accidentally miss it out

deep mulch
#

@crude star @crude star

jade stone
#

oh

#

node has the err first

winged mantle
#

go deffo has it last though

supple whale
#

i remember i did this somehow

#

i dont remember how

#

XD

#

but drunk rn

crude star
#

that cant work

jade stone
crude star
#

after you await its no longer a promise

supple whale
#

yeah it patched then

winged mantle
#

does js support implicit conversion operators

supple whale
#

you need to patch then

#

but no

#

async iterators are symbol.asynciterator

#

or asynciterable

#

i dont remember

#

im fucked up

jade stone
#

ah

supple whale
#

XD

crude star
#

const [{ value, reason }] = await Promise.allSettled([fetch(url)]);

winged mantle
#

why doesn't this work in js

#include <node/console.h>
class CoolBool {
    constructor(value) { this.value = value; } 
    operator bool () { return this.value; }
}

console::log(CoolBool{true});
supple whale
#

but the point is to define it as a lang feature

supple whale
#

i think you can define how an object converts to asymbol

#

but idk if that works

#

i dont rly do rust

jade stone
supple whale
#
const object1 = {
  [Symbol.toPrimitive](hint) {
    if (hint === "number") {
      return 42;
    }
    return null;
  },
};
jade stone
#

that's c++

supple whale
#

damn

#

im a c98 mfer

#

godd damn wasm

royal nymph
#

callbacks yes

#

but go nuh uh

supple whale
#

very likely im wrong

crude star
royal nymph
#

not a real go lover..

supple whale
#

my go experience is limite

crude star
#

doesnt work

crude star
#

yeah

#

you cant change how an object behaves as bool

deep mulch
#

insane

royal nymph
#

well yeah cause all objects are truthy

#
!! new Boolean(false) // true
crude star
#

wait what was the

#

*document.all

royal nymph
#

insane

supple whale
#

there are always exceptions XD

#

WE LOVE JS

jade stone
crude star
#

document.all is the only HTMLAllCollection

#

@royal nymph they should let Proxy create exotic objects like this

supple whale
#

problem is, its a language feature really

#

not an object call

#

!obj doesnt read a property so u cant trap it

#

its kinda like ===

jade stone
limpid mica
crude star
#

lily faster than me

supple whale
#

its probably some hardcoded backwards compatibility shit

#

where its meant to not exist

royal nymph
#

yes

#

the thing I linked answers it

#
if (document.all) {
  // code that uses `document.all`, for ancient browsers
} else if (document.getElementById) {
  // code that uses `document.getElementById`, for “modern” browsers
}
#

it's meant to make code like this use the getElementById but also still support websites that only use .all

jade stone
#

vchars “

elder yarrowBOT
jade stone
#

insane

supple whale
limpid mica
#

new browsers implement document.all for legacy compat reasons but don't want to be detected as ancient IE

supple whale
#

chromium: oh no our backwards compatibility to 2002 browsers

#

also chormium: yeah lets just break all video playback and make constructors randomly segfault on 32 bit systems

crude star
#

i think your usecases are a bit abnormal

supple whale
#

new ImageData() is abnormal?

limpid mica
#

i assume 32-bit systems don't exist when writing software these days smh

supple whale
#

well, actually there are like 3 exceptions from what i know

#

out of roughly 3k

#

ooooh 4 now not 3

#

china released a new atv box

royal nymph
#

they want ancient websites to still work in latest chromium

supple whale
#

nvidia shield, ugoos am6b+, and z9x pro

supple whale
royal nymph
#

if the website is new it means you will fix it 😉

supple whale
#

i think its been 3 years since i reported that filters dont work on offscreen canvases when they were first introduced

#

still no dice

royal nymph
#

what the hell are you making

#

filters in offscreen canvas

supple whale
#

still need to piss performance away by computing colormaps in raw js, instead of using gpu accelerated svg filters

crude star
#

ur the kind of user every developer fears existing

royal nymph
#

hop on wasm or smth

supple whale
supple whale
#

from what i calculated we'd need 9GHz single cpus for wasm to be as fast as native 2.5GHz cpus

#

for this specific task

#

aka text rasterization

supple whale
#

and the cheapest way by a LAAAAAAAAAAAAAAAND slide is to do it using SVG filters, as they support color matrixes

#

so you can pre-compute all possible combinations of color space conversions

#

map them to a color matrix

#

and simply apply that color matrix to an svg filter, and boom, you've got fully GPU accelerated color matrix conversion at 0 overhead for the thread the canvas is running in

#

be it the main thread or the worker thread

#

well, that is if chromium got off their ass and fixed it not working in worker threads

#

didnt do bt.2020 because... the math for it is black magic and i didnt understand it!

#
this._ctx.filter = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='f'><feColorMatrix type='matrix' values='${colorMatrixConversionMap[subtitleColorSpace][videoColorSpace]} 0 0 0 0 0 1 0'/></filter></svg>#f")`
crude star
#

self super react is crazy

supple whale
#

its a vencord plugin

#

so its always on

#

XD

royal nymph
#

wtf is it reacting to

supple whale
#

cursed svg filters

royal nymph
#

bro has a plugin to selfbot react to jsslop

granite geyser
#

this._ctx.filter = url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='f'><feColorMatrix type='matrix' values='${colorMatrixConversionMap[subtitleColorSpace][videoColorSpace]} 0 0 0 0 0 1 0'/></filter></svg>#f")

#

aw

supple whale
#

its not auto

royal nymph
#

oh you mean the always super react

supple whale
#

but yeah that filter is very not what it was made for

#

but chromium snuck url() as one of the options

#

and the flood gates opened

#

cuz the expected use case is

ctx.filter = "blur(4px)";
#

XD

crude star
#

does anyone actually notice their subtitle is in the wrong colorspace

supple whale
#

oh yes

#

very much yes

crude star
#

insane

supple whale
#

nope

#

not insane

#

its GIGA visible

supple whale
#

without color space correction

#

and this is with:

royal nymph
#

just write better code

supple whale
#

????

#

sir do you understand how color spaces work?

#

you need to correct color spaces

#

like

#

what if the video is simply a different color space

#

you can apply subtitles to many videos, and they can be encoded differently with different color spaces

#

so you need to read the video color space, and the subtitle color space

#

and correct

jade stone
#

programming chat

deep mulch
#

they are insane

nimble bone
viscid grove
#

any vim motion enjoyers?
I'm making a calendar program for a school project. Should j be next month or previous month
next seems the most vim-y, but it's on the left so seems more previous to me

viscid grove
#

h and l will be for year

jade stone
#

oh

#

then j is next

#

k is previous

viscid grove
#

that feels so wrong to me

jade stone
viscid grove
#

ok it doesn't anymore

#

idk why it was feeling wrong

viscid grove
jade stone
#

depends on ui

viscid grove
#

h and l seem more "extreme" to me since they're further on the outside

viscid grove
#

i'm making the ui rn

jade stone
#

oh

#

tui

viscid grove
#

yeah

jade stone
#

idk man

#

just pick one

#

not important

viscid grove
#

this is the current ui that's barely functional that i just used for testing

#

i don't think i even have time to make the ui good

#

it's due tomorrow

#

well thanks

jade stone
jade stone
#

@deep mulch @nimble bone rate horrorcode

parseClassDeclaration(clazz: ClassDeclaration): RawExportMap {
    const ret: RawExportMap = {};

    for (const member of clazz.members) {
        if (isMethodDeclaration(member)) {
            if (!member.body)
                continue;
            ret[member.name.getText()] = [member.name];
        } else if (isConstructorDeclaration(member)) {
            // the ConstructoKeyword
            ret[WebpackAstParser.SYM_CJS_DEFAULT] = [member.getChildAt(0)];
        } else if (isPropertyDeclaration(member)) {
            ret[member.name.getText()] = [member.name];
        } else if (isAccessorDeclaration(member)) {
            if (!member.body)
                continue;
            ret[member.name.getText()] = [member.name];
        } else {
            outputChannel.warn("Unhandled class member type. This should be handled");
        }
    }

    // name ?? ClassKeyword
    ret[WebpackAstParser.SYM_CJS_DEFAULT] ??= [clazz.name ?? clazz.getChildAt(0)];

    return ret;
}
nimble bone
jade stone
# nimble bone please never touch a keyboard again

horrorcode pt. 2

tryParseClassDeclaration(node: Identifier): RawExportMap | undefined {
    const varInfo = this.getVarInfoFromUse(node);

    if (!varInfo) {
        return;
    }
    // classes should only have one decl.
    // if someone proves me wrong on this (with an example in discord's code), ill support it
    if (varInfo.declarations.length !== 1) {
        return;
    }

    const [decl] = varInfo.declarations;

    if (!isClassDeclaration(decl.parent)) {
        return;
    }
    return this.parseClassDeclaration(decl.parent);
}
woven mesa
#

@hoary sluice

hoary sluice
#

is this a switch 2

shrewd canopy
#

Thats a first switch pretty sure

#

Switch 2 doesn't have colored joycons afaik

valid jetty
#

class

hoary sluice
hoary sluice
shrewd canopy
winged mantle
dense sand
#

@nimble bone you use kotler compose for android right

#

Well im trying to decide if i should use flutter or kotlin

crude star
#

@supple whale

#

ykyk

dense sand
lavish frigate
supple whale
#

still the wrong thing XD

lavish frigate
shrewd canopy
jade stone
#

Also there’s like no code in that repo

winged mantle
#

it seems to delegate parsing to another lib

#

fair

jade stone
#

Right now I'm working on Getting a UI for all the flux events so you can jump to where any one event is dispatched or handled.

nimble bone
#

salad vibe coded her parser

winged mantle
#

i admire it when people work on projects for a long time

jade stone
#

Only a year

winged mantle
#

after writing go ts gives me migraine

#

i wanna rewrite everything in go

jade stone
#

(Unless you count my nix dotfiles)

jade stone
winged mantle
#

i was really starting to like js but my js code looks like slop now

jade stone
#

Module system is too confusing and I don't like the forced casing for variable names.

winged mantle
#

i think i probably just overengineered things

nimble bone
#

i love js

shrewd canopy
winged mantle
#

and stuff like this isn't inherently a js problem but after writing a bunch of go i hate looking at this

nimble bone
#

just don't make a schema you know you know

winged mantle
#

true

#

maybe i should use less !== undefined throughout the code

#

it's kinda ugly

jade stone
#

Sometimes I wish typescript strayed farther away from js

#

With things like actual overloading (probably impossible)

winged mantle
#

overloading isn't that good

jade stone
#

And runtime generics

jade stone
winged mantle
#

have you never had that ambigious overload error in java and c++

jade stone
#

Not Java or c++

winged mantle
#

anyway i'm kinda looking at my code and thinking how did i get here

#

tbf this is over a year

jade stone
#

Real

#

I think the horrid tests I added a while back and the (somewhat sparse) comments are the only thing keeping me sane rn

winged mantle
#

i think maybe a good goal is to reduce lines of code

#

because the loc is probably an indication i made things more complex than they need to be

#

maybe i should just revert the last 100 commits it will probablybe much better

winged mantle
#

one thing good about my project is the largest file is 250 lines

jade stone
#

I can't really do that with that file

winged mantle
#

just make it less oop

jade stone
lavish frigate
#

oop has been a curse on the programming community

winged mantle
crude star
jade stone
crude star
#

horror

winged mantle
#

i made an extension point system where plugins declare a set of "contributions" which modify the behaviour of other plugins

#

would it be better just to use functions

#

is there a good guide on making a nice plugin architecture with js/ts

crude star
#

what is this

winged mantle
#

yeah honestly my code got worse 😭

#

best bet to revert before my rework and backport stuff

deep mulch
#

kode tode