Programming thread

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
I appreciate and respect the approach Ocaml is taking to trying to establish their language. I think it has the best chance of being adopted out of any of the ML languages.

Someday if I ever stop doing C stuff I'll do some Ocaml stuff to either find a language that is good, or simply learn more about functional patterns.
Ocaml's good stuff.

Facebook lifted Ocaml's compiler internals but added a goofy Javascript-ey syntactical overlay to make ReasonML. There's also F# on the .NET platform.

Ironically, Ocaml's OOP is cringy and annoying and basically no one uses it for anything. Once in awhile you'll encounter it but you'll just want to wrap it away in normal functions. Ocaml ended up just being the popular form of ML that a community sprang up around.

SML inspired a lot of interesting things but it's not really used in production much anymore. Maybe in a few research settings, but that's about it. SML does have this really wild optimizing compiler called MLton, which is neat for number crunching. Here's a performance comparison between MLton and C++, where SML compiled with MLton is actually competitive with C++. Which is amazing considering SML's garbage collected.

I haven't done anything with Haskell myself. Haskell has a reputation for the same cringy community antics that Rust has now, which is unfortunate because I hear it has some interesting concepts. I don't know, I feel like going 100% purely functional, with absolutely no side effects permitted, is going to make things pretty complicated at times, unless you're writing a compiler or language analyzer or something.

In Ocaml, probably 99% of my code is purely functional, but once in awhile you do paint yourself into a corner where having that escape hatch of side effects is a lifesaver.

Finally, there's also Mythryl, which not many people have heard of. Basically some old graybeard unix nerd wanted to create a system-wide replacement for C in Unix (aside from like the kernel or whatever) using SML as the base, with some syntax changes.

I sympathize with his motivations, though I'd just do that stuff in Ocaml. Anyway, he ended up dying of cancer and his project is just an archive now. Shit's sad.
 
This stinks of npm tbh
Rust is such an unusual language. It has little glimmers of perfection here and there but then they took a huge fucking shit over it so bad it makes Cniggers say "you know what, there are some things python actually does quite well..."
...it has a whole section going over the tooling and the implementation of the language.
Based
pure object oriented programming (like Smalltalk)
new Cnigger slang just dropped: "POOP language"
Some of their advocates act like they're going to reinvent the way you think about programming and you'll never, ever have to deal with dirty low level nonsense like bit sizes and CPU caches and stuff like that. That's for the grunts implementing the compiler to deal with, but you working on the important, high level stuff won't have to sully your hands.
This kind of stuff always sounds cool, but then they run into a problem where their perfect übercompiler can't achieve certain optimizations when their perfect language is used in a very slightly wrong way and it proceeds to emit the world's slowest code. And granted, C compilers can often do this too, but at least C is sort of close to how the computer works instead of being situated on a different planet so it doesn't fuck up quite as bad.
I haven't done anything with Haskell myself. Haskell has a reputation for the same cringy community antics that Rust has now, which is unfortunate because I hear it has some interesting concepts. I don't know, I feel like going 100% purely functional, with absolutely no side effects permitted, is going to make things pretty complicated at times, unless you're writing a compiler or language analyzer or something.

In Ocaml, probably 99% of my code is purely functional, but once in awhile you do paint yourself into a corner where having that escape hatch of side effects is a lifesaver.
Any general-purpose language that doesn't include at least a tiny bit of imperative programming is at least somewhat gay, because sometimes the best way to do things is to simply express your problem's solution as a bunch of steps that fuck with niggerlicious spaghetti state.
 
I'd just like to take a moment to say that I think CLion is incredibly disappointing, and I dislike CMake a lot. I had a genuinely better time developing C/C++ with just Emacs and the GNU toolchain.
Okay so, there’s an option in CLion to enable the resharper engine for parsing, and it fixes like 99% of my gripes
 
  • Like
Reactions: Hall of Cost Payer
just had my first serious memory bug in C that took me a while to figure out and it was due to me not knowing exactly how strlen works. Basically I replaced strlen with the number I thought it would return and it works fine.

I get the sense C works best when any decision being made is being done by a human and if you want to abstract something away you need to build the thing that does the abstracting yourself.

Anyway very happy to have found and fixed that particular bug.

I've realized too that while I basically know the Syntax of C, I don't know it well enough to be able to work quickly, which can be make programming in it not very fun if I am trying to get stuff done. What is the solution to this? Do a bunch more programming in C.
 
Okay, so hear me out.

In C, a common pattern with nested structs is to wrap the struct in an anonymous union and expose its members with a further nested struct:
C:
union {
    foo_t foo;
    struct {
        // members of foo
        bar_t bar;
        baz_t baz;
    };
}

What if instead, we had a keyword that did this automatically?
C:
foo_t foo: __expose__((bar)), __expose__((baz));
This would be far superior to the prior method, because the prior method relies on you manually organizing and padding the members you want to expose.

You can do some semi-clever shit like this to automate it a bit, but it's hardly ergonomic, and still requires insight into the contained struct.
C:
struct foo_t
{
    uint8_t bing;
    uint32_t baz;
};


struct bar_t
{
    union
    {
        struct
        {
            uint8_t bing;
            uint64_t __pad1 : offsetof(struct foo_t, baz) - offsetof(struct foo_t, bing);
            uint32_t baz;
        };

        struct foo_t foo;
    };
};

int main() {
    const struct bar_t bar = {
        .bing = 0x1,
        .baz = 0x2,
    };
    const auto foo = bar.foo;
    printf("Bing: %08x\n", foo.bing); // prints 0x00000001
    printf("Baz: %08x\n", foo.baz);   // prints 0x00000002
    return 0;
}

I just hate anything where I feel like I have to 'trick' the compiler, I would rather give the compiler a cue to do this on its own, and alleviate any platform dependency issues.
The use of nested anonymous unions and structs in C is pretty ubiquitous, so I think this is a feasible idea.
 
  • Thunk-Provoking
Reactions: y a t s
If C / low level niggers were mechanics:

>Wow! I just got my mechanic's degree. I could get a job anywhere!
>>(Suddenly, a giant 500 pound turd with a face opens up a secret door from behind the wall)
>>Hello (farts) Oh shit sorry dude, I'm really fucking fat
>Who are you?
>>You're not allowed to be a mechanic until you prove you can make an engine from scratch and I mean make the metal and the entire foundry that makes the metal too
>What? Who says so?
>>We, a bunch of unelected niggers that are on welfare, welfare paid for by actual mechanics, and we jerk off in basements, we do
>Hmmm, well, fuck that actually, I'm going to go get a job.
>>NOOOOUGH DO NOT GET THAT JOB NOOOOOUGH
>>NOOOOUGH DO NOT APPLY TO THAT JOB NOOOOGUH YOU'RE NOT READY BECAUSE "WE" SAY SO
>>NOOOUUUUGH DO NOT ACCEPT THE JOB OFFER NOUUUUUGH DO NOT BUY THAT HOUSE NOOOOUGH DO NOT MARRY THAT WOMAN
>>YOU HAVE TO BE LIKE US AND BE (oh, one second, I have to go spend 10 years arguing with some other sperglord in my IRC about how autistically doing everything by hand will get you a 1% better engine)
>>(10 years pass)
>>YOU HAVE TO BE LIKE US AND BE MASSIVE FUCKING LOSERS BASICALLY AND NOT EVER DO ANYTHING WITH YOUR KNOWLEDGE EXCEPT JERK OFF also whats happened here?
>(As 10 years of circlejerking have passed in an instant, the mechanic moved his way up through the business and started his own dealership and the camera pans over to the new location where the sperglord can continue sperging)
>>NOOOOOOUGH YOU ARENT ALLOWED TO HAVE A DEALERSHIP WITHOUT KNOWING HOW AN ENGINE WORKS NOOOOOOOGUH THIS ISNT ALLOWED BECAUSE OF OUR SMELLY NIGGER BASEMENT BYLAWS THAT WE MADE UP TO WASTE EVERYONE'S TIME AND RUIN HUMANITY YOU HAVE TO DO IT OUR WAY OR ELSE
>Do YOU know how an engine works start to finish?
>>FUCK YOU I HAVE ONLY 5 MORE YEARS BEFORE I UNDERSTAND IT ON A MOLECULAR LEVEL
>What will you do with your omniscient engine knowledge when it is complete?
>>JERK OFF ON IRC AND POST AUTISTIC WHITE PAPERS ABOUT HOW EVERYTHING EVERYONE IS DOING IN THE INDUSTRY IS SUPER WRONG THAT NOBODY WILL EVER READ THEN KILL MYSELF
>>I'M BETTER THAN YOU AND YOUR SHITTY RICH DEALERSHIP DON'T YOU UNDERSTAND
>Btw, I just got word that a new metal has been invented, as it is now 10 years in the future again, you just jerked off on IRC and 10 years passed
>>NOOOOOUGH EVERYONE HAS TO USE THE OLD SHITTY ONE BECAUSE A BUNCH OF SMELLY NIGGERS ON IRC SAY SO I'M A MECHANIC OLDFAG I KNOW WHAT I"M TALKING ABOUT I'M BETTER THAN YOU! GIVE AWAY YOUR DEALERSHIP AND JOIN OUR IRC AND SUCK MY COCK NOOOOOOUGHHH
 
The use of nested anonymous unions and structs in C is pretty ubiquitous
I had never seen this, apparently anonymous structs/unions are not a feature of C99. I would just like to know why you would do this; is it simply a way of privating struct members or is there some benefit in memory usage? Or, if it is just for nesting structs why not use a pointer? My only guess would be for more terse initialization/assignment.
 
I had never seen this, apparently anonymous structs/unions are not a feature of C99. I would just like to know why you would do this; is it simply a way of privating struct members or is there some benefit in memory usage? Or, if it is just for nesting structs why not use a pointer? My only guess would be for more terse initialization/assignment.
Funny how my mainstream normie sheeple OOP lang handles this automatically and also better than any C sperg doing it by hand. As it isn't 1997 anymore and you can get 16GB of ram for $20
 
I had never seen this, apparently anonymous structs/unions are not a feature of C99. I would just like to know why you would do this; is it simply a way of privating struct members or is there some benefit in memory usage? Or, if it is just for nesting structs why not use a pointer? My only guess would be for more terse initialization/assignment.
1721242434450.png
It is much faster to read/write data for one, for another, it does clean up your code on the use end quite a bit. Also, what little 'reflective' capability C has does somewhat necessitate this approach.
 
Funny how my mainstream normie sheeple OOP lang handles this automatically and also better than any C sperg doing it by hand. As it isn't 1997 anymore and you can get 16GB of ram for $20
As soon as my microcontroller has 16GB that will be useful.
 
  • Like
Reactions: geckogoy
View attachment 6202565
It is much faster to read/write data for one, for another, it does clean up your code on the use end quite a bit. Also, what little 'reflective' capability C has does somewhat necessitate this approach.
Compiler optimization takes care of this... for example, this is the output with -O2:
ss.png

You're also assuming a big-endian machine, I think? On a little-endian machine I think that would end up setting a to 3, b to 2, etc. so could be a source of nasty bugs if you're planning on supporting more than one machine.
 
Good, stay out of the actual private sector that matters.
Seeing as there were 28 billion microcontrollers sold in 2023.
Intel sold 50 million CPUs in 2023.

100W CPUs with 16GB of RAM may be sexy, but they don't run your toaster.
 
@llllIllIllIIIIllI could you please say all the things you said in these posts again without using any software written in C? It should be easy if C is a retarded language used only by basement dwellers to write shit nobody cares about, as you claim. If you can't post things like that without using C software, that means C programmers have written important things that you need to have if you want to do basic things. You will have to concede that only a subset of C programmers write exclusively shit nobody cares about, such as those in this forum.
 
Compiler optimization takes care of this... for example, this is the output with -O2:
View attachment 6202816
You're also assuming a big-endian machine, I think? On a little-endian machine I think that would end up setting a to 3, b to 2, etc. so could be a source of nasty bugs if you're planning on supporting more than one machine.
I rarely explicitly create the constant like I did in my example, usually I use it for copying existing structs or initializing
 
Seeing as there were 28 billion microcontrollers sold in 2023.
Intel sold 50 million CPUs in 2023.

100W CPUs with 16GB of RAM may be sexy, but they don't run your toaster.
When you go the embedded route, you get paid one time then the company sells it and makes all the real money.
When you go OOP, you write the code one time then you can set up a business and sell it to everyone. Basically, you're getting the worst of both worlds to sell the wrong thing.

@llllIllIllIIIIllI could you please say all the things you said in these posts again without using any software written in C? It should be easy if C is a retarded language used only by basement dwellers to write shit nobody cares about, as you claim. If you can't post things like that without using C software, that means C programmers have written important things that you need to have if you want to do basic things. You will have to concede that only a subset of C programmers write exclusively shit nobody cares about, such as those in this forum.
All of the C software that matters was already written 30 years ago. The only way to have a C job after 2005 is to be 60 years old and have been working at the company for a long time. They won't hire you over someone with 40 years of exp. So everyone writing C code is just pretending to jerk off and win tryhard points because they are on welfare and just need something to waste time, which is what we see in these threads on all websites.

Programming threads are always dominated by shitty smelly incel C users because if you're on OOP you tend to have a job. On KF this is even more hilarious because the only way to be "famous" as an inCel is to be a lolcow like Byuu.

You fucking need me or else you can't exist. Both in terms of, you need me to be here so you can pretend to flex in C, and validate your existence. Also, I pay for your welfare so you can not starve and accumulate useless C knowledge. You need me for food money and validation or else you can't exist.
 
Back