#🪅-progaming

1 messages · Page 91 of 1

royal nymph
#

it's mainly meant as a type safe compiled ruby alternative

#

crystal and ruby have essentially the same syntax

spark tiger
#

is it like mature enough tho

#

like the ecosystem and stuff

#

tooling etc

valid jetty
royal nymph
#

if you're a big company I wouldn't use it

spark tiger
#

nop i’m me

royal nymph
#

then yes

deep mulch
#

.getOrNone

fleet cedar
spark tiger
royal nymph
#

crystal is really fast while being super easy and fast to write

#

it feels more like a scripting language than a compiled language

#

you only rarely have to write explicit types

valid jetty
# deep mulch .getOrNone
// overloads
fn Array::__load__<T>(ElleMeta meta, T[] self, u64 i) {
    __internal_array_bounds_check(meta.file, meta.line, meta.column, i, self.len());
    return self.elements[i];
}

fn Array::__load_ref__<T>(ElleMeta meta, T[] self, u64 i) -> T * {
    __internal_array_bounds_check(meta.file, meta.line, meta.column, i, self.len());
    return &self.elements[i];
}

fn Array::get<T>(ElleMeta meta, T[] self, u64 i) -> Option<T> {
    if i + 1 > self.size {
        return None();
    }

    return Some(self.elements[i]);
}

fn Array::get_ref<T>(ElleMeta meta, T[] self, u64 i) -> Option<T *> {
    if i + 1 > self.size {
        return None();
    }

    return Some(&self.elements[i]);
}
spark tiger
#

idk why but i’m just really interested in exploring other new languages. like zig, gleam, crystal, nim

deep mulch
#

rosie add visibility operators

lavish frigate
#

zig is irrelevant to me

valid jetty
deep mulch
#

private fn Array::load

spark tiger
valid jetty
#

its what is called when you do array[x]

royal nymph
rugged berryBOT
#

Here is your cr(0.36.1) output @royal nymph

HI
1234
["HELLO", "WORLD"]
deep mulch
#

__internal_array_bounds_check

valid jetty
#

and anyway that exists the operator is !pub

deep mulch
valid jetty
#

a function can be private but theres no mangling so if it doesnt have a unique name itll fail at linking time because duplicate symbols

lavish frigate
valid jetty
#

the function is private

spark tiger
#

my list of languages i want to learn is like elixir, zig, rust, crystal, c, swift, objective-c, nim, gleam, haskell, go, v, scala, julia, odin, ts. is it too many? fr

valid jetty
#

you cant call it yourself

deep mulch
#

!pub is such a weird choice

royal nymph
valid jetty
royal nymph
deep mulch
#

okay but what if you add more visibility types

#

it wont work then

spark tiger
valid jetty
valid jetty
#

either it has modifier x or it doesnt

deep mulch
#

thats way more confusing than just explicit words

valid jetty
#

whats the opposite word for external

deep mulch
#

internal

royal nymph
#

/run ```cr
2.times do
puts "hi"
end

2.times {
puts "hi 2"
}

rugged berryBOT
#

Here is your cr(0.36.1) output @royal nymph

hi
hi
hi 2
hi 2
valid jetty
#

internal doesnt mean what it should here

spark tiger
valid jetty
#

because !external means the function isnt externally defined and needs to have a body

#

that is not an internal function

deep mulch
spark tiger
#

2.times is crazy 😭

royal nymph
rugged berryBOT
#

Here is your cr(0.36.1) output @royal nymph

1234
spark tiger
#

im confused do u like need brackets for func arguments or not

valid jetty
#

i think puts is a builtin?

#

or something

#

idk

#

i guess its optional

royal nymph
spark tiger
#

oh

valid jetty
#

if i had to guess, func(x) is the same as wrapping an expr in parens

#

so its as if you did func((x)) in a language where its mandatory

royal nymph
#

/run ```cr
puts [1, 4, 2, 3].sort.map(&.to_s).join '-'

puts([1, 4, 2, 3].sort().map(&.to_s).join('-'))

#

these are the same

rugged berryBOT
#

Here is your cr(0.36.1) output @royal nymph

1-2-3-4
1-2-3-4
spark tiger
#

learning new languages is so fun

#

if it's not c# or python or java

valid jetty
#

how does it differentiate between fields and function calls 😭

deep mulch
#

sort.map

#

scary

royal nymph
#

most languages don't allow that

spark tiger
#

wtf are macros just regular funcs or what

fleet cedar
lucid trail
#

I really want to do something with crystal now

royal nymph
#

crystal is really cute

#

crystal also has yoda expression

deep mulch
#

love

fleet cedar
#

Cringe, yoda expressions are

royal nymph
rugged berryBOT
#

@royal nymph I received cr(0.36.1) compile errors

Showing last frame. Use --error-trace for full trace.

In file0.code:1:20

 1 | puts "balls" if 42.positive?
                        ^--------
Error: undefined method 'positive?' for Int32
Showing last frame. Use --error-trace for full trace.

In file0.code:1:20

 1 | puts "balls" if 42.positive?
                        ^--------
Error: undefined method 'positive?' for Int32
royal nymph
#

how

lucid trail
royal nymph
#

maybe old crystal version that doesn't have positive? yet

spark tiger
#

macros in crystal sound powerful

royal nymph
#

I find it easier to read during other times tho

#

especially with continue

fleet cedar
#

Are there any benefits to return x if y == 7 over if y == 7: return x

lucid trail
#

continue if makes sense actually

royal nymph
#
arr.each do |e|
    next if e == 42

    puts e
end
#

I think it reads nicer cause it has the more important bit first

#

makes it easier to scan

fleet cedar
#

The important part, such as being a conditional?

valid jetty
#

is that the only way to do it or can you do it the other way too

royal nymph
#

the important part is that we continue :P

valid jetty
#

then imo thats worse

#

because now you have to scan both ways

fleet cedar
#

No the important part is that we maybe continue

royal nymph
#

there's also unless keyword

valid jetty
#

like ruby

#

lol

royal nymph
#
arr.each do |e|
    next unless e == 42
end
#

I keep writing continue cause I'm used to it

fleet cedar
#

If I were to write something in crystal (an unlikely prospect though) I would set up a linter rule that prohibits such out-of-order statements

valid jetty
#

yeah

#

nice in theory but uhh

valid jetty
spark tiger
#

do yall think it’s possible to make a vc plugin that adds more languages to code blocks?

fleet cedar
#

That shouldn't be hard

#

hljs is designed to make that easy

royal nymph
fleet cedar
#

So just gotta get hold of the hljs instance, which probably is already in vencord.common

spark tiger
fleet cedar
#

But also partly because the feature objectively sucks

royal nymph
#

nuh uh

valid jetty
#

can you just pr tree sitter grammar to hljs

fleet cedar
#

No, hljs uses hljs grammars

valid jetty
#

husk

spark tiger
#

/run ```raku

grammar Parser {
rule TOP { I <love> <lang> }
token love { '♥' | love }
token lang { < Raku Perl Rust Go Python Ruby > }
}

say Parser.parse: 'I ♥ Raku';

rugged berryBOT
#

Here is your raku(6.100.0) output @spark tiger

「I ♥ Raku」
 love => 「♥」
 lang => 「Raku」
lucid trail
#

seems like it's more regex for hljs grammars

#

so much regex

fleet cedar
#

Yup

#

A simple one I wrote some time ago ```js
hljs.registerLanguage("calmare", hljs => {
const TERM = [];
TERM.push({
className: "number",
begin: /0[xX][0-9A-Fa-f]+/,
});
TERM.push({
className: "number",
begin: /(-|\b)\d+(.\d*)?((mm|ms|deg|mdeg)(/s)?)?\b/,
});
TERM.push({
className: "tag",
begin: /\b(flag|system|var|global|name|bgm|magic|quest|shop|sound|town|battle|item|look_point|entrance|object|trigger|label|anim|chip|vis|fork|eff|eff_instance|menu|sepith|at_roll|placement|fn|file|char|field_party|party|custom)[/,
end: /]/,
contains: TERM
});
TERM.push({
className: "tag",
begin: /\b(self|null|random)\b/,
});
TERM.push({
className: "string",
begin: /"/,
end: /"/,
});
TERM.push({
className: "string",
begin: /@\w+/
});

return {
    unicodeRegex: true,
    aliases: ["clm"],
    keywords: [],
    contains: [
        ...TERM,
        {
            className: "function",
            begin: /\{/,
            end: /\}/,
            contains: [
                {
                    className: "keyword",
                    begin: /\{/,
                    end: /\}/,
                    contains: TERM,
                },
                {
                    className: "keyword",
                    begin: /#\d*[A-QS-Za-z]/,
                },
                {
                    className: "keyword",
                    begin: /#\d*R.*#/,
                }
            ],
        },
        hljs.COMMENT(/\/\//, /\n/),
        {
            className: "symbol",
            begin: /[-+*/%&^|<>!=~]+/,
        },
    ]
}

});

for(let e of document.getElementsByClassName("language-clm"))
hljs.highlightBlock(e);

lucid trail
#

write a TextMate grammar and use shiki instead

royal nymph
#

crystal is definitely not perfect by any means but I still love writing it

it's such a fun language

#

I just wish the language server was better

#

and need more opportunities to use it

fleet cedar
#

Rewrite vencord in crystal

winged mantle
fleet cedar
#

What's the difference between a pojo and a bean

royal nymph
winged mantle
#

i think pojo is plain object java object which is a more general term for a data-only class

royal nymph
#

I just took a shower and came up with a project idea during it

#

#showerthoughts

winged mantle
#

you take showers?

#

even though my project pure typescript i should write the schemas in java and convert them because i love java

fleet cedar
#

And bean is a plain java object with getters and setters for each field

#

Thereby inflating the line count by 5x and gaining absolutely nothing whatsoever

winged mantle
#

true

#

i love just using public fields in oop languages

#

remembering how you need to manually write constructors in java

royal nymph
#

I hate getter setter pattern

valid jetty
#

getter setter is the worst thing to ever fucking plague programming

#

like it completely voids all invariants you can have about fields in a class or struct

#

the fact that i could write a program

int x = foo.a;
int y = foo.a;
``` and x and y can be different is the worst fucking thing ever
fleet cedar
#

Yes but bean getter/setter pairs also have no invariants

valid jetty
#

the problem is that the syntax is the exact same as regular fields

fleet cedar
#

No, getFoo() is a very different syntax from foo

royal nymph
#

getter setter is more bearable if the language has sugar for it

valid jetty
#

oh well i mean yeah

winged mantle
fleet cedar
#

The problem is that the semantics are the same even though the syntax is boilersome

valid jetty
#

those are fine because you know youre calling a functon

winged mantle
#

which are often used when they are just directly returning the field value

#

and not doing anything

#

just for no reason

hoary sluice
royal nymph
#

but yes I hate getter and setter too

#

rw field >>>> get and set

valid jetty
#

at this point unless you read the impl you cant know whether this is a getter or not

hoary sluice
nimble bone
#

just use NixOs

hoary sluice
#

variables are functions in icy

deep mulch
#

elle will be used as config language in nix

valid jetty
#

well yeah but thats a functional lang

#

that has no place in oop

deep mulch
#

elle will replace nixlang

valid jetty
winged mantle
hoary sluice
# valid jetty

what if you dont depend on side effects, only on internal state

winged mantle
#

give example

royal nymph
hoary sluice
#
val x: Int get() = y / 2
deep mulch
#

@hoary sluice

hoary sluice
#

@deep mulch

valid jetty
winged mantle
deep mulch
#

document the getter

royal nymph
#

yes

#

getters are stinky

deep mulch
#

vender

#

@royal nymph vending language

valid jetty
#

in any sane language, doing a field access is invariant, it cant possibly have side effects because all it does is a memory access

valid jetty
#

as soon as you bring getters and setters into the equation, unless you know what the field is represented as internally, you no longer have that guarantee

hoary sluice
#

in any sane language, calling a function is invariant, it cant possibly have side effects because all it does is a memory access

deep mulch
#

in 1 year elle will look and behave exactly like rust and rosie will rename to rust

hoary sluice
winged mantle
#

if your code has no side effects it just does nothing

valid jetty
#

in what language is it sane to have side effects accessing values with syntax exactly the same as normal field accesses

hoary sluice
#

its not sane

valid jetty
#

lmao exactly my point

deep mulch
#

lazy variable initialization with caching maybe

hoary sluice
#

i didnt disagree with you

hoary sluice
valid jetty
#

the whole thing is that youre turning a pure operation into an impure one (a function call)

deep mulch
#

insane

valid jetty
#

there is no equivalent things when calling functions because in procedural languages every function is impure, thats not an invariant

hoary sluice
#

just say constant

#

javascript brain where constants arent constant

winged mantle
#

i should make a scripting language called lasagna

hoary sluice
#

@valid jetty do u use vim-surround

valid jetty
hoary sluice
#

i think its built into zed

deep mulch
#

add JIT and AOT to elle

hoary sluice
valid jetty
deep mulch
#

oh no explicit type

#

fun

hoary sluice
#

is it () => i32

valid jetty
#

internally yes

deep mulch
#

i suggest making rand:randomi32

hoary sluice
winged mantle
hoary sluice
#

didnt you just complain abuot this

winged mantle
deep mulch
#

random::next_i32

hoary sluice
#

:kotlin

valid jetty
#

thats kinda the idea behind it

hoary sluice
winged mantle
valid jetty
#

its not a constexpr

#

its not computed at compile-time

vocal ether
valid jetty
hoary sluice
valid jetty
#

in fact i specifically state its not

winged mantle
#

inline

valid jetty
hoary sluice
#

const is usually not associated with macros

#

define

valid jetty
valid jetty
winged mantle
#

tbh i just use constexpr for stuff i want inlined

#

not really clear on the difference between inline and constexpr in c++

hoary sluice
#

its a less powerful #define no?

deep mulch
#

wbat the fuck

valid jetty
#

the internal representation is like this

use std/prelude;

fn x() { return rand::random(0, 6); }

fn main() {
    $dbg(x());
    $dbg(x());
    $dbg(x());
    $dbg(x());
}
deep mulch
#

why is it a const that returns a different value

#

HUSK

valid jetty
deep mulch
#

const is a constant, its value should not ever change

valid jetty
#

you can make a constexpr function that takes a constexpr computable value and does stuff like recursion in it at compile time

#

thats why c++ takes so long to compile

winged mantle
#

ohh i guess you use constexpr for it to compute it, not just inline it

valid jetty
#

you can make a fib constexpr function where you pass it 142 and it computes the value from your function at compile time

valid jetty
#

but it works in most cases

deep mulch
#

wouldnt it just be a function

hoary sluice
valid jetty
#

its a function but its called automatically

deep mulch
deep mulch
#

hmm

valid jetty
#

im very clear about this in the documentation

#

It is labelled as a "constant", because although it can return a different value (it can call any function), it cannot be redeclared.

deep mulch
#

that kinda seems like a weird choice

valid jetty
#

yeah but idk what keyword to put

deep mulch
#

function

valid jetty
#

no because its not a function per-se

#

its called automatically when you reference it

valid jetty
#

well yeah

deep mulch
#

getter then

valid jetty
#

its internally a function not semantically

#

but the difference here is that im not doing a pure operation

#

when you access a top level "thing" you know it can return something else

deep mulch
#

In computer programming, a constant is a value that is not altered by the program during normal execution.

valid jetty
#

idk what keyword to use

deep mulch
#

getter or function

valid jetty
#
use std/prelude;

const x = rand::random(0, 6);

fn main() {
    $dbg(x);
    $dbg(x);
    $dbg(x);
    $dbg(x);
}
use std/prelude;

fn x() { return rand::random(0, 6); }

fn main() {
    $dbg(x());
    $dbg(x());
    $dbg(x());
    $dbg(x());
}
valid jetty
deep mulch
#

i dont really see the issue with fn

valid jetty
#

its not a function

deep mulch
#

its easier to understand that way

#

its a function

valid jetty
#

you can define lambdas in constants

royal nymph
#

you will do lambas like kotlin @valid jetty

#

kotlin compiles lambas to classes and gives them insane names

valid jetty
royal nymph
#

look at the stacktrace here

fleet cedar
#

Why does the stacktrace have a sunset background

valid jetty
royal nymph
#

beautiful

deep mulch
#

why is it mangled

royal nymph
deep mulch
#

did you enable proguard

fleet cedar
#

Lambdas do get ugly names yeah

valid jetty
#

it just calls the function lambda.{tmp_counter++}

royal nymph
#

the user who posted that screenshot was using that theme

royal nymph
#

kotler named it that

deep mulch
#

i think newer kotlin its simpler

fleet cedar
#

/run ```java
Runnable r = () -> {};
System.out.println(r);
System.out.println(r.getClass());

rugged berryBOT
#

Here is your java(15.0.2) output @fleet cedar

temp$$Lambda$192/0x0000000800c77a48@27fe3806
class temp$$Lambda$192/0x0000000800c77a48
deep mulch
#

java 15

#

husk

fleet cedar
#

Very beatufl

valid jetty
#

yea anyway

#

maybe not as ugly as java

deep mulch
#

@valid jetty Elle v3

#

best idea

royal nymph
#

/run ```kt
val l = { -> Unit }

fun main() {
println(l)
}

#

I forgot kotlin syntax

rugged berryBOT
#

Here is your kt(1.8.20) output @royal nymph

() -> kotlin.Unit
royal nymph
#

is that even right

deep mulch
#

no

#

1.8.20 so OLD

#

FileKt$$Lambda$13/0x00007fbeb0003a20@1b2c6ec2

#
val l = {}

fun main() {
    println(l)
}
royal nymph
#

why is it just {}

deep mulch
#

i think its classname/address/hashcode

royal nymph
#

horror

deep mulch
#

oh

royal nymph
#

Unit.a @deep mulch

deep mulch
#

its a lambda inside a lambda i think

#

idk

#

@royal nymph alibabacord

royal nymph
#

kotler so unsane for not having void

deep mulch
#

how

fleet cedar
#

Just want to add that c++'s handling of the void type is hilarious

#

And very very painful if you're doing template crimes

still jolt
fleet cedar
#

Yes, unit is what it's called in languages developed after type theory was invented

still jolt
#

sounds fun

shrewd canopy
fleet cedar
#

That's C

#

C++ has std::any, and also templates

ionic lake
#

does qbe generate debug symbols?

valid jetty
#

i think you can get it to

#

there’s something like dbgloc as an instruction iirc

#

i haven’t looked into it yet

deep mulch
#

@valid jetty Elle VHDL

#

@valid jetty make Elle for FPGAs

valid jetty
#

what are either of those words 😭

deep mulch
#

hardware

#

like programmable circuitry

fleet cedar
#

Hardware isn't real

strange matrix
lavish frigate
#

@valid jetty how are you not going insane making elle

hoary sluice
lavish frigate
#

thats a good point

strange matrix
#

(since this is a prog question)

@tribal sapphire
how do i make getline() get from stdout ?

#

OH MY GOD

#

its supposed to be STDIN

#

😭
mfw im r*

#

immana' cry man why am i so dumb

valid jetty
median root
#

wait so if the ascii table goes up to 127 why is it signed to go to -128 and why can it go up to 255 when unsigned

#

whats the actual use for that

#

wouldnt it be much more efficent to just have it limited to the ascii table size?

fleet cedar
#

If you're talking about C's char type, that's not a character

#

That's the smallest addressable size

#

Which is called char because... reasons I guess

strange matrix
median root
#

why does it allow me to use values

#

that arent in the ascii set?

fleet cedar
#

Because it has nothing to do with textual data

median root
#

huh

strange matrix
#

no wait i'm way off

fleet cedar
#

How would an 8-bit integer support unicode

strange matrix
median root
#

i didnt know there was this much to C data types until i saw "ungisned char" in wiki

#

and decided to google this

#

now it feels like im going down a sinkhole

fleet cedar
#

UTF8 is defined in terms of bytes, yes

#

Just like every encoding of everything ever, since cpus and storage both deal in bytes

median root
#

ive always assumed char was limited to 127 since if I was a prgorammer back when computers needed to be the most efficent things immaginable I would also have char limited to a 0-127

valid jetty
#

yes, but adressing things in 7 bits is inefficient

#

we want a byte not almost a byte

#

so its 8 bits instead

fleet cedar
#

Powers of two are good

valid jetty
#

yeah

median root
valid jetty
#

you can

strange matrix
#

so there's no reason why it's called char for it to store a character?

valid jetty
#

people have used that bit for that purpose before

#

even i have

strange matrix
#

can i store a character in a int32_t ?

deep mulch
#

@valid jetty make Elle have 1024 bit numbers

deep mulch
#

it would just have lots of padding

median root
strange matrix
valid jetty
#

you can, but its pointless because ascii chars fit in 1 byte

strange matrix
#

(rlly)

median root
#

then have it 0-128

strange matrix
#

why am i asking i could literally try

valid jetty
#

yes, you can fit 1 whole unicode grapheme in an int32_t

fleet cedar
#

No you can't

#

You can fit one codepoint

valid jetty
#

1 byte for the length and 3 bytes for the actual data

#

you can

#

is that not the same thing

deep mulch
#

Rosie so smart

#

@valid jetty one day you will teach me everything you know

fleet cedar
#

I don't know if "grapheme" is a defined unicode concept

#

But grapheme cluster is

strange matrix
valid jetty
#

rune, grapheme, codepoint

#

whatever you wanna call it

median root
strange matrix
#

i'm storing my strings in size_t from now

#

heap-maxxing

fleet cedar
#

8 bytes can hold 256 different values

strange matrix
#

wait no its not in the heap

fleet cedar
#

-128-127 when signed, 0-255 when unsigned

strange matrix
#

stack-maxxing

valid jetty
median root
fleet cedar
#

If you want unsigned numbers, use unsigned numbers

valid jetty
#

well actually it is unsigned on some platforms lol

fleet cedar
#

If you want signed numbers, use signed numbers

valid jetty
#

its signedness depends on the platform

fleet cedar
#

The cpu doesn't care, it's just 8 bits

valid jetty
#

yeah ^

median root
fleet cedar
#

Types exist in programming languages, not cpus

strange matrix
#

but you could make cpus in programming languages

valid jetty
#

signed vs unsigned is just a difference of how the byte(s) are interpreted by the language

median root
#

"when i grow up im making my own char type which goes from 0-127 and cannot be signed, i will also force the cpu to store bools after each char if avalible for less fragmentation"

deep mulch
#

Elle will only have signed types

valid jetty
median root
#

yeah my concepts of it are really hazy

strange matrix
valid jetty
#

storing a bool right after a char means if you want to retrieve that bool you would get a non-aligned pointer

strange matrix
#

isn't bool just an enum tho ?

#

genuine question

fleet cedar
#

It would also make memcpy not work

valid jetty
#

i mean i guess

fleet cedar
#

But in most languages it's a primitive type

valid jetty
#

but an enum is also a number in most languages

strange matrix
#

how do languages

#

uh

#

that bind enum to strings or other types

#

like

#

ENUM : String

valid jetty
#

it can fit into 1 bit but usually we store it into 1 byte for alignment

strange matrix
#

store that

#

uh

#

like how does that work

valid jetty
fleet cedar
valid jetty
#

when you do Enum.Foo it just substitutes the literal for that inplace

strange matrix
#

so in preproc

#

it all gets

valid jetty
median root
strange matrix
#

like replaced?

fleet cedar
#

They are not integers

valid jetty
strange matrix
#

chatting with absolute choding people and not knowing anything is amazing

median root
fleet cedar
#

No, the OS typically won't let you

fleet cedar
#

It knows which memory ranges are assigned to your process and gets whiny if you violate that

valid jetty
#

but nowadays memory space is lazy and every program thinks it’s the only program that exists in terms of memory

#

and if you access something you’re not allowed to, you get a segfault

median root
#

does it write over? does the os kill the process?

deep mulch
#

@valid jetty hiii

fleet cedar
#

You get a segfault

median root
valid jetty
#

when are you writing more than 16gb of memory

fleet cedar
#

Which typically kills the process, unless you have a funny signal handler

valid jetty
#

yeah

median root
strange matrix
#

or i guess they're both the same

fleet cedar
#

Consider asking questions that are pareseable

median root
strange matrix
valid jetty
#

if you ask malloc for an amount bigger than it can give you, the pointer will be NULL.

#

and you try to use that pointer you will segfault

#

but if you don’t have enough memory left you have bigger problems

median root
#

joverly

valid jetty
#

well yeah because usually you’re not doing manual malloc calls

median root
#

and im guessing having something like

char d[4];

just uses the stack instead calling for heap?

fleet cedar
#

Unless you ask for heap, you're not getting heap

#

C the language does not have a concept of a heap, that's a library thing

median root
deep mulch
#

@valid jetty is made of pie

median root
#

does it all get popped off or does C remember the stack offset for me

fleet cedar
#

What do you mean

#

You can write to it since you took a pointer to that region and passed it down those 15 calls

median root
#

and doesent read the boolean as part of the char?

fleet cedar
#

Discipline

#

If you try to read d[4] then you do indeed get your bool

median root
fleet cedar
#

Or something else that happens to be nearby, stack layout is not guaranteed

median root
#

it starts at the pointer adresss and just keeps reading

#

until the os complains

fleet cedar
#

It reads exactly as much as you tell it to read

#

If you tell your program to read 8 bytes starting at d, then it reads 8 bytes starting at d

median root
fleet cedar
#

*(uint64_t*)d for example

#

Or d[7]

median root
#

hmm

#

im starting to see why the rust borrow model is so appealing

lucid trail
median root
#

im sure im gunna have fun in uni

lucid trail
#

I really didn't understand them until I did a project in C

median root
#

what about pointers is actually so horrible anyway?

#

from what I know they are just a memory adress

fleet cedar
#

They're very very easy to use wrong

median root
#

use wrong how

#

now im scared

fleet cedar
#

d[7]

lucid trail
#

7[d]

fleet cedar
#

Use after free, double free, null pointer, out of bounds, aliasing violations

median root
#

never seen double free or aliasing violations before

#

I always get hit by the segfault errors

fleet cedar
#

Double free isn't anything special, it's just a subcategory of UAF

median root
#

oh

#

aliasing violations?

fleet cedar
#

Compiler can often make much faster code if it knows two pointers are not the same

#

If you tell it that these are not the same but they are, then you have an aliasing violation

median root
fleet cedar
#

C has noalias annotations which tells it that "these pointers do not overlap"

median root
#

so compiler flags can actually altogether stop this error?

#

since its an error purely thrown because the compiler tried to cut corners?

fleet cedar
#

C does not assume pointers are nonoverlapping by default

#

But things can get a lot faster if you tell it to

median root
#

oh yeah is compiler entropy a thing in every C compiler or is it just windows?

fleet cedar
#

Uh, wtf is that supposed to be

median root
#

like the compiler decides to change some bits of code becase... it can

#

ig

fleet cedar
#

That is complete nonsense

median root
#

sick alr imma go spend the rest of my night reading wiki pages

lucid trail
#

why would it do that

strange matrix
#
void trim_whitespace_entire_string(char *str);
void trim_whitespace_begin_string(char *str);
void trim_whitespace_end_string(char *str);

am i supposed to use something else?

royal nymph
#

wtf are those names

lucid trail
#

doesn't trim imply whitespace

strange matrix
lucid trail
#

trim_left

royal nymph
#

trim
trim_left / trim_start
trim_right / trim_end

strange matrix
#

trim_start
trim_end
trim
??

#

ig that good ?

#

no but more like

#

doesn't C have trim funcs ?

#

or glibc ?

lucid trail
#

C doesn't really have strings

strange matrix
#

right

fleet cedar
#

C has nothing

lucid trail
#

yeah

fleet cedar
#

You shouldn't use it

strange matrix
#

C is a standard i guess

#

glibc is the meat

#

or musl

lucid trail
#

it made me appreciate rust a lot more

strange matrix
#

am i right ?

fleet cedar
#

These days, C is an abi, nothing more

strange matrix
fleet cedar
#

In other words, how different languages can talk to each other

strange matrix
fleet cedar
#

I'm not a teacher, I don't make curriculums

strange matrix
#

and you know a large amount

lucid trail
#

probably rust, but do some things in C too

strange matrix
#

oki

hoary sluice
gray heron
#

chat why the fuck does using "*" for app.get not work and give me this shit

C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:73
            throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
            ^

TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
    at name (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:73:19)
    at lexer (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:91:27)
    at lexer.next (<anonymous>)
    at Iter.peek (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:106:38)
    at Iter.tryConsume (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:112:28)
    at Iter.text (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:128:30)
    at consume (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:152:29)
    at parse (C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:183:20)
    at C:\Users\zander\Documents\GitHub\Parlix\node_modules\path-to-regexp\dist\index.js:294:74
    at Array.map (<anonymous>)

Node.js v20.18.0
hoary sluice
strange matrix
hoary sluice
#

musl so annoying

#

probably a great concept but stuff depends on glibc

#

i thought oh cool glibc alternative

#

wasted a day

gray heron
nimble bone
#

send your entire function

gray heron
#

there's no function just some server code

#

UNLESS U MEAN

nimble bone
#

whatever send your code

gray heron
#
app.get("*", (res) => {
  res.sendFile(path.join(__dirname, "public", "index.html"));
});
#

that's what's erroring out

nimble bone
#

first argument has to be the request afaik, 2nd has to be the response

#

i think

#

so do like (req, res)

#

unless i'm blatantly wrong

signal oakBOT
gray heron
#

same error

#

😭

nimble bone
#

insane

gray heron
#

lemme send my file

nimble bone
#

if you change * for / does it work

gray heron
gray heron
nimble bone
#

try /*

gray heron
#

same error

#

same with /*/

hoary sluice
# strange matrix what would you suggest for me tho <@236588665420251137> ?

if you dont have a lot of experience with programming, especially with languages that dont give you everything for free at the cost of performance, you will have a hard time understending why rust does stuff the way it does; there are 2 extremes to this, a university i know starts their students with pascal because its simple, and many others start with python, which is one of the worst choices imo

you should learn c first, everything everywhere is compared to c, if you know how it works in c you can understand the comparison and will have a much easier time learning other systems languages

#

but dont spend too much time on it - dont master it

gray heron
#

webdev was easy to learn for me and the best option i think

hoary sluice
#

if you start a 14 year old (technical high school) on javascript, they will probably have a hard time finding the motivation to learn anything but webdev

#

my high school started with C, and after 2 years started oop with C++ and Java, and a bit of js at the end; nobody in that class can or wants to use anything else

#

and they were taught for 5 years

#

and in 2025 its quite likely they will just become an ai bro

gray heron
#

css was the bestlanguage first for me because it's what you can SEE the fastest and i learn visually and by doing

strange matrix
#

but i want to

gray heron
#

i went css>html>js>ts

#

i'll learn c one day but that shit is complicated as fuck and COMPILING BRO i cant

strange matrix
#

i think my problem today mainly with C was just
how am i supposed to know a functions name
because man pages are really
making my head spin

royal nymph
#

vibecode it

hoary sluice
strange matrix
#

like it's fair for C to be hard for me, because i'm not a person that worked with memory since my experience was in C#

#

but like

#

i wanna

#

i want to try

#

i'm just mad at manpages

#

and well i'm just sometimes dumb
like setting getline(*buf, *buf_size, stdout)

lucid trail
hoary sluice
shrewd canopy
#

I went js then java then cpp then python

strange matrix
#

like

#

rust api docs are so easy

#

can search and everything

#

examples too

gray heron
strange matrix
#

but manpages

#

well

gray heron
#

i've tried like everything

hoary sluice
gray heron
#

yeah you did the whole midlevel programming pipeline

hoary sluice
strange matrix
gray heron
#

much different than the skilltree i fell down

hoary sluice
#

c is big enough for llms to properly document it

hoary sluice
gray heron
#

real

lucid trail
hoary sluice
#

at ~11 years old my dad dropped me into a scala repl, ran help and told me to make smth

lucid trail
#

i was forced to learn java against my will

fleet cedar
#

I started with java too (for minecraft)

shrewd canopy
#

I learned Java to make Bukkit plugins :D

hoary sluice
#

i think like 50% of all devs who started young started with minecraft

#

in the 2010s

lucid trail
#

I've only been programming for 1.5 years

#

is it over for me

gray heron
#

i started my life off sticking to science until i got a computer at 13 so it was a hard switch

#

it was after i lost my extreme love for mc modding

shrewd canopy
fleet cedar
#

I'm not really sure how long I've been programming, but I had a backpack from an international programming competition labeled 2015, so probably started several years before that

hoary sluice
#

i think i did some scratch

#

and the scala thing

gray heron
solemn ravine
#

@woven mesa @young flicker I made a simple swiftpm package which changes your keyboard color

#

but I havent figured out how to change the predictive bar yet

#

it uses swizzling to force the color change

woven mesa
#

so cool

#

what did u swizzle

solemn ravine
#

uikeyboard

#

@woven mesa we need more of this pleadey

native spruce
#

@woven mesa I think you can customize more than just the colors, I did something funny with the keys

woven mesa
#

so true

#

funny letters

valid jetty
#

3d game in a 2d display in a 3d game in a 2d display in a 3d world 😭

valid jetty
#

tsoding server is so funny 😭

gray heron
#

@nimble bone i ended up doing some fucked up regex Lol, my discord clone "PARLIX" is coming along swimingly so far, very slowly tho

#

those things are attachments i'm gonna add a header or smthn and put the attachment count with it too

#

even has deletion

#

just realized the icon isnt aligned this is bothering me

#

there 😭

valid jetty
#

@hoary sluice is this true

#

this is the message im replying to

#

read it out-of-order i guess

frosty obsidian
#

theft machine 9000 that only makes brains become mush

valid jetty
#

i feel like ai shills going "we need to make {field XYZ} ai first!" and then people with experience in that field going "no?? dont do that wtf it ruins any enjoyment working in the field" is the biggest thing

#

the disconnect is huge

frosty obsidian
#

i feel like we ran out of stuff to invent so we just resort to scraping the bottom of the barrel

valid jetty
#

lmao literally

#

i saw a video titled "Minecraft 1.8 is finally dead. We killed it" and i think it embodies that perfectly

#

it died because everyone eventually got bored of nothing new and moved to newer versions while at 1.8 its the same thing with some spin on it

#

same thing with ai except people arent updating

#

or well

#

the ai shills arent updating

#

actual software developers are

frosty obsidian
#

as tom scott once said, "people like a mix of novelty and familiarity"

#

change nothing, people get bored and move on

#

change everything, people hate it and move on

valid jetty
#

people have become so familiar with ai that their brains have turned too much into mush to realize it

#

one day ai websites will be down and theyll be told "write this algorithm" and theyll have no idea because they used to just have ai write it, even if they could write it by hand in the past, ai polluted their brains and made them stupider "oh yeah why should i need to remember this information, ai will regurgitate it for me when i need it"

frosty obsidian
#

im just waiting for this to crash like the dotcom bubble

valid jetty
#

lmaooo

#

imagine @deep mulch working on hyperion without his trusty ais

frosty obsidian
#

imagine @deep mulch working on hyperion without his trusty ais

#

he left

valid jetty
#

no way he actually left

#

insane

lucid trail
#

I've found it useful for learning some things though

#

And AI is sooo bad at debugging, if it doesn't one shot something its basically cooked

lucid trail
#

i ordered a corne with an aluminum case, i'm so excited

formal belfry
#

how can i use css to change server icons from the client side?

frosty obsidian
#

you can use inspect element to find the class for the server icon

pearl vine
formal belfry
#

may try this in the morning, thanks

strange matrix
#

if i want to ignore an error is it good to do this ?

int main(int argc/* ,char **argv */)
fleet cedar
#

Uh, what is that supposed to mean

strange matrix
#

i mean inline commenting out the part that is causing the warn

fleet cedar
#

What warning

#

Unused variable, or what/

strange matrix
#

yeah unused variable
both argc and argv
so i just commented them out

#

like this

#
int main(/*int argc, char **argv*/)
fleet cedar
#

If you do not use argc and argv, just do int main(void)

strange matrix
#

oki

hoary sluice
#

Refactoring a 300 line match statement into separated functions takes a long time even with vim

#

llms solve that

fleet cedar
#

Yeah and insert a few subtle bugs in the process

hoary sluice
#

well no i can see what it did

#

and the task is simple enough for claude 4 not to hallucinate anything, its very good at moving code around

ionic lake
#

my take is that ai makes producing code cheap so if you need some new functionality you should scrap the existing implementation out and let ai do it anew with your new requirements

hoary sluice
#

thats not fun to do and everything will collapse quickly

fleet cedar
#

My take is that throwing out a working implementation in favor of ai slop is a terrible idea

hoary sluice
#

a decent part of my voice assistant is made with llms and while it works now, it was painful to implement and i wish i wrote more of it myself

hoary sluice
#

if you remember my unsafe impl Send, Sync

#

i threw that out in favor of an ai impl with a separated thread for recording and it works

valid jetty
#

it’s almost always better to do it by hand even if it’s slightly inconvenient lol

hoary sluice
#

i did most of it by hand and got extremely bored

valid jetty
#

no, but when it’s done you know it’s correct because you wrote it

strange matrix
#

i feel like you should use LLM for when you don't know some sort of docs (at least for my case it's been like that.)

i feel like knowing the return value and func parameters are the only thing i'd really need an llm to answer me

fleet cedar
#

Why would you use a llm for that rather than docs

#

Unless your language docs suck ||c++||

hoary sluice
strange matrix
hoary sluice
strange matrix
#

the only good piece of docs i've seen so far was in a pdf

fleet cedar
#

That's an oxymoron

strange matrix
#

and even now i'm having a hard time finding it

#

hold on

fleet cedar
#

"Good docs" and "pdf" are mutually exclusive

hoary sluice
hoary sluice
#

and its a 450 page pdf

fleet cedar
#

Imagine how good it would be if it was in a useful format, then

#

Pdf is good for printing, nothing else

hoary sluice
#

using llms as advanced vim macros is completely fine imo

strange matrix
#
Here’s an example of how to use waitpid to get the status from all child processes
that have terminated, without ever waiting. This function is designed to be a handler for
SIGCHLD, the signal that indicates that at least one child process has terminated.

void
sigchld_handler (int signum)
{
int pid, status, serrno;
serrno = errno;
while (1)
{
pid = waitpid (WAIT_ANY, &status, WNOHANG);
if (pid < 0)
{
perror ("waitpid");
break;
}
if (pid == 0)
break;
notice_termination (pid, status);
}
errno = serrno;

}
fleet cedar
#

And who the fuck prints docs

strange matrix
#

this

hoary sluice
#

one use case today is if you have an electronics exam and the student has to do something with an arduino, you might print the section of the datasheet that they need

#

and back when these were created these scenarios were more prevalent

strange matrix
#

mupdf doesn't like me copying text

#

so i have to OCR it with tesseract

#

😭

hoary sluice
#

there were schools/unis that didnt have computers for every student

#

so datasheets were made to be printable

#

some of them are garbage, some of them are awesome, i dont think pdf limits docs

#

there are good pdf docs and there are non-pdf Nix docs

#

software docs will almost always be a website, because writing software means you have a computer to look at them; if you are working with electronics, you might not have a computer and the docs will therefore be in a pdf to be printable, but this has nothing to do with how good they are

valid jetty
#

hey you can print websites

fleet cedar
#

Yeah and it usually turns out like shit

hoary sluice
#

ok no they wont but it wont be the best experience for them

strange matrix
#
  char *path_name = "/usr/bin/";
  char *prog_name = va_arg(args, char *);
  char *comb_str = path_name + prog_name;

why does this not work?
the first two are string literals so i can't add them up in like
prog_name itself

but then i try making a new string which combines those two
and it doesn't let me?

valid jetty
#

over time i learned that readthedocs aren’t real docs

hoary sluice
#

why

hoary sluice
#

it completely depends on whose readthedocs it is

strange matrix
hoary sluice
#

isnt there a function to combine strings

#

strtok or smth

strange matrix
#

i haven't found it

hoary sluice
#

strcat

strange matrix
#

i found strcat

#

but it does it backwards

#

?

hoary sluice
#

then do it backwards

valid jetty
# strange matrix 😭 help me ma'am i stoopid

path_name is an address in memory, comb_str is an address in memory. adding them will give you an invalid address in memory. what you want to do, is to use malloc with strlen(path_name) + strlen(comb_str) + 1, then iterate both strings and set chars in your new string, and finally insert a null terminator (‘\0’) at the end of the str

strange matrix
#

hm

valid jetty
hoary sluice
valid jetty
#

oh i didn’t know that existed

fleet cedar
valid jetty
#

how tf does that work

#

it can’t resize the string what is it doing

hoary sluice
fleet cedar
hoary sluice
valid jetty
strange matrix
#

but then i realize im stoopid

valid jetty
#

even as simple as string concatenation

strange matrix
#

and i don't know how to

#

yeah rexim built a whole strbuilder

valid jetty
#

and then you learn !!

strange matrix
#

i might do that atp

valid jetty
#

oh yeah that’s just an abstraction for this lol

#

it’s just a dynamic array you can push to

hoary sluice
#

c is built for use in 1972, not 2025

strange matrix
#

so is this safe then ?

  char *comb_str;

  comb_str = strcat(path_name, prog_name);
valid jetty
#

i don’t think so

strange matrix
#

i still don't even know if i'm supposed to use free() or not

valid jetty
#

nop, that’s allocated on the stack

fleet cedar
valid jetty
#

which it doesn’t because it’s a string literal

strange matrix
#

would it be okay if i just allocate 1024*4 for all of these ?

valid jetty
#

yeah probably

hoary sluice
#

if its 0 then its fine

#

but theres probably a safer way

strange matrix
#

its probably not 0

valid jetty
#

this is probably the simplest way???

char *comb_str = (char *)malloc(strlen(path_str) + strlen(prog_name) + 1);
strcpy(comb_str, path_str);
strcat(comb_str, prog_name);
``` and get out a null terminated string
hoary sluice
#

buffer overflow

#

strncat?

valid jetty
#

well sure

hoary sluice
#

with error detection

valid jetty
#

there

#

safe

strange matrix
#

wait but this

char *comb_str = (char *)malloc(1024);

is it the same as this :

char *comb_str = malloc(1024 * sizeof char);

??

valid jetty
#

yes

valid jetty
#

on most platforms the size of a char is 1 byte

fleet cedar
#

You need comb_str[0] = 0; first

valid jetty
fleet cedar
#

No, you strcpy

valid jetty
#

that inserts a null terminator for you

valid jetty
fleet cedar
#

Which means it skips past any non-null bytes and then pastes it there

#

Which can be at an arbitrary point since malloc doesn't zero

valid jetty
#

wait actually???

#

so then can you just zero out the memory and use strcpy twice ???

hoary sluice
#

isnt strcpy the same as strcat then

fleet cedar
#

Wait mb misread strcpy as strcat

valid jetty
#

lmao

#

ok

hoary sluice
#

oh

hoary sluice
#

and made prog_name grow by 2MB

valid jetty
#

what

strange matrix
#

yeah i'm getting segfaults

#

now i know i'm doing stuff wrong

#

great indication

hoary sluice
valid jetty
#

did i put it the wrong way round

valid jetty
#

but nothing should be growing

hoary sluice
#

i dont think field access can make side effects in c

valid jetty
#

it can’t

#

and if it’s a good c spec, strcat will accept a const char*

strange matrix
#

oh my god i so stoopid i make malloc for a string i already know the length of

hoary sluice
strange matrix
#

just live reporting my dummyness

#

:3

#

makes me remember later

#

if a char is 1 byte

#

then i don't need to

#

i could just do malloc(1024)

#

right ?

strange matrix
valid jetty
#

malloc(1024) will break if strlen(path_name) + strlen(prog_name) > 1024

hoary sluice
strange matrix
hoary sluice
#

do you know that path_str + prog_name + 1 will never be longer than 1024?

#

if not, malloc according to their lengths

strange matrix
#

well i don't know how to keep track of it

strange matrix
valid jetty
#

you just take their length lol

strange matrix
#

it would change

#

you're telling me i can malloc twice ?

valid jetty
#

the way you keep track of it is you take its length

valid jetty
strange matrix
#

no look

#

user input comes in

#

ohhhh

#

wait

hoary sluice
#

yes you can

strange matrix
#

no im dumb

#

okay

hoary sluice
#

youre mallocing another variable

#

@valid jetty can i

char *foo = malloc(17);
foo = malloc(26);
#

theres nothing wrong with that right

#

itll just get 26 new bytes somewhere else

strange matrix
#
char *prog_name = (char*)malloc(strlen(va_arg(args, char *)));

is this right now ?

fleet cedar
#

What are you doing with that va_arg btw

strange matrix
#

um

#

so i

#

let me show you

strange matrix
#
void execute_prompt(int n, ...) {
  va_list args;
  va_start(args, n);

  char *prog_name = (char*)malloc(strlen(va_arg(args, char *)));

  int status = 0;
  char path_name[10] = "/usr/bin/";
  prog_name = ;
  char *comb_str;

  comb_str = strcat(path_name, prog_name);
  // strncat(prog_name, path_name, strlen(path_name));

  for (int i = 0; i < strlen(comb_str); i++) {
    printf("%c\n", comb_str[i]);
  }

  // pid_t pid = fork();

  // if (pid == 0) {
  //   /* This is the child process. Execute the shell command. */
  //   execl(prog_name, NULL, NULL);
  //   _exit(EXIT_FAILURE);
  // } else if (pid < 0)
  //   /* The fork failed. Report failure. */
  //   status = -1;
  // else
  //   /* This is the parent process. Wait for the child to complete. */
  //   if (waitpid(pid, &status, 0) != pid)
  //     status = -1;
  va_end(args);
}
hoary sluice
#

like no header

#

but my question was if that segfaults or not

#

im guessing not

fleet cedar
#

No, assigning a variable doesn't segfault

hoary sluice
#

i wouldnt be too sure

valid jetty
hoary sluice
#

@valid jetty maybe assigning to that variable creates a side effect that segfaults

hoary sluice
valid jetty
#

it wouldn’t do anything

#

it just makes the original memory before you reassigned unusable

hoary sluice
#

yes i know

valid jetty
#

it doesn’t free the previous memory it just overwrites what the pointer in your variable holds

hoary sluice
#

i was saying

valid jetty
hoary sluice
#

theres nothing wrong with mallocing twice right

#

like that codeblock i sent

fleet cedar
#

malloc is just a function

hoary sluice
#

obviously its semantical nonsense

valid jetty
#

yea no there’s nothing wrong with it it just makes no sense

hoary sluice
fleet cedar
#

So you're doing a varargs function that takes exactly one extra arg

#

Sure, fair enough

strange matrix
#

😭

#

well i'm supposed to take

#

multiple

#

for argv of the program that is supposed to be ran

#

probably two actually

#

two strings

#

good thing you told me

strange matrix
#

*** stack smashing detected ***: terminated

what does this mean now?

fleet cedar
#

It means your buffer overflow corrupted the return address or similar

strange matrix
#

let me gdb it

spark tiger
fleet cedar
#

You are beyond saving

spark tiger
#

deleted some games

strange matrix
#

demonic amount of free space

spark tiger
#

tru

strange matrix
#

i have to implement vectors in C

#

now

#

no nvm i don't need it