[ home ] [ q / soy / qa / r / tct ] [ a / an / bait / ef / art / raid / incel / int / mtv / pol / nate / sci / x ] [ craft / fnac ] [ overboard ] [ chive ] [ rules ] [ bans ] [ wiki ] [ booru ] [ soycraft ] [ dailyjak ] [ FNAC Download ]

/sci/ - Soyence and Technology

Password (For file deletion.)

File: 1699442126452.png (31.5 KB, 179x255, 1699206610770.png)ImgOps

 20736[Last 50 Posts]

what's the difference between C , C++ and C# ? Which should i learn?


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).


partial retarderald doe it's true retards shills C for no reasons?




use rust like a normal person


C = C
C++ = C + Classes + Templates + you don’t have to reinvent linked lists, dynamic arrays, etc.
C# = Java but Microsoft


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#


You 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.




>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


OOP 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.




learn 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)


File: 1699539280098.jpg (88.59 KB, 700x467, roadkill.jpg)ImgOps

>t. rustroon
you 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


post it


Not bait, if you use C++ like "OOP language" you're a retarded nigger


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);

((((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


if its an early exit, it resoves in zero time


oh, 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.


and the code is to extract an epoch from a string, given that the string is padded with 8 bytes so it wont overflow.


>padded with 8 bytes
8bytes set to zero


rust CANT compete with C.
bc you got all the bells and whistles that prevent your cpu from optimizing the shizz.


Marge i dont even know what that is


programming languages.
you might wanna start here:

dont expect to get a job out of it tho
but its a powerful tool.


>0.1% improvement that cost $300 of man hours instead of buying more RAM for $5/gb.


>difference between 1hr of computation and 1 month
go back to your CSS.
boss is expecting that site to be done by the end of this week


>the entire software industry is "theorytards"
the state of unemployed Cnile LARPers kek


being unemployed is not a flex mr fizzbuzzer


i employ myself.
you can seethe now.
i allow it.


back to work you go, wageboy


believe it or not rewriting fizzbuzz in C for the 1000th time this week is not a job LMAO


what makes you think thats what i do?

do you write in rust?
rewrite this:
you have 16 cycles.

4 ns on a 4.2 ghz cpu


to 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


>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


its 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.


Whats an epoch


Put everything in unsafe and do the same stuff, in trans btw


its 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

do it
C, rust, or 41%
but also benchmark it
and that would complcate things if you 41


Get the asm and put in an wrapper for McDonald's or smth


i cant into asm bc im grug
and thats why i do C
it has been designed for the likes of me


Can i seer the io of this code


you 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;

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);

((((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;


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");

int fd = open(av[1], O_RDONLY);
if (!fd)
fprintf(stderr, "fd is null. path : %s\n", av[1]);

int size;
if (read(fd, &size, 4) < 0)
fprintf(stderr, "something went bork with fd. exiting\n");
fprintf(stderr, "size : %d\n",size);

if (size < sizeof(t_name))
fprintf(stderr, "dict size too small to do job properly. exiting\n");

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");
if (rval != size - 4)
fprintf(stderr, "something went bork with fd when big-reading.\nrval (%d)!= size (%d). exiting\n", rval, size);
buffer[size] = 0;


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;
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;
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);


compile 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


Whats are you sposed to feed into this program and what to expect


Isnt long 32bits why is it unioned with 16 chars



Im pretty sure 64bits is long long


no, its 64 and its an array of 2 in the union.


long long == long on x64


Y dont you use stdint


muscle memory tbh


i love C bc i dont need to actually think about the language when i write in it


also 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


>C is NOT portable
well it seems to be on arm and i386 linux, nothing else matters


*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


learn assembly
>not portable!
>too complex!
fizzbuzzers CAN'T into assembly language


C is extremely portable retard. Name something more portable that isn’t FORTH.


absolute fucking illiterate C gets btfod with stupid fucking streams. or endianness without defines

>le C is portable

bc you include 20k lines of code with every header you include you absolute gorilla


big endian processors are irrelevant, everything should be written for little endian


>le c portable le nuh


windows btfos your c code
its not even a matter of architecture


step 1: remove stick from ass
step 2: kill clean code with fire
step 3: enjoy


I’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.


Fizzbuzzers use assembly because they care about the 0% performance gain (in reality 10% performance loss because they didn’t actually check the cycle table).


File: 1699568596853.png (28.4 KB, 255x251, 1681844296310.png)ImgOps

>cycle table


Yeah exactly nobody wants to look at a fucking cycle table


>freestanding C
i 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


now that i think of it
there isnt much that would make my code non-portable.
the syntax more than anything else tbh


No, the person I was responding to brought up streams which don’t exist in freestanding C (or any file io)


Assembly language (if that’s what you are writing in) is not portable. C is portable but less portable than Ada.


same 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

i 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?


Yes 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>.


An 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.


C++, 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.


Nothing 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.


Rust shill detected. Die, rust shill.

The #RITCHIE2024 REICH will gas all Crustaceans.


tell 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.



Least retarded Cnile award


even fizzbuzz benefits from simd, kys retarded larper


im going to #pragma pack push you off a cliff


there's 0 usecases for ever packing a struct


bitfields, device registers, and CPU structs like GDT/IDT


AdaGODs can specify how many bits and what range a type uses.
write a beautiful AVX-512 fizzbuzz


Not relevant, retarded Cnile.
>write fizzbuzz
that's your job, fizzbuzzer


says the fizzbuzzer who has never written a driver


drivers 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.


File: 1699605529388.png (13.18 KB, 417x183, ClipboardImage.png)ImgOps

always align 4 retard
see picrel for a struct that must be packed
>just use shift and mask
The compiler will optimize packed structs better than shift-and-or clogging up the pipeline.


because when i say i want 8 bits what i actually wanted was 32 bits


retarded ctroon thinks his bitfields do something different than bitshifts lol


they are semantically better for the compiler.


no they aren't, retarded nigger


yes they are fizzbuzzer


post where, in the assembly, retarded nigger


the 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.


yes because packed structs and bitfields are for retarded niggers who can't program and everyone who can doesn't give a fuck


File: 1699606335818.jpg (11.58 KB, 191x263, clangtroon.jpg)ImgOps

>use clang, never use gcc


every country in the world has niggers too, what's your point, niggers are le good now?


nigger 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?


retarded bitfieldtroon can't even reply correctly first time, I feel sorry for whoever has to run your code




yeah I don't code, I program, how did you know


>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao


>tinker trannying on distro that cannot be configured
packed struct and bitfield user intelligence lmao


>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory


>troon deleted his posts to make it look like I doubleposted
geeeeeeeg, total unpacked struct and memcpy victory


epic fail



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.


the 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.


>slower than C
no it isn't retarded nigger


it'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++


it never needs to be slower and is never slower


oh my fauxi i didnt expect this to have so many replies


>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



couldnt be further from reality
i've been in the industry for years
but you sure do sound like a lolstudent fizzbuzzer


File: 1699724102211.png (97.39 KB, 531x325, appomanx.png)ImgOps

>i said LE industry
here you go.
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.


and why should i care about that? what point are you even trying to make you gigantic autist


OpenCL and CUDA are not C. They are APIs.


corpos 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

>They are APIs.
nop. your code gets compiled.
no rust in heterogenous ever.
unless through api's, kek


lmao u're definitely on the spectrum


it 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


*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


File: 1699806486684.png (274.39 KB, 587x587, ongezellig coco4.png)ImgOps

its okay
i love u even if you're a Cnile autist chud


my dad is autistic too, and im probably one too, this is what German genes get you.


File: 1699815395759-0.png (312.11 KB, 572x583, nerd-doggo-hez.png)ImgOps

File: 1699815395759-1.webm (1.65 MB, 1280x720, taliban-cure.webm)ImgOps

there is but one god, written in machine code
and His prophet is Dennis Ritchie, peace be upon his name

makes sense.
paternal line are silesians



>useless for anything but embedded and OS development
so literally everything in programming that isnt tranny shit?


OS and propriwtary firmware ia definition of tranny shit


File: 1699891129032.png (353.6 KB, 600x600, recylcle.png)ImgOps

>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 anyways

rust cant compete with C. it just cant.






>eventhoe cscucks can't pass the fizzbuzz test


windows won. cry some more


the winner doesn't need to announce the win, keep dilating


how do you make shadows like these?


by cutting a namefag's throat


File: 1700594367382.png (45.61 KB, 179x255, sektrnoe.png)ImgOps

its hand-drawn. impressive.

[Return][Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ home ] [ q / soy / qa / r / tct ] [ a / an / bait / ef / art / raid / incel / int / mtv / pol / nate / sci / x ] [ craft / fnac ] [ overboard ] [ chive ] [ rules ] [ bans ] [ wiki ] [ booru ] [ soycraft ] [ dailyjak ] [ FNAC Download ]