The C Programming Language

ITT we discuss the C language. No securitards allowed. Ignore all Rust trannies. Ada traps welcome.

Attached: cbook.jpg (379x499, 27K)

garbage that was obsolete decades ago

>obsolete
is that why it's still used for everything low level?

C is basically C++ for people who are too lazy to learn all the complexities of C++.

inb4
>hurrr c++ complexities are just additional bloat durrrr

Attached: bjane_long_boye.jpg (603x324, 105K)

I love using C because the thought that my software might kill someone or send them into financial ruin is pleasant.

*sip* now THAT was a language

Attached: 1558986045532.jpg (233x216, 7K)

>was
you said it old man

Attached: 13b.gif (931x682, 426K)

C was a mistake. Still is.

varrays are so fucking retarded and even sepples standard managed to dodge that shit

Attached: ss+(2019-04-28+at+04.40.45).jpg (607x841, 163K)

I'm currently learning C just now and I have to say, I'm enjoying learning it.

C also isn't an Obsolete-Language. It's still used in today's World. It's used in things like Operating-Systems(E.g. Linux).

C++ is just C but more complex and with Classes. But you're free to pick which Language you prefer. Both have their Ups and Downs. I mean, I'm a bit interested in learning C++ just now.

People who dislike C or lisp I feel like have not gone to a proper university. Tons of my projects in computer networks, operating systems, and artificial intelligence have been in C/Lisp

imagine having memory leaks haha

i learned all the same things as you except used js so I learned it twice as fast...

Fans of the one tend to dislike the other.

Any reason to not just use C++ at this point? It contains all of C and much more.

Imagine being too retarded to prevent memory leaks

-Wvla -Walloca and issue all warnings as a bug

>what are smart pointers?

Well, I guess you could say that it's "Over-Rated" at this point. C++ is pretty much used all over the Place now despite being the Younger-Brother of C.

It's actually quite sad that People don't pay attention to C anymore. It's still a great Language to learn. Again, I'm currently learning it and I love C.

Now I don't have anything against C++(But it does look a bit complex for my Level anyway). If you want to learn and use C++ then go ahead. Nobody's stopping you.

C is /comfy/ tier ngl
No annoying OOP or retarded shit to work with
Weak but static typing
Simple and fast
Can flex on retards who can't grasp something as simple as pointers
Who /C/ gang here?

Attached: 1532536690_4fqXI1-BIOEDLcCQ1IBxkDUk6xrc1kVlh6yJoR2Nw0c.png (750x725, 810K)

>Is currently learning C
>Loves it
Does this make me a part of the /C/ Gang?

If you don't "need" (aka it would actually be useful) the features of C++, don't use C++, just use C

it doesn't cotain that much more and forces to use its defective core features

Yes my friend

imagine using smart pointers without RAII....
like are you retarded lmao

i guess you're smarter than all the very intelligent programmers working on very important code bases that leak memory....

for its compilers

And they can’t sue me
Because of this shiny release of liability form with their signature on it.

I think of it as payback against a world that denied me my promised anime gf

Attached: 36965642_1928430537209133_644845324669550592_n.jpg (324x454, 19K)

>imagine using smart pointers without RAII
Just showing user the easiest way to prevent memory leaks, not the most effective. With RAII you can still have memory leaks if you forget to delete stuff.

>runtime polymorphism uses vtables
>pointer to vtable is packed in every instance instead of with cast to polymorphic pointer
>this hidden member field can only be initialied by constructor
>now every API is trippled based on who calls the constructor
>constructors can only use exceptions for error signaling
>needs destructors as well to do properly exception-safe code
>now every API is yet again doubled depending on rather it calls destructor
>need a fucking wrapper class for every scoped resource
>move semantics exist but require all the classes to have five different functions
>and it still calls destructor afterwards so I sill have to make sure to distinguish invalidated instance

>not using assembly

If you think C is bad, you don't understand C and are a shit programmer.

/thread

I love C for the simplicity. I know C++17 but still ain't convinced that the fancy features make for better programs.

i = ++i;

just don't read that frenchman from Inria book, it's trash.

modern c or something like that.

that's the same as just ++i?

Yes

nice
I'm a filthy poogrammer learning C++ :-)

I miss C I’ve been having to do work in Java and I wanna kms.

Attached: 71B1ACB0-F561-4647-AA5A-BD439EDF6058.jpg (590x550, 34K)

>Can flex on retards who can't grasp something
my favorite c feature.
i get this at work so i just use classes as namespaces and ignore the rest of the oop nonsense. c is better at oop than any oop language anyway. i don't even use macros for my c oop, i just let its naked beauty shine on my divine sources.

I work as an embedded dev, and have seen horrors no man should see. Stack corruption due to buffer overflows, data races due to devs not knowing about memory ordering, sudden crashes due to UB that only appear with certain compilers with some optimization level and vanish when an unrelated change is made.
It may not be C's fault, but you have to wonder why is shit C code so prevalent in this industry.

in a way it is c's fault. they should have never allowed structs and arrays onto the stack. the stack should be reserved for single width types including pointers. unions should probably be banned from the stack, too.

The C Programming Language

/C/ gang
>The C Programming Language

Attached: TheCprogrammingLanguage.jpg (379x499, 27K)

I just got done with a C class as a first language and I hated every second of it. I had no idea what the hell I was doing for the entire fucking course outside of hello world but I still managed to get a B. I don't fucking know how! I just found a copy of K N King and I'm thinking about starting from scratch on it.

Attached: im-gonna-be-honest-m-kind-of-retarded-gonna-be-43624280.png (500x444, 85K)

Attached: Chitanda_Eru_CGang.jpg (852x973, 475K)

What don't you get?

it takes time to get the hang of it, then it's like common sense after that. it helps to go lower and learn what is actually happening when your code is executed.

For one thing I got docked for starting arrays at 1 instead of 0. Other than that honestly understanding use cases for different types of loops is beyond me. I just went with the type that was outlined in the chapter we were on. We were using First Book of ANSI C by Bronson if that means anything. I read the first chapter of King and the difference was night and day.

I feel the same way especially with structs when people do
void foo(struct something instance)

because they're literally copying a bunch of stuff instead of a pointer

The father of many Programming Languages.

C FTW!

Filter salesman poster here is there any reward ($) in learning this beyond being a code monkey? tfw 32 and thinking of this and R.

*ahem*
Rust.

Attached: he cute wink.gif (1000x1000, 78K)

it only gets worse when you start dealing with variable arguments. i tracked down a bug last year caused by the use of a typecast struct passed as a variable argument. they had cast the struct to get rid of a compiler warning and didn't think it would cause problems.

Its a hard but rewarding language. Pretty comfy imo but I understand if you don't want to learn it, you probably won't encounter it your career if you don't do low-level stuff.

God I love programming in C, pointers are so nice to have

C makes me do the big cum.

What is the best IDE for C?

I'm using Codeblocks for now and have used Geany too.

I tried Visual Cblocks, but it didn't want to use any #include statement and it looked like a bitch to make it work

Learn to kode, pajeet.
int
nigger(void) {
int i;
i = i + 1;
return 0; }

int
main(void) {
nigger(); }

>IDE
>for C

I just realized I'm retarded myself. Here, I fixed it.

#include int nigger(void) { int i; i = i + 1; return 0; } int main(void) { nigger(); }

There. Optimized it down to one line of code (the Suckless way).

/code
Test
\code

Race conditions are Chad

Attached: 47FA2B03-1082-4750-B239-84B2CF3303E7.gif (800x450, 2.59M)

Yes. IDE. For C.

Reminder to only use ANSI C

Vim

Youre fucking retarded lol

>No securitards allowed
You mean like the OpenBSD developers? Wait, what did you say? They are the biggest fans of C?
OHNONONONONONO HAHAHAHAHAHAHAHAHAHAHAHHAAHH

You mean ANSI C11 ?

So the average C++ user, gotcha.

I feel like they compliment each other. Like they dont overlap at all.

Why did you (you) me?

C89 master race here, fuck all your 90s+ standards that shit is a total bloatfest

If you write C++ like C, you're not writing C++, you're writing nonconforming C anyway. I wish people would stop acting like they're the same language.

C is a wonderful language. C++ is a wonderful language. They target different tasks in different environments.

undefined behavior

i = ++i + i++
Is undefined behavior

Vim

This guy gets it and has studied C

is it not just evaluated right-to-left?

Good question. The C manual guarantees no order and this may result in undefined behavior

No.

addendum, applicable to C, C++, Rust, and pretty much every language:

Attached: carmack-functions.jpg (3840x2160, 2.45M)

What the fuck? Entire operating systems are built on a house of fucking cards?

C has a concept of sequence points, where it's guaranteed that side effects will "appear" to be evaluated in that order.
For example, && is a sequence point, so ++i && ++i is well-defined code.

However, if you have multiple side-effects on the same variable that are unsequenced to each other, the behaviour is undefined. Basically, if you actually know C, it's not an issue in the slightest.

>on a house of cards
No, rather just don't write C code that could result in undefined behavior. The C manual literally says this is bad practice and the compiler is free to do whatever it wants in this case.

Interestingly enough, in emacs source code, there was a similar bug causing undefined behavior

The point is that the expression is undefined behaviour because it has two different operations within the same sequence point (i=, and ++i). Since they are in the same sequence point, there is no guarantee which order they will be evaluated, what registers are used, how they are evaluated (whether or not they use temporary variables, etc.).

note: Sequence points are delineated by ";", ",", "||", "&&", etc.

Entire operating systems, and much systems code in general, tries to separate out things like this. One operation at a time, per line, much like assembly.

proper systems code would be
++i;
i = i;
or
i = i;
++i;
depending on style, either is redundant anyway.

>666
beyond that

HAHA did you forget to allocate adequate memory for your pointer space? HAHAHA fuck you

It's nice. C99 is good. If you still use C89, you either only do fizzbuzzes or you write horrifying code.
C is really easy to use on Unix.

There is really no reason to not use C11/C18, but the differences are minor enough to not really matter that much.
Although in any multi-threaded situation, the C11 atomic library is definitely worth it.

the idea that any language is free of undefined behavior is silly. for some reason the fact c is open about its undefined behavior and warns developers about it makes everyone assume other languages don't have it.

undefined behavior is only relevant when you want your code to be compatible across multiple implementations of the same language. the linux kernel is meant to be compiled with gcc, so undefined behavior matters little. windows is meant to be compiled with the microsoft compiler so UB doesn't matter.

>did you forget to allocate adequate memory for your pointer space?
nope. everything is good here, thanks.

Attached: mfw.jpg (480x360, 17K)

Well yeah, using C18 is good too. I didn't mean to stay stuck behind at C99, but that people stuck at C89 are missing (which is required to do any network code in a portable way), well-defined floating point math, snprintf(), complex number math, the entire POSIX standard library (since POSIX switched to C99 in 2001) and more.

>the linux kernel is meant to be compiled with gcc
This is incredibly unfortunate since I'd like to be able to compile GNU/Linux with Clang.

>which is required to do any network code in a portable way
>not making everything into plain text for transport
ansi4lyfe

Not exactly. Undefined behavior means the compiler doesn't need to respect your code, so behavior can can change between compiler releases which will break your code. This is why some companies get stuck on old versions of gcc, because upgrading is too dangerous for their code base.

Unspecified behavior is the platform specific stuff which you are talking about.

i'm pretty sure you can. i remember reading about open mandriva switching over to clang as the default compiler. just because they could ignore UB doesn't mean they actually ignored it. kernel devs are another kind of autistic all together.

you can't just ignore ub when working on the kernel, you really can't ignore it in general unless you are working on a closed platform, and it's still a bad idea

Daily reminder that if u write undefined code, the compiler is free to do literally WHATEVER IT WANTS to do

the danger of UB is overblown. as long as you know the implementation you're writing for most behavior is predictable. again, that's not to say you should ignore it. all i'm saying is it's not nearly as common as it's made out to be. kernel devs know gcc well enough to know what kind of code it will generate from their sources, even if it is undefined by any standard.