r/programminghumor • • 16d ago

jSon

2 Upvotes

r/programminghumor • • 17d ago

True

Post image
815 Upvotes

r/programminghumor • • 17d ago

I added generics to c

8 Upvotes

I was watching tsoding's crust stream and I thought it would be so funny if I extended c to have generics. Here is the result of that abomination

#include <stdio.h>

// you can define your own operator in fortran .op. style with a trait
trait<T> DotP {
    // for parsing reasons any dot-op must have whitespaces around it in any context
    T .dot. (Self self, Self other);
}

// using a very similar syntax to rust, you can add generics to structs
typedef<T> struct {
    T x;
    T y;
    T z;
} Vector<T>;

// and by appling the trait to your struct (with generic parmeters)
// you can define what your operator should do.
impl<T> DotP<T> for Vector<T> {
    T .dot. (Self self, Self other){
        return self.x * other.x + self.y * other.y + self.z * other.z;
    }
}

int main(void) {
    // by concretly defining which type you want to use as the generic
    // you create in generated c a struct with that/those type(s)
    Vector<float> fv = {1.0, 2.0, 3.0};
    printf("Dot product of fv^2: %f\n", fv .dot. fv);
    Vector<int> iv = {1, 2, 3};
    printf("Dot product of iv^2: %d\n", iv .dot. iv);
}

// The generated c code looks something like this:

// /* Generated by typedc. */
// #ifndef TYPEDC_SIMPLE_GENERICS_H
// #define TYPEDC_SIMPLE_GENERICS_H
//
// #include <stdio.h>
//
// typedef struct float_Vector float_Vector;
// typedef struct int_Vector int_Vector;
//
// struct float_Vector {
//     float x;
//     float y;
//     float z;
// };
//
// struct int_Vector {
//     int x;
//     int y;
//     int z;
// };
//
// int main(void);
// static inline float float_dot(float_Vector self, float_Vector other);
// static inline int int_dot(int_Vector self, int_Vector other);
//
// int main(void) {
//     float_Vector fv = {1.0, 2.0, 3.0};
//     printf("Dot product of fv^2: %f\n", float_dot(fv, fv));
//     int_Vector iv = {1, 2, 3};
//     printf("Dot product of iv^2: %d\n", int_dot(iv, iv));
// }
//
// static inline float float_dot(float_Vector self, float_Vector other) {
//     return self.x * other.x + self.y * other.y + self.z * other.z;
// }
//
// static inline int int_dot(int_Vector self, int_Vector other) {
//     return self.x * other.x + self.y * other.y + self.z * other.z;
// }
//
// #endif /* TYPEDC_SIMPLE_GENERICS_H */

https://github.com/HyperRays/typedc


r/programminghumor • • 19d ago

theTechBrosWeWantedVsTheTechBrosWeGot

Post image
2.9k Upvotes

r/programminghumor • • 18d ago

SEAL_OF_SOLOMON.md

Post image
84 Upvotes

r/programminghumor • • 18d ago

stagesOfGrief

Post image
19 Upvotes

r/programminghumor • • 18d ago

Rust Jokes

11 Upvotes
  • Python is like your kindergarten teacher.
  • Rust is like your drill sergeant(the mean one).

r/programminghumor • • 19d ago

If We Had Claude in 1998!

Enable HLS to view with audio, or disable this notification

1.5k Upvotes

r/programminghumor • • 20d ago

Love is definitely blind yo 🥲

Post image
422 Upvotes

r/programminghumor • • 18d ago

HTTP request/response, "dramatic re-enactment" version.

Enable HLS to view with audio, or disable this notification

0 Upvotes

For some reason, I've always envisioned HTTP requests in my head like this. ⚔️🐎🏰 Sorry. 😂
(AI declaration per rule 7: Generated via Higgsfield / Kling 4.0)


r/programminghumor • • 20d ago

“It’s open source”

Post image
2.5k Upvotes

r/programminghumor • • 18d ago

What are the % chances that Ramaltman may put a miner in people's computer for his statement on limited availability of DihRAM? [pic unrelated]

0 Upvotes

r/programminghumor • • 18d ago

I Say to the Coding AI "Nyeh!"

0 Upvotes

I was scratching out some python, and it spit out this before I could get to it...

(files, labels) = zip(*[x.split(':') for x in l])

Which I would have ciphered out in about 3-5 minutes, tops.

BUT... within mere seconds, I saw that THIS would be better.

(files, labels) = zip(*(x.split(':') for x in l))

Well... if I were processing 10,000s of elements instead of the 4 that I really
only need. BUT still! Human still rules!


r/programminghumor • • 20d ago

killProcessSamAltman

Post image
306 Upvotes

r/programminghumor • • 21d ago

144p video

Enable HLS to view with audio, or disable this notification

50 Upvotes

r/programminghumor • • 22d ago

VGA > HDMI

Post image
1.6k Upvotes

r/programminghumor • • 19d ago

Coding VS Testing

Post image
0 Upvotes

r/programminghumor • • 20d ago

C#

Post image
0 Upvotes

r/programminghumor • • 22d ago

Watching myself use 12 nested for loops instead of a hash map in first year

Post image
255 Upvotes

r/programminghumor • • 23d ago

If

Post image
765 Upvotes

r/programminghumor • • 22d ago

Making a boss fight... His tracking bevhariour script may need some honing

Enable HLS to view with audio, or disable this notification

53 Upvotes

The game I'm making is Dark Roll 2, it's a marble platformer heavily inspired by soulslike genre!
https://store.steampowered.com/app/4417060/Dark_Roll_2/


r/programminghumor • • 23d ago

Frontend vs Backend

Post image
996 Upvotes

r/programminghumor • • 23d ago

Agile is scam for MBA managers cosplaying as engineers

Thumbnail blog.kmemdump.com
19 Upvotes

r/programminghumor • • 24d ago

99% of "AI Engineering" that nobody talks about

Post image
191 Upvotes

r/programminghumor • • 23d ago

Corporations are software junkyards

Thumbnail blog.kmemdump.com
5 Upvotes