№20738
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).
№20741
>>20738partial retarderald doe it's true retards shills C for no reasons?
№20768
>>20738use rust like a normal person
№20769
C = C
C++ = C + Classes + Templates + you don’t have to reinvent linked lists, dynamic arrays, etc.
C# = Java but Microsoft
№20770
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#
№20782
>>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.
№20796
>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
№20798
>>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.
№20807
>>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)
№20808
>>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
№20811
>>20804Not bait, if you use C++ like "OOP language" you're a retarded nigger
№20815
>>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
№20816
>>20809>>20815(cont)
if its an early exit, it resoves in zero time
№20817
>>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.
№20818
>>20809and the code is to extract an epoch from a string, given that the string is padded with 8 bytes so it wont overflow.
№20819
>>20818>padded with 8 bytes8bytes set to zero
№20822
rust CANT compete with C.
bc you got all the bells and whistles that prevent your cpu from optimizing the shizz.
№20824
>>20736Marge i dont even know what that is
№20825
>>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.
№20826
>>20798>0.1% improvement that cost $300 of man hours instead of buying more RAM for $5/gb.Fizzbuzzer
№20827
>>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
№20833
>>20798>the entire software industry is "theorytards"the state of unemployed Cnile LARPers kek
№20834
>>20827being unemployed is not a flex mr fizzbuzzer
№20835
>>20834i employ myself.
you can seethe now.
i allow it.
№20836
>>20834back to work you go, wageboy
№20837
>>20835>>20836believe it or not rewriting fizzbuzz in C for the 1000th time this week is not a job LMAO
№20838
>>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
№20839
>>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
№20840
>>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
№20841
>>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.
№20843
>>20815Put everything in unsafe and do the same stuff, in trans btw
№20844
>>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
№20845
>>20844Get the asm and put in an wrapper for McDonald's or smth
№20846
>>20845i cant into asm bc im grug
and thats why i do C
it has been designed for the likes of me
№20847
>>20844Can i seer the io of this code
№20848
>>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;
}
№20849
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;
№20850
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);
}
№20851
>>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
№20852
Whats are you sposed to feed into this program and what to expect
№20853
Isnt long 32bits why is it unioned with 16 chars
№20856
>>20854
Im pretty sure 64bits is long long
№20857
>>20853no, its 64 and its an array of 2 in the union.
№20858
>>20856long long == long on x64
№20859
>>20858Y dont you use stdint
№20861
>>20859i love C bc i dont need to actually think about the language when i write in it
№20862
>>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
№20863
>>20862>C is NOT portablewell it seems to be on arm and i386 linux, nothing else matters
№20864
>>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
№20865
learn assembly
>not portable!
>too complex!
fizzbuzzers CAN'T into assembly language
№20866
>>20862C is extremely portable retard. Name something more portable that isn’t FORTH.
№20867
>>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
№20868
>>20867big endian processors are irrelevant, everything should be written for little endian
№20870
>>20868windows btfos your c code
its not even a matter of architecture
№20872
>>20868step 1: remove stick from ass
step 2: kill clean code with fire
step 3: enjoy
№20875
>>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.
№20876
>>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).
№20878
>>20877Yeah exactly nobody wants to look at a fucking cycle table
№20879
>>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
№20880
>>20875now that i think of it
there isnt much that would make my code non-portable.
the syntax more than anything else tbh
№20881
>>20879No, the person I was responding to brought up streams which don’t exist in freestanding C (or any file io)
№20882
>>20880Assembly language (if that’s what you are writing in) is not portable. C is portable but less portable than Ada.
№20884
>>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?
№20888
>>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>.
№20889
>>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.
№20892
>>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.
№20894
>>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.
№20895
>>20894Rust shill detected. Die, rust shill.
The #RITCHIE2024 REICH will gas all Crustaceans.
№20896
>>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.
№20898
>>20897>>20895Least retarded Cnile award
№20900
>>20864even fizzbuzz benefits from simd, kys retarded larper
№20901
>>20898im going to #pragma pack push you off a cliff
№20904
>>20901there's 0 usecases for ever packing a struct
№20905
>>20904bitfields, device registers, and CPU structs like GDT/IDT
№20906
>>20904AdaGODs can specify how many bits and what range a type uses.
>>20900write a beautiful AVX-512 fizzbuzz
№20907
>>20905Not relevant, retarded Cnile.
>>20906>typeretarderald
>write fizzbuzzthat's your job, fizzbuzzer
№20908
>>20907says the fizzbuzzer who has never written a driver
№20909
>>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.
№20911
>>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.
№20912
>>20909because when i say i want 8 bits what i actually wanted was 32 bits
№20913
>>20911retarded ctroon thinks his bitfields do something different than bitshifts lol
№20914
>>20913they are semantically better for the compiler.
№20915
>>20914no they aren't, retarded nigger
№20916
>>20915yes they are fizzbuzzer
№20917
>>20916post where, in the assembly, retarded nigger
№20918
>>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.
№20919
>>20918yes because packed structs and bitfields are for retarded niggers who can't program and everyone who can doesn't give a fuck
№20923
>>20922
every country in the world has niggers too, what's your point, niggers are le good now?
№20924
>>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?
№20925
>>20924retarded bitfieldtroon can't even reply correctly first time, I feel sorry for whoever has to run your code
№20927
>>20926yeah I don't code, I program, how did you know
№20929
>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao
№20932
>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao
№20935
>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory
№20936
>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory
№20948
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.
№20949
>>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.
№20962
>>20949>slower than Cno it isn't retarded nigger
№20964
>>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++
№21028
>>20964it never needs to be slower and is never slower
№21070
oh my fauxi i didnt expect this to have so many replies
№21071
>>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
№21080
>>21071couldnt be further from reality
i've been in the industry for years
but you sure do sound like a lolstudent fizzbuzzer
№21086
>>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.
№21087
>>21086and why should i care about that? what point are you even trying to make you gigantic autist
№21088
>>21086OpenCL and CUDA are not C. They are APIs.
№21090
>>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
№21091
>>21090lmao u're definitely on the spectrum
№21093
>>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
№21094
>>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
№21120
>>21094its okay
i love u even if you're a Cnile autist chud
№21136
>>21094my dad is autistic too, and im probably one too, this is what German genes get you.
№21138
>>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
№21174
>>20738>useless for anything but embedded and OS developmentso literally everything in programming that isnt tranny shit?
№21177
>>21174OS and propriwtary firmware ia definition of tranny shit
№21186
>>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.
№21187
test
№21188
soot
№21890
>>21177windows won. cry some more
№21978
>>21890the winner doesn't need to announce the win, keep dilating
№21986
>>20736how do you make shadows like these?
№22005
>>21986by cutting a namefag's throat