β20738Quote
C is a low level language that is literally older than your grandfather, it's a meme language and useless for anything but embedded and OS development. it also has a weird cult of fizzbuzzer skiddos built around it who spend their lives shilling it on imageboards.
C++ was the first object oriented language to become "mainstream" so to say. it's a superset of C but it's by now obsolete and has been replaced by more modern and better object oriented languages. there are still a lot of legacy codebases that use it, but it's unlikely that anyone mentally sane would start a business project with it today.
C# is a modern object oriented language developed by Microsoft and meant originally as an evolution of Java. it's very dominant in gaming and business applications development and allows you to do about everything you can think of (games, desktop applications, web applications, mobile applications and so on and so forth).
β20741Quote
>>20738partial retarderald doe it's true retards shills C for no reasons?
β20768Quote
>>20738use rust like a normal person
β20769Quote
C = C
C++ = C + Classes + Templates + you donβt have to reinvent linked lists, dynamic arrays, etc.
C# = Java but Microsoft
β20770Quote
C is the good stuff everything that matters is written in, boomer language that built computers as we know them
C++ is C but with OOP (cancer), slower, overcomplicated, and only good for making video games or other large scale things
to know what C# is you first have to know what java is, basically its braindamage
now combine java with microsoft and some more braindamage and you get C#
β20782Quote
>>20770You are a fizzbuzzer who hates OOP because itβs cool to hate OOP. You donβt actually know the pros and cons of OOP. Doubt you know the difference between imperative and declarative.
β20796Quote
>Which should i learn?
having basic C knowledge is useful but for actual projects you should use C++ or C#
also C# jobs are much more common than jobs where you'd use C++ or C
β20798Quote
>>20782OOP is literal dogshit garbage useful only for theorytards who don't know how to program and never had to solve problems where 0.1% boost in performance saves millions of dollars per year.
β20807Quote
>>20736learn C first.
you will learn the basics of programming without having to learn OOP.
but mastering C takes years.
so stick to the strict minimum.
write a couple use cases for all C keywords and then learn something else. like C++. its an "evolution" of C. or even C#.
to be efficient in C you have to be really f* good and it takes ages. theres arcane shit like ilp you can learn only if youre confronted with an example in the codebase. or if youre a turbo autist like me. i had to go through opencl to start using this feature (opencl is C. but semi-asynchronous. same with CUDA. another reason to learn C, it opens the way to learn compute)
β20808Quote
>>20738>t. rustroonyou can do stuff with C you cannot with rust.
i dont wanna shit up the thread too much, but i have a couple of snippets of code that are gonna show you what unspeakable things C does to rust
β20811Quote
>>20804Not bait, if you use C++ like "OOP language" you're a retarded nigger
β20815Quote
>>20809static inline t_epoch fn_fast_epoch(t_name *name)
{
// if (str->s[11])
// return (0);
char *str = name->s;
if (
((str[0] > '9') || (str[0] < '0') ||
(str[1] > '9') || (str[1] < '0')) ||
((str[2] > '9') || (str[2] < '0') ||
(str[3] > '9') || (str[3] < '0')) ||
((str[6] > '9') || (str[6] < '0') ||
(str[8] > '9') || (str[8] < '0')) ||
((str[4] > '9') || (str[4] < '0') ||
(str[7] > '9') || (str[7] < '0')) ||
((str[9] > '9') || (str[9] < '0') ||
(str[5] > '9') || (str[5] < '0'))
// || (str[10])
)
{
// fprintf(stderr, "bad\n");
return (0);
}
return(
((((str[0] - '0') * 1000000000) +
((str[1] - '0') * 100000000)) +
(((str[2] - '0') * 10000000) +
((str[3] - '0') * 1000000))) +
((((str[4] - '0') * 100000) +
((str[5] - '0') * 10000)) +
(((str[6] - '0') * 1000) +
((str[7] - '0') * 100))) +
(((str[8] - '0') * 10) +
(str[9] - '0'))
);
}
t_epoch is a signed long
and t_name can be sustituted for a regular char*: as you see i cast it into a char * anyways
4niggers rustroons got this snippet down to 50 and change cycles.
in C? its 16.
and with 1/10 the verbosity
β20816Quote
>>20809>>20815(cont)
if its an early exit, it resoves in zero time
β20817Quote
>>20809oh, and to be completely frank, i compile it with -O3
but inb4 ->dats cheating
its not.
rust framework is supposed to do that for you by default.
were comparing framework to framework here. language vs language.
β20818Quote
>>20809and the code is to extract an epoch from a string, given that the string is padded with 8 bytes so it wont overflow.
β20819Quote
>>20818>padded with 8 bytes8bytes set to zero
β20822Quote
rust CANT compete with C.
bc you got all the bells and whistles that prevent your cpu from optimizing the shizz.
β20825Quote
>>20824programming languages.
you might wanna start here:
https://www.youtube.com/watch?v=2NWeucMKrLI&list=PL6gx4Cwl9DGAKIXv8Yr6nhGJ9Vlcjyymqdont expect to get a job out of it tho
but its a powerful tool.
β20826Quote
>>20798>0.1% improvement that cost $300 of man hours instead of buying more RAM for $5/gb.Fizzbuzzer
β20827Quote
>>20826>difference between 1hr of computation and 1 monthgo back to your CSS.
boss is expecting that site to be done by the end of this week
β20833Quote
>>20798>the entire software industry is "theorytards"the state of unemployed Cnile LARPers kek
β20834Quote
>>20827being unemployed is not a flex mr fizzbuzzer
β20835Quote
>>20834i employ myself.
you can seethe now.
i allow it.
β20836Quote
>>20834back to work you go, wageboy
β20837Quote
>>20835>>20836believe it or not rewriting fizzbuzz in C for the 1000th time this week is not a job LMAO
β20838Quote
>>20837what makes you think thats what i do?
do you write in rust?
rewrite this:
>>20815you have 16 cycles.
4 ns on a 4.2 ghz cpu
β20839Quote
>>20837to make it easy for you,
pad your buffer. i am not checking for buffer size, neither should you.
but i am chacking for null termination.
so pad your shit and do your best
β20840Quote
>>20837>but i am chacking for null termination.if the format is wrong, ie theres not 10 nums you return 0.
so that we level the planefield.
im pretty sure youre gonna use high level shit like a mong and then get f*.
and that wouldnt be fair
β20841Quote
>>20837its been 21 mins since i gave you the latest hint.
41 since the beginning of the assignement.
you got 40 mins more. i will give you one hour bc thats what it took me to invent and benchmark this code. i might be more lenient, but i am also impatient.
despite what you might imagine i actually respect you.
but this is merely one example where rust actually meets C.
stdlib doesnt count bc a C coder worth his salt casually beats it.
β20843Quote
>>20815Put everything in unsafe and do the same stuff, in trans btw
β20844Quote
>>20842its the number of seconds since 1st june 1970 irrc
the full name is "UNIX epoch" and thats the calendar for everything derived from that system.
so linux, macos and bsd.
and every OS i dont know about
>>20843do it
C, rust, or 41%
but also benchmark it
and that would complcate things if you 41
β20845Quote
>>20844Get the asm and put in an wrapper for McDonald's or smth
β20846Quote
>>20845i cant into asm bc im grug
and thats why i do C
it has been designed for the likes of me
β20847Quote
>>20844Can i seer the io of this code
β20848Quote
>>20847you can see the whole code
——————–#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
typedef long t_epoch;
unionu_name;
typedef union u_namet_name;
union u_name
{
char s[16];
long l[2];
};
static inline t_epoch fn_fast_epoch(t_name *name)
{
// if (str->s[11])
// return (0);
char *str = name->s;
if (
((str[0] > '9') || (str[0] < '0') ||
(str[1] > '9') || (str[1] < '0')) ||
((str[2] > '9') || (str[2] < '0') ||
(str[3] > '9') || (str[3] < '0')) ||
((str[6] > '9') || (str[6] < '0') ||
(str[8] > '9') || (str[8] < '0')) ||
((str[4] > '9') || (str[4] < '0') ||
(str[7] > '9') || (str[7] < '0')) ||
((str[9] > '9') || (str[9] < '0') ||
(str[5] > '9') || (str[5] < '0'))
// || (str[10])
)
{
// fprintf(stderr, "bad\n");
return (0);
}
return(
((((str[0] - '0') * 1000000000) +
((str[1] - '0') * 100000000)) +
(((str[2] - '0') * 10000000) +
((str[3] - '0') * 1000000))) +
((((str[4] - '0') * 100000) +
((str[5] - '0') * 10000)) +
(((str[6] - '0') * 1000) +
((str[7] - '0') * 100))) +
(((str[8] - '0') * 10) +
(str[9] - '0'))
);
}
void fn_strcpy(char *from, char *to)
{
int i = 0;
while (*from && i++ < 15)
*to++ = *from++;
to = 0;
}
β20849Quote
int main(int ac, char **av)
{
int iterations = 1000 * 1000 * 1000 + 1;
// int iterations = 10;
// char *temp = (char *)&(name);
// char test[100] = "0123456789";
// t_name *name_test = (t_name*)test;
// fprintf(stderr, "test fast_epock : %ld\n", fn_fast_epoch(name_test));
// return (0);
if (ac != 2)
{
fprintf(stderr, "wrong numebr of args. need path to test table\n");
exit(1);
}
int fd = open(av[1], O_RDONLY);
if (!fd)
{
fprintf(stderr, "fd is null. path : %s\n", av[1]);
exit(1);
}
int size;
if (read(fd, &size, 4) < 0)
{
fprintf(stderr, "something went bork with fd. exiting\n");
exit(1);
}
fprintf(stderr, "size : %d\n",size);
if (size < sizeof(t_name))
{
fprintf(stderr, "dict size too small to do job properly. exiting\n");
exit(1);
}
char _buffer[size + 1];
char *buffer = (char *)_buffer;
*((int *)buffer) = size;
int rval;
if ((rval = read(fd, buffer + 4, size - 4)) < 0)
{
fprintf(stderr, "something went bork with fd when big-reading. exiting\n");
exit(1);
}
if (rval != size - 4)
{
fprintf(stderr, "something went bork with fd when big-reading.\nrval (%d)!= size (%d). exiting\n", rval, size);
exit(1);
}
buffer[size] = 0;
β20850Quote
int int_final_count = size - sizeof(t_name);
t_name *name;
int i = 0;
t_epoch dummy_epoch = 0;
char c;
int j = 0;
clock_t begin = clock();
while (i < iterations)
{
name = (t_name *)(&(buffer[i % int_final_count]));
c = *(name->s);
dummy_epoch += c;
dummy_epoch %= 1001;
i++;
}
clock_t end = clock();
fprintf(stderr, "dummy epoch : %ld\n", dummy_epoch);
clock_t clock_baseline = end - begin;
double double_baseline = (double)(clock_baseline) / CLOCKS_PER_SEC;
// fprintf(stderr, "clock_baseline : %ld\n", clock_baseline);
fprintf(stderr, "baseline : %lf\n", double_baseline);
i = 0;
begin = clock();
while (i < iterations)
{
name = (t_name *)(&(buffer[i % int_final_count]));
c = *(name->s);
dummy_epoch += fn_fast_epoch(name);
dummy_epoch %= 256;
i++;
}
end = clock();
clock_t clock_spent = end - begin;
double double_spent = (double)(clock_spent) / CLOCKS_PER_SEC;
fprintf(stderr, "time spent: %lf\n", double_spent);
fprintf(stderr, "actual time: %lf\n", double_spent - double_baseline);
// fprintf(stderr, "actual time ratio : %lf\n", (double_stdlib - double_baseline) / (double_spent - double_baseline));
fprintf(stderr, "dummy epoch: %ld\n", dummy_epoch);
return (0);
}
β20851Quote
>>20847compile with -O3
it expects a path to a file as parameter for the executable.
the file is 4 bytes which are an int which tells the total size of the file, the rest is ascii.
making a link for a test file rn
β20852Quote
Whats are you sposed to feed into this program and what to expect
β20853Quote
Isnt long 32bits why is it unioned with 16 chars
β20856Quote
>>20854
Im pretty sure 64bits is long long
β20857Quote
>>20853no, its 64 and its an array of 2 in the union.
β20858Quote
>>20856long long == long on x64
β20859Quote
>>20858Y dont you use stdint
β20861Quote
>>20859i love C bc i dont need to actually think about the language when i write in it
β20862Quote
>>20859also its intended for internal use
and i say that portable C is a retarded idea.
when its achieved, its by duplicate code hidden behind includes, gurded by defines.
C is NOT portable
and using the stdlib makes C 10x slower. also i say its THE source of bugs bc using the stdlib for anything else than system calls annihilates any possibility of code ownership.
in other words,
to do a good job using the stdlib
you have to learn the whole of it by heart, bc you never know which function calls what.
so i say
lets do freeform C.
drop the stdlib
own your code
fuck the idea of portability bc C is a macro asm
β20863Quote
>>20862>C is NOT portablewell it seems to be on arm and i386 linux, nothing else matters
β20864Quote
>>20863nonono
*idiomatic
*normie
*well behaved
C is portable
but whenever you get into the weeds
its all duplicate code
or its slow as all hell
for a simple reason:
a generalist solution has to do more checks than a specialized one
this is the reason you wanna use C
->to create a specialized solution
->it can be orders of magnitude faster even without using simd
β20865Quote
learn assembly
>not portable!
>too complex!
fizzbuzzers CAN'T into assembly language
β20866Quote
>>20862C is extremely portable retard. Name something more portable that isnβt FORTH.
β20867Quote
>>20866absolute fucking illiterate C gets btfod with stupid fucking streams. or endianness without defines
>le C is portablebc you include 20k lines of code with every header you include you absolute gorilla
β20868Quote
>>20867big endian processors are irrelevant, everything should be written for little endian
β20870Quote
>>20868windows btfos your c code
its not even a matter of architecture
β20872Quote
>>20868step 1: remove stick from ass
step 2: kill clean code with fire
step 3: enjoy
β20875Quote
>>20867Iβm talking about freestanding C. Endianness is going to be messy when you are using a language with pointers. Headers donβt increase binary size so i donβt get the complaint.
β20876Quote
>>20865Fizzbuzzers use assembly because they care about the 0% performance gain (in reality 10% performance loss because they didnβt actually check the cycle table).
β20878Quote
>>20877Yeah exactly nobody wants to look at a fucking cycle table
β20879Quote
>>20875>freestanding Ci think youre talking about the opposite, actually.
what i would call freestanding c, you would call an ugly ass hack
but thats bc i tend to work with the primitivest of types bc i "target a specific platform" in politically correct
β20880Quote
>>20875now that i think of it
there isnt much that would make my code non-portable.
the syntax more than anything else tbh
β20881Quote
>>20879No, the person I was responding to brought up streams which donβt exist in freestanding C (or any file io)
β20882Quote
>>20880Assembly language (if thatβs what you are writing in) is not portable. C is portable but less portable than Ada.
β20884Quote
>>20881same person
but then you see that at an even lower level than what i call freestaning c, c is even less portable.
there youre 100% hw-specific
otherwise youre at least posix and then you have streams
>>20882i wouldnt call it portable.
yes, for instance, you can run int 64's on a 32bit machine, but its gonna run like a tank
so is it really portable?
β20888Quote
>>20884Yes it is portable. Portable means that you are able to retarget compilation for a different arch and possibly a different OS. Just because something will run like shit doesnβt mean it isnβt portable. 64-but longs are optimized with SSE by Clang. POSIX is not C. Windows is written in C but has no unistd.h or posix support (unless you use the POSIX subsystem)
Freestanding C has a specific definition according to ISO 9899:
A conforming freestanding implementation shall accept any strictly conforming program in which the use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and <stdnoreturn.h>.
β20889Quote
>>20884An unportable language for comparison is PL/M which is specific to either the 8080, 8086, 286, or 386 depending on what version of PL/M you are using. PL/M is closely tied to the x86 ISA and includes segments, based pointers, and CPU control directives (SET$GLOBAL$DESCRIPTOR$TABLE). GPL for the TI99/4A is another example.
β20892Quote
>>20866C++, GNU Compiler Collection moved on from C to C++ because C++ is objectively better including portability, GCC supports every single relevant and even some irrelevant systems, the only ones who still use C in 2023 are Linus Torvalds and proprietard wagecucks whose chips and compilers are proprietary and specifically designed to be different from everything else in the market to ensure secure vendor lock-in so if a person has a firmware bug or hardware breaks and they fix it at home, they still depend on vendor for patches and recalibrations of sensors and other crap that needs software to work.
β20894Quote
>>20881Nothing exists in C at all, it's blank slate DIY tinkertranny language that is anti-freedom.
C retards larp about bare to metal garbage when they don't even know that their code doesn't run on "bare metal", it runs on a silicon die that has so little metal in it, you could almost count individual atoms.
When they make such basic mistake, I know that 100% of their code is worthless. Shittiest parts of C++ STL are infinitelly better designed than any of Cnile code.
β20895Quote
>>20894Rust shill detected. Die, rust shill.
The #RITCHIE2024 REICH will gas all Crustaceans.
β20896Quote
>>20826tell that to google who wrote their own hash table where every operation is SIMD over vectors of bytes, not your tranny OOP garbage, it literally saved them billions of dollars in CPU time, adding more RAM doesn't work.
β20898Quote
>>20897>>20895Least retarded Cnile award
β20900Quote
>>20864even fizzbuzz benefits from simd, kys retarded larper
β20901Quote
>>20898im going to #pragma pack push you off a cliff
β20904Quote
>>20901there's 0 usecases for ever packing a struct
β20905Quote
>>20904bitfields, device registers, and CPU structs like GDT/IDT
β20906Quote
>>20904AdaGODs can specify how many bits and what range a type uses.
>>20900write a beautiful AVX-512 fizzbuzz
β20907Quote
>>20905Not relevant, retarded Cnile.
>>20906>typeretarderald
>write fizzbuzzthat's your job, fizzbuzzer
β20908Quote
>>20907says the fizzbuzzer who has never written a driver
β20909Quote
>>20908drivers don't require niggerald struct packing garbage used by retarded niggers who can't program, also pretty much all drivers have shitty performance, must be all those unaligned memory accesses since retarded Cniles don't know how computers work.
β20911Quote
>>20909always align 4 retard
see picrel for a struct that must be packed
>just use shift and maskThe compiler will optimize packed structs better than shift-and-or clogging up the pipeline.
β20912Quote
>>20909because when i say i want 8 bits what i actually wanted was 32 bits
β20913Quote
>>20911retarded ctroon thinks his bitfields do something different than bitshifts lol
β20914Quote
>>20913they are semantically better for the compiler.
β20915Quote
>>20914no they aren't, retarded nigger
β20916Quote
>>20915yes they are fizzbuzzer
β20917Quote
>>20916post where, in the assembly, retarded nigger
β20918Quote
>>20917the issue is that GCC has niggerlicious implementation of bitfields that doesn't fucking work because FSF is too busy sucking off rms's feminine penis to fix their shitty compiler.
β20919Quote
>>20918yes because packed structs and bitfields are for retarded niggers who can't program and everyone who can doesn't give a fuck
β20923Quote
>>20922
every country in the world has niggers too, what's your point, niggers are le good now?
β20924Quote
>>20919nigger faggot every good language including all nonshit assemblers (non gas) have packed structs. you have risc on the brain, worried you may get a bus error?
β20925Quote
>>20924retarded bitfieldtroon can't even reply correctly first time, I feel sorry for whoever has to run your code
β20927Quote
>>20926yeah I don't code, I program, how did you know
β20929Quote
>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao
β20932Quote
>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao
β20935Quote
>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory
β20936Quote
>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory
β20948Quote
C is used for systems programming, C++ is used for programs that aren't ingrained into the system (only if you want to doe you can use just C too) and C is a coally chimera between Java and C that people only care about because Unity games are powered by C.
β20949Quote
>>20782the pros are that you have classes for everything and its easier to work on large bloated things (excellent example being video games) with it than if you used C, the cons are that its overcomplicated and slower than C if youre only making a simple program that does one thing and one thing well
C is very unixy.
β20962Quote
>>20949>slower than Cno it isn't retarded nigger
β20964Quote
>>20962it's only slower when it needs to be slower. compare to objc which has a runtime to manage objects instead of doing it at compilation like C++
β21028Quote
>>20964it never needs to be slower and is never slower
β21070Quote
oh my fauxi i didnt expect this to have so many replies
β21071Quote
>>20738>but it's by now obsolete and has been replaced by more modern and better object oriented languages.posted by a first year CS student XDD
β21080Quote
>>21071couldnt be further from reality
i've been in the industry for years
but you sure do sound like a lolstudent fizzbuzzer
β21086Quote
>>21080>i said LE industryhere you go.
picrel.
applel deprecates openCL and CUDA (which basically are C) on their machines. only to realize that metal is extremely shit and the ai accelerators dont cut it.
β21087Quote
>>21086and why should i care about that? what point are you even trying to make you gigantic autist
β21088Quote
>>21086OpenCL and CUDA are not C. They are APIs.
β21090Quote
>>21087corpos are fucking retarded.
corpos in 1980-something:
C is obsolete! we have c++ now!
->ffw 30 years
->corporate creates opencl. an asynchronous C bc the C model just makes sense
->we still havent come up with something better, not for lack of trying
seethe harder, rustroon
even in rust when you wanna go fast you write C
>>21088>They are APIs.nop. your code gets compiled.
no rust in heterogenous ever.
unless through api's, kek
β21091Quote
>>21090lmao u're definitely on the spectrum
β21093Quote
>>21091it honestly did cross my mind
but i dont think im a hard autist.
no legos in my room, i dont get confused by new people.
smalltalk was a skill i had to learn tho
β21094Quote
>>21091*goole search*
fuuck i didnt know this shit was hereditary
i really might have mild autism fucking hell
my father has big issues with socializing. his own father was in "introvert" too.
wtf? i was always told autism is caused by a hormonal imbalance…
i brushed off my elders ineptitude at socializing as because they come from a small village
β21120Quote
>>21094its okay
i love u even if you're a Cnile autist chud
β21136Quote
>>21094my dad is autistic too, and im probably one too, this is what German genes get you.
β21138Quote
>>21120there is but one god, written in machine code
and His prophet is Dennis Ritchie, peace be upon his name
>>21136makes sense.
paternal line are silesians
β21174Quote
>>20738>useless for anything but embedded and OS developmentso literally everything in programming that isnt tranny shit?
β21177Quote
>>21174OS and propriwtary firmware ia definition of tranny shit
β21186Quote
>>21169>nnn c-nile our language is just as fast or even faster!>your days are numbered*shifts code to second gear*
*rust absolutedly btfo*
>nnn thats otism>who needs it anywaysrust cant compete with C. it just cant.
β21187Quote
test
β21188Quote
soot
β21890Quote
>>21177windows won. cry some more
β21978Quote
>>21890the winner doesn't need to announce the win, keep dilating
β21986Quote
>>20736how do you make shadows like these?
β22005Quote
>>21986by cutting a namefag's throat
β25488Quote
bump
β25590Quote
kotlin mogs cshart
β25594Quote
>>25590why would you take something perfectly functional and make it look like the most jeet language on earth p*thon